It is a classic question about SymPy. By default SymPy assumes that
all symbols represent arbitrary complex numbers. For the most part
only simplifications that are compatible with any complex numbers will
be applied either automatically or by explicit simplification
functions such as powsimp, simplify etc. I say "for the most part"
because some evaluation/simplification routines ignore degenerate
cases like x/x -> 1 even though x could be zero.

In this case the question is whether (1/a)^x = 1/(a^x). Suppose that a
= -1 and x = 1/2 then we have:

   (1/(-1))^(1/2) = (-1)^(1/2) = i

On the other hand

   1/(-1)^(1/2) = 1/i = -i

So for a = -1 and x = 1/2 we have (1/a)^x = -1/(a^x).

Recognising that 1/a = a^-1 the more general question is when will
(a^x)^y be equal to a^(x*y). If all symbols are positive or if y is an
integer then this holds but more generally it does not necessarily
hold. From first principles SymPy defines x^y as being exp(log(x)*y)
where log should be understood as having a branch cut on the negative
reals so that log(x) = log(abs(x)) + I*arg(x) and arg(x) is in
(-pi,pi]. This branch cut determines when identities like (1/a)^x =
1/a^x will hold.

--
Oscar

On Sat, 27 Jul 2024 at 13:49, <peter.stahlec...@gmail.com> wrote:
>
> If you declare a to be positive, it simplifies with me.
>
>
>
> From: sympy@googlegroups.com <sympy@googlegroups.com> On Behalf Of Pierre H
> Sent: Saturday, July 27, 2024 2:38 PM
> To: sympy <sympy@googlegroups.com>
> Subject: [sympy] Simplification of a^x * (1/a)^x: not equal to 1?
>
>
>
> Hello,
>
>
>
> This is perhaps a classical question, but since I'm only using SymPy every 
> now and then...
>
>
>
> I wonder why the expression a^x * (1/a)^x doesn't simplify to 1. See code 
> (with SymPy 1.12)
>
>
>
> a,x = symbols('a x')
> simplify(a**x * (1/a)**x)
>
>
>
> (then of course the variant a**x * (1/(a**x)) does simplify to 1).
>
>
>
> So is a SymPy issue that the power of x isn't propagated inside the 1/(a) 
> expression. Or I'm just missing a mathematical subtlety which requires adding 
> some assertions about x and a?
>
>
>
> Pierre
>
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sympy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/1b37bc0c-aa69-4e89-99d0-fb5700920dccn%40googlegroups.com.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sympy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/003401dae023%246da70330%2448f50990%24%40gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAHVvXxRmDAyB6uJKB04K7AQi8MaU7jffGNfqLQvHNvMRP_bhcA%40mail.gmail.com.

Reply via email to