next up previous contents
Next: Matrices Up: Analytical operations Previous: Ordinary differential equations

Substitutions - pattern matching

 

In Macsyma

For comparison with other CAS choose from: Axiom Derive Maple Mathematica Reduce


inputs outputs

    matchdeclare([x, y], true)$

letsimp((cos(x)*cos(y), (cos(x+y) + cos(x-y))/2));

                            cos(y + x) + cos(y - x)
                            -----------------------
                                       2
    letsimp((cos(x)*sin(y), (sin(x+y) - sin(x-y))/2));
                            sin(y + x) + sin(y - x)
                            -----------------------
                                       2
    letsimp((sin(x)*sin(y), (cos(x-y) - cos(x+y))/2));
                            cos(y - x) - cos(y + x)
                            -----------------------
                                       2
    letsimp((cos(x)^2,      (1 + cos(2*x))/2));
                                  cos(2 x) + 1
                                  ------------
                                       2
    letsimp((sin(x)^2,      (1 - cos(2*x))/2));
                                  1 - cos(2 x)
                                  ------------
                                       2
    letsimp(expand((a1*cos(wt) + a3*cos(3*wt) + b1*sin(wt) + b3*sin(3*wt))^3));
        3    3                2              2
      b3  sin (3 wt) + 3 a3 b3  cos(3 wt) sin (3 wt)

          2            2                2            2
 + 3 b1 b3  sin(wt) sin (3 wt) + 3 a1 b3  cos(wt) sin (3 wt)

       2       2
 + 3 a3  b3 cos (3 wt) sin(3 wt) + 6 a3 b1 b3 sin(wt) cos(3 wt) sin(3 wt)

                                                2       2
 + 6 a1 a3 b3 cos(wt) cos(3 wt) sin(3 wt) + 3 b1  b3 sin (wt) sin(3 wt)

                                              2       2
 + 6 a1 b1 b3 cos(wt) sin(wt) sin(3 wt) + 3 a1  b3 cos (wt) sin(3 wt)

     3    3             2               2                2            2
 + a3  cos (3 wt) + 3 a3  b1 sin(wt) cos (3 wt) + 3 a1 a3  cos(wt) cos (3 wt)

          2    2
 + 3 a3 b1  sin (wt) cos(3 wt) + 6 a1 a3 b1 cos(wt) sin(wt) cos(3 wt)

       2       2                   3    3              2            2
 + 3 a1  a3 cos (wt) cos(3 wt) + b1  sin (wt) + 3 a1 b1  cos(wt) sin (wt)

       2       2                 3    3
 + 3 a1  b1 cos (wt) sin(wt) + a1  cos (wt)

declare(int, linear)$

matchdeclare(p, is(diff(p, x) = 0))$

tellsimp(int(x^p, x), x^(p+1)/(p+1));

                        [intrule1, simpargs1]
    tellsimp(int(1, x), x);
                   [intrule2, intrule1, simpargs1]
    int(a^2*b+a^b+3*a-5, a);
                            b + 1    3        2
                           a        a  b   3 a
                           ------ + ---- + ---- - 5 a
                           b + 1     3      2
    int(a^(a+1), a);
                                      a + 2
                                     a
                                     ------
                                     a + 2



Richard Liska