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

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

```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
b
--------------
2  2
a - Sqrt[a -b ]

So, I try

b^2/(a-Sqrt[a^2-b^2])+O[b]^4

and mma returns

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

which is certainly the wrong answer. The correct answer is

2
b
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

2
b
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:

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

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.

Carl

```

• 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