Average Error: 29.1 → 5.1
Time: 7.9s
Precision: binary64
\[1.0536712127723509 \cdot 10^{-8} < a \land a < 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-8} < b \land b < 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-8} < c \land c < 94906265.62425156\]
\[\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 0.7595766079997472:\\ \;\;\;\;\begin{array}{l} t_0 := b \cdot b - 3 \cdot \left(c \cdot a\right)\\ \frac{\frac{t_0 - b \cdot b}{b + \sqrt{t_0}}}{3 \cdot a} \end{array}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(-0.5 \cdot \frac{c}{b} - 0.375 \cdot \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}\right) - 0.5625 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right) + \frac{{c}^{4} \cdot {a}^{3}}{{b}^{7}} \cdot -1.0546875\\ \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 0.7595766079997472:\\
\;\;\;\;\begin{array}{l}
t_0 := b \cdot b - 3 \cdot \left(c \cdot a\right)\\
\frac{\frac{t_0 - b \cdot b}{b + \sqrt{t_0}}}{3 \cdot a}
\end{array}\\

\mathbf{else}:\\
\;\;\;\;\left(\left(-0.5 \cdot \frac{c}{b} - 0.375 \cdot \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}\right) - 0.5625 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right) + \frac{{c}^{4} \cdot {a}^{3}}{{b}^{7}} \cdot -1.0546875\\


\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 0.7595766079997472)
   (let* ((t_0 (- (* b b) (* 3.0 (* c a)))))
     (/ (/ (- t_0 (* b b)) (+ b (sqrt t_0))) (* 3.0 a)))
   (+
    (-
     (- (* -0.5 (/ c b)) (* 0.375 (/ (* a (* c c)) (pow b 3.0))))
     (* 0.5625 (/ (* (pow c 3.0) (* a a)) (pow b 5.0))))
    (* (/ (* (pow c 4.0) (pow a 3.0)) (pow b 7.0)) -1.0546875))))
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 <= 0.7595766079997472) {
		double t_0_1 = (b * b) - (3.0 * (c * a));
		tmp = ((t_0_1 - (b * b)) / (b + sqrt(t_0_1))) / (3.0 * a);
	} else {
		tmp = (((-0.5 * (c / b)) - (0.375 * ((a * (c * c)) / pow(b, 3.0)))) - (0.5625 * ((pow(c, 3.0) * (a * a)) / pow(b, 5.0)))) + (((pow(c, 4.0) * pow(a, 3.0)) / pow(b, 7.0)) * -1.0546875);
	}
	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 2 regimes
  2. if b < 0.75957660799974724

    1. Initial program 11.5

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Simplified11.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--_binary6411.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. Simplified10.5

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

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

    if 0.75957660799974724 < b

    1. Initial program 32.0

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

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

      \[\leadsto \frac{\color{blue}{-\left(1.5 \cdot \frac{c \cdot a}{b} + \left(1.125 \cdot \frac{{c}^{2} \cdot {a}^{2}}{{b}^{3}} + \left(3.1640625 \cdot \frac{{c}^{4} \cdot {a}^{4}}{{b}^{7}} + 1.6875 \cdot \frac{{c}^{3} \cdot {a}^{3}}{{b}^{5}}\right)\right)\right)}}{3 \cdot a} \]
    4. Simplified4.5

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{c \cdot a}{b} - \left(1.125 \cdot \frac{\left(c \cdot a\right) \cdot \left(c \cdot a\right)}{{b}^{3}} + \left(1.6875 \cdot \frac{{\left(c \cdot a\right)}^{3}}{{b}^{5}} + 3.1640625 \cdot \frac{{c}^{4} \cdot {a}^{4}}{{b}^{7}}\right)\right)}}{3 \cdot a} \]
    5. Using strategy rm
    6. Applied *-un-lft-identity_binary644.5

      \[\leadsto \frac{\color{blue}{1 \cdot \left(-1.5 \cdot \frac{c \cdot a}{b} - \left(1.125 \cdot \frac{\left(c \cdot a\right) \cdot \left(c \cdot a\right)}{{b}^{3}} + \left(1.6875 \cdot \frac{{\left(c \cdot a\right)}^{3}}{{b}^{5}} + 3.1640625 \cdot \frac{{c}^{4} \cdot {a}^{4}}{{b}^{7}}\right)\right)\right)}}{3 \cdot a} \]
    7. Applied times-frac_binary644.5

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \frac{-1.5 \cdot \frac{c \cdot a}{b} - \left(1.125 \cdot \frac{\left(c \cdot a\right) \cdot \left(c \cdot a\right)}{{b}^{3}} + \left(1.6875 \cdot \frac{{\left(c \cdot a\right)}^{3}}{{b}^{5}} + 3.1640625 \cdot \frac{{c}^{4} \cdot {a}^{4}}{{b}^{7}}\right)\right)}{a}} \]
    8. Simplified4.5

      \[\leadsto \color{blue}{0.3333333333333333} \cdot \frac{-1.5 \cdot \frac{c \cdot a}{b} - \left(1.125 \cdot \frac{\left(c \cdot a\right) \cdot \left(c \cdot a\right)}{{b}^{3}} + \left(1.6875 \cdot \frac{{\left(c \cdot a\right)}^{3}}{{b}^{5}} + 3.1640625 \cdot \frac{{c}^{4} \cdot {a}^{4}}{{b}^{7}}\right)\right)}{a} \]
    9. Simplified4.5

      \[\leadsto 0.3333333333333333 \cdot \color{blue}{\frac{-1.5 \cdot \left(\frac{c}{b} \cdot a\right) - \left(1.125 \cdot \frac{{\left(c \cdot a\right)}^{2}}{{b}^{3}} + \left(\frac{{\left(c \cdot a\right)}^{3}}{{b}^{5}} \cdot 1.6875 + 3.1640625 \cdot \frac{{\left(c \cdot a\right)}^{4}}{{b}^{7}}\right)\right)}{a}} \]
    10. Taylor expanded around 0 4.2

      \[\leadsto \color{blue}{-\left(0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(1.0546875 \cdot \frac{{c}^{4} \cdot {a}^{3}}{{b}^{7}} + \left(0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + 0.5 \cdot \frac{c}{b}\right)\right)\right)} \]
    11. Simplified4.2

      \[\leadsto \color{blue}{\left(\left(-0.5 \cdot \frac{c}{b} - 0.375 \cdot \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}\right) - 0.5625 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right) + \frac{{c}^{4} \cdot {a}^{3}}{{b}^{7}} \cdot -1.0546875} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification5.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 0.7595766079997472:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - 3 \cdot \left(c \cdot a\right)\right) - b \cdot b}{b + \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(-0.5 \cdot \frac{c}{b} - 0.375 \cdot \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}\right) - 0.5625 \cdot \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}\right) + \frac{{c}^{4} \cdot {a}^{3}}{{b}^{7}} \cdot -1.0546875\\ \end{array} \]

Reproduce

herbie shell --seed 2021205 
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :precision binary64
  :pre (and (< 1.0536712127723509e-8 a 94906265.62425156) (< 1.0536712127723509e-8 b 94906265.62425156) (< 1.0536712127723509e-8 c 94906265.62425156))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))