Average Error: 33.5 → 9.8
Time: 16.9s
Precision: binary64
Cost: 7746
\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
↓
\[\begin{array}{l}
\mathbf{if}\;b_2 \leq -3.423389220310686 \cdot 10^{+150}:\\
\;\;\;\;\frac{\left(-b_2\right) - b_2}{a}\\
\mathbf{elif}\;b_2 \leq 3.891425723699142 \cdot 10^{-38}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}\]
\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}↓
\begin{array}{l}
\mathbf{if}\;b_2 \leq -3.423389220310686 \cdot 10^{+150}:\\
\;\;\;\;\frac{\left(-b_2\right) - b_2}{a}\\
\mathbf{elif}\;b_2 \leq 3.891425723699142 \cdot 10^{-38}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}(FPCore (a b_2 c)
:precision binary64
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
↓
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -3.423389220310686e+150)
(/ (- (- b_2) b_2) a)
(if (<= b_2 3.891425723699142e-38)
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
(/ (* c -0.5) b_2))))double code(double a, double b_2, double c) {
return (-b_2 + sqrt((b_2 * b_2) - (a * c))) / a;
}
↓
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.423389220310686e+150) {
tmp = (-b_2 - b_2) / a;
} else if (b_2 <= 3.891425723699142e-38) {
tmp = (sqrt((b_2 * b_2) - (a * c)) - b_2) / a;
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
Try it out
Enter valid numbers for all inputs
Alternatives
| Alternative 1 |
|---|
| Error | 34.1 |
|---|
| Cost | 59840 |
|---|
\[\frac{\sqrt[3]{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2} \cdot \sqrt[3]{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{\sqrt[3]{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}{\sqrt[3]{a}}\]
| Alternative 2 |
|---|
| Error | 34.3 |
|---|
| Cost | 46400 |
|---|
\[\frac{\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}{\sqrt[3]{a}}\]
| Alternative 3 |
|---|
| Error | 34.0 |
|---|
| Cost | 40640 |
|---|
\[\sqrt[3]{\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}} \cdot \left(\sqrt[3]{\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}} \cdot \sqrt[3]{\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}}\right)\]
| Alternative 4 |
|---|
| Error | 34.0 |
|---|
| Cost | 40384 |
|---|
\[\left(\sqrt[3]{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2} \cdot \sqrt[3]{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}\right) \cdot \frac{\sqrt[3]{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}{a}\]
| Alternative 5 |
|---|
| Error | 34.0 |
|---|
| Cost | 40384 |
|---|
\[\frac{\sqrt[3]{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2} \cdot \left(\sqrt[3]{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2} \cdot \sqrt[3]{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}\right)}{a}\]
| Alternative 6 |
|---|
| Error | 35.2 |
|---|
| Cost | 40128 |
|---|
\[\frac{\sqrt[3]{\sqrt{b_2 \cdot b_2 - c \cdot a}} \cdot \left(\sqrt[3]{\sqrt{b_2 \cdot b_2 - c \cdot a}} \cdot \sqrt[3]{\sqrt{b_2 \cdot b_2 - c \cdot a}}\right) - b_2}{a}\]
| Alternative 7 |
|---|
| Error | 40.3 |
|---|
| Cost | 39232 |
|---|
\[\left(-0.5 \cdot \frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{b_2} \cdot \sqrt[3]{b_2}}\right) \cdot \frac{\sqrt[3]{c}}{\sqrt[3]{b_2}}\]
| Alternative 8 |
|---|
| Error | 53.1 |
|---|
| Cost | 33664 |
|---|
\[\frac{\frac{\sqrt{{b_2}^{6} - {\left(c \cdot a\right)}^{3}}}{\sqrt{{b_2}^{4} + a \cdot \left(c \cdot \left(b_2 \cdot b_2 + c \cdot a\right)\right)}} - b_2}{a}\]
| Alternative 9 |
|---|
| Error | 40.9 |
|---|
| Cost | 32704 |
|---|
\[\left(-0.5 \cdot \frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt{b_2}}\right) \cdot \frac{\sqrt[3]{c}}{\sqrt{b_2}}\]
| Alternative 10 |
|---|
| Error | 42.4 |
|---|
| Cost | 27584 |
|---|
\[\frac{\frac{{\left(\sqrt{b_2 \cdot b_2 - c \cdot a}\right)}^{3} - {b_2}^{3}}{b_2 \cdot \left(b_2 + \left(b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}\right)\right) - c \cdot a}}{a}\]
| Alternative 11 |
|---|
| Error | 34.7 |
|---|
| Cost | 27328 |
|---|
\[\frac{\sqrt{\sqrt[3]{b_2 \cdot b_2 - c \cdot a} \cdot \left(\sqrt[3]{b_2 \cdot b_2 - c \cdot a} \cdot \sqrt[3]{b_2 \cdot b_2 - c \cdot a}\right)} - b_2}{a}\]
| Alternative 12 |
|---|
| Error | 53.0 |
|---|
| Cost | 27264 |
|---|
\[\frac{\sqrt{\frac{{b_2}^{6} - {\left(c \cdot a\right)}^{3}}{{b_2}^{4} + a \cdot \left(c \cdot \left(b_2 \cdot b_2 + c \cdot a\right)\right)}} - b_2}{a}\]
| Alternative 13 |
|---|
| Error | 47.8 |
|---|
| Cost | 27072 |
|---|
\[\sqrt{\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}} \cdot \sqrt{\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}}\]
| Alternative 14 |
|---|
| Error | 33.9 |
|---|
| Cost | 26944 |
|---|
\[\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2} \cdot \frac{\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}{a}\]
| Alternative 15 |
|---|
| Error | 33.9 |
|---|
| Cost | 26944 |
|---|
\[\frac{\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}{a}\]
| Alternative 16 |
|---|
| Error | 33.9 |
|---|
| Cost | 26944 |
|---|
\[\frac{\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}{\frac{a}{\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}}\]
| Alternative 17 |
|---|
| Error | 34.4 |
|---|
| Cost | 26816 |
|---|
\[\frac{\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}} - b_2}{a}\]
| Alternative 18 |
|---|
| Error | 34.8 |
|---|
| Cost | 26816 |
|---|
\[\frac{\left|\sqrt[3]{b_2 \cdot b_2 - c \cdot a}\right| \cdot \sqrt{\sqrt[3]{b_2 \cdot b_2 - c \cdot a}} - b_2}{a}\]
| Alternative 19 |
|---|
| Error | 34.0 |
|---|
| Cost | 26688 |
|---|
\[\frac{1}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{\sqrt[3]{a}}\]
| Alternative 20 |
|---|
| Error | 57.6 |
|---|
| Cost | 20608 |
|---|
\[\frac{\frac{\sqrt{{b_2}^{4} - \left(c \cdot a\right) \cdot \left(c \cdot a\right)}}{\sqrt{b_2 \cdot b_2 + c \cdot a}} - b_2}{a}\]
| Alternative 21 |
|---|
| Error | 48.9 |
|---|
| Cost | 20160 |
|---|
\[\frac{1}{\sqrt{a}} \cdot \frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{\sqrt{a}}\]
| Alternative 22 |
|---|
| Error | 42.5 |
|---|
| Cost | 20096 |
|---|
\[\frac{1}{\frac{a}{\sqrt[3]{{\left(\sqrt{b_2 \cdot b_2 - c \cdot a}\right)}^{3}} - b_2}}\]
| Alternative 23 |
|---|
| Error | 48.8 |
|---|
| Cost | 20032 |
|---|
\[\frac{\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{\sqrt{a}}}{\sqrt{a}}\]
| Alternative 24 |
|---|
| Error | 42.5 |
|---|
| Cost | 19968 |
|---|
\[\frac{\sqrt[3]{{\left(\sqrt{b_2 \cdot b_2 - c \cdot a}\right)}^{3}} - b_2}{a}\]
| Alternative 25 |
|---|
| Error | 49.9 |
|---|
| Cost | 19968 |
|---|
\[\sqrt[3]{{\left(\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\right)}^{3}}\]
| Alternative 26 |
|---|
| Error | 51.9 |
|---|
| Cost | 19968 |
|---|
\[\frac{\sqrt{\sqrt[3]{{\left(b_2 \cdot b_2 - c \cdot a\right)}^{3}}} - b_2}{a}\]
| Alternative 27 |
|---|
| Error | 61.6 |
|---|
| Cost | 19904 |
|---|
\[\frac{\log \left(e^{\sqrt{b_2 \cdot b_2 - c \cdot a}}\right) - b_2}{a}\]
| Alternative 28 |
|---|
| Error | 48.9 |
|---|
| Cost | 19904 |
|---|
\[e^{\log \left(\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\right)}\]
| Alternative 29 |
|---|
| Error | 36.8 |
|---|
| Cost | 19904 |
|---|
\[\frac{e^{\log \left(\sqrt{b_2 \cdot b_2 - c \cdot a}\right)} - b_2}{a}\]
| Alternative 30 |
|---|
| Error | 35.7 |
|---|
| Cost | 19904 |
|---|
\[\frac{e^{\log \left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right)}}{a}\]
| Alternative 31 |
|---|
| Error | 60.5 |
|---|
| Cost | 19904 |
|---|
\[\frac{\log \left(e^{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}\right)}{a}\]
| Alternative 32 |
|---|
| Error | 40.2 |
|---|
| Cost | 19776 |
|---|
\[\left(-0.5 \cdot \left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right)\right) \cdot \frac{\sqrt[3]{c}}{b_2}\]
| Alternative 33 |
|---|
| Error | 40.2 |
|---|
| Cost | 19776 |
|---|
\[\frac{-0.5}{\sqrt[3]{b_2} \cdot \sqrt[3]{b_2}} \cdot \frac{c}{\sqrt[3]{b_2}}\]
| Alternative 34 |
|---|
| Error | 45.7 |
|---|
| Cost | 14016 |
|---|
\[\frac{\left(\sqrt{-c \cdot a} + 0.5 \cdot \frac{b_2 \cdot b_2}{\sqrt{-c \cdot a}}\right) - b_2}{a}\]
| Alternative 35 |
|---|
| Error | 49.6 |
|---|
| Cost | 13504 |
|---|
\[\sqrt{-0.5 \cdot \frac{c}{b_2}} \cdot \sqrt{-0.5 \cdot \frac{c}{b_2}}\]
| Alternative 36 |
|---|
| Error | 50.3 |
|---|
| Cost | 13184 |
|---|
\[\sqrt[3]{\frac{-0.125}{{\left(\frac{b_2}{c}\right)}^{3}}}\]
| Alternative 37 |
|---|
| Error | 50.2 |
|---|
| Cost | 13120 |
|---|
\[e^{\log \left(-0.5 \cdot \frac{c}{b_2}\right)}\]
| Alternative 38 |
|---|
| Error | 43.6 |
|---|
| Cost | 8000 |
|---|
\[\frac{1}{\frac{a}{\frac{b_2 \cdot b_2 - \left(b_2 \cdot b_2 + c \cdot a\right)}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}}}\]
| Alternative 39 |
|---|
| Error | 43.6 |
|---|
| Cost | 8000 |
|---|
\[\frac{b_2 \cdot b_2 - \left(b_2 \cdot b_2 + c \cdot a\right)}{a} \cdot \frac{1}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}\]
| Alternative 40 |
|---|
| Error | 43.6 |
|---|
| Cost | 7872 |
|---|
\[\frac{\frac{b_2 \cdot b_2 - \left(b_2 \cdot b_2 + c \cdot a\right)}{a}}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}\]
| Alternative 41 |
|---|
| Error | 43.6 |
|---|
| Cost | 7872 |
|---|
\[\frac{\frac{b_2 \cdot b_2 - \left(b_2 \cdot b_2 + c \cdot a\right)}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}}{a}\]
| Alternative 42 |
|---|
| Error | 49.6 |
|---|
| Cost | 7808 |
|---|
\[\frac{-0.5 \cdot \frac{c}{\frac{b_2}{a}} - 0.125 \cdot \frac{\left(c \cdot a\right) \cdot \left(c \cdot a\right)}{{b_2}^{3}}}{a}\]
| Alternative 43 |
|---|
| Error | 33.6 |
|---|
| Cost | 7360 |
|---|
\[\frac{\frac{1}{a}}{\frac{1}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}\]
| Alternative 44 |
|---|
| Error | 33.8 |
|---|
| Cost | 7232 |
|---|
\[\frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a} - \frac{b_2}{a}\]
| Alternative 45 |
|---|
| Error | 33.6 |
|---|
| Cost | 7232 |
|---|
\[\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}\]
| Alternative 46 |
|---|
| Error | 33.6 |
|---|
| Cost | 7232 |
|---|
\[\left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right) \cdot \frac{1}{a}\]
| Alternative 47 |
|---|
| Error | 33.5 |
|---|
| Cost | 7104 |
|---|
\[\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\]
| Alternative 48 |
|---|
| Error | 44.2 |
|---|
| Cost | 7040 |
|---|
\[\frac{1}{\frac{a}{\sqrt{-c \cdot a} - b_2}}\]
| Alternative 49 |
|---|
| Error | 43.5 |
|---|
| Cost | 6912 |
|---|
\[\frac{1}{\frac{a}{\sqrt{-c \cdot a}}}\]
| Alternative 50 |
|---|
| Error | 44.2 |
|---|
| Cost | 6912 |
|---|
\[\frac{\sqrt{-c \cdot a} - b_2}{a}\]
| Alternative 51 |
|---|
| Error | 43.5 |
|---|
| Cost | 6784 |
|---|
\[\frac{\sqrt{-c \cdot a}}{a}\]
| Alternative 52 |
|---|
| Error | 56.4 |
|---|
| Cost | 832 |
|---|
\[\frac{\left(b_2 - 0.5 \cdot \frac{c}{\frac{b_2}{a}}\right) - b_2}{a}\]
| Alternative 53 |
|---|
| Error | 45.8 |
|---|
| Cost | 832 |
|---|
\[\frac{\left(0.5 \cdot \frac{c}{\frac{b_2}{a}} - b_2\right) - b_2}{a}\]
| Alternative 54 |
|---|
| Error | 45.7 |
|---|
| Cost | 704 |
|---|
\[\frac{c}{b_2} \cdot 0.5 + -2 \cdot \frac{b_2}{a}\]
| Alternative 55 |
|---|
| Error | 45.5 |
|---|
| Cost | 576 |
|---|
\[\frac{-0.5 \cdot \frac{c}{\frac{b_2}{a}}}{a}\]
| Alternative 56 |
|---|
| Error | 45.6 |
|---|
| Cost | 512 |
|---|
\[\frac{1}{\frac{a}{\left(-b_2\right) - b_2}}\]
| Alternative 57 |
|---|
| Error | 45.6 |
|---|
| Cost | 448 |
|---|
\[\frac{1}{\frac{a}{b_2 \cdot -2}}\]
| Alternative 58 |
|---|
| Error | 45.5 |
|---|
| Cost | 384 |
|---|
\[\frac{\left(-b_2\right) - b_2}{a}\]
| Alternative 59 |
|---|
| Error | 39.8 |
|---|
| Cost | 320 |
|---|
\[-0.5 \cdot \frac{c}{b_2}\]
| Alternative 60 |
|---|
| Error | 45.5 |
|---|
| Cost | 320 |
|---|
\[\frac{b_2 \cdot -2}{a}\]
| Alternative 61 |
|---|
| Error | 56.3 |
|---|
| Cost | 320 |
|---|
\[\frac{b_2 - b_2}{a}\]
| Alternative 62 |
|---|
| Error | 39.8 |
|---|
| Cost | 320 |
|---|
\[\frac{-0.5 \cdot c}{b_2}\]
| Alternative 63 |
|---|
| Error | 61.6 |
|---|
| Cost | 64 |
|---|
\[1\]
| Alternative 64 |
|---|
| Error | 56.3 |
|---|
| Cost | 64 |
|---|
\[0\]
| Alternative 65 |
|---|
| Error | 61.6 |
|---|
| Cost | 64 |
|---|
\[-1\]
Error

