Re: Abs[a] Sin[Abs[a]]
- To: mathgroup at smc.vnet.net
- Subject: [mg20984] Re: [mg20923] Abs[a] Sin[Abs[a]]
- From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
- Date: Thu, 2 Dec 1999 21:41:02 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Mathematica can only manage this under the assumption a>0. In[1]:= Simplify[ Abs[a] Sin[Abs[a]], a > 0] Out[1]= a Sin[a] One problem is that Simplify does not know that Abs[a] is -a for negative a. In[2]:= Simplify[Abs[a], a < 0] Out[2]= Abs[a] In fact one would really like Simplify to manage more complicated cases involving Abs, e.g.: In[3]:= Simplify[Abs[Sin[a]], a < 0] Out[3]= Abs[Sin[a]] Just for fun I have decided to write a quick hack that will give the right answer for these cases. One has to modify Simplify in two ways. Firstly, we add the above missing rule for Abs. This alone however is not enough. The second change is a general rule for Simplify[expr, Element[something, Reals]]. This is a more drastic change to the way Simplify works now but at the moment I can't see anything that would be broken by it. Here is my attempt: In[4]:= Unprotect[Simplify]; Simplify[expr_, x_ < 0] := Simplify[expr /. {Abs[x] :> -x, Abs[Sin[x]] :> -Sin[x]}] Simplify[expr_, Element[x_, Reals]] := If[(Simplify[expr, x > 0] === Simplify[expr, x < 0]) && ((Simplify[expr, x > 0] /. x :> 0) === Simplify[expr, x == 0]), Simplify[expr, x > 0], Simplify[expr]] Protect[Simplify]; (Really we should also give rules for Simplify[expr_,{a___,x_<0,b___}] etc). Now indeed we get: In[5]:= Simplify[Abs[a], a < 0] Out[5]= -a In[6]:= Simplify[Abs[Sin[a]], a < 0] Out[6]= -Sin[a] and finally: In[7]:= Simplify[ Abs[a] *Sin[Abs[a]], Element[a, Reals]] Out[7]= a Sin[a] Of course there is a large number of other non-polynomial functions which are odd and about which Simplify doesn't know so one would like to add a rule for Simplify[Abs[f[a]],a<0] for all of these. Even this however would not work in more complicated cases where f was some non-polynomial non built-in function. The problem is that Simplify relies on the ability to solve inequalities, which can really only be done in the case of polynomial ones. > From: Edward Goldobin <gold at isitel1.isi.kfa-juelich.de> To: mathgroup at smc.vnet.net > Organization: Research Center Juelich GmbH > Date: Wed, 1 Dec 1999 01:49:54 -0500 (EST) > To: mathgroup at smc.vnet.net > Subject: [mg20984] [mg20923] Abs[a] Sin[Abs[a]] > > How to compell Mathematica to simplify > Abs[a] Sin[Abs[a]] > to > a Sin[a] > > ? > Why it does not do it automatically? I also tried > assumptions like a :enum: Reals. > > Thanx > Edward >