



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
This is the simulated result of MATLAB experiment 1a
Typology: Lab Reports
1 / 5
This page cannot be seen from the preview
Don't miss anything!
h→ 0
clear all clc syms x y f = input (‘Enter the given function in variable x:’); x0 = input (‘Enter the x-coordinate of the point:’); y0 = subs (f, x, x0); fx = diff (f, x); m = subs (fx, x, x0); tangent = y0+m*(x-x0); t_line = y-tangent; plotrange = [x0-3, x0+3]; ezplot (f, plotrange); hold on; ezplot (tangent, plotrange) title (‘Tangent line plot’) t = sprintf (‘The tangent to the curve y=%s at (%d, %d) is y=%s’, f, x0, y0, tangent’); disp (t)
lim h→ 0 f ( a + h ) − f ( a ) h
clc syms x y f = input (‘Enter the given function in variable x:’); x0 = input (‘Enter the x-coordinate of the point:’); y0 = subs (f, x, x0); fx = diff (f, x); m = subs (fx, x, x0); tangent = y0+m*(x-x0); t_line = y-tangent; plotrange = [x0-3, x0+3]; ezplot (f, plotrange); hold on; ezplot (tangent, plotrange) title (‘Tangent line plot’) t = sprintf (‘The tangent to the curve y=%s at (%d, %d) is y=%s’, f, x0, y0, tangent’); disp (t)
3. Verify Rolle’s theorem for the function (^) ( x + 2 )^3 ( x − 3 )^4 in the interval [ 2,3]. Plot the curve along with the
The below code illustrates the verification of Rolle’s theorem for the function f(x)= ( x + 2 )^3 ( x − 3 )^4 on the
4. Verify Lagrange’s mean value theorem for the function f(x)=x+e^3 x^ in the interval [0,1]. Plot the curve along with
f’(c)= f ( b )− f ( a ) b − a The below code illustrates the verification of Lagrange’s theorem for the function f(x)=x+e^3 x^ on the interval [0,1] clear all; clc; syms x c; f=input ('Enter the function: '); I=input ('Enter the interval [a, b]: '); a=I (1); b=I (2); fa=subs (f, x, a); fb=subs (f, x, b); df=diff (f, x); dfc=subs (df, x, c); LM=dfc-(fb-fa)/(b-a); c=solve (LM); count=0; for i=1: length(c) if c(i)>a && c(i) count=count+1; tx (count)=c(i); end end fprintf ('The values of c between %d and %d which satisfy LMVT are x=', a, b); disp(double(tx)) xval=linspace (a, b,100); yval=subs (f, x, xval); m=subs (df, tx); % Slopes of tangents at the points between a and b. ty=subs (f, x, tx); plot (xval, yval); hold on;
secant_slope=(fb-fa)/(b-a); secant_line=fa+secant_slope(x-a); sx_val=xval; sy_val=subs (secant_line, x, sx_val); plot (sx_val, sy_val); for i=1: length(tx) txval=linspace(tx(i)-1, tx(i)+1,20); t_line=ty(i)+m(i)(x-tx(i)); tyval=subs (t_line, x, txval); plot (txval, tyval,'k'); hold on plot(tx(i), ty(i),'ok'); end hold off; grid on legend ('Function', 'Secant', 'Tangents'); title ('Demonstration of LMVT');