The Ralston method is a second-order method that can be used to solve an initial
ID: 3865872 • Letter: T
Question
The Ralston method is a second-order method that can be used to solve an initial value, first order ordinary differential equation. Please include Matlab code and do all parts
Problem #3 The Ralston method is a second-order method that can be used to solve an initial value, first-order ordinary differential equation. The algorithm is give below: Vi+1 = : +(k +-k2)h Where k = ft, y) k2 = f t; +-h, y: +kh You are asked to do the following: 3.1 Develop a MATLAB function m-file to implement the algorithm. The input will be the function, the time span, and the initial value. The output of the function should include the time array and the corresponding function array. 3.2 Use your function m-file to solve the following first-order ordinary differential equation from t= 0 to t=1.5 with the initial condition y=3 at t= 0. -0.3t =-1.2y+ 7e 3.3 Make a plot of your solution (with symbols) and compare it to the following exact solution (solid line): dy 70 -0.3t 43 -1.2t . de dt 9 Problem H4. The convective heat transfer problem of cold oil (Pr> 10) flowing over a hot equations. surface can be described by the following second-order ordinary differential 2Dn 22. ATExplanation / Answer
Ralston’s method
a1=1/3;
a2=2/3;
p1=3/4;
q11=3/4;
xr(1)=x0;
yr(1)=y0;
for i=1:1:n
k1=f(xr(i),yr(i));
k2=f(xr(i)+p1*h,yr(i)+q11*k1*h);
yr(i+1)=yr(i)+(a1*k1+a2*k2)*h;
xr(i+1)=xr(i)+h;
end
%Value of y at x=xf
y_ralston=yr(n+1);
% Absolute relative true error for value using Ralston’s Method
et_ralston=abs((y_ralston-yexact)/yexact)*100;
hold on
plot(xr,yr,’color’,’green’,’LineWidth’,2)
% Using first three terms of the Taylor series
syms x y;
fs=char(fcnstr);
% fsp=calculating f'(x,y) using chain rule
fsp=diff(fs,x)+diff(fs,y)*fs;
%Initial values of x and y
xr(1)=x0;
yr(1)=y0;
for i=1:1:n
k1=subs(fs,{x,y},{xr(i),yr(i)});
kk1=subs(fsp,{x,y},{xr(i),yr(i)});
yr(i+1)=yr(i)+k1*h+1/2*kk1*h^2;
xr(i+1)=xr(i)+h;
end
%Value of y at x=xf
y_taylor=yr(n+1);
% Absolute relative true error for value using Taylor series
et_taylor=abs((y_taylor-yexact)/yexact)*100;
hold on
plot(xr,yr,’color’,’black’,’LineWidth’,2)
hold off
legend(‘exact’,’heun’,’midpoint’,’ralston’,’taylor’,1)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.