# How to find a root at the diverging boundary?

**URL:** <https://discourse.julialang.org/t/how-to-find-a-root-at-the-diverging-boundary/79930>\
**Category:** Numerics\
**Created:** [April 24, 2022, 7:15am UTC](https://discourse.julialang.org/t/how-to-find-a-root-at-the-diverging-boundary/79930 "2022-04-24T07:15:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Post date:** [April 24, 2022, 7:15am UTC](https://discourse.julialang.org/t/how-to-find-a-root-at-the-diverging-boundary/79930/1 "2022-04-24T07:15:43Z")

</div>

Say if I have a function f(x; \lambda) which is continuous and smooth where x \in (0, \infty) for any 0\<\lambda \< \lambda^\*. For each \lambda, there is a single minimum at the same location x^\*, f(x^\*; \lambda). f(x^\*; \lambda) is a decreasing function with respect to \lambda, and f(x^\*; \lambda^\*) = 0.

I know, for any \lambda \< \lambda^\*, it should be easy to find the minimum using `Optim.Brent`. However, it seems impossible to use `Roots.find_zero` to locate \lambda^\*, since if Roots propose a \lambda \> \lambda^\*, f(x; \lambda^\*) is diverging.

I am not trained in numerics. Does anyone know such problem and have some idea?

---

<div class="post-metadata">

**Author:** ![j\_verzani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j_verzani/32/8551_2.png) [@j\_verzani](https://discourse.julialang.org/u/j_verzani)\
**Post date:** [April 24, 2022, 11:08am UTC](https://discourse.julialang.org/t/how-to-find-a-root-at-the-diverging-boundary/79930/2 "2022-04-24T11:08:58Z")

</div>

Do you have a bracketing interval? If so use that and this can’t happen. Otherwise, you may need a better initial guess. (The first step is a secant step in the default algorithm, and this may be an issue if your function is flat near the guess.)

---

<div class="post-metadata">

**Author:** ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Post date:** [April 24, 2022, 1:23pm UTC](https://discourse.julialang.org/t/how-to-find-a-root-at-the-diverging-boundary/79930/3 "2022-04-24T13:23:56Z")

</div>

Note that the target solution \lambda^\* is itself on the boundary. Therefore, there will no bracketing interval available.

---

<div class="post-metadata">

**Author:** ![josuagrw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josuagrw/32/1015_2.png) [@josuagrw](https://discourse.julialang.org/u/josuagrw)\
**Post date:** [April 25, 2022, 7:29am UTC](https://discourse.julialang.org/t/how-to-find-a-root-at-the-diverging-boundary/79930/4 "2022-04-25T07:29:25Z")

</div>

Could you look at the inverse of f? Because 1/f should go to zero at \lambda^\ast, correct? Finding the smallest \lambda with 1/f=0 might be easier numerically…

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [April 25, 2022, 8:58am UTC](https://discourse.julialang.org/t/how-to-find-a-root-at-the-diverging-boundary/79930/5 "2022-04-25T08:58:34Z")

</div>

The hypothesis are not that easy to understand. But basically, g(\lambda) := f(x^\*,\lambda) is a decreasing function of \lambda, and you look for a zero of g. Now, you have g(\lambda^\*) = 0 and g(\lambda^\*+0)=\infty? 🤔

---

<div class="post-metadata">

**Author:** ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Post date:** [April 25, 2022, 9:27am UTC](https://discourse.julialang.org/t/how-to-find-a-root-at-the-diverging-boundary/79930/6 "2022-04-25T09:27:34Z")

</div>

Exactly. Is it equivalent to finding the diverging point of g(\lambda)? One way I think of is starting from a small enough \lambda, then gradually increasing \lambda with proper step size and checking whether g(\lambda) is diverging?

---

<div class="post-metadata">

**Author:** ![josuagrw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josuagrw/32/1015_2.png) [@josuagrw](https://discourse.julialang.org/u/josuagrw)\
**Post date:** [April 25, 2022, 9:51am UTC](https://discourse.julialang.org/t/how-to-find-a-root-at-the-diverging-boundary/79930/7 "2022-04-25T09:51:10Z")

</div>

You could attempt to locate the discontinuity with interval arithmetic. Essentially apply g to nested intervals and check if the upper bound of the image is infinite or finite.

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [April 25, 2022, 9:55am UTC](https://discourse.julialang.org/t/how-to-find-a-root-at-the-diverging-boundary/79930/8 "2022-04-25T09:55:56Z")

</div>

I you know that g is convex, I’d say Newton iterations will be smaller than lambda\*
