1
$\begingroup$

I know there may be duplicates, But I have not found any question with a concrete answer for the case I am treating.

If I have a determinant:

Det[f[x]]==0

And I want to solve it for x:

Solve[Det[f[x]]==0,x]

In general, there may be real negative roots, and also imaginary roots.

Question: How can I make Mathematica give me only the real and positive roots of the solution?


Attemp: I tried using Assumptions but it seems to only work for assuming constants under derivatives. Also I tried with:

Refine[Solve[Det[f[x]]==0,x],x>0]

but it doesn't work either.

$\endgroup$
0

1 Answer 1

2
$\begingroup$

E.g.

f[x_] := {{2 + x, x^2}, {1 + x, x^3 - 2}}
Det[f[x]]

-4 - 2 x - x^2 + x^3 + x^4

All roots are

NSolve[Det[f[x]] == 0, x]

{{x -> -1.70528}, {x -> -0.422555 - 1.15516 I}, {x -> -0.422555 + 1.15516 I}, {x -> 1.55039}}

Real and positive:

NSolve[Det[f[x]] == 0 && x > 0, x]

{{x -> 1.55039}}

$\endgroup$
4
  • 1
    $\begingroup$ Solve[Det[f[x]] == 0 && x > 0, x] works as well, though it gives the answer as a root object. take N[ ] to find the numerical value. $\endgroup$
    – bill s
    Oct 18, 2016 at 14:24
  • $\begingroup$ Thank you, that worked for me. The other question I have is if I can do that but given some constat $a$ for example. How can Mathematica know that I am defining a positive real value? I tried using Refine[], but I don't know if I am applying it right because it doesn't seem to work for me. $\endgroup$
    – rsaavedra
    Oct 18, 2016 at 21:27
  • $\begingroup$ What I am trying to say is: given a solution {{x->a},{x->-a}}, discard the negative value of x. $\endgroup$
    – rsaavedra
    Oct 18, 2016 at 21:32
  • $\begingroup$ That is a different issue. See, e.g., here. $\endgroup$
    – corey979
    Oct 18, 2016 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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