Average Error: 36.4 → 7.4
Time: 1.6m
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 -2.430754546208037 \cdot 10^{-37}:\\
\;\;\;\;\frac{c}{\frac{c \cdot \frac{1}{2}}{\frac{b/2}{a}} - \left(b/2 - \left(-b/2\right)\right)}\\
\mathbf{if}\;b/2 \le 3.474250069101817 \cdot 10^{+81}:\\
\;\;\;\;\left(\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}\right) \cdot \frac{1}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b/2}{a}\\
\end{array}\]
Derivation
- Split input into 3 regimes.
-
if b/2 < -2.430754546208037e-37
Initial program 58.1
\[\frac{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied flip-- 58.1
\[\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 33.0
\[\leadsto \frac{\frac{\color{blue}{a \cdot c}}{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}}{a}\]
Applied taylor 14.7
\[\leadsto \frac{\frac{a \cdot c}{\left(-b/2\right) + \left(\frac{1}{2} \cdot \frac{c \cdot a}{b/2} - b/2\right)}}{a}\]
Taylor expanded around -inf 14.7
\[\leadsto \frac{\frac{a \cdot c}{\left(-b/2\right) + \color{blue}{\left(\frac{1}{2} \cdot \frac{c \cdot a}{b/2} - b/2\right)}}}{a}\]
Applied simplify 3.1
\[\leadsto \color{blue}{\frac{c}{\frac{c \cdot \frac{1}{2}}{\frac{b/2}{a}} - \left(b/2 - \left(-b/2\right)\right)}}\]
if -2.430754546208037e-37 < b/2 < 3.474250069101817e+81
Initial program 14.1
\[\frac{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied div-inv 14.2
\[\leadsto \color{blue}{\left(\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}\right) \cdot \frac{1}{a}}\]
if 3.474250069101817e+81 < b/2
Initial program 43.4
\[\frac{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}{a}\]
Applied taylor 0
\[\leadsto -2 \cdot \frac{b/2}{a}\]
Taylor expanded around inf 0
\[\leadsto \color{blue}{-2 \cdot \frac{b/2}{a}}\]
- Recombined 3 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(1585070354 847197416 4271129918 774737073 2582064250 2130020083)'
(FPCore (a b/2 c)
:name "NMSE problem 3.2.1, negative"
(/ (- (- b/2) (sqrt (- (sqr b/2) (* a c)))) a))