a. (15 points) Use Heun\'s method with h-0.5 to solve the following initial-valu
ID: 3184248 • Letter: A
Question
a. (15 points) Use Heun's method with h-0.5 to solve the following initial-value dy problem numerically over the interval from x = 0 to 2.5: =yx2-1.ly where dx r-1.1x y(0) = 1 . Iterate the corrector to ,-1%· (Note that ytr-ue(x) = e3 b. (10 points) Use Midpoint method with h 0.5 to solve the same ODE above over the interval from x = 0 to 2.5. (10 points) Compare the results in parts (a) and (b). Comment about which method gives the best results and why. Do you observe any divergent behaviour? If so, how c. x3-1.1x would you avoid it? Use y.ru(x) 3 as the true solution (Note: Show all of the equations used in your computations clearly. Since each step may involve several iterations, use of Excel or MATLAB is recommended)Explanation / Answer
% Program to solve the initial value problem y' = yx^2 - 1.1y over the interval from x=0 to
% 2.5 where y(0)= 1 . Iterate the corrector to 1% i.e. 0.01
f=@(y,x)((y*(x^2))-((1.1)*y));
%%%%%%%%%%%%% (a) Heun's Mehtod %%%%%%%%%%%%%%
y0 = 1;
x0 = 0;
xf = 2.5;
h = 0.5;
n = (xf-x0)/h;
yh = zeros(n,1);
x = zeros(n,1);
yt = zeros(n,1);
yh(1) = y0;
x(1) = x0;
yt(1) = exp(((1/3)*(x(1)^3))-1.1*x(1));
for i=1:n
k1 = f(yh(i), x(i));
k2 = f(yh(i)+(h*k1), x(i) + h);
yh(i+1) = yh(i) + (h/2)*(k1 + k2);
x(i+1) = x(i) + h;
yt(i+1) = exp(((1/3)*((x(i+1))^3))-1.1*x(i+1));
end
%%%%%%%%%%% (b) Mid Point Method %%%%%%%%%%%%%%%%%%
y10 = 1;
x10 = 0;
x1f = 2.5;
h1 = 0.5;
n1 = (x1f-x10)/h1;
ymp = zeros(n1,1);
x1 = zeros(n1,1);
ymp(1) = y10;
x1(1) = x10;
for i=1:n
k11 = f(ymp(i), x1(i));
k22 = f(ymp(i)+(h1*k11/2), x1(i) + (h1/2));
ymp(i+1) = ymp(i) + (h1*k22);
x1(i+1) = x1(i) + h1;
end
disp('The discrete values for x :');
disp(x);
disp('The result y(x) obtained using the Heuns Method :');
disp(yh);
disp('The result y(x) obtained using the Midpoint Method :');
disp(ymp);
disp('The true result y(x) is obtained as :');
disp(yt);
disp('From the above results it is concluded that the Heuns Mehtod is performing better than the Midpoint mehtod and we did not find any divergent behavior.');
The discrete values for x :
0
0.5000
1.0000
1.5000
2.0000
2.5000
The result y(x) obtained using the Heuns Method :
1.0000
0.6294
0.4866
0.6073
1.4754
7.1991
The result y(x) obtained using the Midpoint Method :
1.0000
0.6239
0.4919
0.6028
1.3643
6.0269
The true result y(x) is obtained as :
1.0000
0.6015
0.4646
0.5916
1.5947
11.6853
(c) From the above results it is concluded that the Heuns Mehtod is performing better than the Midpoint mehtod and we did not find any divergent behavior.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.