Average Error: 35.4 → 6.6
Time: 30.9s
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 -2.8335922143007058 \cdot 10^{+135}:\\
\;\;\;\;-2 \cdot \frac{b/2}{a}\\
\mathbf{if}\;b/2 \le 6.629433900186177 \cdot 10^{-280}:\\
\;\;\;\;\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\\
\mathbf{if}\;b/2 \le 2.4971715086460685 \cdot 10^{-08}:\\
\;\;\;\;\frac{\frac{c}{1} \cdot \frac{a}{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{\left(\left(-b/2\right) - b/2\right) + \frac{\frac{1}{2} \cdot c}{\frac{b/2}{a}}}\\
\end{array}\]
Derivation
- Split input into 4 regimes.
-
if b/2 < -2.8335922143007058e+135
Initial program 54.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 -2.8335922143007058e+135 < b/2 < 6.629433900186177e-280
Initial program 9.0
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
if 6.629433900186177e-280 < b/2 < 2.4971715086460685e-08
Initial program 26.3
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied flip-+ 26.5
\[\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.8
\[\leadsto \frac{\frac{\color{blue}{c \cdot a}}{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}}{a}\]
- Using strategy
rm
Applied *-un-lft-identity 17.8
\[\leadsto \frac{\frac{c \cdot a}{\color{blue}{1 \cdot \left(\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}\right)}}}{a}\]
Applied times-frac 14.1
\[\leadsto \frac{\color{blue}{\frac{c}{1} \cdot \frac{a}{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}}}{a}\]
if 2.4971715086460685e-08 < b/2
Initial program 58.3
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied flip-+ 58.4
\[\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 32.4
\[\leadsto \frac{\frac{\color{blue}{c \cdot a}}{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}}{a}\]
Applied taylor 15.6
\[\leadsto \frac{\frac{c \cdot a}{\left(-b/2\right) - \left(b/2 - \frac{1}{2} \cdot \frac{c \cdot a}{b/2}\right)}}{a}\]
Taylor expanded around inf 15.6
\[\leadsto \frac{\frac{c \cdot a}{\left(-b/2\right) - \color{blue}{\left(b/2 - \frac{1}{2} \cdot \frac{c \cdot a}{b/2}\right)}}}{a}\]
Applied simplify 2.9
\[\leadsto \color{blue}{\frac{c}{\left(\left(-b/2\right) - b/2\right) + \frac{\frac{1}{2} \cdot c}{\frac{b/2}{a}}}}\]
- Recombined 4 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie shell --seed '#(644180380 3784176976 401987740 22459203 1940947670 3323606534)'
(FPCore (a b/2 c)
:name "quad2p (problem 3.2.1, positive)"
(/ (+ (- b/2) (sqrt (- (sqr b/2) (* a c)))) a))