Group Abstract Group Abstract

Message Boards Message Boards

Getting access to all the roots by Solve

How do I get access to all the roots from Solve?

The attached notebook has a simple example.

i'm trying to Solve for s when this equation equals d:

(Sqrt[2] N s^2)/Sqrt[N (3 + N) s^2 \[Sigma]^2 + 2 (1 + N) \[Sigma]^4]

Solve give me a Root object, but the (only) root it returns is a negative one. But perhaps I'm not facile enough with Roots. :-(

ToRadicals can write the expression, which is what I want, but it seems to have chosen two different negative results.

I can pick the parts by hand, but I'd much prefer to do it all programmatically. How do I get the root I want?

What am I missing?

Thanks
Malcolm

POSTED BY: Malcolm Slaney
9 Replies

First, parametrized roots are tricky, both with Root[] and with radicals. Branches come together and split, sometimes changing between real and complex, as the parameter values change. There is a canonical order to Root[] objects when the coefficients of the polynomial are explicit numerical values.

Nonetheless, sometimes it is possible to pick out, say, a root expression that is always positive. With a little human intervention, we can see below that the case at hand is one of these times. I don't know how to automate this. In particular, I feel the dimension reduction step, s -> Sqrt[ssq] σ, probably helps a lot.

assum = s > 0 && σ > 0 && n > 0 && d > 0;

pos = Solve[{CorrelationDPrime[s, σ, n] == d, s > 0} /.
     {s -> Sqrt[ssq] σ, d -> Sqrt[dsq]}
   , ssq, Reals
   , Assumptions -> assum && dsq>0
   ] /.
  {ssq -> rt_} :> {s -> σ*Sqrt@rt /. dsq -> d^2}
(*
  {{s -> Sqrt[(3 d^2 + d^2 n)/(4 n) + 
       Sqrt[16 d^2 + 9 d^4 + 16 d^2 n + 6 d^4 n + d^4 n^2]/(4 n)] σ}}
*)

CorrelationDPrime[s, σ, n] == d /. pos // FullSimplify[#, assum] &
(*  {True}  *)

FullSimplify[s > 0 /. pos, assum]
(*  {True}  *)
POSTED BY: Michael Rogers

Ahh, the joys of MMA. It will do anything if you just ask the right way. :-)

You are right about complex branches. But I now think the original post shows two errors: 1) Only showing one root and not allowing me to ask for all of them, and 2) picking a root that clearly doesn't satisfy the s>0 constraint.

Thanks.

  • Malcolm
POSTED BY: Malcolm Slaney

No luck. But it did cause MMA to chew up a lot of CPU time, to no avail.

I'm not sure why removing the assumptions should help. The square roots all have +/- options, regardless of the constraints.

How do I get MMA to tell me what it knows, the other roots?

Failing that, how do I programmatically edit the result, changing the - square roots to positive?

Thanks.

  • Malcolm
POSTED BY: Malcolm Slaney

In a new session the following code gives four solutions in the blink of an eye:

CorrelationMean[s_, \[Sigma]_, N_] := s^2 + \[Sigma]^2/N ;
CorrelationVariance[s_, \[Sigma]_, N_] := 
  s^2* \[Sigma]^2* (1 + 3/N) + (N + 1) \[Sigma]^4/N^2;
CorrelationDPrime[s_, \[Sigma]_, 
   N_] := (CorrelationMean[s, \[Sigma], N] - 
     CorrelationMean[0, \[Sigma], N])/
   Sqrt[(CorrelationVariance[s, \[Sigma], N] + 
       CorrelationVariance[0, \[Sigma], N])/2];
CorrelationDPrimeSimple = 
  Simplify[CorrelationDPrime[s, \[Sigma], N]] // PowerExpand;
CorrelationThreshold = 
 Solve[CorrelationDPrime[s, \[Sigma], N] == d, s]
POSTED BY: Gianluca Gorni

Oh, cool. Yay!

I apologize to the previous poster, as removing the assumptions seems to be critical. I thought I had restarted my kernel, but perhaps not.

So, why? The assumptions are all reasonable (everything is positive). I don't see this assumption as forcing one solution over the others.

Is this a bug?

Thank you!!!

  • Malcolm
POSTED BY: Malcolm Slaney

I never use $Assumptions, so I am no expert. It surely looks like a bug, though.

POSTED BY: Gianluca Gorni

I would remove the $Assumptions, so that all four algebraic solutions are displayed.

POSTED BY: Gianluca Gorni

The question remains. Yes, some of the roots will be complex, from both roots. How do I get ToRadicals (or Roots) to all of them to me so I can pick the right one? I think Roots is trying to return the positive one (number 2), but it is failing here.

POSTED BY: Malcolm Slaney

It can be worse than negative, it can be complex:

CorrelationThresholdExp /. {\[Sigma] -> 1, N -> 1, d -> 1}

It seems that Solve cannot deal with all the symbolic parameters. With numerical parameters the solution is positive:

Solve[s > 0 && 
   CorrelationDPrime[s, \[Sigma], N] == d /. {\[Sigma] -> 1, N -> 1, 
   d -> 1}, s]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard