If there were only one independent variable in these functions, the usual maxima operations on polynomials are well documented in the Manual, and would have been easy to use. But the functions I needed have one or more parameters in addition to numerical coefficients and the usual argument; and these parameters are just additional variables to maxima.
When I used the pade function to convert a power series to a ratio of polynomials, powers of the parameters were added to the numerical coefficients; so I had to learn how to handle them. Fortunately, maxima has a way to treat a "variable" as a sort of constant: inhibit evaluation by single-quoting a name.
((p-1.d0)*x-2.d0)
so I entered it in a maxima session as
(%i1) den: ((p-1.d0)*x-2.d0);
and maxima returned
(%01) (p - 1.0) x - 2.0
— but this was NOT what I should have done, because (a) it leaves
the parameter p as an unspecified variable, and (b) it
shifts the numerical calculations from exact integer arithmetic to
unreliable floating-point numbers.
Consequently, whenever p is mentioned in later input lines, it is just a symbol. Then I'd have to specify its value every time I wanted a numerical answer. (This can be done, but it's inconvenient.)
If I really wanted a general solution for x that carried p along as a parameter, I could use the solve function:
(%i2) solve (den,x);
which gives the one-element list
2
(%o5) [x = -----]
p - 1
but then I still would need to evaluate the right side of this equation
for some numerical values of p. For example, to see the value of
x for p = 5, i'd need to tell maxima
ev(solve(den,x), p:5);
which sets the value of p for just that input line. Further
manipulations would require adding that condition to subsequent
statements.
First, make the parameter p temporarily immune to evaluation, by prefixing it with a single-quote mark. And write the numerical values as integers, instead of floating-point numbers:
(%i1) den: (('p-1)*x-2);
maxima responds:
(%o1) (p - 1) x - 2
Next, set p:
(%i2) p:5;
(%o2) 5
Now solve for x:
(%i3) ans: ev(solve(den,x));
1
(%o3) [x = -]
2
The solution is a one-element list; its single element is an equation.
And this time, the numerical value of x is its right-hand side.
At this point, we can extract the value of x with the command
rhs(ans[1]);
which prints the right side of the equation.
So it's more informative to examine this product, rather than just x, for the various approximants. It's infinite for p = 1, and approaches a limit of 2.0 as p → ∞. As all the cases of practical interest have very small values of the p*x product, they are far from the dangerous region.
Copyright © 2024, 2025 Andrew T. Young
or the
very basic Maxima page
or the website overview page