Average Error: 34.7 → 9.9
Time: 1.1m
Precision: 64
Ground Truth: 128
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;b/2 \le -3.2345120336434788 \cdot 10^{+106}:\\
\;\;\;\;-2 \cdot \frac{b/2}{a}\\
\mathbf{if}\;b/2 \le 1.135484290896535 \cdot 10^{-164}:\\
\;\;\;\;\frac{1}{\frac{a}{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}}\\
\mathbf{if}\;b/2 \le 4.966247580688122 \cdot 10^{+78}:\\
\;\;\;\;\frac{\frac{c \cdot a}{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(-b/2\right) + b/2\right) - \frac{c}{b/2} \cdot \left(a \cdot \frac{1}{2}\right)}{a}\\
\end{array}\]
Derivation
- Split input into 4 regimes.
-
if b/2 < -3.2345120336434788e+106
Initial program 48.1
\[\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 -3.2345120336434788e+106 < b/2 < 1.135484290896535e-164
Initial program 11.2
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied clear-num 11.3
\[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}}}\]
if 1.135484290896535e-164 < b/2 < 4.966247580688122e+78
Initial program 37.4
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied flip-+ 37.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 16.1
\[\leadsto \frac{\frac{\color{blue}{c \cdot a}}{\left(-b/2\right) - \sqrt{{b/2}^2 - a \cdot c}}}{a}\]
if 4.966247580688122e+78 < b/2
Initial program 58.6
\[\frac{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}{a}\]
- Using strategy
rm
Applied clear-num 58.6
\[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b/2\right) + \sqrt{{b/2}^2 - a \cdot c}}}}\]
Applied taylor 41.2
\[\leadsto \frac{1}{\frac{a}{\left(-b/2\right) + \left(b/2 - \frac{1}{2} \cdot \frac{c \cdot a}{b/2}\right)}}\]
Taylor expanded around inf 41.2
\[\leadsto \frac{1}{\frac{a}{\left(-b/2\right) + \color{blue}{\left(b/2 - \frac{1}{2} \cdot \frac{c \cdot a}{b/2}\right)}}}\]
Applied simplify 9.4
\[\leadsto \color{blue}{\frac{\left(\left(-b/2\right) + b/2\right) - \frac{c}{b/2} \cdot \left(a \cdot \frac{1}{2}\right)}{a}}\]
- Recombined 4 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(1159182669 2372458198 2796218637 1211671712 742930139 482703909)'
(FPCore (a b/2 c)
:name "NMSE problem 3.2.1, positive"
(/ (+ (- b/2) (sqrt (- (sqr b/2) (* a c)))) a))