Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'d like the solution to the third part if all of it isn\'t possible :) clear a

ID: 3804647 • Letter: I

Question

I'd like the solution to the third part if all of it isn't possible :)

clear
a = 0; % start time
b = 200; % end time
e = 0.6;

% initial conditions
q10=1-e; % given
q20=0; % given
p10=0; % given
p20=sqrt((1+e)/(1-e)); % given

% Stepsize and mesh
h = 0.0005;

tt=a:h:b; % Mesh
N=length(tt); % 400,000 if h = 0.0005, b=200
q1=zeros(N,1); % Values for q1
q2=zeros(N,1); % Values for q2
p1=zeros(N,1); % Values for p1
p2=zeros(N,1); % Values for p2
at=zeros(N,1); % Values for at
Ht=zeros(N,1); % Values for Ht

q1(1)=q10; % Initial values
q2(1)=q20; % Initial values
p1(1)=p10; % Initial values
p2(1)=p20; % Initial values

% % Euler Steps

for i=1:N-1

dP = -1*((1/(q1(i)^2 + q2(i)^2))^(3/2));
p1n = p1(i) + h*dP*q1(i);
p2n = p2(i) + h*dP*q2(i);
p1(i+1) = p1n;
p2(i+1) = p2n;

q1n = q1(i) + h*p1(i);
q2n = q2(i) + h*p2(i);
q1(i+1) = q1n;
q2(i+1) = q2n;  
at(i)=(q1(i)*p2(i))-(q2(i)*p1(i)); % angular momentum

Ht(i)=0.5*(((p1(i))^2)+(p2(i))^2)-(1./(sqrt((q1(i))^2+(q2(i))^2)));
  
end

hold on
%plot(q1, q2)
plot(q1, q2)
title('Euler''s Method on Kepler''s problem','fontsize',14)
xlabel('x-position','fontsize',12)
ylabel('y-position','fontsize',12)
legend({'Planet Around the Sun'},'fontsize',14,'Location','northwest')
figure
plot(at)
figure
plot(Ht)
% plot(Ht)

this is what I have

A. Computing Assignment Numerical Solution of Kepler's problem. One of science's great achievements was the discovery of Kepler's laws for planetary motion. in particular, that the planets follow closed elliptical orbits around the sun. In this assignment you will compare different numerical methods for solving Kepler's problem for the motion of a simple solar system consisting of two planets (the two-body problem) For a system of two planets, we may assume one is fixed at the origin with the motion of the other planet being in a 2D plane. Let be the position and momentum vectors of the moving planet, respectively. Kepler's laws give the following ordinary differential equation for q and p( (t) (1) 2 3/2 1. Write a code that implements Euler's method for this problem for time 0 St ST 200 and stepsize h 0.0005. Use the initial conditions Plot your output in the q1-q2 plane, i e. plot the approximate position of the moving planet at time tn for n 0.1 N, where N hl. Briefly describe the qualitative behaviour of the numerical solution. as several conserved quantities, including the angular momentum A 2. The ODE (1) and Hamiltonian H(t), defined b Compute these quantities for your numerical solution. Does your numerical solution also conserve the angular momentum and Hamiltonian? If not, briefly comment on their behaviour for large t 3. For systems such as an alternative to the standard Euler's method is the so-called symplectic Euler method h n-t-1 n-t-1 n--1 3/2 (ga +1,1 ere gn+1.1 and 2 are the components of the vector qn+1 Implement this method and compare it with the standard Euler's method. Describe the behaviour of the numerical solution, and also the angular momentum and Hamiltonian.

Explanation / Answer

clear
a = 0; % start time
b = 200; % end time
e = 0.6;

% initial conditions
q10=1-e; % given
q20=0; % given
p10=0; % given
p20=sqrt((1+e)/(1-e)); % given

% Stepsize and mesh
h = 0.0005;

tt=a:h:b; % Mesh
N=length(tt); % 400,000 if h = 0.0005, b=200
q1=zeros(N,1); % Values for q1
q2=zeros(N,1); % Values for q2
p1=zeros(N,1); % Values for p1
p2=zeros(N,1); % Values for p2
at=zeros(N,1); % Values for at
Ht=zeros(N,1); % Values for Ht

q1(1)=q10; % Initial values
q2(1)=q20; % Initial values
p1(1)=p10; % Initial values
p2(1)=p20; % Initial values

% % Euler Steps

for i=1:N-1

dP = -1*((1/(q1(i)^2 + q2(i)^2))^(3/2));
p1n = p1(i) + h*dP*q1(i);
p2n = p2(i) + h*dP*q2(i);
p1(i+1) = p1n;
p2(i+1) = p2n;

q1n = q1(i) + h*p1(i);
q2n = q2(i) + h*p2(i);
q1(i+1) = q1n;
q2(i+1) = q2n;  
at(i)=(q1(i)*p2(i))-(q2(i)*p1(i)); % angular momentum

Ht(i)=0.5*(((p1(i))^2)+(p2(i))^2)-(1./(sqrt((q1(i))^2+(q2(i))^2)));
  
end

hold on
%plot(q1, q2)
plot(q1, q2)
title('Euler''s Method on Kepler''s problem','fontsize',14)
xlabel('x-position','fontsize',12)
ylabel('y-position','fontsize',12)
legend({'Planet Around the Sun'},'fontsize',14,'Location','northwest')
figure
plot(at)
figure
plot(Ht)
% plot(Ht)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote