Subject: "depends" problem of variables with subscripts
From: Vadim
Date: Mon, 09 Jul 2007 14:18:20 +0400
Richard Fateman wrote:
>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.
>
>
I think this is quite often a need that such output hacks to become
implemented, once and for all.
IMO quite often it is desireable to have Maxima output to be in line
with some mathematical paper.
For example, yesterday I had a need to have greek psi with some lower
index prefixed with italic 'd' with lower index, (partial field
derivative) but acting as independant variable.
I wrote such variables as d_0_psi_3 and read accordingly, but this is
not convenient.
It is very desireable for me to have, for example, some kind of
declaration, so to have special TeX sequence for my given variable
something like
declare_output_tex(d_0_psi_3, "\partial _0 \psi^3");
also optionally following:
declare_output_ascii(d_0_psi_3, "subsup d 0 psi 3");
(using subsup function further defined by you)
so whenever said variable occured, it will be shown appropriately in TeX
(read: TeXmacs)
This could fulfill many requests, IMHO.
Is it reasonable to implement?
>
>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
>
>
>