Average Error: 36.5 → 6.0
Time: 2.0m
Precision: 64
Internal precision: 2432
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;b/2 \le -1.751131060884064 \cdot 10^{+136}:\\
\;\;\;\;-2 \cdot \frac{b/2}{a}\\
\mathbf{if}\;b/2 \le 8.548826144111727 \cdot 10^{-60}:\\
\;\;\;\;\frac{1}{\frac{a}{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b/2 + \left(-b/2\right)}{a} - \frac{\frac{1}{2} \cdot c}{b/2}\\
\end{array}\]
Derivation
- Split input into 3 regimes.
-
if b/2 < -1.751131060884064e+136
Initial program 56.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}}\]
if -1.751131060884064e+136 < b/2 < 8.548826144111727e-60
Initial program 12.5
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied clear-num 12.7
\[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}}}\]
if 8.548826144111727e-60 < b/2
Initial program 58.5
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
Applied taylor 39.1
\[\leadsto \frac{\left(-b/2\right) + \left(b/2 - \frac{1}{2} \cdot \frac{c \cdot a}{b/2}\right)}{a}\]
Taylor expanded around inf 39.1
\[\leadsto \frac{\left(-b/2\right) + \color{blue}{\left(b/2 - \frac{1}{2} \cdot \frac{c \cdot a}{b/2}\right)}}{a}\]
Applied simplify 0
\[\leadsto \color{blue}{\frac{b/2 + \left(-b/2\right)}{a} - \frac{\frac{1}{2} \cdot c}{b/2}}\]
- Recombined 3 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie shell --seed '#(772101555 1905824529 294602591 2478279198 2123125427 4197813737)'
(FPCore (a b/2 c)
:name "quad2p (problem 3.2.1, positive)"
(/ (+ (- b/2) (sqrt (- (sqr b/2) (* a c)))) a))