On Mon, Nov 3, 2008 at 4:00 PM, Alan Bromborsky <[EMAIL PROTECTED]> wrote:
>
> The following code unconditionally removes abs from products and
> quotients,  but it would be much better if  abs could be removed
> conditinally depending on what range of values the variables can assume
> when the user specifies the ranges of the independent variables!
>
>
> sym_type = sympy.core.symbol.Symbol
> pow_type = sympy.core.power.Pow
> abs_type = sympy.abs
> mul_type = sympy.core.mul.Mul
>
> def unabs(x):
>    if type(x) == mul_type:
>        y = unabs(x.args[0])
>        for yi in x.args[1:]:
>            y *= unabs(yi)
>        return(y)
>    if type(x) == pow_type:
>        y = 1/unabs(x.args[0])
>        return(y)
>    if len(x.args) == 0:
>        return(x)
>    if type(x) == abs_type:
>        return(x.args[0])
>    return(x)

Thanks for the code. Feel free to attach it to some issue. If you want
it to become part of sympy soon, try to create patch with a test, so
that others can easily see if it's an improvement or regression over
the current state.

Ondrej

--~--~---------~--~----~------------~-------~--~----~
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