Average Error: 37.2 → 6.1
Time: 11.0s
Precision: 64
Internal precision: 3200
\[\frac{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}{a}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;b/2 \le -3.570134797179894 \cdot 10^{-59}:\\
\;\;\;\;\frac{c}{b/2} \cdot \frac{-1}{2}\\
\mathbf{if}\;b/2 \le 2.0227608047655974 \cdot 10^{+110}:\\
\;\;\;\;\frac{1}{\frac{a}{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b/2} + \frac{\left(-b/2\right) - b/2}{a}\\
\end{array}\]
Derivation
- Split input into 3 regimes.
-
if b/2 < -3.570134797179894e-59
Initial program 58.7
\[\frac{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}{a}\]
Applied taylor 15.7
\[\leadsto \frac{\frac{-1}{2} \cdot \frac{c \cdot a}{b/2}}{a}\]
Taylor expanded around -inf 15.7
\[\leadsto \frac{\color{blue}{\frac{-1}{2} \cdot \frac{c \cdot a}{b/2}}}{a}\]
Applied simplify 0.0
\[\leadsto \color{blue}{\frac{c}{b/2} \cdot \frac{-1}{2}}\]
if -3.570134797179894e-59 < b/2 < 2.0227608047655974e+110
Initial program 13.6
\[\frac{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied clear-num 13.7
\[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}}}\]
if 2.0227608047655974e+110 < b/2
Initial program 48.9
\[\frac{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied clear-num 48.9
\[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}}}\]
Applied taylor 13.2
\[\leadsto \frac{1}{\frac{a}{\left(-b/2\right) - \left(b/2 - \frac{1}{2} \cdot \frac{c \cdot a}{b/2}\right)}}\]
Taylor expanded around inf 13.2
\[\leadsto \frac{1}{\frac{a}{\left(-b/2\right) - \color{blue}{\left(b/2 - \frac{1}{2} \cdot \frac{c \cdot a}{b/2}\right)}}}\]
Applied simplify 0.1
\[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{c}{b/2} + \frac{\left(-b/2\right) - b/2}{a}}\]
- Recombined 3 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie shell --seed '#(1067773715 2765207660 218871639 3688798924 2755544087 2054563380)'
(FPCore (a b/2 c)
:name "quad2m (problem 3.2.1, negative)"
(/ (- (- b/2) (sqrt (- (sqr b/2) (* a c)))) a))