Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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] $$

share|improve this question
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}. –  Artes Jan 13 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. –  episanty Jan 23 at 16:31
    
@episanty You can simplify it manually, as I showed in the edit. –  Tom Feb 4 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.) –  episanty Feb 4 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 at 18:18
add comment

2 Answers 2

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.

share|improve this answer
    
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 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? –  episanty Jan 14 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 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. –  episanty Jan 14 at 12:07
    
Sorry for being brief yesterday, I was on my phone. Please see the edit for the maths –  Tom Jan 15 at 21:59
add comment
   (((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.

share|improve this answer
    
I don't want to treat s[1] as a number, just a symbol whose square is 1 –  Tom Jan 14 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? –  Alexei Boulbitch Jan 14 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 at 21:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.