# How do I suppress an automatic sign change? II

Let me be try to be highly specific, as my previous attempt How do I suppress an automatic sign change? to pose the question initially had a sign error, and perhaps became a little muddled.

In the course of pursuing the question Evaluate a certain three-dimensional constrained integral, the term (one of 694)

r = (202338335476512488921084723200 x^6 Sqrt[-(-1 + 2 x) (2 - x +  2 Sqrt[1 - x - 2 x^2])]Boole[1/38 (10 - Sqrt[5]) < x <= 1/4])/(319794090309 (723 + 17 Sqrt[5]))


is generated.

My attempt, r/.c, to apply (so the term becomes integrable--as can be checked) the rule (now corrected from earlier version--again, my apologies)

c := Sqrt[-(-1 + 2 x) (2 - x + 2 Sqrt[1 - x - 2 x^2])] -> 1 - 2 x + Sqrt[1 - x - 2 x^2]


fails (because apparently the expression -(-1 + 2 x) is ab initio converted to (1-2 x)).

What needs to be done, so that the intended conversion takes place?

Unfortunately, it would seem the apparent "automatic" conversion of $$-(-1 + 2 x)$$ to $$(1-2 x)$$ is not so "automatic" that it is performed in the formula for $$r$$ itself, which would obviate the apparent dilemma.

• Probably I do not understand something. When I evaluated your expression for r the term -(-1 + 2 x) automatically transformed into (1 - 2 x). Did it happen with your expression also? If yes, the rule application is senseless. If not, there is something wrong with your code. May it be that a part of your expression was held? Sep 24, 2020 at 12:54
• Thanks--Alexei Boulbitch. So, the question appears to remain of how can I accomplish the clearly intended conversion (one I need to do repeatedly), so I obtain integrable terms. Sep 24, 2020 at 13:08
• For me, the automatic conversion of −(−1+2𝑥) to (1−2𝑥) is performed in the formula for 𝑟 itself (V12.1.1). In any case, the situation you describe should be handled by HoldPattern: c = HoldPattern[Sqrt[-(-1 + 2 x) (2 - x + 2 Sqrt[1 - x - 2 x^2])]] -> Sqrt[(1 - 2 x) (2 - x + 2 Sqrt[1 - x - 2 x^2])]. However, I can't test it, since r is automatically converted. Sep 24, 2020 at 14:12
• Fabulous--Michael E2! It now works--in my V. 12.1.0.0 . Sep 24, 2020 at 14:27
• Unbelieveably frustrating! I have this array of 694 terms, call it H. If I use the command H/.c, where c is as indicated. The change does NOT now take place. Also, Do[H[[i]]=H[[i]]/.c,{i,1,694}] does not work either. Incredible! Seems to be totally unpredictable. Sep 24, 2020 at 14:55

This doesn't answer your question, but hopefully provides an alternate approach where you don't need to worry about pattern matching issues when doing replacements. The following function (inspired by chyanog's answer to a related question) is a more programmatic way to denest some radical expressions:

denestSqrt[e_, domain_, x_] := Replace[
y /. Solve[Simplify[Reduce[Reduce[y == e && domain, x], y, Reals], domain], y],
{
{r_} :> r,
_ -> e
}
]


Now, instead of doing the following (and worrying about possible issues with pattern matching due to small differences in the FullForm):

r /. c


you can do:

r /. Sqrt[s_] :> denestSqrt[Sqrt[s], 1/38 (10 - Sqrt[5]) < x <= 1/4, x]


(202338335476512488921084723200 x^6 (1 - 2 x + Sqrt[1 - x - 2 x^2]) Boole[ 1/38 (10 - Sqrt[5]) < x <= 1/4])/(319794090309 (723 + 17 Sqrt[5]))

• OK, very interesting! I have an array of length 694, with different Boole statements and various integrands--some of the form in the question--for which I've already developed various denesting rules. (Not all the integrands need to be denested.) So, can I systematically proceed through the array, denesting as I go, applying the approach you indicate? Sep 24, 2020 at 22:29
• Doesn't seem to work--no detesting. r = (202338335476512488921084723200 x^6 Sqrt[-(-1 + 2 x) (2 - x + 2 Sqrt[1 - x - 2 x^2])] Boole[1/38 (10 - Sqrt[5]) < x <= 1/4])/(319794090309 (723 + 17 Sqrt[5])); r /. Sqrt[s_] :> denestSqrt[Sqrt[s], Last[r][[1]], x] yielding (202338335476512488921084723200 x^6 Sqrt[(1 - 2 x) (2 - x + 2 Sqrt[1 - x - 2 x^2])] Boole[1/38 (10 - Sqrt[5]) < x <= 1/4])/(319794090309 (723 + 17 Sqrt[5])) Trying to generalize for array members, where r= G[[679]].. Sep 24, 2020 at 23:52
• @PaulB.Slater See update. You will need to use strict inequalities, though. Sep 25, 2020 at 0:17
• Got it to work, apparently! But now how do I, in general (for my 694-long array), render non-strict inequalities into purely strict form, so the methodology can work? Sep 25, 2020 at 0:36
• @PaulB.Slater I think it should work with nonstrict inequalities now. Sep 25, 2020 at 4:59