Write a user-defined function that adds or subtracts two polynomials of any order. Name the function p=po1yadd(p1, p2, operation). The first two input arguments pi and p2 are the vectors of the coefficients of the two polynomials. (If the two polynomials are not of the same order, the function adds the necessary zero elements to the shorter vector.) The third input argument operation is a string that can be either ‘add’ or ‘sub’, for adding or subtracting the polynomials, respectively, and the output argument is the resulting polynomial.
Use the function to add and subtract the following polynomials:
f
1
(
x
)
=
8
x
6
+
10
x
5
−
5
x
3
+
13
x
2
−
4
x
−
2
and
f
2
(
x
)
=
4
x
4
+
7
x
2
+
6