# Solve scalar quadratic equation

I am implementing a Trust-Region method using Dogleg for the search direction defined as $\tau p^U$ for $0 \leq \tau \leq 1$ and $p^U + (\tau -1)(p^B-p^U)$ if $1 \leq \tau \leq 2$. To compute $\tau$ we have to solve the following equation:

$\| p^U + (\tau - 1)(p^B-p^U) \|^2 = \Delta ^2.$

I tried to expand it in order to arrive at an equation of the form $ax^2+bx+c=0$. I obtain:

$$(\tau -1)^2\|p^B-p^U\|^2 + 2(\tau -1)(p^U,p^B-p^U) + \|p^U\|^2 - \Delta ^2 = 0 .$$

I do not not if it is correct or not and how to proceed. Any suggestion?

• Seems fine, just go on. Apr 21 '17 at 20:13
• That seems right. If $p^U$ is inside the trust region and $p^B$ outside, you now need to determine the positive root of your quadratic in $\tau$. Remember the right way to compute roots of a quadratic in finite precision. Apr 24 '17 at 20:51