How simplify and expand work in Maple

929 Views Asked by At

When I do:

expand(sin(5*u))                (1)

The output is:

16*sin(u)*cos(u)^4 - 12*sin(u)*cos(u)^2 + sin(u)                (2)

If I want it to give me an expression with merely sin(u) in it, I would do:

simplify(expand(sin(5*u)), [cos(u)^2 = 1 - sin(u)^2])                (3) 

The output of (3) is:

16*sin(u)^5 - 20*sin(u)^3 + 5*sin(u)                (4)

Now, I want to expand tan(4*u). I write:

expand(tan(4*u))                (5)

The output of (5) is:

(4*tan(u) - 4*tan(u)^3)/(1 - 6*tan(u)^2 + tan(u)^4)                (6)

I want it to be in terms of just sin(u) and cos(u). The natural thing to do (I suppose) is to write:

simplify(expand(tan(4*u)), [tan(u) = sin(u)/cos(u)])                (7)

But the output of (7) is just:

(4*tan(u) - 4*tan(u)^3)/(1 - 6*tan(u)^2 + tan(u)^4)                (8)

Which is the same expression as (6). So, (7) turned out to be useless.

My questions are:

$1)$ When is this method (putting an identity inside []) useful and what are its limitations?

$2)$ Are there any shortcuts or better methods to work with than this one?

1

There are 1 best solutions below

0
On BEST ANSWER

If you only wish to substitute tan(u)=sin(u)/cos(u) then use either the 2-argument form of the eval command (or the subs or algsubs commands).

expr := expand(tan(4*u));           

                                                3
                             4 tan(u) - 4 tan(u)
                    expr := -----------------------
                                        2         4
                            1 - 6 tan(u)  + tan(u)

eval( expr, tan(u)=sin(u)/cos(u) );

                                            3
                         4 sin(u)   4 sin(u)
                         -------- - ---------
                          cos(u)           3
                                     cos(u)
                        -----------------------
                                    2         4
                            6 sin(u)    sin(u)
                        1 - --------- + -------
                                   2          4
                             cos(u)     cos(u)

normal( eval( expr, tan(u)=sin(u)/cos(u) ) );

                                   2         2
                   4 sin(u) (sin(u)  - cos(u) ) cos(u)
                - -------------------------------------
                        4           2       2         4
                  sin(u)  - 6 sin(u)  cos(u)  + cos(u)

simplify( eval( expr, tan(u)=sin(u)/cos(u) ) );

                                             2
                    4 sin(u) cos(u) (2 cos(u)  - 1)
                    -------------------------------
                               4           2
                       8 cos(u)  - 8 cos(u)  + 1

This particular substitution for tan in terms of sin and cos can also be made as a conversion. (Here too you could wrap with normal or simplify just to get a more terse result.)

convert( expr, sincos );

                                            3
                         4 sin(u)   4 sin(u)
                         -------- - ---------
                          cos(u)           3
                                     cos(u)
                        -----------------------
                                    2         4
                            6 sin(u)    sin(u)
                        1 - --------- + -------
                                   2          4
                             cos(u)     cos(u)

simplify( convert( expr, sincos ) );

                                             2
                    4 sin(u) cos(u) (2 cos(u)  - 1)
                    -------------------------------
                               4           2
                       8 cos(u)  - 8 cos(u)  + 1

Here are some other ways to get your first example's result,

examp := expand(sin(5*u));                       

                                 4                   2
        examp := 16 sin(u) cos(u)  - 12 sin(u) cos(u)  + sin(u)

If we use the 2-argument eval (or subs) command and try to substitute for cos(u)^2 then the cos(u)^4 will be left untouched. So that's one advantage to using "simplify with subrelations", which what your original code did.

For this example it's possible to substitute for cos(u) and use sqrt.

expand( eval( examp, cos(u)=sqrt(1-sin(u)) ) );

                           3            2
                  16 sin(u)  - 20 sin(u)  + 5 sin(u)

But you can also attain your desired result without using either sqrt or simplification with side-relations, by using the algsubs command.

algsubs( cos(u)^2=1-sin(u)^2, examp );

                           5            3
                  16 sin(u)  - 20 sin(u)  + 5 sin(u)

There may not be a canonical "simplest" form for expressions like yours. So, as you've seen, invoking simplify leaves some decisions up to the system. If your goal is to perform some particular substitutions and obtain a particular form of result then you may be better off choosing particular manipulations.

When I want to retain more control of the substitutions then my own preference is to use 2-argument eval where possible, and if that is not satisfactory then to use algsubs, and if neither is adequate then to use simplification with side-relations.