[Maxima] In Need of Help In Defining a List of n variables
robert.dodier at gmail.com
Tue Oct 7 22:58:49 CDT 2008
On Tue, Oct 7, 2008 at 11:06 AM, Azhar Hasham
<azhar.hasham at googlemail.com> wrote:
> I'm a new user of Maxima and am currently trying to figure out how to
> produce a list of n variables (x1,... xn) where n is general. I'm aware of
> the function makelist, but for this I need to define an integer value for n
> which I don't want to do.
Maxima in some respects treats subscripted variables like ordinary,
unsubscripted ones, so to some extent you can just write x, x,
x[i], x[n] or whatever. (Maxima probably should be more consistent
about subscripted variables but let's leave it alone for now.)
> Ultimately I want to define the following function on these n variables:
> and then find the taylor expansion of this function in the variables
> Is it possible to do this without actually specifying a value for n?
Well, I think so, if you just want compute a definite number of terms.
(I don't know how to compute the n'th derivative of g where n is indefinite.)
Here's what I get. I haven't checked this result.
(%i1) display2d : false$
(%i2) g(x) := sum (((n*x[i])/sum(x[j], j, 1, n) - 1)^2, i, 1, n)$
(%i3) foo : g(u);
(%i4) declare (sum, linear);
(%i5) expand (foo);
(%i6) niceindices (%);
(%i7) foo1 : diff (%, u[i]);
(%i8) foo2 : diff (foo1, u[i]);
(%i9) foo3 : diff (foo2, u[i]);
What makes this tractable by Maxima is that there aren't any indices
other than a literal i, for example, I made j go away by renaming it to i
(via niceindices), and there isn't anything like i + 1 or n - i.
It's probably possible to get Maxima to do the right thing for those cases
but it would be more work.
Note that by default sum does not distribute over minus.
declare(sum, linear) makes that happen.
Hope this helps,
More information about the Maxima