MAT 1011 DA MATLAB.pdf - EXPERIMENT 1A NAME AASHISH SHARMA...

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

EXPERIMENT 1A NAME: AASHISH SHARMA REG.NO.: 19BCE0971 SLOT: L41+L42 AIM: To find the tangent line to the given curve y=x 2 at (2,4) MATLAB CODE: 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) INPUT: Enter the given function in variable x: x^2 Enter the x-coordinate of the point:2
OUTPUT: The tangent to the curve y= x^2 at (2,4) is y= 4*x - 4 EXPERIMENT 1A
NAME: AASHISH SHARMA REG.NO.:19BCE0971 SLOT: L41+L42 AIM: To verify Rolle’s Theorem for the function x 3 /3 3x on the interval [-3,3] MATLAB 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' );

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture