function [L,B,R]=ple_jupiter(Date)
% Low accuracy planetray ephemeris for Jupiter.
% Package: celestial.SolarSys
% Description: Low accuracy planetray ephemeris for Jupiter. Calculate
%              Jupiter heliocentric longitude, latitude and radius
%              vector referred to mean ecliptic and equinox of date.
%              Accuarcy: ~1' in long/lat, ~0.001 au in dist.
% Input  : - matrix of dates, [D M Y frac_day] per line,
%            or JD per line. In TT time scale.
% Output : - Longitude in radians.
%          - Latitude in radians.
%          - Radius vector in au.
% Reference: VSOP87
% See also: ple_planet.m
% Tested : Matlab 5.3
%     By : Eran O. Ofek                    Oct 2001
%    URL : http://weizmann.ac.il/home/eofek/matlab/
% Example: [L,B,R]=celestial.SolarSys.ple_jupiter(2451545)
% Reliable: 2
%------------------------------------------------------------------------------


RAD = 180./pi;

FunTPI = @(X) (X./(2.*pi) - floor(X./(2.*pi))).*2.*pi;

SizeDate = size(Date);
N        = SizeDate(1);
ColN     = SizeDate(2);

if (ColN==4),
   JD = celestial.time.julday(Date);
elseif (ColN==1),
   JD = Date;
else
   error('Illigal number of columns in date matrix');
end

Tau = (JD(:) - 2451545.0)./365250.0;

SumL0 = 59954691 ...
   + 9695899.*cos(5.0619179 + 529.6909651.*Tau) ...
   + 573610.*cos(1.444062 + 7.113547.*Tau) ...
   + 306389.*cos(5.417347 + 1059.381930.*Tau) ...
   + 97178.*cos(4.14265 + 632.78374.*Tau) ...
   + 72903.*cos(3.64043 + 522.57742.*Tau) ...
   + 64264.*cos(3.41145 + 103.09277.*Tau) ...
   + 39806.*cos(2.29377 + 419.48464.*Tau) ...
   + 38858.*cos(1.27232 + 316.39187.*Tau) ...
   + 27965.*cos(1.78455 + 536.80451.*Tau) ...
   + 13590.*cos(5.77481 + 1589.07290.*Tau) ...
   + 8769.*cos(3.6300 + 949.1756.*Tau) ...
   + 8246.*cos(3.5823 + 206.1855.*Tau) ...
   + 7368.*cos(5.0810 + 735.8765.*Tau) ...
   + 6263.*cos(0.0250 + 213.2991.*Tau) ...
   + 6114.*cos(4.5132 + 1162.4747.*Tau) ...
   + 5305.*cos(1.3067 + 14.2271.*Tau) ...
   + 4905.*cos(1.3208 + 110.2063.*Tau) ...
   + 4647.*cos(4.6996 + 3.9322.*Tau) ...
   + 3045.*cos(4.3168 + 426.5982.*Tau) ...
   + 2610.*cos(1.5667 + 846.0828.*Tau) ...
   + 2028.*cos(1.0638 + 3.1814.*Tau) ...
   + 1921.*cos(0.9717 + 639.8973.*Tau) ...
   + 1765.*cos(2.1415 + 1066.4955.*Tau) ...
   + 1723.*cos(3.8804 + 1265.5675.*Tau) ...
   + 1633.*cos(3.5820 + 515.4639.*Tau) ...
   + 1432.*cos(4.2968 + 625.6702.*Tau) ...
   + 973.*cos(4.098 + 95.979.*Tau) ...
   + 884.*cos(2.437 + 412.371.*Tau);

