I am a sympy beginner, and fairly new to python, so I suspect that my
question has a simple answer, but have not been able to figure it out
myself.
I have sympy expressions containing the built-in Abs function. The
arguments of Abs() are polynomials in a=symbol('a',
real=True,positive=True) . Here are a three examples:
Abs(a**2 + 2)
sqrt(2)*Abs(2*a**2 - 1)/3
sqrt(2)*(a + 1)*Abs(a - 1)/3
Here's the point: I know that 'a' is approximately 0.6. So in cases where
the argument of Abs has an unambiguous sign (within floating-point
precision) I would like to simplify the absolute value. For example in the
three cases above I would like:
Abs(a**2 + 2) -> a**2 + 2
sqrt(2)*Abs(2*a**2 - 1)/3 -> sqrt(2)*(1- 2*a**2)/3
sqrt(2)*(a + 1)*Abs(a - 1)/3 -> sqrt(2)*(a + 1)*(1-a)/3
where the right arrow '->' indicates replacement or simplification. Note
the change of sign in the second and third examples, because (for example)
I know that (a-1) is negative.
Is there a (simple) way to implement this?
Thank you!
Bruce
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/1319753f-5d6a-48b4-9bf7-6caac9d97c34n%40googlegroups.com.