This must be done in Matlab This must be done in Matlab MATLAB The user snoura i
ID: 3876621 • Letter: T
Question
This must be done in Matlab This must be done in Matlab MATLAB The user snoura input an array snoura ve input Tor tne supstrate concentration. A pro should be generated showing the reaction rate as function of concentration for both substrates Create a program that uses the Taylor series to expand the function f(x) In(1+x) . a. b. c. Include a plot of the function for x = [0:10] Note that xo-o Calculate In(l+x) for x-0.5 and x -2.0. Determine the relative error based on the exact solution if you include 1, 2, 3 or 4 terms in the seriesExplanation / Answer
Matlab Script:--
clear;
clc;
syms x %declare x as syms
f=log(1+x); %define function f(x)=ln(1+x)
y=taylor(f); %taylor series expansion
fprintf("Taylor series expansion is: ");
disp(y);
x1=0:10; %x values from 1 to 10
y1=subs(y, x, x1); %solutions from taylor series expasion
plot(x1,y1); %plot obtained solutions with respect to x values
x2=0.5; %taking x value as 0.5
y2=subs(y, x, x2); %find solution when x=0.5
fprintf(" when x=0.5 answer is %f",y2);
x3=2.0; %taking x value as 2.0
y3=subs(y, x, x3); %%find solution when x=2.0
fprintf(" when x=2.0 answer is %f",y3);
%calculating relative error when x=0.5 and consider first 5 terms in toyler series expansion
relative_error=log(1+0.5)/subs(y,x,0.2)-1;
fprintf(" Relative error is %f",relative_error);
Output:--
Taylor series expansion is: x^5/5 - x^4/4 + x^3/3 - x^2/2 + x
when x=0.5 answer is 0.407292
when x=2.0 answer is 5.066667
Relative error is 1.223790>>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.