# Least squares fitting

• April 18th 2009, 04:29 AM
Twig
Least squares fitting
Hi

Having some problems with setting this one up.

According to Kepler´s first law, a comet should have an elliptic, parabolic or hyperbolic orbit(with gravitational attractions from planets ignored). In suitable polar coordinates, the position $(r,\phi)$ of a comet satisfies an equation of the form $r = \beta +e(r\cdot cos(\phi))$ , where $\beta$ is a constant and "e" is the eccentricity of the orbit, with $0 \leq e < 1$ for an ellipse, e=1 for a parabola and e > 1 for a hyperbola.

Given the data below, determine the type of orbit, and predict where the comet will be when $\phi = 4.6$ , radians.

$\left[ \begin{matrix} \phi & 0.88 & 1.1 & 1.42 & 1.77 & 2.14 \\ r & 3.00 & 2.30 & 1.65 & 1.25 & 1.01 \end{matrix} \right]$

Solving for r gives, $r = \frac{\beta}{(1-e\cdot cos(\phi))}$

How would I set a design matrix up?
• April 21st 2009, 11:45 PM
ZeroDivisor
Hi Twig,

the line of best fit is r = beta + e(r cos phi)
That suggests you define x_i = r cos phi and y_i = r (i=1,..,5).
The formulae for least squares are this:
beta = (sum x_i y_i times sum x_i - sum y_i times sum x_i^2) / ((sum x_i)^2 - n sum x_i^2) --- here n = 5
e = (sum y_i - n beta) / sum x_i
I get
beta = 1.451 and e = 0.811 (i.e. elliptic)
If phi = 4.6, then your formula for r yields r = 1.33.

Best

ZD