Average Error: 36.1 → 6.1
Time: 29.5s
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 -9.117517880804678 \cdot 10^{+140}:\\
\;\;\;\;\frac{c}{b/2} \cdot \frac{-1}{2}\\
\mathbf{if}\;b/2 \le 3.131324707375834 \cdot 10^{-52}:\\
\;\;\;\;\frac{1}{\frac{\sqrt{b/2 \cdot b/2 - c \cdot a} + \left(-b/2\right)}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{\frac{b/2}{\frac{1}{2}}} - b/2 \cdot \frac{2}{a}\\
\end{array}\]
Derivation
- Split input into 3 regimes.
-
if b/2 < -9.117517880804678e+140
Initial program 61.4
\[\frac{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}{a}\]
Applied taylor 14.8
\[\leadsto \frac{\frac{-1}{2} \cdot \frac{c \cdot a}{b/2}}{a}\]
Taylor expanded around -inf 14.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 -9.117517880804678e+140 < b/2 < 3.131324707375834e-52
Initial program 25.6
\[\frac{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied flip-- 29.0
\[\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 17.2
\[\leadsto \frac{\frac{\color{blue}{a \cdot c}}{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}}{a}\]
- Using strategy
rm
Applied clear-num 17.3
\[\leadsto \color{blue}{\frac{1}{\frac{a}{\frac{a \cdot c}{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}}}}\]
Applied simplify 12.1
\[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{b/2 \cdot b/2 - c \cdot a} + \left(-b/2\right)}{c}}}\]
if 3.131324707375834e-52 < b/2
Initial program 37.4
\[\frac{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}{a}\]
Applied taylor 10.5
\[\leadsto \frac{\frac{1}{2} \cdot \frac{c \cdot a}{b/2} - 2 \cdot b/2}{a}\]
Taylor expanded around inf 10.5
\[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \frac{c \cdot a}{b/2} - 2 \cdot b/2}}{a}\]
Applied simplify 0.2
\[\leadsto \color{blue}{\frac{c}{\frac{b/2}{\frac{1}{2}}} - b/2 \cdot \frac{2}{a}}\]
- Recombined 3 regimes into one program.
- Removed slow pow expressions
Runtime
Please report a bug with the following info:
herbie --seed '#(2119936345 846178467 2549547724 1485677938 2992606190 2182940698)'
(FPCore (a b/2 c)
:name "NMSE problem 3.2.1, negative"
(/ (- (- b/2) (sqrt (- (sqr b/2) (* a c)))) a))