Consider the following wellposed IVP t1 M 1 sts 2 1 y1 2 wit

Consider the following well-posed IVP: (t)-1 M, 1 sts 2; (1) y(1) 2, with the exact solution ylt) tln t 20. oose the step sizes h 0.2,0.1, 0.05, respectively. (a) Use Taylor\'s method of order two to approximate the solution. Discuss the behavior of the approximated solution as a function of h, and compare it with the exact solution in plots of t versus y. Estimate the order of the method from the error. Which value of h do you need to choose (approximately) to achieve an accuracy of 10 for y 2)? (b) Use Midpoint method (p.286) to redo Part (a). (c) pare the results and running times of Part (a) and (b). hat does the comparison of error and running time tell us about the efficiency of the two methods? Requirements Submit the code file to CCLE 2: A MATLAB (or other software) function taylor2.m that implements Taylor\'s method of order two, a MATLAB function (or other software) midpt.m that implements Mid- point method, and a MATLAB (or other software) script main..m that solves the IVP (1) and plots the approximated solutions versus the exact one.

Solution

Solution:

Using Taylor\'s method of order 2: See the code below:

-------------------------------------------

%solution of initial value problem using Taylor\'s method of order 2
%y is function of t.
%Given
a=1; %lower limit for t
b=2; %upper limit for t
alpha=2; %value of function y at a
h = [0.2 0.1 0.05]; %vector of step sizes

%function y
function yt = y(t)
yt = t*log(t)+2*t;
end

%function for first derivative of y - y\'
function ydash_t = ydash(t)
ydash_t=1+y(t)/t;
end

%function for second derivative of y - y\'\'
function ydashdash_t = ydashdash(t)
ydashdash_t=1/t;
end

%first taylor term
omega0=alpha;

for step = h
printf(\"\ For step size:%f\ \",step);
time = a:step:b;
printf(\"Using Taylor\'s method:\ \");
printf(\"%.2f \",omega0);
omega_prev=omega0;
for i = time
    omega_i=omega_prev+step*ydash(i)+((step^2)/2)*ydashdash(i); %calculation of Taylor\'s term
    printf(\"%.2f \",omega_i);
    omega_prev=omega_i;
end
printf(\"\ For exact soloution:\ \");
for i = time
    yt_i=y(i);
    printf(\"%.2f \",yt_i);  
end
end

-------------------------------

Output:

-------------------------------

For step size:0.200000
Using Taylor\'s method:
2.00 2.62 3.27 3.95 4.66 5.39 6.14
For exact soloution:
2.00 2.62 3.27 3.95 4.66 5.39
For step size:0.100000
Using Taylor\'s method:
2.00 2.30 2.62 2.94 3.27 3.61 3.95 4.30 4.66 5.02 5.39 5.76
For exact soloution:
2.00 2.30 2.62 2.94 3.27 3.61 3.95 4.30 4.66 5.02 5.39
For step size:0.050000
Using Taylor\'s method:
2.00 2.15 2.30 2.46 2.62 2.78 2.94 3.11 3.27 3.44 3.61 3.78 3.95 4.13 4.30 4.48 4.66 4.84 5.02 5.20 5.39 5.57
For exact soloution:
2.00 2.15 2.30 2.46 2.62 2.78 2.94 3.11 3.27 3.44 3.61 3.78 3.95 4.13 4.30 4.48 4.66 4.84 5.02 5.20 5.39

------------------------------------------

 Consider the following well-posed IVP: (t)-1 M, 1 sts 2; (1) y(1) 2, with the exact solution ylt) tln t 20. oose the step sizes h 0.2,0.1, 0.05, respectively.
 Consider the following well-posed IVP: (t)-1 M, 1 sts 2; (1) y(1) 2, with the exact solution ylt) tln t 20. oose the step sizes h 0.2,0.1, 0.05, respectively.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site