Question

Problem #3: The Ralston method is a second-order method that can be used to solve an initial-value, first-order ordinary diff

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

The detailed solution is given below.

clear;
clc;

f = @(t,y) -1.5.*y + 7*exp(-0.4.*t);

H = [0.3 0.1 0.05];
nh = numel(H);
   
for j = 1:nh
    h = H(j); 
    t = 0:h:1.3;
    nt = numel(t);
    % Initial Condition
    y = zeros(1,nt);
    y(1) = 3;

    figure(j)
    hold on
    xlabel('t')
    ylabel('y')
    m = sprintf('h = %.2f\n',h);
    % Ralston Method
    for i = 1:nt-1
        k1 = f(t(i),y(i));
        k2 = f(t(i)+3/4*h,y(i)+3/4*k1*h);

        y(i+1) = y(i) + (1/3*k1 + 2/3*k2)*h;  
    end
    
    % ode45
    [to,yo]=ode45(@(t,y)f(t,y),t,y(1));
    plot(to,yo,'linewidth',2,'DisplayName','Ralston Method')
    plot(t,y,'-.','linewidth',2,'DisplayName','ode45')
    title(m);
    grid on
    legend show
end

h = 0.30 3.7 Ralston Method - ode45 3.6 3. 5 3.4 у 3. ديا 3.2 3.1 3 0.2 0.4 0.6 0.8 1 1.2 t

h = 0.10 3.7 Ralston Method -ode45 3.6 3 on 3.4 у 3.3 3.2 3.1 3 0 0.2 0.4 0.6 0.8 1 1.2 1.4 t

h = 0.05 3.7 Ralston Method -- ode45 3.6 3 on 3.4 у 3.3 3.2 3.1 3 0 0.2 0.4 0.6 0.8 1 1.2 1.4 t

Please upvote the solution if found satisfactory.

Add a comment
Know the answer?
Add Answer to:
Problem #3: The Ralston method is a second-order method that can be used to solve an...
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
  • Problem #3: The Ralston method is a second-order method that can be used to solve an...

    Problem #3: The Ralston method is a second-order method that can be used to solve an initial-value, first-orde ordinary differential equation. The algorithm is given below: Vi#l=>: +($k+ş kz)h Where ky = f(ti,y:) * = f(mehr) You are asked to do the following: 3.1 Following that given in Inclass activity #10a, develop a MATLAB function to implement the algorithm for any given function, the time span, and the initial value. 3.2 Use your code to solve the following first-order ordinary...

  • 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...

  • Problem #4. The convective heat transfer problem of cold oil flowing over a hot surface can...

    Problem #4. The convective heat transfer problem of cold oil flowing over a hot surface can be described by the following second-order ordinary differential equations. d'T dT +0.83x = 0 dx? dx T(0)=0 (1) T(5)=1 where T is the dimensionless temperature and x is the dimensionless similarity variable. This is a boundary-value problem with the two conditions given on the wall (x=0, T(O) = 0) and in the fluid far away from the wall (x = 5, T(5) = 1)....

  • Using the fourth order Runge-Kutta method (KK4 to solve a first order initial value problem NOTE:...

    Need help with this MATLAB problem: Using the fourth order Runge-Kutta method (KK4 to solve a first order initial value problem NOTE: This assignment is to be completed using MATLAB, and your final results including the corresponding M- iles shonma ac Given the first order initial value problem with h-time step size (i.e. ti = to + ih), then the following formula computes an approximate solution to (): i vit), where y(ti) - true value (ezact solution), (t)-f(t, v), vto)...

  • Problem #4. The convective heat transfer problem of cold oil flowing over a hot surface can...

    Problem #4. The convective heat transfer problem of cold oil flowing over a hot surface can be described by the following second-order ordinary differential equations. der 0 dx T(0)=0 (1) T(5)=1 where T is the dimensionless temperature and x is the dimensionless similarity variable. dr? +0.83, dT This is a boundary-value problem with the two conditions given on the wall (x=0, T(O) = 0) and in the fluid far away from the wall (x = 5,7/5) = 1). You are...

  • Hello These are a math problems that need to solve by MATLAB as code Thank you...

    Hello These are a math problems that need to solve by MATLAB as code Thank you ! Initial Value Problem #1: Consider the following first order ODE: dy-p-3 from to 2.2 with y() I (a) Solve with Euler's explicit method using h04. (b) Solve with the midpoint method using h 0.4. (c) Solve with the classical fourth-order Runge-Kutta method using 0.4 analytical solution of the ODE is,·? solution and the numerical solution at the points where the numerical solution is...

  • MATLAB 25. Do the following operations. - Write the MATLAB function and save it. function dxdt=difdenk(t,x)...

    MATLAB 25. Do the following operations. - Write the MATLAB function and save it. function dxdt=difdenk(t,x) dxdtax+5, Then solve this function with the following command on Command Window. [tx]=ode23('difdenk”,[02],0) plot(tx) xlabel(t) ylabel(y) Solve the following ordinary differential equation using MATLAB's Ordinary Differential Equation (ODE) solver with the initial condition of x(0) = 0 for a time span between 0 and 2. = x +t

  • MATLAB CODE: Task 2 8y dt Solve the above ordinary differential equation (ODE) using Euler's method with step sizes of: 2. h 0.75 3. h 0.5 4. h 0.001 a) For each step size, plot the results at eac...

    MATLAB CODE: Task 2 8y dt Solve the above ordinary differential equation (ODE) using Euler's method with step sizes of: 2. h 0.75 3. h 0.5 4. h 0.001 a) For each step size, plot the results at each step starting from y(0) 3 to y(3). b) Plot on the same figure as part a) the analytical solution which is given by: 9 24 -8t c) Calculate and print the percentage error between the Euler's method and the analytical result...

  • 5. Consider the following second order explicit Runge-Kutta scheme: k=hf(an, Yn) k2 = hf(2, +h, yn...

    5. Consider the following second order explicit Runge-Kutta scheme: k=hf(an, Yn) k2 = hf(2, +h, yn +ki) Yn+k2. Yn+1 (a) Express the following ordinary differential equation and initial conditions as a sys- tem of first order equations: y(1)=1, /(1) 3. (b) Use the second order explicit Runge-Kutta scheme with one step to compute an approximation to y(1.2). 5. Consider the following second order explicit Runge-Kutta scheme: k=hf(an, Yn) k2 = hf(2, +h, yn +ki) Yn+k2. Yn+1 (a) Express the following...

  • PLEASE PLEASE,ONLY ANSWER THIS QUESTION IF YOU COULD GIVE ME THE MATLAB CODE.THANK YOU. Consider the...

    PLEASE PLEASE,ONLY ANSWER THIS QUESTION IF YOU COULD GIVE ME THE MATLAB CODE.THANK YOU. Consider the following Ordinary Differential Equation (ODE): dy = 3.0*** + 1.08 * 210 – 3* y2 dat with initial condition at point xo = 0.375: Yo = 0.0044 Apply Runge-Kutta method of the second order with h = 0.25 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...

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