Jump to content

Backward Euler Method

Featured Replies

Hi!!! I need some help...
I want to write a code in matlab for the backward euler method.
How can I solve the equation to determine y^(n+1)??? Are newton's method, fixed point iteration, fsolve, fzero equal???

  • Author

To use Newton's method, do i have to write:

for i=1:n
y(n+1)=y(n)-(g(y(n))/dg(y(n));

where g=y(n+1)-y(n)-h*f(t(n+1),y(n+1)) ???

For the backward Euler's method, you could use something like the following:

 

clc;
clear;

ti=0;
tf=10;
n=5000;
h=(tf-ti)/n;
t(1)=ti;
y(1)=1;

for i=1:n
dydt=sin(t(i));
t(i+1)=t(i)+h;
y(i+1)=y(i)+h*dydt;
end;

plot(t,y)

 

 

I used dy/dt=sin(t) as an example function. To make it go backwards, all you have to do is make tf<ti, so that h becomes negative.

Edited by elfmotat

Archived

This topic is now archived and is closed to further replies.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.