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

Substitutions - pattern matching

 

In Reduce

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


inputs outputs

    factor cos,sin;

(a1*cos(wt) + a3*cos(3*wt) + b1*sin(wt) + b3*sin(3*wt))**3 where 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;

                     2       2
    (cos(9*wt)*a3*(a3  - 3*b3 )

                         2        2
     + 3*cos(7*wt)*(a1*a3  - a1*b3  - 2*a3*b1*b3) + 3*cos(5*wt)*

        2           2                     2        2
     (a1 *a3 + a1*a3  - 2*a1*b1*b3 - a1*b3  - a3*b1  + 2*a3*b1*b3) +

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

     + 3*cos(wt)*

        3     2             2        2                       2        2
     (a1  + a1 *a3 + 2*a1*a3  + a1*b1  + 2*a1*b1*b3 + 2*a1*b3  - a3*b1 )

                          2     2
      + sin(9*wt)*b3*(3*a3  - b3 )

                                    2           2
      + 3*sin(7*wt)*(2*a1*a3*b3 + a3 *b1 - b1*b3 ) + 3*sin(5*wt)*

        2                                  2        2           2
     (a1 *b3 + 2*a1*a3*b1 + 2*a1*a3*b3 - a3 *b1 - b1 *b3 + b1*b3 ) +

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

     + 3*sin(wt)*

        2        2                       2        3     2             2
     (a1 *b1 + a1 *b3 - 2*a1*a3*b1 + 2*a3 *b1 + b1  - b1 *b3 + 2*b1*b3 )

     )/4
    operator integrate;

linear integrate;

let integrate(~x**~p,x) => x**(p+1)/(p+1) when df(p,x)=0, integrate(~x,x) => x**2/2, integrate(1,~x) => x$

integrate(a^2*b+a^b+3*a-5,a);

           b      2  2      2
     a*(6*a  + 2*a *b  + 2*a *b + 9*a*b + 9*a - 30*b - 30)
    -------------------------------------------------------
                           6*(b + 1)
    integrate(a^(a+1),a);
               a
    integrate(a *a,a)



Richard Liska