Derivation
- Split input into 3 regimes
if b_2 < -3.4233892203106858e150
Initial program 62.0
\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
Simplified62.0
\[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
Taylor expanded around -inf 2.7
\[\leadsto \frac{\color{blue}{-1 \cdot b_2} - b_2}{a}\]
Simplified2.7
\[\leadsto \frac{\color{blue}{\left(-b_2\right)} - b_2}{a}\]
Simplified2.7
\[\leadsto \color{blue}{\frac{\left(-b_2\right) - b_2}{a}}\]
if -3.4233892203106858e150 < b_2 < 3.891425723699142e-38
Initial program 12.7
\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
Simplified12.7
\[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}}\]
if 3.891425723699142e-38 < b_2
Initial program 54.5
\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
Simplified54.5
\[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
Taylor expanded around inf 7.7
\[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}}\]
- Using strategy
rm Applied associate-*r/_binary647.7
\[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b_2}}\]
Simplified7.7
\[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b_2}}\]
- Recombined 3 regimes into one program.
Final simplification9.8
\[\leadsto \begin{array}{l}
\mathbf{if}\;b_2 \leq -3.423389220310686 \cdot 10^{+150}:\\
\;\;\;\;\frac{\left(-b_2\right) - b_2}{a}\\
\mathbf{elif}\;b_2 \leq 3.891425723699142 \cdot 10^{-38}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}\]
Reproduce
herbie shell --seed 2021042
(FPCore (a b_2 c)
:name "quad2p (problem 3.2.1, positive)"
:precision binary64
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))