Subject: "depends" problem of variables with subscripts
From: Richard Fateman
Date: Mon, 9 Jul 2007 10:07:48 -0700
There are implementation barriers to doing depends(x[n],t), which is why it
is not done. Also assume..
Dependencies are stored on the property lists of symbols. X[n] is not a
symbol.
This could be overcome, but at what looks like a substantial run-time cost.
(To see if it REALLY matters, I suppose one would have to implement and time
it, for doing lots of derivatives).
Since what you are essentially doing here is an input and output hack,
there is not a good reason for making the change to the internals, though
you are welcome to do so in your own copy --- it is open source, after all.
You can define x[n,m]:= concat(subsup," " ,x," ",n," ",m); This means that
x[3,4] is changed to "subsup x 3 4".
Then some display hack would be needed so that subsup x 3 4 would display
just like x[3]^4
This could be done by adding a clause to nformat to check for atoms of the
form you have in mind..
Here is most of what is needed
(defun subsuper(h)
;; convert an atom "$subsup x n m" into a triple, (x n m)
;; other atoms result in nil
(setf h (symbol-name h))
(if (and (>(length h) 10)(string= (subseq h 0 8) "$subsup "))
(let ((pos 9))
(multiple-value-setq (name pos)
(read-from-string h nil nil :start pos))
(multiple-value-setq (sub pos)
(read-from-string h nil nil :start pos))
(multiple-value-setq (super pos)
(read-from-string h nil nil :start pos))
(list name sub super))
nil)) (list name sub super))
nil))
There was some effort for "extensions" to nformat; I don't know if it was
put in, finally.
This could be fit in there.
RJf
> -----Original Message-----
> From: Evan [mailto:evanxxx at gmail.com]
> Sent: Monday, July 09, 2007 8:54 AM
> To: fateman at cs.berkeley.edu
> Cc: maxima at math.utexas.edu
> Subject: Re: [Maxima] "depends" problem of variables with subscripts
>
> On 7/9/07, Richard Fateman <fateman at cs.berkeley.edu> wrote:
> > Sure, do the whole computation with x_n_m and before displaying it,
> > substitute x[n]^m.
> > Except if m=1, this will work, but maybe do x[n]^"1" or
> some such thing.
> >
>
> I don't think it's a good idea
>
> usually I'd like to see the intermediate results frequently and decide
> what to do next, or "intermediate" results are also what I want.
> substitute frequently just for displaying would be distracting.
>
> I browsed this mailinglist and noted "using 'depends' and 'assume' on
> arrays" post a few days ago, a similar issue is also raised there.
>
> It seems that there are reasons for maxima to support
> "depends(x[n],t)" and other such statements. wondering whether it will
> be implemented in the (near?) future.
>