2
$\begingroup$

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

$\endgroup$
5
  • 1
    $\begingroup$ 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}. $\endgroup$
    – Artes
    Jan 13, 2014 at 17:09
  • $\begingroup$ 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. $\endgroup$ Jan 23, 2014 at 16:31
  • $\begingroup$ @episanty You can simplify it manually, as I showed in the edit. $\endgroup$
    – Tom
    Feb 4, 2014 at 19:01
  • $\begingroup$ @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.) $\endgroup$ Feb 4, 2014 at 19:11
  • $\begingroup$ @episanty If $s[1]^2=1$, then $s[1]+s[1]^2==s[1]+1$, so we get the same answer $\endgroup$
    – Tom
    Feb 8, 2014 at 18:18

2 Answers 2

1
$\begingroup$

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.

$\endgroup$
5
  • $\begingroup$ 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]. $\endgroup$
    – Tom
    Jan 14, 2014 at 1:49
  • $\begingroup$ 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? $\endgroup$ Jan 14, 2014 at 10:23
  • $\begingroup$ 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. $\endgroup$
    – Tom
    Jan 14, 2014 at 11:10
  • $\begingroup$ 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. $\endgroup$ Jan 14, 2014 at 12:07
  • $\begingroup$ Sorry for being brief yesterday, I was on my phone. Please see the edit for the maths $\endgroup$
    – Tom
    Jan 15, 2014 at 21:59
0
$\begingroup$
   (((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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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