Average Error: 34.8 → 7.1
Time: 40.8s
Precision: 64
Internal precision: 128
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;b/2 \le -4.319226994044875 \cdot 10^{+67}:\\
\;\;\;\;-2 \cdot \frac{b/2}{a}\\
\mathbf{if}\;b/2 \le 5.120204351893868 \cdot 10^{-209}:\\
\;\;\;\;\left(\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}\right) \cdot \frac{1}{a}\\
\mathbf{if}\;b/2 \le 3.982973803951657 \cdot 10^{+64}:\\
\;\;\;\;\frac{\frac{a \cdot c}{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b/2 + \left(-b/2\right)}{a} - \frac{1}{2} \cdot \frac{c}{b/2}\\
\end{array}\]
Derivation
- Split input into 4 regimes.
-
if b/2 < -4.319226994044875e+67
Initial program 43.3
\[\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 -4.319226994044875e+67 < b/2 < 5.120204351893868e-209
Initial program 11.1
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied div-inv 11.2
\[\leadsto \color{blue}{\left(\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}\right) \cdot \frac{1}{a}}\]
if 5.120204351893868e-209 < b/2 < 3.982973803951657e+64
Initial program 33.6
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied flip-+ 33.7
\[\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 16.7
\[\leadsto \frac{\frac{\color{blue}{a \cdot c}}{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}}{a}\]
if 3.982973803951657e+64 < b/2
Initial program 58.0
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
Applied taylor 40.8
\[\leadsto \frac{\left(-b/2\right) + \left(b/2 - \frac{1}{2} \cdot \frac{a \cdot c}{b/2}\right)}{a}\]
Taylor expanded around inf 40.8
\[\leadsto \frac{\left(-b/2\right) + \color{blue}{\left(b/2 - \frac{1}{2} \cdot \frac{a \cdot c}{b/2}\right)}}{a}\]
Applied simplify 0.0
\[\leadsto \color{blue}{\frac{b/2 + \left(-b/2\right)}{a} - \frac{1}{2} \cdot \frac{c}{b/2}}\]
- Recombined 4 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(2625926391 3503486618 912057187 398085515 3882332553 2259635200)'
(FPCore (a b/2 c)
:name "quad2p (problem 3.2.1, positive)"
(/ (+ (- b/2) (sqrt (- (sqr b/2) (* a c)))) a))