sing the RK4 method, give the numerical approximation for the IVP: y' = ty; 0) = e; with a step size of h = 0.5 for the point at t = Euler's Method (e.g. simply using the k1 values to approximate this ODE)?. 20. How does this compare he exact solution to the IVP above is y(t) = et“/2+1. In a single figure, plot the sults of RK4, Euler methods and the exact function (thus, your plot should contain lines). To show the full Y-range, the Y-axis should be plotted using a log-scale, owever the X-axis should remain linear. To do this, type "set(gca, 'YScale','log')" n the line below that used to create the plot. Make sure that your figure has a gend that describes what each line corresponds to.
sing the RK4 method, give the numerical approximation for the IVP: y' = ty; 0) = e; with a step size of h = 0.5 for the point at t = Euler's Method (e.g. simply using the k1 values to approximate this ODE)?. 20. How does this compare he exact solution to the IVP above is y(t) = et“/2+1. In a single figure, plot the sults of RK4, Euler methods and the exact function (thus, your plot should contain lines). To show the full Y-range, the Y-axis should be plotted using a log-scale, owever the X-axis should remain linear. To do this, type "set(gca, 'YScale','log')" n the line below that used to create the plot. Make sure that your figure has a gend that describes what each line corresponds to.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
![Using the RK4 method, give the numerical approximation for the IVP: y'
y(0) = e; with a step size of h
to Euler's Method (e.g. simply using the ki values to approximate this ODE)?.
ty;
20. How does this compare
0.5 for the point at t
The exact solution to the IVP above is y(t) = et“/2+1. In a single figure, plot the
results of RK4, Euler methods and the exact function (thus, your plot should contain
3 lines). To show the full Y-range, the Y-axis should be plotted using a log-scale,
however the X-axis should remain linear. To do this, type "set(gca, 'YScale','log')"
on the line below that used to create the plot. Make sure that your figure has a
legend that describes what each line corresponds to.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fc95612c8-1a43-42cd-bc76-feb768f89efb%2F5289d4c1-9fe6-4ec5-b09d-11e477cc2866%2Fzaazrx8_processed.png&w=3840&q=75)
Transcribed Image Text:Using the RK4 method, give the numerical approximation for the IVP: y'
y(0) = e; with a step size of h
to Euler's Method (e.g. simply using the ki values to approximate this ODE)?.
ty;
20. How does this compare
0.5 for the point at t
The exact solution to the IVP above is y(t) = et“/2+1. In a single figure, plot the
results of RK4, Euler methods and the exact function (thus, your plot should contain
3 lines). To show the full Y-range, the Y-axis should be plotted using a log-scale,
however the X-axis should remain linear. To do this, type "set(gca, 'YScale','log')"
on the line below that used to create the plot. Make sure that your figure has a
legend that describes what each line corresponds to.
![t_in=0;
*S Matlab code for Euler, Improved Euler, RK4 and ode45 method
clear all
close all
Function for which solution have to do
f=@ (t,y) t.*y;
ext_val=@ (t) exp( (t. 2/2)+1);
SEuler method
* amount of intervals
* initial t
* initial y
* at what point we have to evaluate
* Number of steps
h=0.5;
y_in-exp(1);
t_eval=20;
n= (t_eval-t_in)/h;
t_elrl (1)=t_in;
y_elrl(1)=y_in;
for i-1:n
SEular Steps
m=double (f(t_in,y_in));
in=t_in+h;
y_in=y_in+h*m;
t_elrl (i+1)=t_in;
y_elrl (i+l)=y_in;
end
fprintf('\nThe solution using Euler Method for h=8.2f at t(8.2f)
is te\n',h,t_elrl(end),y_elrl(end))
*RK4 method
* amount of intervals
h=0.5;
t_in=0;
Y_in-exp(1);
t_eval=20;
n= (t_eval-t_in)/h;
t_rk1 (1)=t_in;
y_rk1(1) "y_in;
tial t
* initial y
S at what point we have to evaluate
* Number of steps
for i-1:n
&RK4 Steps
kl=h*double (f (t_in,y_in));
k2=h*double (f( (t_in+h/2), (y in+kl/2)));
k3=h*double(f( (t in+h/2), (y in+k2/2)));
k4=h*double (f( (t_in+h), (y_in+k3)));
dy= (1/6)* (k1+2*k2+2 *k3+k4);
t in=t in+h;
y_in=y_in+dy;
t rkl (i+1)=t_in;
Y_rkl (i+1)=y_in;
end
fprintf('\nThe solution using Runge Kutta Method for h=t.2f at
t(8.1f) is Be\n',h,t_rk1 (end),y_rkl (end))
ext_sol=ext_val(t_rk1);
semilogy (t_elr1,y_elrl)
1
hold on
semilogy (t_rkl,y_rkl)
semilogy (t_rk1,ext_sol)
xlabel ('time')
ylabel ('y(t)')
title('y(t) vs. t plot')
legend ('Euler','RK4','Exact Solution')
The solution using Euler Method for h=0.50 at t(20.00) is 2.264072e+28
The solution using Runge Kutta Method for h=0.50 at t(20.0) is
2.283976e+67
y(t) vs. t plot
100
FEuler
-RK4
Exact Solution
100
100
100
TO
100
100
1010
10°
4
10
12
14
16
18
20
time](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fc95612c8-1a43-42cd-bc76-feb768f89efb%2F5289d4c1-9fe6-4ec5-b09d-11e477cc2866%2F6ndlj99_processed.png&w=3840&q=75)
Transcribed Image Text:t_in=0;
*S Matlab code for Euler, Improved Euler, RK4 and ode45 method
clear all
close all
Function for which solution have to do
f=@ (t,y) t.*y;
ext_val=@ (t) exp( (t. 2/2)+1);
SEuler method
* amount of intervals
* initial t
* initial y
* at what point we have to evaluate
* Number of steps
h=0.5;
y_in-exp(1);
t_eval=20;
n= (t_eval-t_in)/h;
t_elrl (1)=t_in;
y_elrl(1)=y_in;
for i-1:n
SEular Steps
m=double (f(t_in,y_in));
in=t_in+h;
y_in=y_in+h*m;
t_elrl (i+1)=t_in;
y_elrl (i+l)=y_in;
end
fprintf('\nThe solution using Euler Method for h=8.2f at t(8.2f)
is te\n',h,t_elrl(end),y_elrl(end))
*RK4 method
* amount of intervals
h=0.5;
t_in=0;
Y_in-exp(1);
t_eval=20;
n= (t_eval-t_in)/h;
t_rk1 (1)=t_in;
y_rk1(1) "y_in;
tial t
* initial y
S at what point we have to evaluate
* Number of steps
for i-1:n
&RK4 Steps
kl=h*double (f (t_in,y_in));
k2=h*double (f( (t_in+h/2), (y in+kl/2)));
k3=h*double(f( (t in+h/2), (y in+k2/2)));
k4=h*double (f( (t_in+h), (y_in+k3)));
dy= (1/6)* (k1+2*k2+2 *k3+k4);
t in=t in+h;
y_in=y_in+dy;
t rkl (i+1)=t_in;
Y_rkl (i+1)=y_in;
end
fprintf('\nThe solution using Runge Kutta Method for h=t.2f at
t(8.1f) is Be\n',h,t_rk1 (end),y_rkl (end))
ext_sol=ext_val(t_rk1);
semilogy (t_elr1,y_elrl)
1
hold on
semilogy (t_rkl,y_rkl)
semilogy (t_rk1,ext_sol)
xlabel ('time')
ylabel ('y(t)')
title('y(t) vs. t plot')
legend ('Euler','RK4','Exact Solution')
The solution using Euler Method for h=0.50 at t(20.00) is 2.264072e+28
The solution using Runge Kutta Method for h=0.50 at t(20.0) is
2.283976e+67
y(t) vs. t plot
100
FEuler
-RK4
Exact Solution
100
100
100
TO
100
100
1010
10°
4
10
12
14
16
18
20
time
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education