Maybe we should just remove all auto-separation from the core and add  
your routine to separate()/powsimp().

Aaron Meurer
On Aug 22, 2009, at 10:47 PM, smichr wrote:

>
> THE ISSUE
> When roots are expanded, (a*b)**e --> a**e * b**e, the expanded result
> will be off by a factor of a root of -1, fix = (-1)**(2-A*e) to be
> exact (if I finally have all the math right) where A is 2*(nn//2) and
> nn is the number of negatives in the arguments (just a and b in this
> case) [*].
>
> EXAMPLE
> if a = -1 and b = 2 then nn is 1, A = 0, and fix = 1 (i.e. no
> correction factor is needed) but if b = -2 then nn = 2, A = 2 and fix
> = -1**(2-2*e) (so if e is 1/2 the answer is off by a factor of -1 from
> what it would have been if the two terms were not expanded). In this
> latter example, the answer is technically right, giving one of the
> roots of -2 but this result might not be expected; one might be
> expecting the primary branch solution, thus the raising of issue 1161
> and issue 896. Since the roots of -1 can generate both real and
> imaginary components when e is not 1/2, e.g. (-1)**(1/3) = .5 + .
> 866*I, it is possible that an answer looks "way off" when the roots
> are expanded. Taking the previous example with a, b = -1, -2, a**e *
> b**e -> -0.63 + 1.1*I instead of 1.26.
>
> [If you try this previous example in sympy you might find that
> a**e*b**e evaluates to 1.25 for the values of a, b, and e cited but
> that is because sympy automatically combines the exponents together
> before evaluating, effectively cancelling out the signs of a and b.]
>
> QUESTION
> I'm wondering what the best way to handle the correction factor might
> be. Right now I have a function that returns a factor (let's call it
> Si, short for sign) relating the expanded and unexpanded roots:
>
> (a*b)**e = Si(a,b,e) * a**e * b**e
>
> But it doesn't come back as "Si(a,b,e)" it comes back as an expression
> with several sign() terms in it, for example:
>
>>>> sqrt(a*b)
> a**(1/2)*b**(1/2)*sign(a*b)**(1/2)/(sign(a)**(1/2)*sign(b)**(1/2))
>
> Does anybody have an idea of what the best way to represent this
> factor might be? My preference would be to have something that is as
> unobtrusive as possible. Perhaps a new function? If so, what would be
> a good name? How should it be represented? I think I would prefer just
> a single character, but perhaps a function that always only shows it's
> arguments would be better as shown above.
>
> This factor is needed in several places: mul, power, simplify at
> least. My thinking is to put this into simplify but maybe it should be
> in functions.
>
> Hopefully I've been clear enough about the problem and a solution that
> others can give some input as to how this should be implemented.
>
> /c
>
> [*] This is one way to implement the correction factor: by putting the
> number of negatives information in the exponent. The way I actually
> have it implemented right now is to put the sign information in the
> bases and leave the exponents alone so the factor when applied to the
> expanded form of the root appears as a series of "sign(x_i)**e" terms
> in the denominator. Ideally, I think this should all be hidden from
> the user because for more complicated expressions, e.g. sqrt(1*b) +
> (a*b)^(1/3), the correction factor introduces a lot of "symbolic
> noise".
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to