MathGroup Archive 1997

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

Search the Archive

How do you make Mma assume a parameter is real and positive?

  • To: mathgroup at
  • Subject: [mg7343] How do you make Mma assume a parameter is real and positive?
  • From: "C. Woll" <carlw at>
  • Date: Tue, 27 May 1997 22:27:26 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

Hi all,

If I give mma the input Sqrt[3^2] I get back 3, but when I give it
Sqrt[a^2] I don't get back a. This is exactly the behavior I expect. 
However, suppose that I want to tell mma that a is a real positive number,
so that I want Sqrt[a^2] to return a. How can I do this?

Let me give you the background for this question. As a simple example,
suppose I am trying to find the series expansion of 

          2  2
a - Sqrt[a -b ]

So, I try


and mma returns

---------- + O[b]^4
a-Sqrt[a ]

which is certainly the wrong answer. The correct answer is

2 a - --- + O[b]^4
      2 a

So, I need to tell mma that Sqrt[a^2] is a while it is doing its series
expansion algorithm. Another manifestation of this problem occurs when
taking limits, since mma gives

Limit[-------------, b->0] ---> 0
              2  2
      a-Sqrt[a -b ]

which is also incorrect (it should be 2 a). The usual solution of using
ComplexExpand doesn't help here. My solution for this particular example
was to add new rules for Power: 

Power[Power[a,n_],m_]:=Power[a,n m];

I would have preferred to add an upvalue to a, but a would be too deeply
buried if I were to try

a /: Power[Power[a,n_],m_]:=Power[a,n m]

I am not crazy about the above method, since it slows down the application
of Power everywhere, so I am curious if anybody has a better method.

Thanks for any suggestions.


  • Prev by Date: Re: N and NSolve
  • Next by Date: List manipulation
  • Previous by thread: All involutions of a permutation
  • Next by thread: List manipulation