Average Error: 28.3 → 15.0
Time: 47.2s
Precision: 64
\[1.05367121277235087 \cdot 10^{-8} \lt a \lt 94906265.6242515594 \land 1.05367121277235087 \cdot 10^{-8} \lt b \lt 94906265.6242515594 \land 1.05367121277235087 \cdot 10^{-8} \lt c \lt 94906265.6242515594\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \le -1.866959106508209 \cdot 10^{-6}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(b, b, -\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{\sqrt{a}}{\sqrt[3]{1} \cdot \sqrt[3]{1}}}{\frac{3 \cdot a}{\frac{c}{\sqrt{b}}}} \cdot \frac{\frac{\sqrt{a} \cdot 1}{\sqrt[3]{1}}}{\sqrt{b}}\\ \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}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \le -1.866959106508209 \cdot 10^{-6}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, b, -\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\frac{-1.5 \cdot \frac{\sqrt{a}}{\sqrt[3]{1} \cdot \sqrt[3]{1}}}{\frac{3 \cdot a}{\frac{c}{\sqrt{b}}}} \cdot \frac{\frac{\sqrt{a} \cdot 1}{\sqrt[3]{1}}}{\sqrt{b}}\\

\end{array}
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 temp;
	if ((((-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)) <= -1.8669591065082085e-06)) {
		temp = ((fma(b, b, -((b * b) - ((3.0 * a) * c))) / (-b - sqrt(((b * b) - ((3.0 * a) * c))))) / (3.0 * a));
	} else {
		temp = (((-1.5 * (sqrt(a) / (cbrt(1.0) * cbrt(1.0)))) / ((3.0 * a) / (c / sqrt(b)))) * (((sqrt(a) * 1.0) / cbrt(1.0)) / sqrt(b)));
	}
	return temp;
}

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) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)) < -1.8669591065082085e-06

    1. Initial program 17.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied flip-+17.7

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

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

    if -1.8669591065082085e-06 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a))

    1. Initial program 41.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Taylor expanded around inf 12.4

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity12.4

      \[\leadsto \frac{-1.5 \cdot \frac{a \cdot c}{\color{blue}{1 \cdot b}}}{3 \cdot a}\]
    5. Applied *-un-lft-identity12.4

      \[\leadsto \frac{-1.5 \cdot \frac{a \cdot \color{blue}{\left(1 \cdot c\right)}}{1 \cdot b}}{3 \cdot a}\]
    6. Applied associate-*r*12.4

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

      \[\leadsto \frac{-1.5 \cdot \color{blue}{\left(\frac{a \cdot 1}{1} \cdot \frac{c}{b}\right)}}{3 \cdot a}\]
    8. Applied associate-*r*12.3

      \[\leadsto \frac{\color{blue}{\left(-1.5 \cdot \frac{a \cdot 1}{1}\right) \cdot \frac{c}{b}}}{3 \cdot a}\]
    9. Applied associate-/l*12.3

      \[\leadsto \color{blue}{\frac{-1.5 \cdot \frac{a \cdot 1}{1}}{\frac{3 \cdot a}{\frac{c}{b}}}}\]
    10. Using strategy rm
    11. Applied add-sqr-sqrt12.4

      \[\leadsto \frac{-1.5 \cdot \frac{a \cdot 1}{1}}{\frac{3 \cdot a}{\frac{c}{\color{blue}{\sqrt{b} \cdot \sqrt{b}}}}}\]
    12. Applied associate-/r*12.5

      \[\leadsto \frac{-1.5 \cdot \frac{a \cdot 1}{1}}{\frac{3 \cdot a}{\color{blue}{\frac{\frac{c}{\sqrt{b}}}{\sqrt{b}}}}}\]
    13. Applied associate-/r/12.5

      \[\leadsto \frac{-1.5 \cdot \frac{a \cdot 1}{1}}{\color{blue}{\frac{3 \cdot a}{\frac{c}{\sqrt{b}}} \cdot \sqrt{b}}}\]
    14. Applied add-cube-cbrt12.5

      \[\leadsto \frac{-1.5 \cdot \frac{a \cdot 1}{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}}{\frac{3 \cdot a}{\frac{c}{\sqrt{b}}} \cdot \sqrt{b}}\]
    15. Applied add-sqr-sqrt12.6

      \[\leadsto \frac{-1.5 \cdot \frac{\color{blue}{\left(\sqrt{a} \cdot \sqrt{a}\right)} \cdot 1}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{3 \cdot a}{\frac{c}{\sqrt{b}}} \cdot \sqrt{b}}\]
    16. Applied associate-*l*12.6

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

      \[\leadsto \frac{-1.5 \cdot \color{blue}{\left(\frac{\sqrt{a}}{\sqrt[3]{1} \cdot \sqrt[3]{1}} \cdot \frac{\sqrt{a} \cdot 1}{\sqrt[3]{1}}\right)}}{\frac{3 \cdot a}{\frac{c}{\sqrt{b}}} \cdot \sqrt{b}}\]
    18. Applied associate-*r*12.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \le -1.866959106508209 \cdot 10^{-6}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(b, b, -\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{\sqrt{a}}{\sqrt[3]{1} \cdot \sqrt[3]{1}}}{\frac{3 \cdot a}{\frac{c}{\sqrt{b}}}} \cdot \frac{\frac{\sqrt{a} \cdot 1}{\sqrt[3]{1}}}{\sqrt{b}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020066 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :precision binary64
  :pre (and (< 1.0536712127723509e-08 a 94906265.62425156) (< 1.0536712127723509e-08 b 94906265.62425156) (< 1.0536712127723509e-08 c 94906265.62425156))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))