SumL1 = 52993480757 ...
   + 489741.*cos(4.220667 + 529.690965.*Tau) ...
   + 228919.*cos(6.026475 + 7.113547.*Tau) ...
   + 27655.*cos(4.57266 + 1059.38193.*Tau) ...
   + 20721.*cos(5.45939 + 522.57742.*Tau) ...
   + 12106.*cos(0.16986 + 536.80451.*Tau) ...
   + 6068.*cos(4.4242 + 103.0928.*Tau) ...
   + 5434.*cos(3.9848 + 419.4846.*Tau) ...
   + 4238.*cos(5.8901 + 14.2271.*Tau) ...
   + 2212.*cos(5.2677 + 206.1855.*Tau) ...
   + 1746.*cos(4.9267 + 1589.0729.*Tau) ...
   + 1296.*cos(5.5513 + 3.1814.*Tau) ...
   + 1173.*cos(5.8565 + 1052.2684.*Tau) ...
   + 1163.*cos(0.5145 + 3.9322.*Tau) ...
   + 1099.*cos(5.3070 + 515.4639.*Tau) ...
   + 1007.*cos(0.4648 + 735.8765.*Tau) ...
   + 1004.*cos(3.1504 + 426.5982.*Tau);

SumL2 = 47234.*cos(4.32148 + 7.11355.*Tau) ...
   + 38966 ...
   + 30629.*cos(2.93021 + 529.69097.*Tau) ...
   + 3189.*cos(1.0550 + 522.5774.*Tau) ...
   + 2729.*cos(4.8455 + 536.8045.*Tau) ...
   + 2723.*cos(3.4141 + 1059.3819.*Tau) ...
   + 1721.*cos(4.1873 + 14.2271.*Tau);

SumL3 = 6502.*cos(2.5986 + 7.1135.*Tau) ...
   + 1357.*cos(1.3464 + 529.6910.*Tau) ...
   +  471.*cos(2.475 + 14.227.*Tau);

SumL4 = 669.*cos(0.853 + 7.114.*Tau) ...
   - 114;

SumL5 = 50.*cos(5.26 + 7.11.*Tau);


L = SumL0 + SumL1.*Tau + SumL2.*Tau.^2 ...
          + SumL3.*Tau.^3 + SumL4.*Tau.^4 + SumL5.*Tau.^5;
L = L.*1e-8;

L = FunTPI(L);

SumB0 = 2268616.*cos(3.5585261 + 529.690965.*Tau) ...
   + 110090 ...
   + 109972.*cos(3.908093 + 1059.381930.*Tau) ...
   + 8101.*cos(3.6051 + 522.5774.*Tau) ...
   + 6438.*cos(0.3063 + 536.8045.*Tau) ...
   + 6044.*cos(4.2588 + 1589.0729.*Tau) ...
   + 1107.*cos(2.9853 + 1162.4747.*Tau);

SumB1 = 177352.*cos(5.701665 + 529.690965.*Tau) ...
   + 3230.*cos(5.7794 + 1059.3819.*Tau) ...
   + 3081.*cos(5.4746 + 522.5774.*Tau) ...
   + 2212.*cos(4.7348 + 536.8045.*Tau) ...
   - 1694 ...
   + 346.*cos(4.746 + 1052.268.*Tau);

SumB2 = 8094.*cos(1.4632 + 529.6910.*Tau) ...
   - 813 ...
   + 742.*cos(0.957 + 522.577.*Tau);

SumB3 = 252.*cos(3.381 + 529.691.*Tau) ...
   + 122.*cos(2.733 + 522.577.*Tau);

SumB4 = 15.*cos(4.53 + 522.58.*Tau);

SumB5 = 1.*cos(0.09 + 522.58.*Tau);

B = SumB0 + SumB1.*Tau + SumB2.*Tau.^2 ...
          + SumB3.*Tau.^3 + SumB4.*Tau.^4 + SumB5.*Tau.^5;
B = B.*1e-8;

%B = FunTPI(B);

