clear all
%The code was developed as part of capstone project in Fulbright
%Distguished Teacher Award Program 2012.
%This code analyze the data of the discrepancies in the longitude of Uranus
%The code reads the data from the file littlewood_smooth.txt and the idea
%is to fine the year of conjunction which is the year that Uranus and
%Neptune were line up (it was in 1822). The code calculates the first and
%the second time derivative and plot them. The idea is that this code can
%be used by student or teachers and show how the knowlege gained from
%observations can help to find the the year of conjunction wheb the
%change in the discrepancies became maximum.
%Thus for near the year of conjunction can be indentified by two
%condtions: 1 . Maximum of the first derevative . 2. The second derivative
%is equal to zero., becuse the direction is changed before and just after
%the year of conjunction.
%Students can try to use higher order approximation for the derivative and
%and compare between the results.
load littlewood_smooth.txt -ascii;
data=littlewood_smooth;
year=data(:,1);
delta=data(:,2);
n=size(delta);
n=n(1);
figure
set(gca,'FontSize',16)
plot(year+1780,delta,'o','LineWidth',2)
grid on
xlabel('Year')
ylabel('Discrepancies Between Observed and Calculated Longitude of Uranus')
%__________________________________________________________________________
%Computing a first order first derivative (the code don't use these
%results. The students can studt the fdifferent between the the first and
%the fourth order results.
for i=2:n-1
d(i)=(delta(i+1)-delta(i-1))/2;
end
d=d(2:end);
yy=(2:1:n-1);
%figure
%plot(yy+1779,d,'k','LineWidth',2)
%xlabel('Year')
%ylabel('First Time Derivative')
grid on
hold on
%______________________________________________
figure
set(gca,'FontSize',16)
%Calculating a fourth order first derivative
for j=3:(n-2)
d1(j)=(-delta(j+2)+8*delta(j+1)-8*delta(j-1)+delta(j+2))/12;
end
d1=d1(3:end);
yyy=(3:1:n-2);
plot(yyy+1779,d1,'b','LineWidth',2)
xlabel('Year')
ylabel('First Time Derivative')
grid on
hold on
m=size(d);
m=m(2);
for i=2:m-1
dd(i)=(d(i+1)-d(i-1))/2;
end
dd=dd(2:end);
yd=(2:1:m-1);
figure
%plot(yd+1780,dd,'r','LineWidth',2)
set(gca,'FontSize',16)
grid on
hold on
%__________________________________________________________
%Computing the second derivative which is the derivative of the first
%derivative (fourth order approximation is used.
k=size(d1);
k=k(2);
for j=3:(k-2)
dd1(j)=(-d1(j+2)+8*d1(j+1)-8*d1(j-1)+d1(j+2))/12;
end
dd1=dd1(3:end);
ydd=(3:1:k-2);
plot(ydd+1781,dd1,'r','LineWidth',2)
grid on
hold on
xlabel('Year')
ylabel('Second Time Derivative')