Download presentation

Presentation is loading. Please wait.

Published bySarah Stephens Modified over 3 years ago

1
Differential Equations Prof. Muhammad Saeed Mathematical Modeling and Simulation UsingMATLAB (Plus Symbolic Mathematics) 1

2
§Symbolic Math syms x y z a b ; 1.Expansion: expand((x+a)^3); expand(sin(a+b)); 2.Factorization: factor(a^2-b^2); 3.Series Summation: syms k n; symsum(k,0,10);symsum(k^2,1,4);sysmsum(k,0,n-1) 4.Substitution: Expr=x^2+6*x+9; subs(Expr,x,2); subs(Expr,x,a); 5.Solution of Equations: solve(3*x^3+2*x^2-4*x+12=0); solve(3*x^3+2*x^2-4*x+12); solve(sin(2*x)-cos(x)=0); 6.Solution of Simultaneous Equations: eqn1=4*x+3*y=5; eqn2=2*x+2*y=-3; S=solve(eqn1,eqn2); { S.x, S.y} S=solve(eqn1,eqn2, …….); 2

3
§Symbolic Math: 7.Limit: limit(sin(x)/x) f = sin(x)/x; limit(f);limit(f,a); limit(f, x,a,); limit(f,x,a,right); limit(f,x,a,left); 8.Taylor Series: f=exp(x); taylor(f, 5); taylor(f, 5,2); 9.Graph Plot: ezplot(f, [-3 3]) 10.Differentiation: syms x n; diff(x^n) diff((sin(x))^2) diff(x*sin(x*y), y, 2) 3

4
§Symbolic Math: 11.Integration: syms x y n a b int(x^n); int(x^n, n); int(xy^2,y,0,4); int(x^3, a,b); 12.Laplace Transform: syms s b t w x; laplace(t^3); laplace(exp(-b*t)); laplace(exp(a*s)) ; laplace(sin(w*x),t); laplace(cos(x*w),w,t); laplace(diff(sym('F(t)'))) 4

5
§Symbolic Math: 13. Inverse Laplace Transform: ilaplace(1/s^3); ilaplace(1/(s+b); ilaplace(b/(s^2+b^2)); 14.More to study: fourier, ifourier, ztrans, iztrans, sym, poly2sym, sym2poly findsym, simplify, collect See for DE solution using Laplace Transform: DESymb.m 5

6
§Symbolic Solution of Differential Equations: dsolve(Dy+2*y = 12) dsolve(Dy = sin(a*t)) dsolve(D2y = c^2*y) [x, y] = dsolve(Dx = 3*x+4*y, Dy = -4*x+3*y ) dsolve(Dy = sin(a*t), y(0) = 0) ; { y(0) = c } dsolve(D2y = c^2*y,y(0) = 1,Dy(0) = 0) [x, y] = dsolve(Dx = 3*x+4*y, Dy = -4*x+3*y,x(0) = 0,y(0) = 1) dsolve(D2y+9*sin(y) = 0,y(0) = 0,y(L) = 0) 6

7
§Numeric Solution of Differential Equations: 1.Eulers Method. Example: DEEulersMethod.m 2.MATLAB ODE Solvers 7 SolverSolves These Kinds of ProblemsMethod ode45 Nonstiff differential equationsRunge-Kutta ode23 Nonstiff differential equationsRunge-Kutta ode113 Nonstiff differential equationsAdams ode15s Stiff differential equations and DAEsNDFs (BDFs) ode23s Stiff differential equationsRosenbrock ode23t Moderately stiff differential equations and DAEsTrapezoidal rule ode23tb Stiff differential equationsTR-BDF2 ode15i Fully implicit differential equationsBDFs

8
§Numeric Solution of Differential Equations: 8 a) DEs Of Order 1: [t, y]=solver(func,[ti tj], y(i)) function ydot=funcName(t,y) ydot= f(y,t)………. ; end ODEs: b) DEs Of Order 2: [t, x]=solver(function,[ti, tj],[y(i), y(j)]) function xdot=funcName(t,x) xdot(1)=x(2) xdot(2)= func( x(1), x(2), t ) xdot=[xdot(1);xdot(2)]; end; ODE:, van der Pol Eqn.

9
9 §Numeric Solution of Differential Equations: Examples: I. DEs Of Order 1 function ydot = DEorder1_01(t,y) ydot = sin(t); end [t,y] = ode23(DEorder1_01, [0, 4*pi], 0); Analytic Solution y= 1-cos(t)

10
10 §Numeric Solution of Differential Equations: Examples: 2. DEs Of Order 2 function ydot = vdpol(t,y) mu = 2; ydot(1) = y(2); ydot(2) = mu*(1-y(1)^2)*y(2) – y(1); ydot = [ydot(1); ydot(2)]; end [t,y] = ode45(vdpol, [0, 20],[2; 0]); ( van der Pol Eqn. )

11
11 §Numeric Solution of Differential Equations: Examples: 2. DEs Of Order 2 ( van der Pol Eqn. ) function ydot = vdpol2((t,y,mu) ydot(1) = y(2); ydot(2) = mu*(1-y(1)^2)*y(2) – y(1); ydot = [ydot(1); ydot(2)] end options=odeset(Refine,4); [t,y] = ode45(vdpol, [0, 20], [2; 0], options, 2);

12
12 END

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google