Calling Euler Method to solve Shooting Method

17 Ansichten (letzte 30 Tage)
Muhammad Usman
Muhammad Usman am 8 Mai 2021
Bearbeitet: Torsten am 24 Nov. 2024 um 20:19
Hi, I am trying to solve a BVP:
y''(x) +5y'(x)+4y(x) = 1 with boundary conditions y(0) = 0 and y(1)=1
using shooting method.
I found many examples by solving such BVP using ode45 but I want to solve it by euler method (not allowed to use built-in command), but I got stuck in doing so.
I need help to do so...
Thanks,

Akzeptierte Antwort

Alan Stevens
Alan Stevens am 9 Mai 2021
You need to express your 2nd order ode as two 1st order odes
y``(x) + 5y`(x) + 4y(x) = 1
v = dy/dx
dv/dx = y``(x)
So you have
y`(x) = v(x)
v`(x) = 1 - 4*y(x) - 5*v(x)
Now your Euer expressions become
t(i) = t(i-1) + h;
y(i) = y(i-1) + h*v(i-1);
v(i) = v(i-1) + h*(1 - 4*y(i-1) - 5*v(i-1));
and you must supply initial values for both y and v.
  4 Kommentare
Fareeha
Fareeha am 24 Nov. 2024 um 11:35
how will we use built in command to solve this problem?
Torsten
Torsten am 24 Nov. 2024 um 19:51
Bearbeitet: Torsten am 24 Nov. 2024 um 20:19
Use "bvp4c" or - for simple problems as the one given - "dsolve".
If you are forced to use the shooting method, combine "ode45" and "fsolve".
syms y(x)
ysol = dsolve(diff(y,2)+5*diff(y,x)+4*y(x)==1,[y(0)==0,y(1)==1])

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Numerical Integration and Differential Equations finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by