Absolute value removal

87 views
Skip to first unread message

brombo

unread,
Jul 9, 2015, 8:27:15 AM7/9/15
to sy...@googlegroups.com
Is there a simple way of removing all absolute values from an expression.  For example if the expression is (Abs(sin(w))/cos(w)) + Abs(w) return (sin(w)/cos(w)) + w.

AMiT Kumar

unread,
Jul 9, 2015, 11:10:41 AM7/9/15
to sy...@googlegroups.com
Hi brombo,

The simplest thing, I can think of as of now:

In [23]: a = (Abs(sin(w))/cos(w)) + Abs(w)

In [24]: S(str(a).replace('Abs', ''))
Out[24]: w + sin(w)/cos(w)



AMiT Kumar

Renato Coutinho

unread,
Jul 9, 2015, 11:23:45 AM7/9/15
to sy...@googlegroups.com
Wouldn't it be better to use

a =
Abs(sin(w))/cos(w) + Abs(w)
a.replace(Abs, Id)

rather than deal with strings?

Best,
Renato

--
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+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/ca8e56be-e29f-48a4-bb57-06a30d7b957f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

AMiT Kumar

unread,
Jul 9, 2015, 11:26:49 AM7/9/15
to sy...@googlegroups.com


On Thursday, July 9, 2015 at 8:53:45 PM UTC+5:30, Renato Coutinho wrote:
Wouldn't it be better to use

a =
Abs(sin(w))/cos(w) + Abs(w)
a.replace(Abs, Id)

rather than deal with strings?


Yes, that is certainly better, I couldn't recall this, earlier.

Thanks!
 
AMiT Kumar

Alan Bromborsky

unread,
Jul 10, 2015, 5:10:49 PM7/10/15
to sy...@googlegroups.com
Thank you both of you for your solutions.

--
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+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
Reply all
Reply to author
Forward
0 new messages