20
MA2213 Lecture 10 ODE

MA2213 Lecture 10

  • Upload
    meagan

  • View
    64

  • Download
    1

Embed Size (px)

DESCRIPTION

MA2213 Lecture 10. ODE. Topics. Importance p. 367-368. Introduction to the theory p. 368-373. Analytic solutions p. 368-372. Existence of solutions p. 372. Direction fields p. 376-379. Numerical methods. Forward Euler p. 383. Richardson’s extrapolation formula p. 391. - PowerPoint PPT Presentation

Citation preview

Page 1: MA2213 Lecture 10

MA2213 Lecture 10

ODE

Page 2: MA2213 Lecture 10

Topics

Importance p. 367-368Introduction to the theory p. 368-373

Numerical methods

Forward Euler p. 383

Richardson’s extrapolation formula p. 391

Analytic solutions p. 368-372

Existence of solutions p. 372Direction fields p. 376-379

Systems of equations p. 432

Two point boundary value problems p. 442

Page 3: MA2213 Lecture 10

Importance

“Differential equations are among the most important mathematical tools used in producing models of physical and biological sciences, and engineering.” They can be classified into:

Ordinary :

))(,(f)(' xYxxY

have 1 independent variable

)()(),()( txtytytx

Partial : have > 1 independent variable

2

2

2

2

2

2

y

u

x

u

t

u

wave equation

2

2

2

2

y

u

x

u

t

u

heat equation

Page 4: MA2213 Lecture 10

Analytic Solutions

Integration cxdxgxYxgxY )()()()('

Integrating Factors

Separation of Variables

cxxxxxYxxxg cos2sin)2()(cos)( 22

)()()()(' xbxYxaxY

)()(

),()( )()( xadx

xdxbexYe

dx

d xx

dxxaxcdxxbeezY xx )()(],)([)( )()(

KxYxrYxY /)(1)()('

dxrKxYxY

xdY

)/)(1)((

)(

)1)(0(

)0()(

xr

xr

eYK

eYKxY

Page 5: MA2213 Lecture 10

Existence of Solutions

Theorem 8.1.3 (page 372) Let and

be continuous functions of

0000' )(;)),(,(f)( YxYxxxxYxxY

),(f zxzzx /),(f x

1)0(;])([2)( 2' YxYxxY

)(xY

and

z at all points ),( zx in some neighborhood of

).,( 00 Yx Then there is a unique function

defined on some interval ],,[ 00 xx satisfying

Example 8.1.4 (p. 372) The initial value problem

admits the solution 11,1

1)(

2

x

xxY

Page 6: MA2213 Lecture 10

Direction Fields

At any point (x,y) on the graph of a solution of the

).,(f yx),()(' YxfxY the slope isequationDirection fields illustrate these slopes.

Example 8.1.8 (page 376) Consider

The slope at (x,y) is y (independent of x).

[x,y] = meshgrid(-2:0.5:2,-2:0.5:2);dx = ones(9); % Generates a mesh of 1’sdy = y; quiver(x,y,dx,dy);

.' YY

xlabel('x coordinate axis')ylabel(y coordinate axis')title(' direction field v = [1 y]^T ')

Page 7: MA2213 Lecture 10

Direction Field

Page 8: MA2213 Lecture 10

Solution Curves

The solutions of

hold onx = -2:0.01:1;;y1 = exp(x);y2=-exp(x);plot(x,y1,x,y2)hold off

YY ' are xYxY e)0()(

Page 9: MA2213 Lecture 10

Direction Field with Two Solution Curves

Page 10: MA2213 Lecture 10

Forward Euler Method

)(xYLet

bxxxYxxY 0' ,))(,(f)(

be the solution of the initial value problem

00 )( YxY Numerical methods will give an approximate solution at

a discrete set of nodes bxxxx N 210For simplicity we choose evenly spaced nodes

.,...,1,0 Nnhnxxn Taylor’s approximation

))(,(f)()()()( '1 nnnnnn xYxhxYxYhxYxY

gives the forward Euler method for approximations

10),,(f1 Nnyxhyy nnnn

00 Yy

Page 11: MA2213 Lecture 10

Examples of Forward Euler Method

)(xYLet

,)(' xxY be the solution of the initial value problem

00 )( YxY For nodes Nnhnxxn ,...,1,0 forward Euler method gives approximations

10,1 Nnxhyy nnn,00 Yy so

,001 xhYy ),( 0002 hxhxhYy

),2()( 00003 hxhhxhxhYy

2/)1( 200 hnnxnhYyn

Page 12: MA2213 Lecture 10

Error of Forward Euler Method

)(xYLet

,)(' xxY be the solution of the initial value problem

00 )( YxY For nodes Nnhnxxn ,...,1,0 the exact solution is

2/)1( 200 hnnxnhYyn

nx

xn xdxYxY0

0)(

2/| 2200

221

0 0hnnhxYxY nx

x and the numerical approximation equals

therefore we have the error

)(2/)(2/)( 02 hOxxhnhyxY nnn

Page 13: MA2213 Lecture 10

Richardson Extrapolation

It can be shown, using an analysis similar to the one on the preceding page, that the numerical solution obtainedusing the forward Euler method with step size satisfies h

33

2210 )()( hahahanhxYhyn

therefore, the approximation using step size satisfies

These two estimates can be combined to give

2/h

4/2/)()2/( 22102 hahanhxYhy n

2/)()()2/(2 2202 hanhxYhyhy nn

which has a much smaller error than )2/(2 hy n

This process can be extended as in slides 36,40 Lect 7.

Page 14: MA2213 Lecture 10

Systems of Equations

The general form of a system of two first-order differential equations is (page 432)

0,101211'1 )()),(),(,(f)( YxYxYxYxxY

This system can be simply represented using vectors

00' )()),(,(f)( YxYxYxxY

0,202212'2 )()),(),(,(f)( YxYxYxYxxY

2

2

1

0,2

0,10

2

1 ,),(f

),(f),(f,)(,

)(

)()( Rz

zx

zxzx

Y

YxY

xY

xYxY

Page 15: MA2213 Lecture 10

Systems of EquationsFor the system of two equations in slide 3

0,2

0,10

1

2' )(,)(

)()(

Y

YxY

xY

xYxY

2

2

1

1

2 ,),(f Rz

zz

z

zzx

and the solution of the initial value problem is

0,2

0,1

00

00

2

1

)(cos)(sin

)(sin)(cos

)(

)()(

Y

Y

xxxx

xxxx

xY

xYxY

Page 16: MA2213 Lecture 10

Systems of Equations

Y0 = [1;0]; h = 0.001; N = round(1000*2*pi); x0 = 0;Y(:,1) = Y0; x(1) = x0;for n = 1:N

x(n+1) = x(n)+h;f = [-Y(2,n);Y(1,n)];Y(:,n+1) = Y(:,n) + h*f;

endfigure(1); plot(x,Y(1,:),x,Y(2,:)); grid; title(‘approximate solution’)figure(2); plot(x,Y(1,:)-cos(x),x,Y(2,:)-sin(x)); grid;title(‘error’)

Page 17: MA2213 Lecture 10

Systems of Equations

Page 18: MA2213 Lecture 10

Systems of Equations

Page 19: MA2213 Lecture 10

Two-Point Boundary Value Problems

],[),()()()()()( ''' baxxrxYxqxYxpxY A second-order linear boundary value problem (p. 442)

21 )(,)( gbYgaY can be discretized. We choose

nodes ,0,/)(, NiNabhihaxi let

211''11' 2

)(,2

)(h

YYYxY

h

YYxY iii

iii

i

),(),(),(),( iiiiiiii xrrxqqxppxYY

11, NiYy iito obtain linear equations for

iii

iiii rhy

hpyqhy

hp 21

21 1

22

21

Page 20: MA2213 Lecture 10

Homework Due Lab 5 (Week 13, 12-16 November)

was proposed as a model for population growth by Peirre Verhulst in 1838. Draw its direction fields and solution curves for Y(0) = .5K and Y(0)=1.5K.

,/)(1)()(' KxYxYrxY 1. The logistic equation

4. Write the MATLAB Program on page 445, study pages 446-448, and do problem 7 on page 449. (Extrapolated means Richardson extrapolated)

2. Implement the forward Euler method to compute the two solutions above. Use plots and tables to show how Richardson extrapolation decreases the errors.

3. Study the Lotka-Volterra predator-prey model on page 433 and then do problem 9 on page 441. Extra Credit: Use the secant method to compute the smallest x > 0 so that Y(x) = Y(0) where Y is the solution in part (b).