Average Error: 38.5 → 4.8
Time: 9.8s
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 -9.26777223902318 \cdot 10^{+150}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b/2} - \frac{b/2 + b/2}{a}\\
\mathbf{if}\;b/2 \le 3.8012790836766795 \cdot 10^{-128}:\\
\;\;\;\;\frac{1}{\frac{a}{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b/2} \cdot \frac{-1}{2}\\
\end{array}\]
Derivation
- Split input into 3 regimes.
-
if b/2 < -9.26777223902318e+150
Initial program 59.4
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied add-sqr-sqrt 59.4
\[\leadsto \frac{\color{blue}{{\left(\sqrt{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}\right)}^2}}{a}\]
Applied taylor 13.4
\[\leadsto \frac{{\left(\sqrt{\frac{1}{2} \cdot \frac{c \cdot a}{b/2} - 2 \cdot b/2}\right)}^2}{a}\]
Taylor expanded around -inf 13.4
\[\leadsto \frac{{\left(\sqrt{\color{blue}{\frac{1}{2} \cdot \frac{c \cdot a}{b/2} - 2 \cdot b/2}}\right)}^2}{a}\]
Applied simplify 0.0
\[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{c}{b/2} - \left(\frac{b/2}{a} + \frac{b/2}{a}\right)}\]
Applied simplify 0.1
\[\leadsto \frac{1}{2} \cdot \frac{c}{b/2} - \color{blue}{\frac{b/2 + b/2}{a}}\]
if -9.26777223902318e+150 < b/2 < 3.8012790836766795e-128
Initial program 11.0
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied clear-num 11.2
\[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}}}\]
if 3.8012790836766795e-128 < b/2
Initial program 58.9
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
Applied taylor 15.5
\[\leadsto \frac{\frac{-1}{2} \cdot \frac{c \cdot a}{b/2}}{a}\]
Taylor expanded around inf 15.5
\[\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 3 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie shell --seed '#(1067615470 1817955187 3564058462 2385304812 1026693554 2746013648)'
(FPCore (a b/2 c)
:name "quad2p (problem 3.2.1, positive)"
(/ (+ (- b/2) (sqrt (- (sqr b/2) (* a c)))) a))