Average Error: 36.8 → 6.4
Time: 14.2s
Precision: 64
Internal precision: 2944
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;b/2 \le -1.5852813649951211 \cdot 10^{+33}:\\
\;\;\;\;\frac{\frac{c}{b/2} \cdot \left(a \cdot \frac{1}{2}\right) - \left(b/2 - \left(-b/2\right)\right)}{a}\\
\mathbf{if}\;b/2 \le 5.3630996565742086 \cdot 10^{-235}:\\
\;\;\;\;\frac{1}{\frac{a}{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}}\\
\mathbf{if}\;b/2 \le 1.6164635363498484 \cdot 10^{-18}:\\
\;\;\;\;\frac{\frac{c \cdot a}{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b/2} \cdot \frac{-1}{2}\\
\end{array}\]
Derivation
- Split input into 4 regimes.
-
if b/2 < -1.5852813649951211e+33
Initial program 38.4
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied clear-num 38.5
\[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}}}\]
Applied taylor 10.4
\[\leadsto \frac{1}{\frac{a}{\left(-b/2\right) + \left(\frac{1}{2} \cdot \frac{c \cdot a}{b/2} - b/2\right)}}\]
Taylor expanded around -inf 10.4
\[\leadsto \frac{1}{\frac{a}{\left(-b/2\right) + \color{blue}{\left(\frac{1}{2} \cdot \frac{c \cdot a}{b/2} - b/2\right)}}}\]
Applied simplify 3.0
\[\leadsto \color{blue}{\frac{\frac{c}{b/2} \cdot \left(a \cdot \frac{1}{2}\right) - \left(b/2 - \left(-b/2\right)\right)}{a}}\]
if -1.5852813649951211e+33 < b/2 < 5.3630996565742086e-235
Initial program 11.3
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied clear-num 11.4
\[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}}}\]
if 5.3630996565742086e-235 < b/2 < 1.6164635363498484e-18
Initial program 26.8
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied flip-+ 27.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 19.2
\[\leadsto \frac{\frac{\color{blue}{c \cdot a}}{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}}{a}\]
if 1.6164635363498484e-18 < b/2
Initial program 57.9
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
Applied taylor 15.2
\[\leadsto \frac{\frac{-1}{2} \cdot \frac{c \cdot a}{b/2}}{a}\]
Taylor expanded around inf 15.2
\[\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}}\]
- Recombined 4 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie shell --seed '#(1064555532 179913862 452496668 2441903500 287849034 462453547)'
(FPCore (a b/2 c)
:name "quad2p (problem 3.2.1, positive)"
(/ (+ (- b/2) (sqrt (- (sqr b/2) (* a c)))) a))