Average Error: 34.9 → 7.0
Time: 1.2m
Precision: 64
Ground Truth: 128
\[\frac{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}{a}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;b/2 \le -7.599846762415676 \cdot 10^{+61}:\\
\;\;\;\;\frac{c}{b/2} \cdot \frac{-1}{2}\\
\mathbf{if}\;b/2 \le -3.836119197736596 \cdot 10^{-106}:\\
\;\;\;\;\frac{\frac{c \cdot a}{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}}{a}\\
\mathbf{if}\;b/2 \le 4.966247580688122 \cdot 10^{+78}:\\
\;\;\;\;\frac{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b/2} + \frac{\left(-b/2\right) - b/2}{a}\\
\end{array}\]
Derivation
- Split input into 4 regimes.
-
if b/2 < -7.599846762415676e+61
Initial program 58.0
\[\frac{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}{a}\]
Applied taylor 15.8
\[\leadsto \frac{\frac{-1}{2} \cdot \frac{c \cdot a}{b/2}}{a}\]
Taylor expanded around -inf 15.8
\[\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 -7.599846762415676e+61 < b/2 < -3.836119197736596e-106
Initial program 40.5
\[\frac{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied flip-- 40.6
\[\leadsto \frac{\color{blue}{\frac{{\left(-b/2\right)}^2 - {\left(\sqrt{{b/2}^2 - a \cdot c}\right)}^2}{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}}}{a}\]
Applied simplify 16.4
\[\leadsto \frac{\frac{\color{blue}{c \cdot a}}{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}}{a}\]
if -3.836119197736596e-106 < b/2 < 4.966247580688122e+78
Initial program 12.0
\[\frac{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}{a}\]
if 4.966247580688122e+78 < b/2
Initial program 43.1
\[\frac{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied clear-num 43.2
\[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}}}\]
Applied taylor 10.9
\[\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 10.9
\[\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.0
\[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{c}{b/2} + \frac{\left(-b/2\right) - b/2}{a}}\]
- Recombined 4 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(3760836333 3113101096 1594397572 961627152 2528714756 2949901030)'
(FPCore (a b/2 c)
:name "NMSE problem 3.2.1, negative"
(/ (- (- b/2) (sqrt (- (sqr b/2) (* a c)))) a))