Euler Method without using ODE solvers

33 vues (au cours des 30 derniers jours)
Marko Kovacevic
Marko Kovacevic le 17 Juin 2015
Commenté : James Tursa le 11 Avr 2016
I am trying to write a code that will solve a first order differential equation using Euler's method(Improved Euler's, Modified Euler's, and Euler-Cauchy). I don't want to use an ode solver, rather would like to use numerical methods which will return values for (x,y) and f(x,y) and plot of function f. I'm not sure how to begin to write this in MATLAB. I have solved the equation by hand and I'm now trying to write a code that solves that equation. Formulas for Improved Euler's, Modified Euler's, and Euler-Cauchy which I need to use are:
Improved Euler's:
Modified Euler's:
Euler-Cauchy's:
The equation to be used is y'=xy^2+y, y(0)=1, x∈[0,0.5], with step h=0.05
Any help is appreciated. Thank you in advance.

Réponses (1)

James Tursa
James Tursa le 17 Juin 2015
Modifié(e) : James Tursa le 17 Juin 2015
What have you done so far? Can you code up the simple Euler's Method? E.g., if you started with this generic expression of Euler's Method:
y(i+1) = y(i) + h * f(x(i),y(i))
can you put that inside of a MATLAB m-code for loop to generate results for some range of x with a given h?
Then, using that code, modify it for the other methods you are interested in.
Your "Modified Euler's" method doesn't look like Modified Euler to me ... it just looks like Euler's method using a h/2 step instead of a h step. (Maybe there is more to these methods in your doc that you didn't post?). E.g., see this link:
https://en.wikipedia.org/wiki/Heun%27s_method
  6 commentaires
Sanjida Ahmed
Sanjida Ahmed le 11 Avr 2016
Running this code,it gives nothing to display.whats the problem?I am new in Matlab.please help me.
James Tursa
James Tursa le 11 Avr 2016
What code are you running? If you have a different problem to solve, it would be better to open up a new question.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by