Modified Euler method is another numerical method to solve the first order ordinary differential equation with given initial condition. This method is better compare to Simple Euler method. Because this method take an arithmetic average of slopes at xi and xi+1, mean, at the end points of each sub-interval. In this, we compute first approximation value to yi+1 and then improve it by making use of average slope. The local truncation error of Modified Euler method is O(h3)
At here, we write the code of Modified Euler Method in MATLAB step by step. MATLAB is easy way to solve complicated problems that are not solve by hand or impossible to solve at page. MATLAB is develop for mathematics, therefore MATLAB is the abbreviation of MATrix LABoratory.
The formula of Modified Euler method is
At here, we solve the differential equation by using Modified Euler method with the help of MATLAB.
% Numerical Method
% Modified Euler method using MATLAB coding
% Modified Euler method also known as Runge-Kutta method of order 2
clear all;
close all;
clc;
f=inline('y-t^2+1');
x0=input('Enter x0=');
y0=input('Enter y0=');
xn=input('Enter upper limit of interval xn=');
h=input('Enter width (equal space) h=');
n=(xn-x0)/h;
fprintf('--------------------------------------------\n')
fprintf(' x y ynew\n');
fprintf('--------------------------------------------\n')
for i=1:n
y1=y0+h*(f(x0,y0)+f(x0+h,y0+h*f(x0,y0)))/2;
fprintf('%f %f %f \n',x0,y0,y1)
y0=y1;
x0=x0+h;
end
Other Numerical Methods with MATLAB Coding
- Bisection Method with MATLAB
- Newton Raphson Method with MATLAB
- Secant Method with MATLAB
- Regula Falsi Method with MATLAB
- Fixed Point Iteration with MATLAB
- Trapezoidal Rule with MATLAB
- Simpson 1/3 Rule with MATLAB
- Simpson 3/8 Rule with MATLAB
- Bool’s Rule with MATLAB
- Weddle’s Rule with MATLAB
- Euler Method with MATLAB
- Modified Euler Method with MATLAB
- Midpoint Method with MATLAB
- Runge-Kutta Method with MATLAB
- Millen’s Method with MATLAB
- Adams Bashforth Moulton Method with MATLAB
- Newton Forward Difference Interpolation with MATLAB
- Newton Backward Difference Interpolation with MATLAB
- Lagrange Interpolation with MATLAB
- Newton Divided Difference Interpolation with MATLAB
- Hermite Interpolation with MATLAB
- Natural Cubic Spline Interpolation with MATLAB
- Gauss Jacobi Method with MATLAB
- Gauss Seidal Method with MATLAB
- Power Method with MATLAB