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,
arraycommand 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
arraycreates 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 :
sumis 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 and , equate the partial derivatives to zero and solve the resulting linear equations:
solvecommand of Maple is much more powerful than its relative in Maxima, so we don't have to modify equations
da = 0and
db = 0any 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.
solveis a list of two equations.
solutionsreturns the first equation,
b = ..., and
solutionsreturns 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:
solutionslist if you tried,
b := rhs(solutions);instead of
b0 := rhs(solutions), because it would substitute the new value of b into the
solutionslist at the same time. It is safer to create new variables
b0while extracting the relevant assignments with
So far, so good. Now we are going to hit the same bug as
we have already found in Maxima. Taking derivatives
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
And so this is our Maple result for
for n=5 and k=3:
pickapartcommand in Maple, so we can't simplify expressions for
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
denom, which would extract numerator and denominator from both
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.