Re: Re: Eliminating (-1)^2
- To: mathgroup at smc.vnet.net
- Subject: [mg16483] Re: [mg16464] Re: [mg16402] Eliminating (-1)^2
- From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
- Date: Tue, 16 Mar 1999 03:59:40 -0500
- Sender: owner-wri-mathgroup at wolfram.com
Unfortunately my reply was nonsense, caused by a sign mixup n the input. Without the mistake the method below will not work because Simplify will return the expression to its preferred form. So something more complex is needed. One way is to temprarily replace a by -b, Simplify, collect with respect to x and then replace b by -a. Here is an example: In[13]:= Map[Collect[#,x]&,Simplify[v/.{a->-b}],1]/.{b->-a} Out[13]= 2 ((1 - a) x + a y) In general the simplestthing to do is just to accept what Mathematica considers the simplest form! On Sat, Mar 13, 1999, Andrzej Kozlowski <andrzej at tuins.ac.jp> wrote: >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/ > Andrzej Kozlowski Toyama International University JAPAN http://sigma.tuins.ac.jp/ http://eri2.tuins.ac.jp/