Hey there, please can you solve this solved Qusetion in MatLab by any way Use Ze
ID: 3110503 • Letter: H
Question
Hey there, please can you solve this solved Qusetion in MatLab by any way
Use Zero through third order Taylor series expansions to predict f(3) for f(x) = 25 x^3 - 6x^2 + 2x - 10 x = 1 x_i = 1; x_i+1 = 3 f(3) = 2S(3)^3 - 6(3)^2 + 2(3) - 10 = 617 Zero order: f(x_i + 1) = f(x_i) f(3) = f(1) 2S(1)^3 - 6(1)62 + 2(1) - 10 = 11 sigma t = |617 - 11/617| times 100 = 98.21717% First order: f(x_i+1) + f'(x_i) .h f'(x) = 75 x^2 -12x + 2 f'(1) = 7S(1)^2 - 12(1) + 2 = 6S h = 3 - 1 = 2 f(3) = 11 + 6S(2) = 141 sigma t = |617 - 141/617| times 100 = 77.1476% Second order: f(x_i+1) = f(x_i) + f(x_i) h + f'(x) h^2/2! F"(x_i) = 150 x -12 f"(1) = 150 (1) - 12 = 138 f(3) = 11 + 6S(2) + 138. (2)^2/2! = 208 sigma t = |617 - 208/617| times 100 = 66.28% Third order: f(x_i+ 1) = f(x_i) + f'(x_i) h + f"(x_i)h^2/2! + f'''(x_i) h^3/3! F'''(x_i) = 150 f'''(150) = 150 f(3) = 11 + 6S(2) + 138 (2)^2/2! + 150 (2)^3/3! = 617 sigma t = |617 - 617/617 times 100 = 0%Explanation / Answer
clc;
clear all
f=@(x)25*x^3-6*x^2+2*x-10;
f1=@(x)75*x^2-12*x+2; %first derivative
f2=@(x) 150*x-12*x; %second derivative
f3=@(x)150; % 3rd derivative
x1=3;
x2=1;
h=x1-x2;
F(1)=f(x2); % zeroth order
F(2)=F(1)+f1(x2)*h; % first order
F(3)=F(2)+f2(x2)*(h^2/2); % second order
F(4)=F(3)+f3(x2)*(h^3/6); % third order
err(1)=abs((f(3)-F(1))/f(3))*100;
err(2)=abs((f(3)-F(2))/f(3))*100;
err(3)=abs((f(3)-F(3))/f(3))*100;
err(4)=abs((f(3)-F(4))/f(3))*100;
disp('_____________________________________________________')
disp('Order F error % ' )
disp('_____________________________________________________')
for i=1:4
fprintf('%3.0f th %10.5f %10.5f ',i-1, F(i),err(i))
end
_____________________________________________________
Order F error %
_____________________________________________________
0 th 11.00000 98.21718
1 th 141.00000 77.14749
2 th 417.00000 32.41491
3 th 617.00000 0.00000