1 answer

I want Matlab code. 22.2 Solve the following problem over the interval from x = 0 to 1 using a

Question:

22.2 Solve the following problem over the interval from x = 0 to 1 using a step size of 0.25 where y(0)-1. Display all your r

I want Matlab code.

22.2 Solve the following problem over the interval from x = 0 to 1 using a step size of 0.25 where y(0)-1. Display all your results on the same graph. r dV = (1 + 4x) (a) Analytically. (b) Using Euler's method. (c) Using Heun's method without iteration. (d) Using Ralston's method. (e) Using the fourth-order RK method.

Answers

%%%Matlab code

clc;
close all;
clear all;
[email protected](x , y) (1+4*x)*sqrt(y);
y1(1)=1;
x(1)=0;
h=0.25;
t=0:h:1;
%%% Analytical method
[t1 y1]=ode45(f,[0 1],y1(1));

%%% Eular method
y2(1)=1;
for n=1:length(t)-1;
y2(n+1)=y2(n)+h*f(t(n),y2(n));
end

%%%% Hen's Method
y3(1)=1;
for n=1:length(t)-1
yp=h*f(t(n),y3(n));
y3(n+1)=y3(n)+h/2*(f(t(n),y3(n))+f(t(n),yp));
end


%%%% RK-Method
yr(1)=1;
for k=1:length(t)-1
  
k1=h*feval(f,t(k),yr(k));
k2=h*feval(f,t(k)+h/2,yr(k)+k1/2);
k3=h*feval(f,t(k)+h/2,yr(k)+k2/2);
k4=h*feval(f,t(k)+h,yr(k)+k3);
yr(k+1)=yr(k)+(k1+2*k2+2*k3+k4)/6;
end


%%% Ralstan method
yrl(1)=1;
for k=1:length(t)-1
k1=h*f(t(k),yrl(k));
k2= h*f(t(k) + 2 *h / 3, yrl(k) + 2* k1 / 3 );
yrl(k+1)=yrl(k)+1/4*(k1+3*k2);
end

