Initial Value Problems for ODEs-Machine Learning-Lecture Handout, Exercises of Machine Learning

This lecture notes was distributed for Machine Learning course by Pakistan Institute of Engineering and Applied Sciences, Islamabad (PIEAS). Its main points are: Initial, Value, Problems, Ordinary, Differential, Equations, Euler, Analytical, Solution, Method, Taylor, Series

Typology: Exercises

2011/2012

Uploaded on 07/19/2012

zaraa
zaraa 🇵🇰

6 documents

1 / 17

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Dr. Hanif Durad 2
Lecture Outline
Example: Linear System of ODEs
Nonlinear Systems using pplane8
Euler’s Method
Analytical Solution
Taylor Series Methods
Heun’s method
RK-4 method
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Initial Value Problems for ODEs-Machine Learning-Lecture Handout and more Exercises Machine Learning in PDF only on Docsity!

Dr. Hanif Durad

Lecture Outline

^ Example: Linear System of ODEs ^ Nonlinear Systems using pplane8 ^ Euler’s Method ^ Analytical Solution ^ Taylor Series Methods ^ Heun’s method ^ RK-4 method

Example: Linear System ofODEs

>> A = [8,-5,10;2,1,2;-4,4,-6];>> eig(A)>> v1 = null(A - (-2)eye(3),'r')>>v2 = null(A - (3)eye(3),'r')>> v3 = null(A - (2)*eye(3),'r')>> V = [v1,v2,v3], b = [2;2;-3]>> c = V\b

Dr. Hanif Durad

Polking, ODE, P-

‘r’=rational choiceb is ICs vector

Nonlinear Systems using pplane8(1/3)x’=(1/2)x ( 2y-( x -4) ^2)y’=(1/2) ( y( -x^2 + 8x -2*y -8) )

Dr. Hanif Durad

Nonlinear Systems using pplane8(2/3)

Dr. Hanif Durad

Euler’s Method

^ Two codes have been tested against it Examples9.8 for y’=y and y’=-y^ 

Code named (euler.m) has been taken fromNUMERICAL METHODS: Using Matlab, by JohnH. Mathews and Kurtis D. Fink  Code named (eulode.m) has been taken fromApplied Numerical Methods with MATLAB forEngineers and Scientists By Steven Chapra

Dr. Hanif Durad

Using euler.m (1/2)

^ We change diffeq1 and diffeq2 for example 9.8for y

′=y and y

′=-y

^ >> euler (for y

′=y using diffeq1) ans =^0

1.00000.5000^ 1.50001.0000^ 2.25001.5000^ 3.37502.0000^ 5.06252.5000^ 7.59383.0000^ 11.39063.5000^ 17.08594.0000^ 25.

Dr. Hanif Durad

st^1 Program using Euler Method

B4, P-

Using eulode.m

>> dydt=@(t,y) y>>[^ t,y] = eulode (dydt,[0 4],1,0.5);>> [t,y]ans =^0

1.00000.5000^ 1.50001.0000^ 2.25001.5000^ 3.37502.0000^ 5.06252.5000^ 7.59383.0000^ 11.39063.5000^ 17.08594.0000^ 25.

Dr. Hanif Durad

nd^2 Program using Euler Method

Chapra B2, P-

function_handle (@)

^ Handle used in calling functions indirectly ^ Syntax^ 

handle = @functionname  handle = @(arglist)anonymous_function  Description^ ^ handle = @functionname returns a handle to the specifiedMATLAB function.^ ^ For more details see MATLAB help

Dr. Hanif Durad

Analytical Solution (2/3)

y=dsolve('D2y+4Dy+3y=0', 'y(0)=3', 'Dy(0)=4')y = 13/(2exp(t)) - 7/(2exp(3*t))>> pretty(y)^13

7 -------- - ----------2 exp(t)

2 exp(3 t)

Dr. Hanif Durad

Analytical Solution (3/3)>> y=dsolve('D2y+3yDy=0', 'y(0)=0','y(2)=1')Warning: Explicit solution could not be found.> In dsolve at 101y = [ empty sym ]

Dr. Hanif Durad Kiusalaas, P-

Heun’s method

  • f=@(t,y) -2ty^2f = @(t,y)-2ty^2>> heun(f,0,1,1,4)ans = 0 1.00000. - 0. - 0. - 0. - 0. - 0. - 1. - 0.

  • Example 9.12 , P- Dr. Hanif Durad

RK-4 method

f=@(t,y) -2ty^2f = @(t,y)-2ty^2>> rk41(f,0,1,1,4)ans =

0 1.00000.^

Dr. Hanif Durad

Assignment-