Average Error: 34.2 → 7.1
Time: 7.5s
Precision: binary64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \leq -8.575640252968764 \cdot 10^{+151}:\\ \;\;\;\;\frac{1}{\frac{a}{b} \cdot -1.5}\\ \mathbf{elif}\;b \leq -3.4742121233166865 \cdot 10^{-259}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c}}{a \cdot 3} - \frac{b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 1.474316731636549 \cdot 10^{+89}:\\ \;\;\;\;\frac{1}{\frac{-\left(b + \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c}\right)}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{a}{b} \cdot 1.5 - 2 \cdot \frac{b}{c}}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \leq -8.575640252968764 \cdot 10^{+151}:\\
\;\;\;\;\frac{1}{\frac{a}{b} \cdot -1.5}\\

\mathbf{elif}\;b \leq -3.4742121233166865 \cdot 10^{-259}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c}}{a \cdot 3} - \frac{b}{a \cdot 3}\\

\mathbf{elif}\;b \leq 1.474316731636549 \cdot 10^{+89}:\\
\;\;\;\;\frac{1}{\frac{-\left(b + \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c}\right)}{c}}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{a}{b} \cdot 1.5 - 2 \cdot \frac{b}{c}}\\

\end{array}
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(FPCore (a b c)
 :precision binary64
 (if (<= b -8.575640252968764e+151)
   (/ 1.0 (* (/ a b) -1.5))
   (if (<= b -3.4742121233166865e-259)
     (- (/ (sqrt (- (* b b) (* (* a 3.0) c))) (* a 3.0)) (/ b (* a 3.0)))
     (if (<= b 1.474316731636549e+89)
       (/ 1.0 (/ (- (+ b (sqrt (- (* b b) (* (* a 3.0) c))))) c))
       (/ 1.0 (- (* (/ a b) 1.5) (* 2.0 (/ b c))))))))
double code(double a, double b, double c) {
	return (-b + sqrt((b * b) - ((3.0 * a) * c))) / (3.0 * a);
}
double code(double a, double b, double c) {
	double tmp;
	if (b <= -8.575640252968764e+151) {
		tmp = 1.0 / ((a / b) * -1.5);
	} else if (b <= -3.4742121233166865e-259) {
		tmp = (sqrt((b * b) - ((a * 3.0) * c)) / (a * 3.0)) - (b / (a * 3.0));
	} else if (b <= 1.474316731636549e+89) {
		tmp = 1.0 / (-(b + sqrt((b * b) - ((a * 3.0) * c))) / c);
	} else {
		tmp = 1.0 / (((a / b) * 1.5) - (2.0 * (b / c)));
	}
	return tmp;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if b < -8.5756402529687641e151

    1. Initial program 63.1

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified63.1

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied flip--_binary64_108664.0

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b \cdot b}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}}}{3 \cdot a}\]
    5. Simplified62.7

      \[\leadsto \frac{\frac{\color{blue}{a \cdot \left(c \cdot -3\right)}}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}}{3 \cdot a}\]
    6. Simplified62.7

      \[\leadsto \frac{\frac{a \cdot \left(c \cdot -3\right)}{\color{blue}{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    7. Using strategy rm
    8. Applied clear-num_binary64_111062.7

      \[\leadsto \color{blue}{\frac{1}{\frac{3 \cdot a}{\frac{a \cdot \left(c \cdot -3\right)}{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}}\]
    9. Simplified62.5

      \[\leadsto \frac{1}{\color{blue}{\left(b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \frac{-1}{c}}}\]
    10. Taylor expanded around -inf 3.5

      \[\leadsto \frac{1}{\color{blue}{-1.5 \cdot \frac{a}{b}}}\]
    11. Simplified3.5

      \[\leadsto \frac{1}{\color{blue}{\frac{a}{b} \cdot -1.5}}\]

    if -8.5756402529687641e151 < b < -3.47421212331668654e-259

    1. Initial program 8.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified8.4

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied div-sub_binary64_11168.4

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} - \frac{b}{3 \cdot a}}\]

    if -3.47421212331668654e-259 < b < 1.474316731636549e89

    1. Initial program 30.5

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified30.5

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied flip--_binary64_108630.5

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b \cdot b}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}}}{3 \cdot a}\]
    5. Simplified16.7

      \[\leadsto \frac{\frac{\color{blue}{a \cdot \left(c \cdot -3\right)}}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}}{3 \cdot a}\]
    6. Simplified16.7

      \[\leadsto \frac{\frac{a \cdot \left(c \cdot -3\right)}{\color{blue}{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    7. Using strategy rm
    8. Applied clear-num_binary64_111016.8

      \[\leadsto \color{blue}{\frac{1}{\frac{3 \cdot a}{\frac{a \cdot \left(c \cdot -3\right)}{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}}\]
    9. Simplified9.7

      \[\leadsto \frac{1}{\color{blue}{\left(b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \frac{-1}{c}}}\]
    10. Using strategy rm
    11. Applied associate-*r/_binary64_10539.6

      \[\leadsto \frac{1}{\color{blue}{\frac{\left(b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot -1}{c}}}\]
    12. Simplified9.6

      \[\leadsto \frac{1}{\frac{\color{blue}{-\left(b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{c}}\]

    if 1.474316731636549e89 < b

    1. Initial program 58.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified58.4

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied flip--_binary64_108658.4

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b \cdot b}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}}}{3 \cdot a}\]
    5. Simplified30.9

      \[\leadsto \frac{\frac{\color{blue}{a \cdot \left(c \cdot -3\right)}}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}}{3 \cdot a}\]
    6. Simplified30.9

      \[\leadsto \frac{\frac{a \cdot \left(c \cdot -3\right)}{\color{blue}{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    7. Using strategy rm
    8. Applied clear-num_binary64_111031.0

      \[\leadsto \color{blue}{\frac{1}{\frac{3 \cdot a}{\frac{a \cdot \left(c \cdot -3\right)}{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}}\]
    9. Simplified28.8

      \[\leadsto \frac{1}{\color{blue}{\left(b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \frac{-1}{c}}}\]
    10. Taylor expanded around inf 3.8

      \[\leadsto \frac{1}{\color{blue}{1.5 \cdot \frac{a}{b} - 2 \cdot \frac{b}{c}}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification7.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -8.575640252968764 \cdot 10^{+151}:\\ \;\;\;\;\frac{1}{\frac{a}{b} \cdot -1.5}\\ \mathbf{elif}\;b \leq -3.4742121233166865 \cdot 10^{-259}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c}}{a \cdot 3} - \frac{b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 1.474316731636549 \cdot 10^{+89}:\\ \;\;\;\;\frac{1}{\frac{-\left(b + \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c}\right)}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{a}{b} \cdot 1.5 - 2 \cdot \frac{b}{c}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020292 
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))