Question

What's the f(t,y) in this question?

One of sciences great achievements was the discovery of Keplers laws for planetary motion; in particular, that the planetsEuler's method requires f(t,y). What's the f(t,y) function in this assignment? q(t) and p(t) are vectors. How am I supposed to apply them in Euler's method?

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

The Matlab scripts eulFwdSys.m, eulFwdSysSolver.m, dydtSys.m are posted at the end along with the generated plot. Please run the script eulFwdSysSolver.m to generate the desired results and plot.Q (t) = Pct) so .. (1) a; = Ⓡp aź = 3 .. (2) and, P (t) - 132 (t). or, b, c - a, B= - = ...(4) ...4) So, the eqns (1), (2Thus, the Euler method is applied on the system of first order equations, wher ty (Ps, Pz, 91, 92, t ) = Þg tę (ba, pa, 93, 9

eulFwdSys.m

function [t, y] = eulFwd (dydt, tSpan, initCond, timeStep)
% eulode: Euler ODE solver
% [t,y] = eulode (dydt, tSpan, initCond, timeStep):
% uses Euler's method to integrate an ODE

% input:
% dydt = name of the function M−file that evaluates the ODE
% tspan = [ti, tf] where ti and tf = initial and
% final values of the independent variable t
% initCond = initial value of dependent variables
% timeStep = step size of the independent variable

% output:
% t = vector of independent variable
% yp = vector of solution for dependent variable

tInitial = tSpan(1);
tFinal   = tSpan(2);
t = (tInitial: timeStep :tFinal)';

y(1, :) = initCond;
yp(1, :) = y(1, :);

for i = 1: length(t)-1   
    y(i + 1, :) = y(i, :) + dydt(t(i), y(i, :)) * timeStep;
    yp(i + 1, :) = y(i + 1, :);
end
end

eulFwdSysSolver.m

clear, close all; clc

tSpan = [0 200];
timeStep = 5e-4;
ec = 0.6;
y0 = [ 1-ec, 0, 0, sqrt((1+ec)/(1-ec))];

[t, y] = eulFwd(@dydtSys, tSpan, y0, timeStep);

figure
plot(t, y(:, 1), t, y(:, 2), t, y(:, 3), t, y(:, 4))
xlabel( '\bf t' )
ylabel( '\bf y' )
legend('q_1', 'q_2', 'p_1', 'p_2')
grid on
grid minor

dydtSys.m

function rhs = dydtSys(t, y)
% governing ODE dydt = rhs
% dydt = dydt(t, y)

% input:
% x = independent variable
% y = dependent variable

% output:
% dydt = rhs of the ODE

dydt1 = y(3);
dydt2 = y(4);
dydt3 = -y(1)/((y(1))^2+(y(2))^2)^(3/2);
dydt4 = -y(2)/((y(1))^2+(y(2))^2)^(3/2);

rhs = [dydt1, dydt2, dydt3, dydt4];

end0.5 KM -0.5 – 20 40 60 100 140 160 180 200
Add a comment
Know the answer?
Add Answer to:
What's the f(t,y) in this question? Euler's method requires f(t,y). What's the f(t,y) function in this...
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
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