Non-negative roots in Newton Raphson Method

I am trying to numerically find the roots of a multivariate function using Newton-Raphson method. The function is such that it does not admit negative values of one of the parameter, the function cannot be evaluate to real values at such points. As I run the algorithm the code runs into problem because whenever I get a negative value of the parameter as the root, from some initial guess, the model cannot be evaluated and hence the iteration cannot continue.

The model is the Weibull Distribution, $f(v)=(k/\lambda)(x/\lambda )^{(k-1)} (e^{(x/\lambda)})^{k}$. Here, $k$ & $\lambda$ are required to be greater than or equal to zero.

So my question is: As the algorithm for NewtonRaphson method runs, how do I stop the algorithm to avoid negative roots in successive iterations? I figured simply taking their modulus is probably not the right way to do it.

One possible way that I figured was to start with a another guess but that does not seem like a viable solution and it might possibly be time consuming.

• The simplest thing to do is, as you say, "if" you get a negative number in the iteration, stop it, choose a slightly different starting value, and restart the iteration. Yes that will be time consuming. But unless you have other information as to what the positive roots will be, no other way will work as well. – user247327 Jun 4 '17 at 12:10
• Replace $k$ and $λ$ with $e^a$ and $e^{-b}$, then the restriction to positive values is automatically satisfied without further restrictions on $a$ and $b$. – LutzL Jun 4 '17 at 12:28
• So if I understand this right, instead of looking for roots of $k$ and $\lambda$ which cannot be negative I replace them with $e^a$ and $e^-b$ and look for the values of $a$ and $b$ and convert them back to $k$ and $\lambda$. Am I correct @LutzL? – Shaz Jun 14 '17 at 17:08
• Also, why did you suggest that I take $\lambda$ equal to the negative exponential? – Shaz Jun 14 '17 at 18:01
• Yes. And to reduce the amount of divisions, as $λ$ appears mostly in denominators. But in the end it is meaningless, as long as the conversion back uses the same convention. – LutzL Jun 14 '17 at 18:29