Problem 2 2 points For the polynomial f x0 0025x5 00625x4 03
Problem 2 (2 points) For the polynomial f (x0 0.025x5 0.0625x4 0.333x3 x2 2 (a) Find fO9) (b) Calculate the value of the function for x 1, 0.5, 0, 0.5, 1, 1.5, 2, 2.5 (c Plot the polynomial for 4 sx S4 (d) Find the value(s) of x for which f(x) 0 (e) Find f(X) 30.025A5 0.0625A4 0.333A3 A2-2I, where T2 1 31 Problem 3 (3 points) You are given the following function definition. X+2, 4e for-6 Sx -2 for -2 Sx 2.5 (x 6.5) /3 for 2.5 sxs6 (a) Use MATLAB to create an array for f(x for-6 s x S 6. (b) Plot f(x for -6 s x s 6 (c) Using a single fprintf command to output the following When the x-value is 3.5, then the f (x) value is When the x-value is 2.5 then the f (x) value is When the x-value is 1.5, then the f (x) value is When the x-value is 0, then the f (x) -value is When the x-value is 1.5 then the f (x) -value is When the x-value is 2.5, then the f (x) -value is When the x-value is 3.5, then the f (x) -value is
Solution
1. For evaluation the value:
polyval(x,9)
2. For the different values
use polyval (x, value) :for each value
i.e. polyval (x, [-1, -0.5, 0, 0.5, 1, 1.5, 2. 2.5])
3. T =linspace (-4,4,100);
plot (T, p)
4. For f(x) = 0
create a vector to represent the polynomial , i.e. coeff.
p = [0.025, -0.0625, -0.333, 1, 0, -2]
x = roots(p)
5. polyvalm(x,A)
Here A is the square matrix and I is the identity matrix
A = [2 -1 3; 4 1 8; 2 1 4];
Y = polyvalm(x,A)
