Message Boards Message Boards

Does Assumptions not work on Root objects?

Posted 4 years ago

[Cross-posting from MSE, since no one there had an answer.]

Typically, one can restrict symbolic quantities using Assumptions.

Suppose, for instance, that I want to solve $a=x^2$ for $x$, with $a>0$, restricting my answer to the positive root.

r1 = Reduce[a == x^2, x]
Simplify[r1, Assumptions -> x > 0 && a > 0]

$x=-\sqrt{a} \,\,||\, x=\sqrt{a}$

$\sqrt{a}=x$

However, it appears that Assumptions does not work on symbolic quantities when they are expressed as Root objects. For instance, r2 contains four symbolic quantities:

expr=H3O^4 + H3O^3*(KaHA + KaHB) + 
H3O^2*(KaHA*KaHB - (cHA*KaHA + cHB*KaHB) - Kw) - 
H3O*((cHA + cHB)*KaHA*KaHB + Kw*(KaHA + KaHB)) - KaHA*KaHB*Kw;
r2= Reduce[expr==0, H3O]

enter image description here

Now suppose I want to determine if any of these gives a positive value for the variable H3O when all the parameters are postive:

sr2=Simplify[r2, Assumptions->H3O > 0 && KaHA > 0 && KaHB > 0 && cHA > 0 && cHB > 0 && Kw > 0]

The output of sr2 is identical to that of r2. Yet a single numerical test shows that the restrictions given by Assumptions are ignored. Specifically, Simplify/Assumptions returns all four Root objects for H3O, even though only one of them numerically evaluates as positive:

N[sr2 /. {KaHA -> 10^-(375/100), KaHB -> 10^-(4756/1000), cHA -> 5/1000, cHB -> 5/1000, Kw -> 10^-14}, 10]

H3O == -0.001074531007 || H3O == -0.00003186037898 || H3O == -9.999999686*10^-13 || H3O == 0.0009110246413

I tried to apply Simplify/Assumptions to another expression that also contains Root objects, and encountered the same behavior.

So does Assumptions not work for Root objects generally and, if so, why?

It's possible this is happening because Root objects need to be "unpacked" (with ToRadicals) before constraint-testing can be done by Assumptions, and Simplify doesn't unpack Root objects.

One can restrict the answer by instead applying the restrictions within Reduce:

 r3= Reduce[expr==0 && H3O > 0 && KaHA > 0 && KaHB > 0 && cHA > 0 && cHB > 0 && Kw > 0, H3O];
 N[r3 /. {KaHA -> 10^-(375/100), KaHB -> 10^-(4756/1000), cHA -> 5/1000, cHB -> 5/1000, Kw -> 10^-14}, 10]

H3O == 0.0009110246413

As to why I don't just use the latter (r3) as a workaround, r2 runs in a fraction of a second while r3 takes ~10 hours. So I was hoping that r2, followed by Simplify/Assumptions on Root objects, might take less time.

But if unpacking is needed, the time will be long either way. For instance, I could unpack r2 using ToRadicals, and then apply Simplify/Assumptions to that, but then I get back to the same problem: excessive computation time.

Hence it seems I need to either pay on the front end (in Reduce) or on the back end (ToRadicals and then Simplify/Assumptions) because it's the constraint-testing that is time-consuming, and it has to be done one place or the other.

[N.B.: I am using MMA 12.0.0.0 for MacOS.]

POSTED BY: A B
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract