# replacement rules don't account for signs [duplicate]

I would like to make a single replacement rule that disregards the sign. I have the following expression:

cond = -((-(2 + s^2) (E2 (x1 - x2) + E1 (x2 - x3)) + Sqrt[(2 + s^2)^2 (E2 (x1 - x2) + E1 (x2 - x3))^2 - 32 E1 E2 s^2 (x1 - x2) (x2 - x3)])/((2 + s^2) (E2 (x1 - x2) + E1 (x2 - x3)) + Sqrt[(2 + s^2)^2 (E2 (x1 - x2) + E1 (x2 - x3))^2 - 32 E1 E2 s^2 (x1 - x2) (x2 - x3)]))


I would like to simplify this expression, but if I make a replacement rule like

cond/.{x2-x1 -> l1}


this does nothing because it doesn't realize that x1-x2 = -l1. Is there a way to solve this?

## marked as duplicate by J. M. is away♦May 23 '17 at 8:28

• Why not use x1 -> x2 - l1? – J. M. is away May 23 '17 at 8:14
• The bottom line is that ReplaceAll isn't meant to work for math formulas this way. Solve/Eliminate/Reduce etc are. Or you can use x1 -> x2 - l1 to overcome Replacement limitations. For general approach check the link, have you? hard to say without examples, all problems of the same 'class' should be solvable by a solution that works for one of them. – Kuba May 23 '17 at 9:14
• @AlejandroMarcosAragon you clearly didn't read/check links in the duplicate question. Apart of that, nonlinearity is not a problem, the bottle neck is what Solve/Eliminate/Reduce can do. – Kuba May 23 '17 at 9:24