MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Rearranging terms - user-defined

  • To: mathgroup at smc.vnet.net
  • Subject: [mg127109] Re: Rearranging terms - user-defined
  • From: "Nasser M. Abbasi" <nma at 12000.org>
  • Date: Sun, 1 Jul 2012 02:05:25 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <jsmgen$1mf$1@smc.vnet.net>
  • Reply-to: nma at 12000.org

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



  • Prev by Date: Re: An easier functional way to divide each Column of matrix by a
  • Next by Date: Numerical integration over an arbitrary 2D domain
  • Previous by thread: Re: An easier functional way to divide each Column of matrix by a
  • Next by thread: Re: Rearranging terms - user-defined