KEMBAR78
Labwork 6b | PDF | Numerical Analysis | Equations
0% found this document useful (0 votes)
8 views19 pages

Labwork 6b

The document provides exercises and hints for solving ordinary differential equations (ODEs) using numerical methods in Matlab/Octave, specifically focusing on Euler's method and the fourth-order Runge-Kutta method. It includes example problems, code snippets, and suggestions for step sizes to improve accuracy. Additionally, there are bonus exercises for further practice with these numerical techniques.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views19 pages

Labwork 6b

The document provides exercises and hints for solving ordinary differential equations (ODEs) using numerical methods in Matlab/Octave, specifically focusing on Euler's method and the fourth-order Runge-Kutta method. It includes example problems, code snippets, and suggestions for step sizes to improve accuracy. Additionally, there are bonus exercises for further practice with these numerical techniques.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Numerical Methods

ODE

Thai Minh Quan - Numerical Methods 1


Euler’s method

Exercise 1: Solve this problem using Matlab/Octave

Thai Minh Quan - Numerical Methods 2


Euler’s method

Hint

dydt=@(t,y) 4*exp(0.8*t) - 0.5*y;

[t,y] = eulode(dydt,[0 4],2,1);

disp([t,y])

plot([t,y])

Thai Minh Quan - Numerical Methods 3


Euler’s method

Matlab

this error can be


reduced by using a
smaller step size.

Thai Minh Quan - Numerical Methods 4


Matlab

ODE Solvers in Matlab

Thai Minh Quan - Numerical Methods 5


Matlab

Exercise 2
Solve the ODE using Matlab/Octave:
y’ = 2t

Use a time interval of [0,5] and the initial condition y0 = 0.

Thai Minh Quan - Numerical Methods 6


Hint:

Thai Minh Quan - Numerical Methods 7


Runge-Kutta methods

The fourth-order version

Thai Minh Quan - Numerical Methods 8


Runge-Kutta methods
Exercise 3: using Matlab/Octave

Formula:

Thai Minh Quan - Numerical Methods 9


Runge-Kutta methods
Analytical solution

Thai Minh Quan - Numerical Methods 10


Runge-Kutta methods
Hint:

Thai Minh Quan - Numerical Methods 11


Runge-Kutta methods
Continue with h=0.2

Thai Minh Quan - Numerical Methods 12


Runge-Kutta methods
Continue with h=0.05

Thai Minh Quan - Numerical Methods 13


Runge-Kutta methods

Thai Minh Quan - Numerical Methods 14


Runge-Kutta methods
Full code

Thai Minh Quan - Numerical Methods 15


Runge-Kutta methods
Exercise 4: RF4 in Matlab/Octave

Thai Minh Quan - Numerical Methods 16


Runge-Kutta methods
Check: Analytical solution and RF4 solution

Thai Minh Quan - Numerical Methods 17


Bonus Exercise

Use the fourth-order Runge-Kutta methods with step sizes of 0.1 and
0.5 to solve for y between t = 0 and 1.

Thai Minh Quan - Numerical Methods 18


Euler’s method

Bonus Exercise

Thai Minh Quan - Numerical Methods 19

You might also like