Question: PNGE 3202 Numerical Methods : Matlab code for Taylors series expansion Open new Matiab file : click file, new, and then save it as yourname.m
PNGE 3202 Numerical Methods : Matlab code for Taylors series expansion Open new Matiab file : click file, new, and then save it as yourname.m in selected and knowr folder % MATLAB CODE FOR TAYLORS FUNCTION clear % Anything written after 96 is a comment in matlab syms x ; % use help syms to know @ syms function f exp(x) ; %write your function here 12-taylor(f.x,0, 'Order,5),% call inbuilt taylor function:; try help taylor on command line ezplot(:9% use again help ezplot to know @ ezplot hold on;% again help and read the description ezplot(12): Also try Find the Maclaurin series expansion for f= sin(xyx. The default truncation order is 6, Taylor series approximation of this expression does not have a fifth-degree term, so taylor approximates this expression with the fourth-degree polynomial: syms x f sin(x)/x t6 taylor(f, x) Use Order to control the truncation order. For example, approximate the same expression up to the orders 8 and 10: t8 taylor(f, x, 'Order', 8) t 10 = taylor(f, x, Order', 10) Matlab Code for Error Analysis For function f(x.t)-x/t use Matlab to find the estimation error (assuming the first order taylor expression) atx-4 +- 0.002 and t-2+-0.001 %Open New file and save it on known source folder % Matlab code syms x t The total error is then expressed as: Dx-0.002; D-0.001: dydx-diff(y.x) dydt diffy.x) Err-abs(dydx)*Dx + abs(dydt) D F subs(y.(xt).14,2) DF subs(Err.(x.t).(4.2) DF 26 Y is F+/-DE
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
