Items tagged with subexpression

Hi everybody.

I often regret that Maple 18 and further versions (maybe some others before ?) do not represent lengthy and complex outputs by introducing substitution expressions (i.e. %1, %2, ...) as Maple 5 or 8 did.

An exemple can be found in the Maple V release 5 programming Guide (p95, expression %1 = ...)

To be more precise I provide you the output Maple 2015 gives on the same problem treated in "Introduction to Maple, André Heck (1993) Springer Verlag" ; page 86 (no advertising here !).

The problem is about solving a polynomial system in 3 indeterminates.
One of the (set of) solutions is quite complex and looks like (I represent just the beginning of the complete solution) :

{x = %1, y = -1/8*(%1^6 + 15*%1^4 ...) / %1^4 , z = ...}
%1 := RootOf(....)  

From at least Maple 18 this same solution takes this form

{x =  RootOf(....), y = -1/8*( RootOf(....)^6 + 15* RootOf(....)^4 ...) / %1^4 , z = ...}

My question is very simple : Does it exist a way to tell Maple to act as Maple 5/8 did ?

Thanks in advance.


PS1 : I tried things like subs(RootOf(....)=freeze(RootOf(....)), sols) but it is not perfect because I dit this manually, by a copy of RootOf(....) from the output and a paste into the subs(....) input (shame on me !)


PS2 : I use to work in worksheet mode, not document mode, and I would prefer an answer adapted to the worksheet mode.

 

Download Maple2015.mw

I have occasionally a need to map a function over the components of an expression; but not just at the top level---which map() does---but to an arbitrary level. One application is e.g. to throw simplify at subexpressions of a complicated object. Sooner or later I will want to specify the deepest level also... I looked through the docs and Help but could not find anything like that. I had expected map[n]() to do something like this, but it does not.

Does Maple have a...

Apart from the online description of this new Maple 16 feature here, there is also the help-page for subexpressionmenu.

I don't know of a complete listing of its current functionality, but the key thing is that it acts in context. By that I mean that the choice of displayed actions depends on the kind of subexpression that one has selected with the mouse cursor.

Apart from arithmetic operations, rearrangements and some normalizations of equations, and plot previews, one of the more interesting pieces of functionality is the various trigonometric substitutions. Some of the formulaic trig substitutions provide functionality that has otherwise been previously (I think) needed in Maple.

In Maple 16 it is now much easier to do some trigonometric identity solving, step by step.

Here is an example executed in a worksheet. (This was produced by merely selecting subexpressions of the output at each step, and waiting briefly for the new Smart Popup menus to appear automatically. I did not right-click and use the traditional context-sensitive menus. I did not have to type in any of the red input lines below: the GUI inserts them as a convenience, for reproduction. This is not a screen-grab movie, however, and doesn't visbily show my mouse cursor selections. See the 2D Math version further below for an alternate look and feel.)

expr:=sin(3*a)=3*sin(a)-4*sin(a)^3:

expr;

sin(3*a) = 3*sin(a)-4*sin(a)^3

# full angle reduction identity: sin(3*a)=-sin(a)^3+3*cos(a)^2*sin(a)
-sin(a)^3+3*cos(a)^2*sin(a) = 3*sin(a)-4*sin(a)^3;

-sin(a)^3+3*cos(a)^2*sin(a) = 3*sin(a)-4*sin(a)^3

# subtract -sin(a)^3 from both sides
(-sin(a)^3+3*cos(a)^2*sin(a) = 3*sin(a)-4*sin(a)^3) -~ (-sin(a)^3);

3*cos(a)^2*sin(a) = 3*sin(a)-3*sin(a)^3

# divide both sides by 3
(3*cos(a)^2*sin(a) = 3*sin(a)-3*sin(a)^3) /~ (3);

cos(a)^2*sin(a) = sin(a)-sin(a)^3

# divide both sides by sin(a)
(cos(a)^2*sin(a) = sin(a)-sin(a)^3) /~ (sin(a));

cos(a)^2 = (sin(a)-sin(a)^3)/sin(a)

# normal 1/sin(a)*(sin(a)-sin(a)^3)
cos(a)^2 = normal(1/sin(a)*(sin(a)-sin(a)^3));

cos(a)^2 = 1-sin(a)^2

# Pythagoras identity: cos(a)^2=1-sin(a)^2
1-sin(a)^2 = 1-sin(a)^2;

1-sin(a)^2 = 1-sin(a)^2

 

The very first step above could also be done as a pair of simpler sin(x+y) reductions involving sin(2*a+a) and sin(a+a), depending on what one allows onself to use. There's room for improvement to this whole approach, but it looks like progress.

Download trigident1.mw

In a Document, rather than using 1D Maple notation in a Worksheet as above, the actions get documented in the more usual way, similar to context-menus, with annotated arrows between lines.

expr := sin(3*a) = 3*sin(a)-4*sin(a)^3:

expr

sin(3*a) = 3*sin(a)-4*sin(a)^3

(->)

2*cos(a)*sin(2*a)-sin(a) = 3*sin(a)-4*sin(a)^3

(->)

4*cos(a)^2*sin(a)-sin(a) = 3*sin(a)-4*sin(a)^3

(->)

4*cos(a)^2*sin(a) = 4*sin(a)-4*sin(a)^3

(->)

cos(a)^2*sin(a) = sin(a)-sin(a)^3

(->)

cos(a)^2 = (sin(a)-sin(a)^3)/sin(a)

(->)

cos(a)^2 = 1-sin(a)^2

(->)

1-sin(a)^2 = 1-sin(a)^2

(->)

1 = 1

``

Download trigident2.mw

 

I am not quite sure what is the best way to try and get some of the trig handling in a more programmatic way, ie. by using the "names" of the various transformational formulas. But some experts here may discover such by examination of the code. Ie,

eval(SubexpressionMenu);

showstat(SubexpressionMenu::TrigHandler);

The above can leads to noticing the following (undocumented) difference, for example,

> trigsubs(sin(2*a));
              
                                 1       2 tan(a)
[-sin(-2 a), 2 sin(a) cos(a), --------, -----------,
                              csc(2 a)            2
                                        1 + tan(a)

    -1/2 I (exp(2 I a) - exp(-2 I a)), 2 sin(a) cos(a), 2 sin(a) cos(a)]

> trigsubs(sin(2*a),annotate=true);

["odd function" = -sin(-2 a), "double angle" = 2 sin(a) cos(a),

                               1                       2 tan(a)
    "reciprocal function" = --------, "Weierstrass" = -----------,
                            csc(2 a)                            2
                                                      1 + tan(a)

    "Euler" = -1/2 I (exp(2 I a) - exp(-2 I a)),

    "angle reduction" = 2 sin(a) cos(a),

    "full angle reduction" = 2 sin(a) cos(a)]

And that could lead one to try constructions such as,

> map(rhs,indets(trigsubs(sin(a),annotate=true),
>                identical("double angle")=anything));

                             {2 sin(a/2) cos(a/2)}

Since the `annotate=true` option for `trigsubs` is not documented in Maple 16 there is more potential here for useful functionality.

Page 1 of 1