Average Error: 33.6 → 8.0
Time: 11.8s
Precision: 64
Internal precision: 2688
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;b/2 \le -1.6573860688298954 \cdot 10^{+150}:\\
\;\;\;\;-2 \cdot \frac{b/2}{a}\\
\mathbf{if}\;b/2 \le 1.828821921218125 \cdot 10^{-208}:\\
\;\;\;\;\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\\
\mathbf{if}\;b/2 \le 7.666985785588564 \cdot 10^{+91}:\\
\;\;\;\;\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.6573860688298954e+150
Initial program 59.7
\[\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.6573860688298954e+150 < b/2 < 1.828821921218125e-208
Initial program 9.7
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
if 1.828821921218125e-208 < b/2 < 7.666985785588564e+91
Initial program 36.0
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied flip-+ 36.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 17.0
\[\leadsto \frac{\frac{\color{blue}{c \cdot a}}{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}}{a}\]
if 7.666985785588564e+91 < b/2
Initial program 59.0
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
Applied taylor 15.7
\[\leadsto \frac{\frac{-1}{2} \cdot \frac{c \cdot a}{b/2}}{a}\]
Taylor expanded around inf 15.7
\[\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 '#(1066372953 114334025 411438303 1288252006 2962405338 2829794477)'
(FPCore (a b/2 c)
:name "quad2p (problem 3.2.1, positive)"
(/ (+ (- b/2) (sqrt (- (sqr b/2) (* a c)))) a))