SumR0 = 520887429 ...
   + 25209327.*cos(3.49108640 + 529.69096509.*Tau) ...
   + 610600.*cos(3.841154 + 1059.381930.*Tau) ...
   + 282029.*cos(2.574199 + 632.783739.*Tau) ...
   + 187647.*cos(2.075904 + 522.577418.*Tau) ...
   + 86793.*cos(0.71001 + 419.48464.*Tau) ...
   + 72063.*cos(0.21466 + 536.80451.*Tau) ...
   + 65517.*cos(5.97996 + 316.39187.*Tau) ...
   + 30135.*cos(2.16132 + 949.17561.*Tau) ...
   + 29135.*cos(1.67759 + 103.09277.*Tau) ...
   + 23947.*cos(0.27458 + 7.11355.*Tau) ...
   + 23453.*cos(3.54023 + 735.87651.*Tau) ...
   + 22284.*cos(4.19363 + 1589.07290.*Tau) ...
   + 13033.*cos(2.96043 + 1162.47470.*Tau) ...
   + 12749.*cos(2.71550 + 1052.26838.*Tau) ...
   + 9703.*cos(1.9067 + 206.1855.*Tau) ...
   + 9161.*cos(4.4135 + 213.2991.*Tau) ...
   + 7895.*cos(2.4791 + 426.5982.*Tau) ...
   + 7058.*cos(2.1818 + 1265.5675.*Tau) ...
   + 6138.*cos(6.2642 + 846.0828.*Tau) ...
   + 5477.*cos(5.6573 + 639.8973.*Tau) ...
   + 4170.*cos(2.0161 + 515.4639.*Tau) ...
   + 4137.*cos(2.7222 + 625.6702.*Tau) ...
   + 3503.*cos(0.5653 + 1066.4955.*Tau) ...
   + 2617.*cos(2.0099 + 1581.9593.*Tau) ...
   + 2500.*cos(4.5518 + 838.9693.*Tau) ...
   + 2128.*cos(6.1275 + 742.9901.*Tau) ...
   + 1912.*cos(0.8562 + 412.3711.*Tau) ...
   + 1611.*cos(3.0887 + 1368.6603.*Tau) ...
   + 1479.*cos(2.6803 + 1478.8666.*Tau) ...
   + 1231.*cos(1.8904 + 323.5054.*Tau) ...
   + 1217.*cos(1.8017 + 110.2063.*Tau) ...
   + 1015.*cos(1.3867 + 454.9094.*Tau);

SumR1 = 1271802.*cos(2.6493751 + 529.6909651.*Tau) ...
   + 61662.*cos(3.00076 + 1059.38193.*Tau) ...
   + 53444.*cos(3.89718 + 522.57742.*Tau) ...
   + 41390 ...
   + 31185.*cos(4.88277 + 536.80451.*Tau) ...
   + 11847.*cos(2.41330 + 419.48464.*Tau) ...
   + 9166.*cos(4.7598 + 7.1135.*Tau) ...
   + 3404.*cos(3.3469 + 1589.0729.*Tau) ...
   + 3203.*cos(5.2108 + 735.8765.*Tau) ...
   + 3176.*cos(2.7930 + 103.0928.*Tau) ...
   + 2806.*cos(3.7422 + 515.4639.*Tau) ...
   + 2677.*cos(4.3305 + 1052.2684.*Tau) ...
   + 2600.*cos(3.6344 + 206.1855.*Tau) ...
   + 2412.*cos(1.4695 + 426.5982.*Tau) ...
   + 2101.*cos(3.9276 + 639.8973.*Tau) ...
   + 1646.*cos(5.3095 + 1066.4955.*Tau) ...
   + 1641.*cos(4.4163 + 625.6702.*Tau) ...
   + 1050.*cos(3.1611 + 213.2991.*Tau) ...
   + 1025.*cos(2.5543 + 412.3711.*Tau);

SumR2 = 79645.*cos(1.35866 + 529.69097.*Tau) ...
   + 8252.*cos(5.7777 + 522.5774.*Tau) ...
   + 7030.*cos(3.2748 + 536.8045.*Tau) ...
   + 5314.*cos(1.8384 + 1059.3819.*Tau) ...
   + 1861.*cos(2.9768 + 7.1135.*Tau);

SumR3 = 3519.*cos(6.0580 + 529.6910.*Tau) ...
   + 1073.*cos(1.6732 + 536.8045.*Tau) ...
   + 916.*cos(1.413 + 522.577.*Tau);

SumR4 = 129.*cos(0.084 + 536.805.*Tau) ...
   + 113.*cos(4.249 + 529.691.*Tau);

R = SumR0 + SumR1.*Tau + SumR2.*Tau.^2 ...
          + SumR3.*Tau.^3 + SumR4.*Tau.^4;
R = R.*1e-8;

