MathGroup Archive 1993

[Date Index] [Thread Index] [Author Index]

Search the Archive

Reduction Problem

  • To: mathgroup <mathgroup at yoda.physics.unc.edu>
  • Subject: Reduction Problem
  • From: Roberto Sierra <73557.2101 at compuserve.com>
  • Date: 30 Jun 93 15:16:46 EDT

I'm having trouble adding a couple of extensions to Plus and
Sqrt to perform specific session-wide reductions in the eqns
I am working with.  I want these reductions to always occur,
not just when I call Replace (/.) or ReplaceRepeated (//.).

Here are the definitions:

    Unprotect[Sqrt,Plus];
      Sqrt[x_^n_?EvenQ] := x^(n/2);     (* True if x>=0 *)
      Plus[1, Cos[t_]] := 2 Cos[t/2]^2; (* True for all t *)
      Plus[x_, x_ Cos[t_]] := 2 x Cos[t/2]^2;
    Protect[Sqrt,Plus];

Here are some tests, which indicates that my defs work:

    In[6] :=
        Sqrt[t^2]   (* Don't worry about t<0 *)
    Out[6] :=
        t

    In[7] :=
        1 + Cos[t]
    Out[7] :=
              t 2
        2 Cos[-]
              2

    In[8] :=
        2 + 2 Cos[t]
    Out[8] :=
          t 2
    4 Cos[-]
          2

OK.  Here's the problem.  Using a 'real' expression, I
don't get both rules working together.  Why?

    In[9] :=
        ds1 = Sqrt[ (1+Cos[theta])^2 + Sin[theta]^2 ]
    Out[9] :=
                   theta 4             2
        Sqrt[4 Cos[-----]  + Sin[theta] ]
                     2

    In[10] :=
        ds2 = ExpandAll[ds1,Trig->True]
    Out[10] :=
                   theta 2
        2 Sqrt[Cos[-----] ]
                     2

If I type this expression back into MMA, I get the fully
reduced equation:

    In[11] :=
        2 Sqrt[Cos[theta/2]^2]
    Out[11] :=
              theta
        2 Cos[-----]
                2


What's going on??

Signed,
   Confused






  • Prev by Date: Re: Mathematica Question
  • Next by Date: Parser
  • Previous by thread: Dynamic programming
  • Next by thread: Parser