1

How hard is to program that given a symbolic expression like

$$ f = x^2 + y^2 + k \, , $$ I could teach to Maple that $x^2 + y^2 = r^2$ and then it expresses f like

$$ f = r^2 + k \, ? $$

Of course I want to implement it for more difficult expressions but this would be a good start.

dapias
  • 215
  • do you want to know how to write an equation of a circle in Maple ???? – mounir ben salem Sep 15 '15 at 08:32
  • Do you want your expressions automatically transformed, or would it be okay if you had to enter a command to do it? The automatic is difficult, but I think doable. I'd have to research how to do it. The command is easy. And, are your "more difficult expressions" still polynomial? The polynomial case is easier than the non-polynomial. – Carl Love Sep 15 '15 at 14:42
  • @mounirbensalem: No, not a circle. The OP is clearly and statedly just providing a simplified example of something more general that is desired. – Carl Love Sep 15 '15 at 14:46

1 Answers1

1

If you expressions are polynomials then you can apply the algsubs command to get that form.

restart:

expr := f = x^2 + y^2 + k:

rule := x^2 + y^2 = r^2:

algsubs(rule, expr);

                                   2
                              f = r  + k

A more powerful way to obtain f expressed like that, which will work for a broader class of expressions, is to simplify it under side relations. Eg,

restart:

expr := f = x^2 + y^2 + k:

rule := x^2 + y^2 = r^2:

simplify( expr, {rule} ); 

                                   2
                              f = r  + k

A more automatic mechanism is to use the alias command. Here we just invoke alias once at the start, and then subsequently the expression shows in the desired form without having to apply another special command. Eg,

restart:  

alias(x^2=r^2-y^2):

expr := f = x^2 + y^2 + k;

                                       2
                          expr := f = r  + k

The r^2 on the RHS can be computationally combined with instance of r^2 itself.

expr - r^2;

                                2
                              -r  + f = k

But here is a drawback (which you might consider serious): it'd be nicer if the RHS of the following were displayed just as x^2 + k.

expr - y^2;

                           2        2    2
                         -y  + f = r  - y  + k
acer
  • 5,293