Average Error: 34.4 → 20.5
Time: 11.1s
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 -1.360963170256676 \cdot 10^{+154}:\\ \;\;\;\;\frac{\frac{-b}{3}}{a}\\ \mathbf{elif}\;b \leq 8.442885290902578 \cdot 10^{-123}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{3 \cdot a}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{\frac{c}{-3 \cdot \left(b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{\sqrt[3]{a}}\\ \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 -1.360963170256676 \cdot 10^{+154}:\\
\;\;\;\;\frac{\frac{-b}{3}}{a}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{3 \cdot a}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{\frac{c}{-3 \cdot \left(b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{\sqrt[3]{a}}\\

\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 -1.360963170256676e+154)
   (/ (/ (- b) 3.0) a)
   (if (<= b 8.442885290902578e-123)
     (* 0.3333333333333333 (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) a))
     (*
      (/ (* 3.0 a) (* (cbrt a) (cbrt a)))
      (/ (/ c (* -3.0 (+ b (sqrt (- (* b b) (* (* 3.0 a) c)))))) (cbrt a))))))
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 <= -1.360963170256676e+154) {
		tmp = (-b / 3.0) / a;
	} else if (b <= 8.442885290902578e-123) {
		tmp = 0.3333333333333333 * ((sqrt((b * b) - ((3.0 * a) * c)) - b) / a);
	} else {
		tmp = ((3.0 * a) / (cbrt(a) * cbrt(a))) * ((c / (-3.0 * (b + sqrt((b * b) - ((3.0 * a) * c))))) / cbrt(a));
	}
	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 3 regimes
  2. if b < -1.3609631702566761e154

    1. Initial program 64.0

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

      \[\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 associate-/r*_binary6464.0

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

      \[\leadsto \frac{\frac{\color{blue}{0} - b}{3}}{a}\]

    if -1.3609631702566761e154 < b < 8.4428852909025777e-123

    1. Initial program 11.2

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

      \[\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 *-un-lft-identity_binary6411.2

      \[\leadsto \frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - \color{blue}{1 \cdot b}}{3 \cdot a}\]
    5. Applied *-un-lft-identity_binary6411.2

      \[\leadsto \frac{\color{blue}{1 \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}} - 1 \cdot b}{3 \cdot a}\]
    6. Applied distribute-lft-out--_binary6411.2

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b\right)}}{3 \cdot a}\]
    7. Applied times-frac_binary6411.3

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

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

    if 8.4428852909025777e-123 < b

    1. Initial program 51.8

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

      \[\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 associate-/r*_binary6451.8

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

      \[\leadsto \frac{\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}}{a}\]
    7. Simplified24.7

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

      \[\leadsto \frac{\frac{\frac{\left(a \cdot c\right) \cdot -3}{\color{blue}{b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3}}{a}\]
    9. Using strategy rm
    10. Applied frac-2neg_binary6424.7

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

      \[\leadsto \frac{\frac{\frac{\color{blue}{\left(3 \cdot a\right) \cdot c}}{-\left(b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{3}}{a}\]
    12. Using strategy rm
    13. Applied add-cube-cbrt_binary6425.1

      \[\leadsto \frac{\frac{\frac{\left(3 \cdot a\right) \cdot c}{-\left(b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{3}}{\color{blue}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}}\]
    14. Applied *-un-lft-identity_binary6425.1

      \[\leadsto \frac{\frac{\frac{\left(3 \cdot a\right) \cdot c}{-\left(b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{\color{blue}{1 \cdot 3}}}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}\]
    15. Applied *-un-lft-identity_binary6425.1

      \[\leadsto \frac{\frac{\frac{\left(3 \cdot a\right) \cdot c}{-\left(b + \color{blue}{1 \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}\right)}}{1 \cdot 3}}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}\]
    16. Applied *-un-lft-identity_binary6425.1

      \[\leadsto \frac{\frac{\frac{\left(3 \cdot a\right) \cdot c}{-\left(\color{blue}{1 \cdot b} + 1 \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{1 \cdot 3}}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}\]
    17. Applied distribute-lft-out_binary6425.1

      \[\leadsto \frac{\frac{\frac{\left(3 \cdot a\right) \cdot c}{-\color{blue}{1 \cdot \left(b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{1 \cdot 3}}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}\]
    18. Applied distribute-rgt-neg-in_binary6425.1

      \[\leadsto \frac{\frac{\frac{\left(3 \cdot a\right) \cdot c}{\color{blue}{1 \cdot \left(-\left(b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)\right)}}}{1 \cdot 3}}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}\]
    19. Applied times-frac_binary6424.0

      \[\leadsto \frac{\frac{\color{blue}{\frac{3 \cdot a}{1} \cdot \frac{c}{-\left(b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{1 \cdot 3}}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}\]
    20. Applied times-frac_binary6424.0

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

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

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

      \[\leadsto \frac{3 \cdot a}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \color{blue}{\frac{\frac{c}{-3 \cdot \left(b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{\sqrt[3]{a}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification20.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.360963170256676 \cdot 10^{+154}:\\ \;\;\;\;\frac{\frac{-b}{3}}{a}\\ \mathbf{elif}\;b \leq 8.442885290902578 \cdot 10^{-123}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{3 \cdot a}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{\frac{c}{-3 \cdot \left(b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{\sqrt[3]{a}}\\ \end{array}\]

Reproduce

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