Using euler's forward method solve this integration:
dx/dt = -10 * x(t) + 5
x(0) = 4
The time step is 0.01, and the time interval is from 0 to 20.
Please show all steps and calculations, because this is just an example problem to help me get a better understanding of euler's method.
Euler's method is a numerical process to find out the solution of a 1st order ordinary differential equation
With the initial condition
Here we have
Numerical Scheme for Euler's method is, we divide the time period to N small parts and then try to interpolate the solution at every small step. i.e.
(Here the step is 0.01)
Here
Now here is a MATLAB code for the given problem
function [ output ] = g(x,t)
output=-10*x+5;
end
EUL.m
clc
clear all
a=0;b=20;
h=0.01 ;
n=(b-a)/h;
n=ceil(n);
x=linspace(a,b,n+1);
ya=4;
eu=zeros(1,n+1);eu(1)=ya;
y=zeros(1,n+1);y(1)=ya;
for i=1:n
eu(i+1)=eu(i)+h*g(x(i),eu(i));
end
Thanks
R
Get Answers For Free
Most questions answered within 1 hours.