1 / 12

Approximating the derivatives

Approximating the derivatives. Numerical ODE (1D). Initial Value Problem:. Example:. Approximate . Numerical ODE (1D). Example:. Approximate . Forward Euler Method. Forward Euler Method. Example:. Numerical ODE (1D). Example:. function [xi,ti]=feuler(t0,T,n,xi_0) k=(T-t0)/n;

keola
Download Presentation

Approximating the derivatives

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. Approximating the derivatives

  2. Numerical ODE (1D) Initial Value Problem: Example: Approximate

  3. Numerical ODE (1D) Example: Approximate

  4. Forward Euler Method Forward Euler Method Example:

  5. Numerical ODE (1D) Example: function [xi,ti]=feuler(t0,T,n,xi_0) k=(T-t0)/n; ti=[t0:k:T]; F=inline('xi+4*exp(0.5*t)+5','xi','t'); xi(1) = xi_0; for i=2:n+1 xi(i) = xi(i-1)+k*F(xi(i-1),ti(i-1)); end [xi,ti]=feuler(0,1,100,-5) plot(ti,xi,'bo-')

  6. Crank–Nicolson Method Forward Euler Method Backward Euler Method Crank-Nicolson Method Larson Book Each of these three method have its own characteristics regarding accuracy, stability, and computational cost. Loosely speaking, forward Euler is very fast, backward Euler numerically stable, and Crank-Nicolson the most accurate.

  7. Numerical ODE (System) System of ODEs: Numerical: M nxn matrix Forward Euler Method Crank-Nicolson Method

  8. Numerical ODE (System) Special Case: M nxn matrix A nxn matrix Crank-Nicolson Method

  9. Numerical ODE (System) Example: function [xi,t]=cnm(t0,T,n,xi_0) k=(T-t0)/n; t=[t0:k:T]; b=inline('[t.^2-1;3.*t+2]'); A=[1,0;0,1]; M=[2,1;1,2]; MpA=M+(k/2)*A; MmA=M-(k/2)*A; xi(:,1) = xi_0; for i=2:n+1 bb= (k/2)*( b(t(i)) + b(t(i-1)) ); rhs = MmA*xi(:,i-1)+bb; xi(:,i) = MpA\rhs; end with the initial condition Use Crank-Nicolson Method to solve the system. Then plot the two components of the solution.

  10. Numerical ODE (System) Exercise: with the initial condition Use Crank-Nicolson Method to solve the system. Then plot the two components of the solution.

  11. Numerical ODE (2ed order) 2ed order: Introduce a new varible to reduce it into 1st order

  12. Numerical ODE (System) Example: with the initial condition Use Crank-Nicolson Method to solve the system. Then plot the two components of the solution.

More Related