Within Maxima we have to declare three arrays: *x*_{i}, *y*_{i}, and
:

Here we have used the command

Now let us define the figure of merit, :

We locate the minimum of by equating its partial derivatives with respect to

So far so good. We have just evaluated that

In principle all that we need to do now, should be to invoke
`solve` as follows:

But

In Maxima we have to help it a little. We do that by extracting
*a* and *b* from the sum manually:

Maxima gets infuriatingly stubborn at this stage and refuses to split sums

So, at this stage we tell Maxima what to do ourselves. The command
`pickapart(eda, 4)`

splits the whole expression , `eda`

into its components down to the fourth nesting level. The components
are referred to as `E21`

, `E22`

, and `E23`

. Using
these we assemble a new expression manually by saying:

eeda : sum(e21, i, 1, n) + sum(e22, i, 1, n) + sum(e23, i, 1, n);Here is how it all happens:

and now similarly for `edb`

:

At this stage *a* and *b* have been taken out of the sums explicitly,
and the resulting equations are easily seen to be linear in *a*and *b*. Consequently `solve` can be invoked again, this time on
a simplified problem:

Translating this into a normal mathematical notation we obtain the following results:

and

But our job is still not finished. We have to find expressions for
standard deviations in *a* and *b*. We extract the solution from the
list of lists returned by `solve`, again, by using `pickapart`:

This way we can make new assignments to

Placing a dollar instead of a semicolon at the end of an expression supresses Maxima chatter mode, so that we don't see the same large expressions being printed all over again.

*a* and *b* so defined are functions of *y*_{i}. Errors in *y*_{i},
the sigmas, ,
propagate into errors in *a* and
in *b*
following the error propagation law:

and

But here we are going to hit a problem. The problem is that both Maxima

namely:

*This is a bug!* In this context all three, Maxima, Maple, and
Mathematica, think
that *y*_{k} is an altogether different beast from *y*_{i}, and since
they don't find any explicit occurrence of *y*_{k} in *a* they return
.

But we can work around it.

Consider a simpler expression:

and its derivative with respect to say,

Now let us try to reproduce this result in Maxima.

Observe that Maxima is reluctant to evaluate the derivative, even when it has been told about the values of

So, let us use this trick to evaluate
for some specific value of *k*, say, 3, in Maxima:

This looks quite good, but it is a touch too long to digest. We need to rewrite expression

`D70`

in a more compact form,
using again capital sigmas for sums. We use our faithful I have performed this calculation earlier (as you can see from the

`C`

number that jumped suddenly to 200), which is why
Maxima does not print the values of `E172`

, `E150`

,
and so on. But you can always ask Maxima what they are. For example:
To save you the effort:

Making the following substitutions: , and , we can finally write down the following result:

We will now apply the same methodology to evaluate
.

where, as before,

Again replacing
and
we obtain
the following result:

Those quantities, ,
*S*_{xx}, etc., are clearly very useful
in -fitting. By introducing *S*_{y} and *S*_{xy}we can rewrite expressions for *a* and *b* in a more compact form: