In Maple things initially proceed in a much the same way as
they did in Maxima. And so, we have to define arrays xi, yi,
and
first:
array command is slightly different from that
of Maxima. We will summarise those differences in a table towards the
end of this chapter. In short, the command array creates a
new array with dimensions given its first argument. The second argument
is optional and can be used to initialise the values in an array.
Now we define
:
sum is nearly the same as in Maxima. The only
difference is the way that the range of i is specified.
The next step is to evaluate
solve command of Maple is much more powerful than
its relative in Maxima, so we don't have to modify equations
da = 0 and db = 0 any further. On the other hand,
we have to save the result on a list, which we are going to call
solutions, because Maple doesn't generate
expression labels automatically. Having saved the solution we will then
be able to chop it to pieces and make corresponding
assignments to a and b.
solve is a list of two equations.
solutions[1] returns the first equation, b = ...,
and solutions[2] returns the second one, a = ....
In order to make the assignments we have to use function
rhs, which extracts the right hand side of
an equation it is applied to:
solutions list if you tried,
b := rhs(solutions[1]);instead of
b0 := rhs(solutions[1]), because it would substitute the
new value of b into the solutions list at the same time.
It is safer to create new variables a0 and b0 while
extracting the relevant assignments with rhs.
So far, so good. Now we are going to hit the same bug as
we have already found in Maxima. Taking derivatives
and
returns zero
in both cases!
Unfortunately, Maple in this context is even worse than Maxima.
Let us look again at a simpler expression
dy[k] as one unstructured object. We have
to request differentiation with respect to y[3] explicitly:
And so this is our Maple result for
,
for n=5 and k=3:
pickapart command
in Maple, so we can't simplify expressions for da0y and
db0y, easily, in terms of new, dynamically generated
variables.
Maple has some low level utilities for splitting
expressions apart and some high level ones, of which you have
already encountered rhs. In this case
you could also try numer and denom, which would
extract
numerator and denominator from both da0y and
db0y, but while doing so, they would fully expand
the resulting expressions too, making them even less readable and
less manageable.
In summary, this is where we've got to stop in Maple. The
obtained expressions for a, b,
,
and
are correct
(cf. Section 2.1.8), and
can be easily compared to results returned by Maxima.