Azzera filtri
Azzera filtri

Runge-Kutta method

1 visualizzazione (ultimi 30 giorni)
Aslam Ali
Aslam Ali il 6 Ago 2020
Commentato: John D'Errico il 15 Ago 2020
Write the Matlab / C++ routine of Runge-Kutta method of Order four for the following problem
y^'-y=3x^2,y(0)=4
for the range 0.1≤x≤0.5, by taking h=0.025.
Note: Please give proper answer, this question is fro numerical analysis.
  3 Commenti
Aslam Ali
Aslam Ali il 6 Ago 2020
I can't attempt this question because i didn't understand it please if anyone know the answer and code then kinly share it
Steven Lord
Steven Lord il 6 Ago 2020
This sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the MATLAB Onramp tutorial (https://www.mathworks.com/support/learn-with-matlab-tutorials.html) to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.

Accedi per commentare.

Risposte (1)

esat gulhan
esat gulhan il 15 Ago 2020
%RUNGE KUTTA METHOD OF ORDER FOUR
clc;clear; % Clears the screen
h=0.025; % step size
x = 0.1:h:0.5;
y = zeros(1,length(x));
y(1) = 4; % initial condition,y(1) is y(0) value
F_xy = @(x,y) 3*x^2+y; % function
for i=1:(length(x)-1) % calculation loop
k_1 = F_xy(x(i),y(i));
k_2 = F_xy(x(i)+0.5*h,y(i)+0.5*h*k_1);
k_3 = F_xy((x(i)+0.5*h),(y(i)+0.5*h*k_2));
k_4 = F_xy((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
for i=1:(length(x))
fprintf('%12.5f',x(i),y(i));fprintf('\n')
end
You should use ode45 formula in order to this formula, you can solve this problem with dsolve.
  1 Commento
John D'Errico
John D'Errico il 15 Ago 2020
Please don't do homework assignments for people. This teaches them nothing, except how to get someone else to do their work for them.

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by