Substituting expressions in Maxima result



You absolutely should not be doing this with a RegEx!  Maxima has lots of
functions for manipulating algebraic expressions.

Take a look at the documentation for subst and ratsubst to start.  Later you
can look at the pattern matching subsystems.

In your case, the simplest would be just:

     subst(myvectnorm, sqrt(a^2+b^2+c^2), expr )

assuming you mean literal a, b, and c.  If you want to substitute for the
pattern sqrt(a^2+b^2+c^2), where a, b, and c have various forms, you'll need
to look at pattern matching.

        -s


On Tue, Sep 23, 2008 at 12:07 PM, weaker <weaker at directbox.com> wrote:

> Hi all,
>
> I have a very long expression as a maxima result. In it there is quite
> often the part sqrt(a^2 + b^2 + c^2) (the frobenius norm of a vector).
> Now I want to substitute that by a variable like e.g. "myvectnorm".
>
> Do I have to do that with a RegEx search/replace in an editor or can I
> tell maxima to do that already inside maxima? I'd prefer doing it in
> maxima to avoid stupid RegEx errors. And it would make for an easier
> copying into C++ (which is tedious because all "^2" must be replaced).
>
> Best regards,
> weaker
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>