2

I'm currently trying to solve a system of (3) nonlinear equations of (3) variables which are the baryonic density, the isospin asymmetry and and the density of a fluid with the Broyden's method (a quasi-Newton method) included in the GSL.

The problem is that I don't know how to avoid negative roots. I don't want them because it's obviously nonphysical. I guess I should use some conditions but I don't know which ones... I'm programming in C.

Could you help please?

Thanks in advance!

T. Auerrac
  • 33
  • 7
  • 2
    Would [scicomp.se] be a better home for this question? – Qmechanic Mar 30 '17 at 10:04
  • 5
    I'm voting to close this question as off-topic because it is about software design and not physics. [scicomp.se] or [so] might be better suited. – Kyle Kanos Mar 30 '17 at 10:10
  • That said, check out Boost's root finders, pretty sure they're all bounded/bracketed solvers (it also wouldn't surprise me that they reduce to bisection under that, but who knows). – Kyle Kanos Mar 30 '17 at 10:10
  • There are also other as-efficient root solvers available that surely can be bracketed easily (Brent's method & Ridders' method both come to mind). – Kyle Kanos Mar 30 '17 at 10:16
  • 1
    Kinsol, part of the Sundials solver suite (http://computation.llnl.gov/projects/sundials/kinsol), solves systems of nonlinear algebraic equations, allows you to specify inequality constraints on the variables, and is callable from C. – Bill Greene Mar 30 '17 at 16:20
  • If it's not too difficult, perhaps you could try a change of variables. For example, instead of solving for T, you could solve for ln(T). – nukeguy Mar 30 '17 at 21:12
  • 3
    @nukeguy I'm not sure a Log change of variable is well advised here, as it might lead to poor conditioning. A linear COV might make more sense, though the solution of Bill seems most direct. –  Mar 31 '17 at 14:42
  • @SpencerBryngelson Perhaps, yes, it depends very much on his problem of interest. But I feel that, if the equations represent something physical and his solution must be positive for a good physical, then changing the variables to something that prevents it from becoming negative should be okay. I wonder what the Jacobian of his nonlinear system near 0 looks like without a change of variables. – nukeguy Mar 31 '17 at 15:41
  • 1
    Maybe you should include the system of equations you're solving, for reference? – J. M. Apr 01 '17 at 09:13

1 Answers1

0

I finally solved my problem.

I still use the GSL but I changed the Broyden's method for the classical discrete Newton's method because I saw that Broyden's method "is not recommended for serious use" (source: https://www.gnu.org/software/gsl/manual/html_node/Algorithms-without-Derivatives.html#Algorithms-without-Derivatives).

I also programmed "mirrors" to avoid nonphysical values.

Thanks for the assistance.

T. Auerrac
  • 33
  • 7