# Simplification with assumptions

I'm trying to make Mathematica do some simplifications for me. I have the expression

((1 + s[1]) (-1 + s[2]) )/(-1 + s[1] s[2])


and want to simplify this with the assumption that

s[1]^2==1


(it should simplify to 1+s[1], as can be verified manually)

I obviously tried

Simplify[((1 + s[1]) (-1 + s[2]) )/(-1 + s[1] s[2]), s[1]^2 == 1]


to no avail. Is there any way I can persuade Mathematica to do this for me?

Edit:

Here's the manual simplification:

$$\frac{(1 + s[1]) (-1 + s[2])}{-1 + s[1] s[2]}=\frac{(1 + s[1])(-1+s[1]^{-1})(-1+s[1]s[2])+(-1+s[1]^{-1})+(-1+s[1]s[2]) }{-1 + s[1] s[2]}=\frac{(1 + s[1])((-1+s[1])(-1+s[1]s[2])+(-1+s[1])+(-1+s[1]s[2]))}{-1 + s[1] s[2]}=\frac{(1 + s[1])((-1+s[1])(-1+s[1]s[2])+(-1+s[1])+(-1+s[1]s[2]))}{-1 + s[1] s[2]}=\frac{(1 + s[1])(-1+s[1])((-1+s[1]s[2])+1)+(1+s[1])(-1+s[1]s[2])}{-1 + s[1] s[2]}=\frac{0((-1+s[1]s[2])+1)+(1+s[1])(-1+s[1]s[2])}{-1 + s[1] s[2]}=1+s[1]$$

• Since there is no s[1]^2 in the expression it can't be simplified. You can do c /. Solve[((1 + s[1]) (-1 + s[2]))/(-1 + s[1] s[2]) == c && s[1]^2 == 1, c, MaxExtraConditions -> All] or Cancel[((1 + s[1]) (-1 + s[2]))/(-1 + s[1] s[2]) /. {{s[1] -> -1}, {s[1] -> 1}}] or Simplify[((1 + s[1]) (-1 + s[2]))/(-1 + s[1] s[2]), s[1] == #] & /@ {-1, 1}. Jan 13, 2014 at 17:09
• What's to select that version, though, from $s[1]+s[1]^2$, or indeed $1+1/s[1]$? It's not a particularly well-defined problem. Jan 23, 2014 at 16:31
• @episanty You can simplify it manually, as I showed in the edit.
– Tom
Feb 4, 2014 at 19:01
• @Tom I don't see that that's the case. For me it simplifies to $s[1]+s[1]^2$. There must be something wrong with your workings. (... or, the problem is not well defined.) Feb 4, 2014 at 19:11
• @episanty If $s[1]^2=1$, then $s[1]+s[1]^2==s[1]+1$, so we get the same answer
– Tom
Feb 8, 2014 at 18:18

Simplify has built-in support for the Assumptions option. Thus, for example,

Simplify[Sqrt[x^2]]


will return the same argument, since the real part of x could be negative, then it can simplify it further:

Simplify[Sqrt[x^2], Assumptions -> x > 0]


returns x.

In your case, though, there is no ready simplification because there's no real need to call s[1]^2. On the other hand, one can see that your assumption severely restricts the values s[1] can take. I would advise you to see this in the light of "s[1] must satisfy this given equation": you can then Solve it and see what happens to your expression when you substitute in the values. Thus,

((1 + s[1]) (-1 + s[2]))/(-1 + s[1] s[2]) /. Solve[s[1]^2 == 1, s[1]]


returns {0,2}, which is what I believe you were expecting. If your expression gets more complicated, you may need to bring in a further Simplify step enveloping the substitution.

• That's not quite what I want - I don't want to fix the value of s[1], I just want it to be a symbol whose square is 1. With just this assumption (not setting s[1] to be equal to +1 or -1) one can (manually) reduce the expression to 1+s[1].
– Tom
Jan 14, 2014 at 1:49
• Can you do it manually, though, without doing a case-by-case analysis? Otherwise, an equally compelling case might be made that under that restriction your expression equals (1+s[1])^2/2. How is the code to know what expression to simplify this to? Jan 14, 2014 at 10:23
• You can do it manually by writing (-1+s[2])=(-1+s[1]^(-1))(-1+s[1]s[2])+(-1+s[1]^(-1))+(-1+s[1]s[2]) and then expanding the numerator.
– Tom
Jan 14, 2014 at 11:10
• Apologies, but I don't follow those maths. Are you sure they are correct? It would help if you included in your question a LaTeX'd version of the manual simplification you are hoping Mathematica can do. Jan 14, 2014 at 12:07
• Sorry for being brief yesterday, I was on my phone. Please see the edit for the maths
– Tom
Jan 15, 2014 at 21:59
   (((1 + s[1]) (-1 + s[2]))/(-1 + s[1] s[2]) // Expand) /.
s[1] -> 1 // Simplify

(*   2    *)

(((1 + s[1]) (-1 + s[2]))/(-1 + s[1] s[2]) // Expand) /.
s[1] -> -1 // Simplify

(*  0   *)


Have fun.

• I don't want to treat s[1] as a number, just a symbol whose square is 1
– Tom
Jan 14, 2014 at 11:15
• @Tom If there is something whose square is 1, one concludes that something is either 1, or -1. Did I miss anything? Jan 14, 2014 at 15:40
• Only if you assume that s[1] is a complex number - I want to just treat it as a symbol
– Tom
Jan 15, 2014 at 21:59