figure;
plot(t1,y1);
hold on
plot(t,y2,'-*');
hold on
plot(t,y3,'-o');
hold on
plot(t,yr','-^')
hold on
plot(t,yrl);
grid on
legend('Exact solution','Eular method','Hen''s Method','RK-4 method','Ralston method');
xlabel('x');
ylabel('y');

OUTPUT:

Exact solution Eular method -Hens Methood 6 RK-4 method Ralston method 5 2 0.3 0.6 0.8 0.1 0.2 0.4 0.5 0.7 0.9

.

Similar Solved Questions

1 answer
Facts: Two individuals, Aaron and Bob, want to form a new business venture, invest $5,000 each...
Facts: Two individuals, Aaron and Bob, want to form a new business venture, invest $5,000 each in it, and raise additional capital of $10 million from either a handful or thousands of investors. a. What are the three principal alternative regimes in the Code for taxing the business income that might...
1 answer
IF Sn=1+1/2+1/2^2+.......+1/(2^n-1),find the least value of n for which 2-Sn<1/100?
IF Sn=1+1/2+1/2^2+.......+1/(2^n-1),find the least value of n for which 2-Sn<1/100?...
1 answer
5) Put the following C-H bonds in order of which onc would lead to the most...
5) Put the following C-H bonds in order of which onc would lead to the most stable radical. If the C-H bond forms a more stable radical, then the bond strength will be weaker. НА HB least stable radical most stable radical weakest C-H bond НЕ strongest C-H bond Н Hp...
1 answer
John has bought a residential flat in Mong Kok at a price of $6 million. He...
John has bought a residential flat in Mong Kok at a price of $6 million. He has applied for a fully-amortizing mortgage loan from a bank for 25 years, and the interest rate for the loan was based on a composite: “Prime rate minus 2.5%”. Suppose the current prime rate and the maximum loan...
1 answer
Many pathogens enter the human body via the upper respiratory system. Please identify both the viral...
Many pathogens enter the human body via the upper respiratory system. Please identify both the viral and bacterial pathogens that infect the upper respiratory system. Specifically, the sinuses, the auditory tube, the nasal cavity, middle ear, and the trachea....
1 answer
Question 6: Draw the output wave form for the following circuits. The input is a 10V...
Question 6: Draw the output wave form for the following circuits. The input is a 10V peak sin wave and Yiotall diodes are same 1V ▲Vo Dilv R1 ▲Vo Iv. D1 in +out 10 '61完以...
1 answer
1 Let F = (22+y2) -y i + x j). Find a nontrivial curve Cį such...
1 Let F = (22+y2) -y i + x j). Find a nontrivial curve Cį such that F .dm = 0 and a nontrivial curve C, such that fc, F.dm #0. Justify Sc, F your answers....
1 answer
Problem 19. PREVIEW ONLY - ANSWERS NOT RECORDED (5 points) The angle of elevation from a...
Problem 19. PREVIEW ONLY - ANSWERS NOT RECORDED (5 points) The angle of elevation from a sailboat in a lake to the top of a vertical cliff is 60° The sailboat is 210 feet from the foot of the cift How high is the cht? feet . Round your answer to the nearest foot...
1 answer
Bring this DNA sequence to protein using the transcription (3pts) and translation (4 pts) processes. note:...
Bring this DNA sequence to protein using the transcription (3pts) and translation (4 pts) processes. note: Pending the direction your DNA is located Second position UUU Ae UCU UCC cys DU Sey UAU UAC UAA UAG UGU UGC UGA UGG UUA tyr Stop Stop JC Stop CUU CUC his CUA 5 'ATGCCGACGCCATAA 3' L...
1 answer
Consider the function Let where f(t) is differentiable for all t ∈ R. Show that z satisfies the ...
Consider the function Let where f(t) is differentiable for all t ∈ R. Show that z satisfies the partial differential equation (x2 − y2 ) ∂z/∂x + xy ∂z/∂y = xyz for all (x, y) ∈ R2 \ { (t, 0)|t ∈ R }....
1 answer
Use what you need of the following set of information to answer the question: S0 =...
Use what you need of the following set of information to answer the question: S0 = $1.1420/€            S0 = £0.7776/$                    &...
1 answer
A car is traveling at 55.0 mi/h on a horizontal highway. (a) If the coefficient of...
A car is traveling at 55.0 mi/h on a horizontal highway. (a) If the coefficient of static friction between road and tires on a rainy day is 0.102, what is the minimum distance in which the car will stop? (b) What is the stopping distance when the surface is dry and ?s = 0.605?...
1 answer
Required information [The following information applies to the questions displayed below.] Wells Technical Institute (WTI), a...
Required information [The following information applies to the questions displayed below.] Wells Technical Institute (WTI), a school owned by Tristana Wells, provides training to individuals who pay tuition directly to the school. WTI also offers training to groups in off-site locations. Its unadju...
1 answer
There is a problem regarding power system. A balanced, Y-connected voltage source with Vab = 38020...
There is a problem regarding power system. A balanced, Y-connected voltage source with Vab = 38020 rad is applied to a balanced, delta-connected load with ZA = 20.00 20.20rad 12. The line impedance between the source and load is Zi = 2.2021.22rad 22 for each phase. Calculate the real power losses i...
1 answer
40pts) Given the following code segment. mSwer= input("Enter age: ") ile answer != 'q' : try:...
40pts) Given the following code segment. mSwer= input("Enter age: ") ile answer != 'q' : try: print(int(answer) ) answer input ( " Enter age: ") except Value E rror : print ("Invalid answer 'q' age") Show what is printed if the user enters the following values...
1 answer
75 Required Information [The following information applies to the questions displayed below) All of the current...
75 Required Information [The following information applies to the questions displayed below) All of the current year's entries for Zimmerman Company have been made, except the following adjusting entries. The company's annual accounting year ends on December 31 a. On September 1 of the curre...
1 answer
Why does a patient get Diflucan after a renal transplant? Thank you to whoever can answer...
Why does a patient get Diflucan after a renal transplant? Thank you to whoever can answer this!...
1 answer
A hot piece of aluminum weighing 50.0 grams at 350°C is dropped into 500. grams of...
A hot piece of aluminum weighing 50.0 grams at 350°C is dropped into 500. grams of water at 22.0°C. What is the final temperature of the water? The specific heat of aluminum is 0.902 J/g°C and that of water is 4.184 J/g°C....