# 19MIS0171_VL2019201005248_AST01.pdf - DIGITAL ASSIGNMENT 1...

• 9

This preview shows page 1 - 4 out of 9 pages.

DIGITAL ASSIGNMENT 1 SHARVESH S 19MIS0171 1. Verify Rolle’s theorem for the function (x -3) 3 (x-3) 4 in the interval [-2,3]. Code: >>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); >>if fa==fb >>c=solve(dfc); >>count=0; >>for i=1:length(c) >>if c(i)>a && c(i)<b >>count=count+1; >>r(count)=c(i); >> end >>end >>values=sprintf('The values of c between %d and %d which satisfy Rolles theorem are x=',a,b); >>disp(values) >>disp(r) >>else >>disp('f(a) and f(b) are not equal, function doesnot satisfy conditions for Rolles theorem'); >>end
>>tval=subs(f,x,r); >>xval=linspace(a,b,100); >>yval=subs(f,x,xval); >>plot(xval,yval); >>[p,q]=size(xval); >>for i=1:length(tval) >>hold on; >>plot(xval,tval(i)*ones(p,q),'r'); >>hold on; >>plot(r(i),tval(i),'ok'); >>end >>hold off; >>legend('Function','Tangent'); >>title('Demonstration of Rolles theorem'); INPUT AND WITH PROCESSED OUTPUT GRAPH:
2. Verify Lagrange’s mean value theorem for the function x+e 3x in the interval [0,1].Plot the curve along with the secant joining the endpoints and the tangents at points which satisfy Lagrange’s mean value theorem.