Average Error: 34.2 → 7.7
Time: 15.6s
Precision: 64
Internal precision: 2176
\[\frac{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}{a}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;b/2 \le -2.87424490884018 \cdot 10^{+81}:\\
\;\;\;\;\frac{c}{b/2} \cdot \frac{-1}{2}\\
\mathbf{if}\;b/2 \le -4.834287429638526 \cdot 10^{-103}:\\
\;\;\;\;\frac{\frac{c \cdot a}{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}}{a}\\
\mathbf{if}\;b/2 \le 2.3106113327966147 \cdot 10^{+121}:\\
\;\;\;\;\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 4 regimes.
-
if b/2 < -2.87424490884018e+81
Initial program 58.2
\[\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 -2.87424490884018e+81 < b/2 < -4.834287429638526e-103
Initial program 41.2
\[\frac{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied flip-- 41.3
\[\leadsto \frac{\color{blue}{\frac{\left(-b/2\right) \cdot \left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c} \cdot \sqrt{{b/2}^2 - a \cdot c}}{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}}}{a}\]
Applied simplify 15.0
\[\leadsto \frac{\frac{\color{blue}{c \cdot a}}{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}}{a}\]
if -4.834287429638526e-103 < b/2 < 2.3106113327966147e+121
Initial program 11.9
\[\frac{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied div-inv 12.1
\[\leadsto \color{blue}{\left(\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}\right) \cdot \frac{1}{a}}\]
if 2.3106113327966147e+121 < b/2
Initial program 52.2
\[\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 4 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie shell --seed '#(1067901057 3396600083 3715501224 3126139233 3908045574 1593683916)'
(FPCore (a b/2 c)
:name "quad2m (problem 3.2.1, negative)"
(/ (- (- b/2) (sqrt (- (sqr b/2) (* a c)))) a))