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;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Alternatives

Alternative 1
Error34.1
Cost59840
\[\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
Error34.3
Cost46400
\[\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
Error34.0
Cost40640
\[\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
Error34.0
Cost40384
\[\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
Error34.0
Cost40384
\[\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
Error35.2
Cost40128
\[\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
Error40.3
Cost39232
\[\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
Error53.1
Cost33664
\[\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
Error40.9
Cost32704
\[\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
Error42.4
Cost27584
\[\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
Error34.7
Cost27328
\[\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
Error53.0
Cost27264
\[\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
Error47.8
Cost27072
\[\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
Error33.9
Cost26944
\[\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
Error33.9
Cost26944
\[\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
Error33.9
Cost26944
\[\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
Error34.4
Cost26816
\[\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
Error34.8
Cost26816
\[\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
Error34.0
Cost26688
\[\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
Error57.6
Cost20608
\[\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
Error48.9
Cost20160
\[\frac{1}{\sqrt{a}} \cdot \frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{\sqrt{a}}\]
Alternative 22
Error42.5
Cost20096
\[\frac{1}{\frac{a}{\sqrt[3]{{\left(\sqrt{b_2 \cdot b_2 - c \cdot a}\right)}^{3}} - b_2}}\]
Alternative 23
Error48.8
Cost20032
\[\frac{\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{\sqrt{a}}}{\sqrt{a}}\]
Alternative 24
Error42.5
Cost19968
\[\frac{\sqrt[3]{{\left(\sqrt{b_2 \cdot b_2 - c \cdot a}\right)}^{3}} - b_2}{a}\]
Alternative 25
Error49.9
Cost19968
\[\sqrt[3]{{\left(\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\right)}^{3}}\]
Alternative 26
Error51.9
Cost19968
\[\frac{\sqrt{\sqrt[3]{{\left(b_2 \cdot b_2 - c \cdot a\right)}^{3}}} - b_2}{a}\]
Alternative 27
Error61.6
Cost19904
\[\frac{\log \left(e^{\sqrt{b_2 \cdot b_2 - c \cdot a}}\right) - b_2}{a}\]
Alternative 28
Error48.9
Cost19904
\[e^{\log \left(\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\right)}\]
Alternative 29
Error36.8
Cost19904
\[\frac{e^{\log \left(\sqrt{b_2 \cdot b_2 - c \cdot a}\right)} - b_2}{a}\]
Alternative 30
Error35.7
Cost19904
\[\frac{e^{\log \left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right)}}{a}\]
Alternative 31
Error60.5
Cost19904
\[\frac{\log \left(e^{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}\right)}{a}\]
Alternative 32
Error40.2
Cost19776
\[\left(-0.5 \cdot \left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right)\right) \cdot \frac{\sqrt[3]{c}}{b_2}\]
Alternative 33
Error40.2
Cost19776
\[\frac{-0.5}{\sqrt[3]{b_2} \cdot \sqrt[3]{b_2}} \cdot \frac{c}{\sqrt[3]{b_2}}\]
Alternative 34
Error45.7
Cost14016
\[\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
Error49.6
Cost13504
\[\sqrt{-0.5 \cdot \frac{c}{b_2}} \cdot \sqrt{-0.5 \cdot \frac{c}{b_2}}\]
Alternative 36
Error50.3
Cost13184
\[\sqrt[3]{\frac{-0.125}{{\left(\frac{b_2}{c}\right)}^{3}}}\]
Alternative 37
Error50.2
Cost13120
\[e^{\log \left(-0.5 \cdot \frac{c}{b_2}\right)}\]
Alternative 38
Error43.6
Cost8000
\[\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
Error43.6
Cost8000
\[\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
Error43.6
Cost7872
\[\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
Error43.6
Cost7872
\[\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
Error49.6
Cost7808
\[\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
Error33.6
Cost7360
\[\frac{\frac{1}{a}}{\frac{1}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}\]
Alternative 44
Error33.8
Cost7232
\[\frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a} - \frac{b_2}{a}\]
Alternative 45
Error33.6
Cost7232
\[\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}\]
Alternative 46
Error33.6
Cost7232
\[\left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right) \cdot \frac{1}{a}\]
Alternative 47
Error33.5
Cost7104
\[\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\]
Alternative 48
Error44.2
Cost7040
\[\frac{1}{\frac{a}{\sqrt{-c \cdot a} - b_2}}\]
Alternative 49
Error43.5
Cost6912
\[\frac{1}{\frac{a}{\sqrt{-c \cdot a}}}\]
Alternative 50
Error44.2
Cost6912
\[\frac{\sqrt{-c \cdot a} - b_2}{a}\]
Alternative 51
Error43.5
Cost6784
\[\frac{\sqrt{-c \cdot a}}{a}\]
Alternative 52
Error56.4
Cost832
\[\frac{\left(b_2 - 0.5 \cdot \frac{c}{\frac{b_2}{a}}\right) - b_2}{a}\]
Alternative 53
Error45.8
Cost832
\[\frac{\left(0.5 \cdot \frac{c}{\frac{b_2}{a}} - b_2\right) - b_2}{a}\]
Alternative 54
Error45.7
Cost704
\[\frac{c}{b_2} \cdot 0.5 + -2 \cdot \frac{b_2}{a}\]
Alternative 55
Error45.5
Cost576
\[\frac{-0.5 \cdot \frac{c}{\frac{b_2}{a}}}{a}\]
Alternative 56
Error45.6
Cost512
\[\frac{1}{\frac{a}{\left(-b_2\right) - b_2}}\]
Alternative 57
Error45.6
Cost448
\[\frac{1}{\frac{a}{b_2 \cdot -2}}\]
Alternative 58
Error45.5
Cost384
\[\frac{\left(-b_2\right) - b_2}{a}\]
Alternative 59
Error39.8
Cost320
\[-0.5 \cdot \frac{c}{b_2}\]
Alternative 60
Error45.5
Cost320
\[\frac{b_2 \cdot -2}{a}\]
Alternative 61
Error56.3
Cost320
\[\frac{b_2 - b_2}{a}\]
Alternative 62
Error39.8
Cost320
\[\frac{-0.5 \cdot c}{b_2}\]
Alternative 63
Error61.6
Cost64
\[1\]
Alternative 64
Error56.3
Cost64
\[0\]
Alternative 65
Error61.6
Cost64
\[-1\]

Error

Derivation

  1. Split input into 3 regimes
  2. if b_2 < -3.4233892203106858e150

    1. Initial program 62.0

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified62.0

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around -inf 2.7

      \[\leadsto \frac{\color{blue}{-1 \cdot b_2} - b_2}{a}\]
    4. Simplified2.7

      \[\leadsto \frac{\color{blue}{\left(-b_2\right)} - b_2}{a}\]
    5. Simplified2.7

      \[\leadsto \color{blue}{\frac{\left(-b_2\right) - b_2}{a}}\]

    if -3.4233892203106858e150 < b_2 < 3.891425723699142e-38

    1. Initial program 12.7

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified12.7

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}}\]

    if 3.891425723699142e-38 < b_2

    1. Initial program 54.5

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified54.5

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around inf 7.7

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b_2}}\]
    4. Using strategy rm
    5. Applied associate-*r/_binary647.7

      \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b_2}}\]
    6. Simplified7.7

      \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b_2}}\]
  3. Recombined 3 regimes into one program.
  4. 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))