Average Error: 36.3 → 6.1
Time: 32.7s
Precision: 64
Internal precision: 2944
\[\frac{\left(-b/2\right) + \sqrt{b/2 \cdot b/2 - a \cdot c}}{a}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;b/2 \le -1.83182834227653 \cdot 10^{+137}:\\
\;\;\;\;\frac{\frac{\frac{1}{2} \cdot c}{\frac{b/2}{a}} - \left(b/2 + b/2\right)}{a}\\
\mathbf{if}\;b/2 \le 1.9148583814984746 \cdot 10^{-58}:\\
\;\;\;\;\left(\left(-b/2\right) + \sqrt{b/2 \cdot b/2 - a \cdot c}\right) \cdot \frac{1}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b/2\right) + b/2}{a} - \frac{c}{b/2} \cdot \frac{1}{2}\\
\end{array}\]
Derivation
- Split input into 3 regimes.
-
if b/2 < -1.83182834227653e+137
Initial program 55.2
\[\frac{\left(-b/2\right) + \sqrt{b/2 \cdot b/2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied div-inv 55.2
\[\leadsto \color{blue}{\left(\left(-b/2\right) + \sqrt{b/2 \cdot b/2 - a \cdot c}\right) \cdot \frac{1}{a}}\]
Taylor expanded around -inf 14.0
\[\leadsto \color{blue}{\left(\frac{1}{2} \cdot \frac{c \cdot a}{b/2} - 2 \cdot b/2\right)} \cdot \frac{1}{a}\]
Applied simplify 1.7
\[\leadsto \color{blue}{\frac{\frac{\frac{1}{2} \cdot c}{\frac{b/2}{a}} - \left(b/2 + b/2\right)}{a}}\]
if -1.83182834227653e+137 < b/2 < 1.9148583814984746e-58
Initial program 12.4
\[\frac{\left(-b/2\right) + \sqrt{b/2 \cdot b/2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied div-inv 12.6
\[\leadsto \color{blue}{\left(\left(-b/2\right) + \sqrt{b/2 \cdot b/2 - a \cdot c}\right) \cdot \frac{1}{a}}\]
if 1.9148583814984746e-58 < b/2
Initial program 58.1
\[\frac{\left(-b/2\right) + \sqrt{b/2 \cdot b/2 - a \cdot c}}{a}\]
Taylor expanded around inf 39.3
\[\leadsto \frac{\left(-b/2\right) + \color{blue}{\left(b/2 - \frac{1}{2} \cdot \frac{c \cdot a}{b/2}\right)}}{a}\]
Applied simplify 0.0
\[\leadsto \color{blue}{\frac{\left(-b/2\right) + b/2}{a} - \frac{c}{b/2} \cdot \frac{1}{2}}\]
- Recombined 3 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie shell --seed '#(2329929097 3210370195 3111198779 2406363002 3511342718 2136436390)'
(FPCore (a b/2 c)
:name "quad2p (problem 3.2.1, positive)"
(/ (+ (- b/2) (sqrt (- (* b/2 b/2) (* a c)))) a))