We begin by creating arrays xi, yi and :
Arrayis, in this context, identical to the syntax of Maxima's command
array. The only difference is that whereas the array xi created by Maxima would have entries from x0 through x300, in Mathematica the numbering goes from x1 through x300. Unfortunately we also get a screenful of gibberish after the array has been successfully allocated. Recall that in Maxima we could terminate a command with a dollar sign instead of a semicolon, and in this way tell Maxima to shut up. In Mathematica we accomplish the same task by terminating Mathematica's command with a semicolon, instead of just a newline.
And so, we can now safely proceed to allocate arrays yi and :
Now let us proceed with the definition of
and its derivatives with respect to a and b:
pickapart. All Mathematica expressions are stored as lists, much as in Lisp. But they are printed on Mathematica's output in a way, to which Mathematica users are more accustomed. You can ask Mathematica to print an expression the way it is stored by invoking a command
dchi2b[a,b], but that part is not stored in an evaluated form. We can easily create a new expression, in which the derivative is fully evaluated by calling the
ReplaceParttakes an expression as its first argument. The number of the expression part to be replaced is given in the third argument. The second argument contains the replacement. In our case the replacement is the expression, which Mathematica labelled as
Out. Recall that we had the same facility available to us in Maxima: all inputs and outputs were automatically labelled, and could be reused while conversing with Maxima.
We can now repeat this procedure for
Solvestill can't cope with the equations. As in Maxima we need to disentangle a and b explicitly from the sum, so that Mathematica's
Solvewould notice that the resulting equations are really quite simple and linear in a and b.
Let us begin by expanding the fractions in the sums:
Solve. We must factor out a and b. We do that again by manipulating the Sums manually, since tricks such as:
So here is how we rewrite these expressions manually:
Sumin Mathematica is designed specifically for working with power series rather than with arrays.
On the other hand, you must have noticed that Mathematica's vocabulary is rich enough to let us design more sophisticated rewriting rules for sums and derivatives, and we will explore this possibility further down the road.
Now, at long last, we can solve the equations:
As was the case in Maxima and in Maple, Mathematica evaluates
incorrectly too, returning zero in both cases:
Compare these results with Section 2.1.8.