# Mathematics Roots, Differentiation and Integration Prof. Muhammad Saeed.

## Presentation on theme: "Mathematics Roots, Differentiation and Integration Prof. Muhammad Saeed."— Presentation transcript:

Mathematics Roots, Differentiation and Integration Prof. Muhammad Saeed

1.r = roots(p) 2.r = fzero(func,x0), 3.r = fzero(func,[x1 x2]) a)r = fzero('3*x^3+2*x^2-5*x+7',5) b)r = fzero(@myfun,x0) c)r = fzero(@(x) exp(x)*sin(x),x0) d)Hfnc = @(x) x^2*cos(2*x)*sin(x*x) r = fzero(Hfnc, [x0 x1]) 4.a= 1.5; r = fzero(@(x) myfun(x,a),0.1) 5.options = optimset('Display','iter','TolFun',1e-8) opts=optimset(options,'TolX',1e-4) r = fzero(fun,x 0,opts) 2Mathematical modeling & Simulations

6.[r,fval] = fzero(...) 7.[r,fval,exitflag] = fzero(...) 8.[r,fval,exitflag,output] = fzero(...) output.algorithm :Algorithm used output.funcCount Number of function evaluations output.intervaliterations:Number of iterations taken to find an interval output.iterations: Number of zero-finding iterations output.message:Exit message ExitFlags 1Function converged to a solution x. -1Algorithm was terminated by the output function. -3NaN or Inf function value was encountered during search for an interval containing a sign change. -4Complex function value was encountered during search for an interval containing a sign change. -5Algorithm might have converged to a singular point. 9.[….. ] =fminbnd(…) 3Mathematical modeling & Simulations

4 [r,p,k] = residue(b,a) [b,a] = residue(r,p,k) 1.Symbolic a.syms x t z alpha; #int(-2*x/(1+x^2)^2) #int(x/(1+z^2),z) #int(x*log(1+x),0,1) #int(2*x, sin(t), 1)

5Mathematical modeling & Simulations 2.Numerical # Z = trapz(Y) #Z = trapz(X,Y) Example: IntegralTrapz.mIntegralTrapz.m #Z = quad(hfun,a,b) #Z = quad(hfun,a,b,tol) #[Z,fcnt] = quad(...) #Z= quad(@fun,a,b) #[Z, fcnt]=quad(……) # Z=quad(fun,a,b,tol,trace) #Z=quadl(……..) The quad function may be most efficient for low accuracies with nonsmooth integrands. The quadl function may be more efficient than quad at higher accuracies with smooth integrands.

1.Symbolic syms x f = sin(5*x) g = exp(x)*cos(x); diff(g); diff(g,2) syms s t f = sin(s*t) ; diff(f,t) ; diff(f,s); diff(f,t,2); 2.Numerical diff(x) ; diff(y) z=diff(y)./diff(x) z=diff(y,2)./diff(x,2) polyder(p) polyder(a,b) 7Mathematical modeling & Simulations

8

END 9Mathematical modeling & Simulations