Within Maxima we have to declare three arrays: xi, yi, and
:
Now let us define the figure of merit,
:
In principle all that we need to do now, should be to invoke
solve as follows:
In Maxima we have to help it a little. We do that by extracting
a and b from the sum manually:
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 aand b. Consequently solve can be invoked again, this time on
a simplified problem:
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:
a and b so defined are functions of yi. Errors in yi,
the sigmas,
,
propagate into errors in a and
in b
following the error propagation law:
This is a bug! In this context all three, Maxima, Maple, and
Mathematica, think
that yk is an altogether different beast from yi, and since
they don't find any explicit occurrence of yk in a they return
.
But we can work around it.
Consider a simpler expression:
So, let us use this trick to evaluate
for some specific value of k, say, 3, in Maxima:
D70 in a more compact form,
using again capital sigmas for sums. We use our faithful pickapart
to do that:
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:
We will now apply the same methodology to evaluate
.
Again replacing
and
we obtain
the following result:
Those quantities,
,
Sxx, etc., are clearly very useful
in
-fitting. By introducing Sy and Sxywe can rewrite expressions for a and b in a more compact form: