0% found this document useful (0 votes)
381 views2 pages

Q4.5 Use Zero-Through Third Order Taylor Series Expansions To Predict F (3) For

The document uses Taylor series expansions up to third order to approximate the function f(x) = 25x^3 - 6x^2 + 7x - 88 at x = 3, with a base of x = 1. It calculates the true value of f(3) and the approximations from each order of Taylor expansion. It also computes the percent relative error of each approximation compared to the true value.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
381 views2 pages

Q4.5 Use Zero-Through Third Order Taylor Series Expansions To Predict F (3) For

The document uses Taylor series expansions up to third order to approximate the function f(x) = 25x^3 - 6x^2 + 7x - 88 at x = 3, with a base of x = 1. It calculates the true value of f(3) and the approximations from each order of Taylor expansion. It also computes the percent relative error of each approximation compared to the true value.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Q4.

5
Use zero-through third order Taylor series expansions to predict f(3) for

using a base x = 1. Compute the true percent relative error Et for each approximation
Mfile Code
fprintf('f = 25*x^3 - 6*x^2 + 7*x - 88\n')
fprintf('Use zero-through third order Taylor series\n')
fprintf('expansions to predict f(3) for\n\n')
fprintf('\tf = 25*x^3 - 6*x^2 + 7*x - 88\n\n')
fprintf('using a base x = 1. Compute the true percent relative error Et for
each approximation\n\n')
fprintf('solution\n\n')
xo = 3;
true_value = 25*xo^3 - 6*xo^2 + 7*xo - 88;
x = 1;
Fd1 = 75*x^2 - 12*x + 7;
fprintf('First derivative\t: f'' = 75*x^2 - 12*x + 7,
Fd1)
Fd2 = 150*x - 12;
fprintf('Second derivative\t: f" = 150*x - 12,
Fd2)
Fd3= 150;
fprintf('Third derivative\t: f''" = 150,
Fd3)

f''(1) = %d \n',
f"(1) = %d \n',
f''"(1) = %d \n',

fprintf('For base x = 1\n')


x = 1;
T_0 = 25*x^3 - 6*x^2 + 7*x - 88;
T_1 = T_0 + (75*x^2 - 12*x + 7)*2;
T_2 = T_1 + (150*x - 12)*(2^2)/factorial(2);
T_3 = T_2 + 150*(2^3)/factorial(3);
Error_0 = (true_value - T_0)*100/true_value;
Error_1 = (true_value - T_1)*100/true_value;
Error_2 = (true_value - T_2)*100/true_value;
Error_3 = (true_value - T_3)*100/true_value;
fprintf('\tOrder\t\tExpansion and Value\t
E%%\n')
fprintf('\t0\t\t\tf(3) = %d\t\t\t\t\t\t
%0.2f%% \n',T_0, Error_0)
fprintf('\t1\t\t\tf(3) = -62 + 70(2^1) = %d\t\t
%0.2f%%
\n',T_1,Error_1)
fprintf('\t2\t\t\tf(3) = 78 + (138*(2^2))/2! =%d\t\t %0.2f%%
\n',T_2,Error_2)
fprintf('\t3\t\t\tf(3) = 354 + (150*(2^3))/3! = %d\t %0.2f%%
\n',T_3,Error_3)

Result

You might also like