Average Error: 33.6 → 8.1
Time: 19.2s
Precision: 64
Internal precision: 1920
\[\frac{\left(-b2\right) + \sqrt{b2 \cdot b2 - a \cdot c}}{a}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;b2 \le -1.48170602986717 \cdot 10^{+22}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b2} - 2 \cdot \frac{b2}{a}\\
\mathbf{if}\;b2 \le 3.5271429953440576 \cdot 10^{-270}:\\
\;\;\;\;\left(\left(-b2\right) + \sqrt{b2 \cdot b2 - a \cdot c}\right) \cdot \frac{1}{a}\\
\mathbf{if}\;b2 \le 5.573681450579778 \cdot 10^{+158}:\\
\;\;\;\;\frac{\frac{c \cdot a}{\left(-b2\right) - \sqrt{b2 \cdot b2 - a \cdot c}}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b2} \cdot \frac{-1}{2}\\
\end{array}\]
Derivation
- Split input into 4 regimes.
-
if b2 < -1.48170602986717e+22
Initial program 35.2
\[\frac{\left(-b2\right) + \sqrt{b2 \cdot b2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied div-inv 35.4
\[\leadsto \color{blue}{\left(\left(-b2\right) + \sqrt{b2 \cdot b2 - a \cdot c}\right) \cdot \frac{1}{a}}\]
Applied taylor 0.0
\[\leadsto \frac{1}{2} \cdot \frac{c}{b2} - 2 \cdot \frac{b2}{a}\]
Taylor expanded around -inf 0.0
\[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{c}{b2} - 2 \cdot \frac{b2}{a}}\]
if -1.48170602986717e+22 < b2 < 3.5271429953440576e-270
Initial program 10.9
\[\frac{\left(-b2\right) + \sqrt{b2 \cdot b2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied div-inv 11.0
\[\leadsto \color{blue}{\left(\left(-b2\right) + \sqrt{b2 \cdot b2 - a \cdot c}\right) \cdot \frac{1}{a}}\]
if 3.5271429953440576e-270 < b2 < 5.573681450579778e+158
Initial program 34.8
\[\frac{\left(-b2\right) + \sqrt{b2 \cdot b2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied flip-+ 34.9
\[\leadsto \frac{\color{blue}{\frac{{\left(-b2\right)}^2 - {\left(\sqrt{b2 \cdot b2 - a \cdot c}\right)}^2}{\left(-b2\right) - \sqrt{b2 \cdot b2 - a \cdot c}}}}{a}\]
Applied simplify 15.2
\[\leadsto \frac{\frac{\color{blue}{c \cdot a}}{\left(-b2\right) - \sqrt{b2 \cdot b2 - a \cdot c}}}{a}\]
if 5.573681450579778e+158 < b2
Initial program 62.9
\[\frac{\left(-b2\right) + \sqrt{b2 \cdot b2 - a \cdot c}}{a}\]
Applied taylor 14.2
\[\leadsto \frac{\frac{-1}{2} \cdot \frac{c \cdot a}{b2}}{a}\]
Taylor expanded around inf 14.2
\[\leadsto \frac{\color{blue}{\frac{-1}{2} \cdot \frac{c \cdot a}{b2}}}{a}\]
Applied simplify 0.0
\[\leadsto \color{blue}{\frac{c}{b2} \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 '#(3052192724 3812927732 3686175817 630908657 2373248591 511094450)'
(FPCore (a b2 c)
:name "NMSE problem 3.2.1, positive"
:pre (and (>= (* b2 b2) (* a c)) (!= a 0))
(/ (+ (- b2) (sqrt (- (* b2 b2) (* a c)))) a))