MathGroup Archive 2010

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

Search the Archive

Re: disable canceling

It would be useful to know what your objective is here. What do you mean by
"after evaluation get some expression"? Is this for didactic reasons?
Otherwise, what is gained by not canceling the factors?

In any case, you could use HoldForm on selected factors to prevent
canceling. But to do any real mathematics you will eventually have to use
ReleaseHold and at that point any matching factors will cancel.

g[s] = s HoldForm[s + 1]/((s + 1) (s + 2)) 
% // ReleaseHold 

(s (s+1))/((1+s) (2+s)) 

g[s] = HoldForm[s (s + 1)]/(s + 2); 
c[s] = 1/(s (s + 1)); 
l[s] = g[s] c[s] 
% // ReleaseHold 

s (s+1)/(s (1+s) (2+s))  

Sometimes there might be meaningful math that can be done while part of an
expression is held and them when the Hold is released it will no longer
simplify as before. The Presentations package has a CreateSubexpression
command that holds a sub-expression with a Tooltip and a tag so one can more
easily control the evaluations. 

Presentations also has a MultiplyByOne command that multiplies the Numerator
and Denominator of an expression by the same factor, but allows operations
on the two parts so the factor does not automatically cancel. For example,
we could construct g[s] by:


s/(s + 2); 
% // MultiplyByOne[s + 1, Identity, Expand]

(s + s^2)/((1 + s) (2 + s))

Here the final expression has nothing held. You might have defined it that
way in the first place.

David Park
djmpark at  

From: Petr Martinec [mailto:petr.martinec at] 

Hi all,
is here posibility to prevent canceling in Mathematica? I need it to
work with transfer and contreller functions (dynamic system theory). I
would like to input like this

g[s] = s (s + 1)/((s + 1) (s + 2));

and after evaluation get same expression. Another situation is:


g[s] = s (s + 1)/(s + 2);
c[s] =1/(s(s + 1));
l[s] = g[s] c[s]

l[s] = s(s + 1)/(s(s + 1)(s + 2))

It is possible to get this result?

thanks for your answers.

  • Prev by Date: Re: Re: Replace and ReplaceAll -- simple application
  • Next by Date: Re: default options, OptionsPattern[], and FilterRules[]
  • Previous by thread: Re: disable canceling
  • Next by thread: Re: Re: disable canceling