Then please rectify my code (give it a range of -10,10) function extreme syms x; assume(x,'real') f=input('Enter function:','s'); fun=sym(f); df=diff(fun);
fprintf('\nDerivative of your function is:\n%s\n',char (df)) xmin=input('Enter lower limit of range of function;'); xmax=input('Enter upper limit of range of function;');
if (nargin<4) N=100; end dx=(xmax-xmin)/N; x2=xmin; y2=f(x2); y=[]; for i=1:N x1=x2; y1=y2; x2=xmin+i*dx; y2=f(x2); if (y1*y2<=0) y=fsolve(f,(x2*y1-x1*y2)/(y1-y2)); end end fprintf('\n%f',y)
r=input('\nHow many roots do you see above?'); n=r; disp ('Enter each point indivivually'); for i=1:n fprintf('\nInput point 0%d\n',i) r1=input(':'); y=r1; fprintf('\n Root%d=%f\n',i,y) end