0% found this document useful (0 votes)
13 views2 pages

Numerical 3

Uploaded by

azhanfayazalvee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Numerical 3

Uploaded by

azhanfayazalvee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Numerical 3

function y1 = fn(x,y)
y1 = x.^2 + y;
end
4th Order Runge-Kutta Method
clc
clear all
x0 = 0;
y0 = 1;
h = .05;
xn = input(' enter the value of the point ');
n = (xn - x0) / h;
for i = 1 : n
k1 = h*fn(x0,y0);
k2 = h*fn(x0+h/2,y0+k1/2);
k3 = h*fn(x0+h/2,y0+k2/2);
k4 = h*fn(x0+h,y0+k3);
y1 = y0 + (1/6)*(k1+2*k2+2*k3+k4);

y0 = y1;
x0=x0+h;
end
disp(y1)
Modified Euler’s Method
clc
clear all
x0 = 0;
y0 = 1;
h = .05;
xn = input(' enter the value of the point ');
n = (xn - x0) / h;
for i = 1 : n
y1 = y0 + h*fn(x0,y0); %initial
while (1)
y2 = y0 + h*[fn(x0,y0)+fn(x0+h,y1)]/2;
if abs(y2-y1) < 0.00001
break
else y1 = y2
end
end
x0 = x0 + h
y0 = y1
end
disp (y1)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy