1 / 9

Mathematics Roots, Differentiation and Integration

Mathematics Roots, Differentiation and Integration. Prof. Muhammad Saeed.  Roots. r = roots(p) r = fzero (func,x0), r = fzero ( func ,[x1 x2]) r = fzero ('3*x^3+2*x^2-5*x+7',5) r = fzero (@myfun,x0) r = fzero (@(x) exp(x)*sin(x),x0) Hfnc = @(x) x^2* cos (2*x)*sin(x*x)

tadita
Download Presentation

Mathematics Roots, Differentiation and Integration

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MathematicsRoots, Differentiation and Integration Prof. Muhammad Saeed

  2.  Roots • r = roots(p) • r = fzero(func,x0), • r = fzero(func,[x1 x2]) • r = fzero('3*x^3+2*x^2-5*x+7',5) • r = fzero(@myfun,x0) • r = fzero(@(x) exp(x)*sin(x),x0) • 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,x0,opts) Mathematical 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 • 1 Function converged to a solution x. • -1 Algorithm was terminated by the output function. •   -3 NaN or Inf function value was encountered during search for an interval containing a sign change. •   -4 Complex function value was encountered during search for an interval containing a sign change. •   -5 Algorithm might have converged to a singular point. • 9.[….. ] =fminbnd(…) Mathematical modeling & Simulations

  4.  Residues [r,p,k] = residue(b,a)[b,a] = residue(r,p,k) •  Integration • 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) Mathematical modeling & Simulations

  5.  Integration • Numerical • # Z = trapz(Y)# Z = trapz(X,Y)Example: IntegralTrapz.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.” Mathematical modeling & Simulations

  6.  Integration q = quadgk(fun,a,b)[q,errbnd] = quadgk(fun,a,b,tol)[q,errbnd] = quadgk(fun,a,b,param1,val1,param2,val2,...) [q,errbnd] = quadgk(@(x)x.^5.*exp(-x).*sin(x),0,inf, '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 = dblquad(@(x,y)sqrt(max(1-(x.^2+y.^2),0)), -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 = @(x,y,z)y*sin(x)+z*cos(x); Q = triplequad(F,0,pi,0,1,-1,1);

  7.  Differentiation • 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); • Numerical • diff(x) ; diff(y) • z=diff(y)./diff(x) • z=diff(y,2)./diff(x,2) • polyder(p) • polyder(a,b) Mathematical modeling & Simulations

  8. Rounding • ceil • floor • fix • round • Discrete Mathematics • fs=factor(n) • f=factorial(n) • g=gcd(a,b) • l=lcm(a,b) • c=nchoosek(n,r) • v=[3 6 7]; p=perms(v) • p=primes(n) Mathematical modeling & Simulations

  9. END Mathematical modeling & Simulations

More Related