Re: Eliminating (-1)^2
- To: mathgroup at smc.vnet.net
- Subject: [mg16464] Re: [mg16402] Eliminating (-1)^2
- From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
- Date: Sat, 13 Mar 1999 02:22:01 -0500
- Sender: owner-wri-mathgroup at wolfram.com
In the absence of any knowledge of a there is no reason why the answer you want should be considered simpler than the one Mathematica gives. Mathematica just follows its own rules for ordering symbols and numbers. You can get slightly more "normal" looking expresions by using TraditionalForm for output: In[86]:= a-1 Out[86]= -1+a In[87]:= %//TraditionalForm Out[87]//TraditionalForm= a - 1 Of course you can always use pattern matching to force Mathematica to give you the answer in any form you like. For eample in your case: In[1]:= v=(-(1-a)x -a y)^2 Out[1]= 2 ((-1 + a) x - a y) In[2]:= Simplify[v/.(-1+a) x-a y->-1((a-1)x+a y)] Out[2]= 2 ((-1 + a) x + a y) This will also work on more complex expresions: In[3]:= Simplify[3v+2v^2+Sin[v]/.(-1+a) x-a y->-1((a-1)x+a y)] Out[3]= 2 4 3 ((-1 + a) x + a y) + 2 ((-1 + a) x + a y) + 2 Sin[((-1 + a) x + a y) ] On Thu, Mar 11, 1999, Nicolas B.E. Sawyer <nbes at eee.nott.ac.uk> wrote: >1) How do I get Mathematica to eliminate factors of (-1)^2. Specifically >I want to replace occurrences of (-(1-a)x -a y)^2 by ((1-a)x +a y)^2 >within an expression? > >2) Using InputForm > >In[132]:= >(-(1 - a)x - a y)^2 > >Out[132]= > 2 >(-((1 - a) x) - a y) > >but with StandardForm > >In[130]:= >?!?(?((?(-?((1 - a)?)?) x - a? y)?)?^2?) > >Out[130]= > 2 >((-1 + a) x - a y) > >Why the difference in the results and why doesn't either give the >following? > > 2 >((1 - a) x + a y) > >Finally, since > >Simplify[(-x - y)^2] > >gives > > 2 >(x + y) > >why does > >Simplify[(-(1 - a)*x - a*y)^2] > >yield > > 2 >((-1 + a) x - a y) ? > >-- >Nicolas B.E. Sawyer > > >Department of Electrical and Electronic Engineering, >University of Nottingham, >University Park, >Nottingham, >NG7 2RD. > >Tel: +44 115 9515151 ext 12028 >Fax: +44 115 9515616 > >E-mail: nbes at eee.nottingham.ac.uk Andrzej Kozlowski Toyama International University JAPAN http://sigma.tuins.ac.jp/ http://eri2.tuins.ac.jp/