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


Groups > comp.soft-sys.math.mathematica > #10710

Re: Rearranging terms - user-defined

From "Nasser M. Abbasi" <nma@12000.org>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Rearranging terms - user-defined
Date 2012-07-01 06:05 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jsopau$pu$1@smc.vnet.net> (permalink)
References <jsmgen$1mf$1@smc.vnet.net>

Show all headers | View raw


On 6/30/2012 4:21 AM, 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)
>

How about just simplify or collect?

In[5]:= Simplify[a+b x-b y]
Out[5]= a+b (x-y)

In[6]:= Collect[a+b x-b y,b]
Out[6]= 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.
>

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

I do not know how to do this, because Mathematica evaluator will
always simplify -(1-p) to -p+1, other than using HoldForm,
but then you can't use the result without releasing the Hold:

In[17]:= expr/.Plus[1,Times[-1,x_]]->HoldForm[-(1-x)]
Out[17]= -(1-p)

May be there is a way. I do not know myself now.

--Nasser

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Rearranging terms - user-defined drehstuhl2@googlemail.com - 2012-06-30 09:21 +0000
  Re: Rearranging terms - user-defined "Nasser M. Abbasi" <nma@12000.org> - 2012-07-01 06:05 +0000

csiph-web