Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #10718 > unrolled thread

Re: Rearranging terms - user-defined

Started byAndrzej Kozlowski <akozlowski@gmail.com>
First post2012-07-01 06:12 +0000
Last post2012-07-01 06:12 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Rearranging terms - user-defined Andrzej Kozlowski <akozlowski@gmail.com> - 2012-07-01 06:12 +0000

#10718 — Re: Rearranging terms - user-defined

FromAndrzej Kozlowski <akozlowski@gmail.com>
Date2012-07-01 06:12 +0000
SubjectRe: Rearranging terms - user-defined
Message-ID<jsopoc$115$1@smc.vnet.net>
On 30 Jun 2012, at 11:19, drehstuhl2@googlemail.com wrote:

> Does anyone know how to tell mathematica the following:
>
> I have an expression like: a + bx -by
> and I want to factorise it like: a + b(x-y)
>
> BUT: I want Mathematica to show the difference (x-y) whenever possible 
(in the different calculations - not just place b outside the bracket). 
That's because equations are easier to discuss if they are written in a 
special way.

Well, in my opinion the best way is:

a + b x - b y + O[x, y]^2 // Normal

a+b (x-y)

Note that the degree of the O term should be higher than the highest 
polynomial term in your expression. This will work in fact even in non 
polynomial cases such as:

g = a + c*x^2 - 2*c*x*y + c*y^2 + 1/(x^3 - 3*x^2*y + 3*x*y^2 - y^3) + 
18*x - 18*y

Then:

Normal[g + O[x, y]^5]
a + c*(x - y)^2 + 18*(x - y) + 1/(x - y)^3


>
> Another example would be: using probabilities, I always want to write 
mathematica -(1-p) instead of -p+1 throughout the notebook.

Actually, that is involves a  different issue. You can't make 
Mathematica write -(1-p) instead of p-1 without using HoldForm because 
Mathematica will always evaluate

 -(p - 1)

1 - p

You can deal with this using HoldForm but in my opinion it is not worth 
it and likely eventually get you into trouble.

However, if your coefficient is something other than -1 then indeed the 
previous method will also work, for example

 -2p+2 +O[p,1]^2//Normal
 -2 (p-1)


Andrzej Kozlowski

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web