Question

LAB. Implement the classical procedure (8.82), and apply it to equation (8.66). Solve it with stepsizes of h = 0.25 and 0.125

0 0
Add a comment Improve this question Transcribed image text
Answer #1

clc

clear all

close all

format long

f=@(x,y) -y+2*cos(x);

disp('Solution for h=0.25')

[X1,Y1]=runge4(f,[0,1],1,0.25)

[X2,Y2]=runge4(f,[0,1],1,0.125)

plot(X1,Y1,X2,Y2);

legend('h=0.25','h=0.125')

function [x,y]=runge4(f,tspan,y0,h)

x = tspan(1):h:tspan(2); % Calculates upto y(3)

y = zeros(length(x),1);

y(1,:) = y0; % initial condition

for i=1:(length(x)-1) % calculation loop

k_1 = f(x(i),y(i,:));

k_2 = f(x(i)+0.5*h,y(i,:)+0.5*h*k_1);

k_3 = f((x(i)+0.5*h),(y(i,:)+0.5*h*k_2));

k_4 = f((x(i)+h),(y(i,:)+k_3*h));

y(i+1,:) = y(i,:) + (1/6)*(k_1+2*k_2+2*k_3+k_4)*h; % main equation

end

end

Add a comment
Know the answer?
Add Answer to:
LAB. Implement the classical procedure (8.82), and apply it to equation (8.66). Solve it with stepsizes...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a MATLAB Code to 8.5 (9) LAB. Implement the classical procedure (8.82), and apply it...

    Write a MATLAB Code to 8.5 (9) LAB. Implement the classical procedure (8.82), and apply it to equation (8.66). Solve it with stepsizes of h = 0.25 and 0.125 Compare with results in Table 8.13, the fourth- order Fehlberg example. Y'(x) = -Y(x) + 2 co$(x), Y(0) = 1 (8.66) Runge-Kutta methods of higher order can also be developed. A popular classical method is the following fourth-order procedure: Vi = f (xn, yn) h h v2 = f ( xx...

  • Implement the classical procedure, and apply it to equation, Solve it with step sizes bf h...

    Implement the classical procedure, and apply it to equation, Solve it with step sizes bf h = 0.25 and 0.125 Compare with results in Table 8.13, the fourth order Fehlberg example. 8.5 (9) LAB. Implement the classical procedure (8.82), and apply it to equation (8.66). Solve it with stepsizes of h = 0.25 and 0.125 Compare with results in Table 8.13, the fourth- order Fehlberg example. Y'(x) = -Y(x) + 2 cos(x), Y(0) = 1 (8.66) h Runge-Kutta methods of...

  • According to the Existence and Uniqueness theorem, the differential equation (t−5)y′+ysin(t)=5t ...

    According to the Existence and Uniqueness theorem, the differential equation (t−5)y′+ysin(t)=5t necessarily has a unique solution on the interval 0<t≤5. TRUE FALSE A numerical method is said to converge if its approximate solution values for a differential equation y′=f(t,y), y1,y2,...,yn, approach the true solution values ϕ(t1),ϕ(t2),...,ϕ(tn), as the stepsize h→∞. TRUE FALSE If a numerical method has a global truncation error that is proportional to the nth power of the stepsize, then it is called an nth order method. TRUE...

  • 4. (25 points) Solve the following ODE using classical 4th-order Runge- Kutta method within the domain...

    4. (25 points) Solve the following ODE using classical 4th-order Runge- Kutta method within the domain of x = 0 to x= 2 with step size h = 1: dy 3 dr=y+ 6x3 dx The initial condition is y(0) = 1. If the analytical solution of the ODE is y = 21.97x - 5.15; calculate the error between true solution and numerical solution at y(1) and y(2).

  • With 5. Consider the differential equation y, f(x,y) with initial condition y(zo) = yo. Show that...

    1 with 5. Consider the differential equation y, f(x,y) with initial condition y(zo) = yo. Show that, zi = zo +h, the solution at x1 can be obtained with an er ror O(h3) by the formula In other words, this formula describes a Runge-Kutta method of order 2. with 5. Consider the differential equation y, f(x,y) with initial condition y(zo) = yo. Show that, zi = zo +h, the solution at x1 can be obtained with an er ror O(h3)...

  • Consider the following Ordinary Differential Equation (ODE): dy = 0.3 * x2 + 0.04 * 26...

    Consider the following Ordinary Differential Equation (ODE): dy = 0.3 * x2 + 0.04 * 26 – 4* y? dx with initial condition at point 20 = 0.6875: yo = 0.0325 Apply Runge-Kutta method of the second order with h = 0.125 and the set of parameters given below to approximate the solution of the ODE at the three points given in the table below. Fill in the blank spaces. Round up your answers to 4 decimals. Yi 0.0325 0.6875...

  • hand written solution only (not computerised) if not possible then please refund the question becs i have already re...

    hand written solution only (not computerised) if not possible then please refund the question becs i have already recieved a computerised solution from you but i dont understand. 3In modelling the velocity y of a chain slipping off a horizontal platform, the differential equation y, 10/y-y/x is derived. Suppose the initial condition is y( 1-1 (a) Euler's method for solving yf(x), y(xoyo, is given by yn+n+hf(an,yn), where h is a fixed stepsize, xn xo + nh, and yn y(xn). Apply...

  • Is it possible to do this without matlab? 3In modelling the velocity y of a chain slipping off a horizontal platform, th...

    Is it possible to do this without matlab? 3In modelling the velocity y of a chain slipping off a horizontal platform, the differential equation y'- 10/y - y/x is derived. Suppose the initial condition is y (1)1 (a) Euler's method for solving y-f(x,y), y(XO-yo, is given byYn+1-yn+hf(xn,Yn) where h is a fixed stepsize, xnxo nh, and yn ~y(x). Apply one step of Euler's method to the initial value problem given above (b) Apply one step of the improved Euler method...

  • this is numerical analysis. Please do a and b 4. Consider the ordinary differential equation 1'(x)...

    this is numerical analysis. Please do a and b 4. Consider the ordinary differential equation 1'(x) = f(x, y(x)), y(ro) = Yo. (1) (a) Use numerical integration to derive the trapezoidal method for the above with uniform step size h. (You don't have to give the truncation error.) (b) Given below is a multistep method for solving (1) (with uniform step size h): bo +1 = 34 – 2n=1 + h (362. Yn) = f(n=1, 4n-1)) What is the truncation...

  • Consider the following initial value problem у(0) — 0. у%3D х+ у, (i) Solve the differential equation above in tabul...

    Consider the following initial value problem у(0) — 0. у%3D х+ у, (i) Solve the differential equation above in tabular form with h= 0.2 to approximate the solution at x=1 by using Euler's method. Give your answer accurate to 4 decimal places. Given the exact solution of the differential equation above is y= e-x-1. Calculate (ii) all the error and percentage of relative error between the exact and the approximate y values for each of values in (i) 0.2 0.4...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT