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

Substitutions - pattern matching

 

In Axiom

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


inputs outputs

    sincosRules:= rule _

(cos(x)*cos(y) == (cos(x+y) + cos(x-y))/2; _

cos(x)*sin(y) == (sin(x+y) - sin(x-y))/2; _

sin(x)*sin(y) == (cos(x-y) - cos(x+y))/2; _

cos(x)**2 == (1 + cos(2*x))/2; _

sin(x)**2 == (1 - cos(2*x))/2 )

                       %X cos(y + x) + %X cos(- y + x)
   {%X cos(x)cos(y) == -------------------------------,
                                      2
                       %Y sin(y + x) - %Y sin(- y + x)
    %Y cos(x)sin(y) == -------------------------------,
                                      2
                       - %Z cos(y + x) + %Z cos(- y + x)
    %Z sin(x)sin(y) == ---------------------------------,
                                       2
          2    cos(2x) + 1        2    - cos(2x) + 1
    cos(x)  == -----------, sin(x)  == -------------}
                    2                        2
                            Type: Ruleset(Integer,Integer,Expression Integer)
sincosRules (a1*cos(wt) + a3*cos(3*wt) + b1*sin(wt) + b3*sin(3*wt))**3
       3        3          2                2                 2                2
     b3 sin(3wt)  + (3b1 b3 sin(wt) + 3a3 b3 cos(3wt) + 3a1 b3 cos(wt))sin(3wt)
   +
            2          2
         3b1 b3 sin(wt)  + (6a3 b1 b3 cos(3wt) + 6a1 b1 b3 cos(wt))sin(wt)
       +
            2           2                                  2          2
         3a3 b3 cos(3wt)  + 6a1 a3 b3 cos(wt)cos(3wt) + 3a1 b3 cos(wt)
    *
       sin(3wt)
   +
       3       3          2                 2               2
     b1 sin(wt)  + (3a3 b1 cos(3wt) + 3a1 b1 cos(wt))sin(wt)
   +
         2           2                                  2          2
     (3a3 b1 cos(3wt)  + 6a1 a3 b1 cos(wt)cos(3wt) + 3a1 b1 cos(wt) )sin(wt)
   +
       3        3         2               2      2          2
     a3 cos(3wt)  + 3a1 a3 cos(wt)cos(3wt)  + 3a1 a3 cos(wt) cos(3wt)
   +
       3       3
     a1 cos(wt)
                                                     Type: Expression Integer
    int:= operator('int);
                                                          Type: BasicOperator

intRules:= rule _

(int(x + :y, z) == int(x, z) + int(y, z); _

int(k*x | freeOf?(k, z), z) == k*int(x, z); _

int(y | integer? y, z) == y*z; _

int(x**(?p | D(p, x) = 0), x) == x**(p+1)/(p+1) )

   {int(y + x,z) == 'int(y,z) + 'int(x,z), int(k x,z) == k'int(x,z),
                                   p + 1
                          p       x
    int(y,z) == y z, int(x ,x) == ------}
                                  p + 1
                            Type: Ruleset(Integer,Integer,Expression Integer)
    intRules int(a**2*b+a**b+3*a-5, a)
     b + 1     2     2               2            2
    a      + (a b + a )int(b,a) + (3a  - 5a)b + 3a  - 5a
    ----------------------------------------------------
                           b + 1
                                                     Type: Expression Integer
    intRules int(a**(a+1), a)
     a + 2
    a
    ------
    a + 2
                                                     Type: Expression Integer



Richard Liska