function [ sqres ] = sqres( n )
%SQRES is the squared ratio of mean Earth-sun to Earth-sun on day n
%   Uses a second degree Fourier expansion to compute the squared ratio of 
%   the mean Earth-sun distance to the actual distance on a given 
%   day n. January 1 is day 1. The formula is taken from the book Global 
%   physical climatology by Dennis L. Hartmann (p. 349)

thetad = 2*pi*(n-1)/365;

% Fourier-coefficients
a0 = 1.000110;
a1 = 0.034221;  b1 = 0.001280;
a2 = 0.000719;  b2 = 0.000077;

sqres = a0 + a1*cos(thetad) + b1*sin(thetad) + a2*cos(2*thetad) + b2*sin(2*thetad);