Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mathematics Roots, Differentiation and Integration Prof. Muhammad Saeed.

Similar presentations


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

1 Mathematics Roots, Differentiation and Integration Prof. Muhammad Saeed

2 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 = c)r = exp(x)*sin(x),x0) d)Hfnc x^2*cos(2*x)*sin(x*x) r = fzero(Hfnc, [x0 x1]) 4.a= 1.5; r = 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

3 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 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)

5 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= #[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.

6 q = quadgk(fun,a,b) [q,errbnd] = quadgk(fun,a,b,tol) [q,errbnd] = quadgk(fun,a,b,param1,val1,param2,val2,...) [q,errbnd] = 'RelTol',1e-8,'AbsTol',1e-12) The quadgk function may be most efficient for high accuracies and oscillatory integrands. It supports infinite intervals and can handle moderate singularities at the endpoints. It also supports contour integration along piecewise linear paths. q = dblquad(fun,xmin,xmax,ymin,ymax) q = dblquad(fun,xmin,xmax,ymin,ymax,tol) q = dblquad(fun,xmin,xmax,ymin,ymax,tol,method) q = -1, 1, -1, 1) triplequad(fun,xmin,xmax,ymin,ymax,zmin,zmax) triplequad(fun,xmin,xmax,ymin,ymax,zmin,zmax,tol) triplequad(fun,xmin,xmax,ymin,ymax,zmin,zmax,tol,method) F Q = triplequad(F,0,pi,0,1,-1,1);

7 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 8

9 END 9Mathematical modeling & Simulations


Download ppt "Mathematics Roots, Differentiation and Integration Prof. Muhammad Saeed."

Similar presentations


Ads by Google