Cubic critical, wide range

Percentage Accurate: 17.5% → 99.7%
Time: 7.8s
Alternatives: 4
Speedup: 23.2×

Specification

?
\[\left(\left(4.930380657631324 \cdot 10^{-32} < a \land a < 2.028240960365167 \cdot 10^{+31}\right) \land \left(4.930380657631324 \cdot 10^{-32} < b \land b < 2.028240960365167 \cdot 10^{+31}\right)\right) \land \left(4.930380657631324 \cdot 10^{-32} < c \land c < 2.028240960365167 \cdot 10^{+31}\right)\]
\[\begin{array}{l} \\ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
	return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c)
	return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a))
end
function tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 4 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 17.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
	return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c)
	return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a))
end
function tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}

Alternative 1: 99.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \frac{c}{\frac{3 \cdot \left(\left(-b\right) - \sqrt{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}\right)}{3}} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ c (/ (* 3.0 (- (- b) (sqrt (fma c (* a -3.0) (* b b))))) 3.0)))
double code(double a, double b, double c) {
	return c / ((3.0 * (-b - sqrt(fma(c, (a * -3.0), (b * b))))) / 3.0);
}
function code(a, b, c)
	return Float64(c / Float64(Float64(3.0 * Float64(Float64(-b) - sqrt(fma(c, Float64(a * -3.0), Float64(b * b))))) / 3.0))
end
code[a_, b_, c_] := N[(c / N[(N[(3.0 * N[((-b) - N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{c}{\frac{3 \cdot \left(\left(-b\right) - \sqrt{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}\right)}{3}}
\end{array}
Derivation
  1. Initial program 15.8%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
  2. Taylor expanded in a around 0 15.8%

    \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{3 \cdot \left(c \cdot a\right)}}}{3 \cdot a} \]
  3. Step-by-step derivation
    1. flip-+15.7%

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} \cdot \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}}{3 \cdot a} \]
    2. add-sqr-sqrt16.2%

      \[\leadsto \frac{\frac{\left(-b\right) \cdot \left(-b\right) - \color{blue}{\left(b \cdot b - 3 \cdot \left(c \cdot a\right)\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}{3 \cdot a} \]
  4. Applied egg-rr16.2%

    \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \left(b \cdot b - 3 \cdot \left(c \cdot a\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}}{3 \cdot a} \]
  5. Step-by-step derivation
    1. sqr-neg16.2%

      \[\leadsto \frac{\frac{\color{blue}{b \cdot b} - \left(b \cdot b - 3 \cdot \left(c \cdot a\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}{3 \cdot a} \]
    2. associate--r-99.2%

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

      \[\leadsto \frac{\frac{\left(b \cdot b - b \cdot b\right) + \color{blue}{\left(c \cdot a\right) \cdot 3}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}{3 \cdot a} \]
    4. associate-*r*99.5%

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

    \[\leadsto \frac{\frac{\color{blue}{\left(b \cdot b - b \cdot b\right) + c \cdot \left(a \cdot 3\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}{3 \cdot a} \]
  7. Step-by-step derivation
    1. div-inv99.4%

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

      \[\leadsto \frac{\color{blue}{0} + c \cdot \left(a \cdot 3\right)}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}} \cdot \frac{1}{3 \cdot a} \]
    3. cancel-sign-sub-inv99.4%

      \[\leadsto \frac{0 + c \cdot \left(a \cdot 3\right)}{\left(-b\right) - \sqrt{\color{blue}{b \cdot b + \left(-3\right) \cdot \left(c \cdot a\right)}}} \cdot \frac{1}{3 \cdot a} \]
    4. metadata-eval99.4%

      \[\leadsto \frac{0 + c \cdot \left(a \cdot 3\right)}{\left(-b\right) - \sqrt{b \cdot b + \color{blue}{-3} \cdot \left(c \cdot a\right)}} \cdot \frac{1}{3 \cdot a} \]
    5. *-commutative99.4%

      \[\leadsto \frac{0 + c \cdot \left(a \cdot 3\right)}{\left(-b\right) - \sqrt{b \cdot b + -3 \cdot \left(c \cdot a\right)}} \cdot \frac{1}{\color{blue}{a \cdot 3}} \]
    6. associate-/r*99.2%

      \[\leadsto \frac{0 + c \cdot \left(a \cdot 3\right)}{\left(-b\right) - \sqrt{b \cdot b + -3 \cdot \left(c \cdot a\right)}} \cdot \color{blue}{\frac{\frac{1}{a}}{3}} \]
  8. Applied egg-rr99.2%

    \[\leadsto \color{blue}{\frac{0 + c \cdot \left(a \cdot 3\right)}{\left(-b\right) - \sqrt{b \cdot b + -3 \cdot \left(c \cdot a\right)}} \cdot \frac{\frac{1}{a}}{3}} \]
  9. Step-by-step derivation
    1. *-commutative99.2%

      \[\leadsto \color{blue}{\frac{\frac{1}{a}}{3} \cdot \frac{0 + c \cdot \left(a \cdot 3\right)}{\left(-b\right) - \sqrt{b \cdot b + -3 \cdot \left(c \cdot a\right)}}} \]
    2. associate-/r*99.4%

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

      \[\leadsto \color{blue}{\frac{1 \cdot \left(0 + c \cdot \left(a \cdot 3\right)\right)}{\left(a \cdot 3\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b + -3 \cdot \left(c \cdot a\right)}\right)}} \]
    4. *-lft-identity99.4%

      \[\leadsto \frac{\color{blue}{0 + c \cdot \left(a \cdot 3\right)}}{\left(a \cdot 3\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b + -3 \cdot \left(c \cdot a\right)}\right)} \]
    5. associate-/r*99.7%

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

      \[\leadsto \frac{\frac{0 + c \cdot \left(a \cdot 3\right)}{a \cdot 3}}{\left(-b\right) - \sqrt{\color{blue}{{b}^{2}} + -3 \cdot \left(c \cdot a\right)}} \]
    7. +-commutative99.7%

      \[\leadsto \frac{\frac{0 + c \cdot \left(a \cdot 3\right)}{a \cdot 3}}{\left(-b\right) - \sqrt{\color{blue}{-3 \cdot \left(c \cdot a\right) + {b}^{2}}}} \]
    8. *-commutative99.7%

      \[\leadsto \frac{\frac{0 + c \cdot \left(a \cdot 3\right)}{a \cdot 3}}{\left(-b\right) - \sqrt{\color{blue}{\left(c \cdot a\right) \cdot -3} + {b}^{2}}} \]
    9. associate-*r*99.7%

      \[\leadsto \frac{\frac{0 + c \cdot \left(a \cdot 3\right)}{a \cdot 3}}{\left(-b\right) - \sqrt{\color{blue}{c \cdot \left(a \cdot -3\right)} + {b}^{2}}} \]
    10. unpow299.7%

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

      \[\leadsto \frac{\frac{0 + c \cdot \left(a \cdot 3\right)}{a \cdot 3}}{\left(-b\right) - \sqrt{\color{blue}{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}}} \]
    12. associate-/r*99.4%

      \[\leadsto \color{blue}{\frac{0 + c \cdot \left(a \cdot 3\right)}{\left(a \cdot 3\right) \cdot \left(\left(-b\right) - \sqrt{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}\right)}} \]
  10. Simplified99.7%

    \[\leadsto \color{blue}{\frac{c}{1 \cdot \frac{3 \cdot \left(\left(-b\right) - \sqrt{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}\right)}{3}}} \]
  11. Final simplification99.7%

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

Alternative 2: 99.4% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \frac{\frac{\left(b \cdot b - b \cdot b\right) + c \cdot \left(3 \cdot a\right)}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}{3 \cdot a} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/
  (/
   (+ (- (* b b) (* b b)) (* c (* 3.0 a)))
   (- (- b) (sqrt (- (* b b) (* 3.0 (* c a))))))
  (* 3.0 a)))
double code(double a, double b, double c) {
	return ((((b * b) - (b * b)) + (c * (3.0 * a))) / (-b - sqrt(((b * b) - (3.0 * (c * a)))))) / (3.0 * a);
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = ((((b * b) - (b * b)) + (c * (3.0d0 * a))) / (-b - sqrt(((b * b) - (3.0d0 * (c * a)))))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
	return ((((b * b) - (b * b)) + (c * (3.0 * a))) / (-b - Math.sqrt(((b * b) - (3.0 * (c * a)))))) / (3.0 * a);
}
def code(a, b, c):
	return ((((b * b) - (b * b)) + (c * (3.0 * a))) / (-b - math.sqrt(((b * b) - (3.0 * (c * a)))))) / (3.0 * a)
function code(a, b, c)
	return Float64(Float64(Float64(Float64(Float64(b * b) - Float64(b * b)) + Float64(c * Float64(3.0 * a))) / Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(c * a)))))) / Float64(3.0 * a))
end
function tmp = code(a, b, c)
	tmp = ((((b * b) - (b * b)) + (c * (3.0 * a))) / (-b - sqrt(((b * b) - (3.0 * (c * a)))))) / (3.0 * a);
end
code[a_, b_, c_] := N[(N[(N[(N[(N[(b * b), $MachinePrecision] - N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(c * N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{\left(b \cdot b - b \cdot b\right) + c \cdot \left(3 \cdot a\right)}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}{3 \cdot a}
\end{array}
Derivation
  1. Initial program 15.8%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
  2. Taylor expanded in a around 0 15.8%

    \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{3 \cdot \left(c \cdot a\right)}}}{3 \cdot a} \]
  3. Step-by-step derivation
    1. flip-+15.7%

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} \cdot \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}}{3 \cdot a} \]
    2. add-sqr-sqrt16.2%

      \[\leadsto \frac{\frac{\left(-b\right) \cdot \left(-b\right) - \color{blue}{\left(b \cdot b - 3 \cdot \left(c \cdot a\right)\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}{3 \cdot a} \]
  4. Applied egg-rr16.2%

    \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \left(b \cdot b - 3 \cdot \left(c \cdot a\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}}{3 \cdot a} \]
  5. Step-by-step derivation
    1. sqr-neg16.2%

      \[\leadsto \frac{\frac{\color{blue}{b \cdot b} - \left(b \cdot b - 3 \cdot \left(c \cdot a\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}{3 \cdot a} \]
    2. associate--r-99.2%

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

      \[\leadsto \frac{\frac{\left(b \cdot b - b \cdot b\right) + \color{blue}{\left(c \cdot a\right) \cdot 3}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}{3 \cdot a} \]
    4. associate-*r*99.5%

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

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

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

Alternative 3: 99.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{c}{3 \cdot a} \cdot \frac{3 \cdot a}{\left(-b\right) - \sqrt{b \cdot b + c \cdot \left(a \cdot -3\right)}} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (*
  (/ c (* 3.0 a))
  (/ (* 3.0 a) (- (- b) (sqrt (+ (* b b) (* c (* a -3.0))))))))
double code(double a, double b, double c) {
	return (c / (3.0 * a)) * ((3.0 * a) / (-b - sqrt(((b * b) + (c * (a * -3.0))))));
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = (c / (3.0d0 * a)) * ((3.0d0 * a) / (-b - sqrt(((b * b) + (c * (a * (-3.0d0)))))))
end function
public static double code(double a, double b, double c) {
	return (c / (3.0 * a)) * ((3.0 * a) / (-b - Math.sqrt(((b * b) + (c * (a * -3.0))))));
}
def code(a, b, c):
	return (c / (3.0 * a)) * ((3.0 * a) / (-b - math.sqrt(((b * b) + (c * (a * -3.0))))))
function code(a, b, c)
	return Float64(Float64(c / Float64(3.0 * a)) * Float64(Float64(3.0 * a) / Float64(Float64(-b) - sqrt(Float64(Float64(b * b) + Float64(c * Float64(a * -3.0)))))))
end
function tmp = code(a, b, c)
	tmp = (c / (3.0 * a)) * ((3.0 * a) / (-b - sqrt(((b * b) + (c * (a * -3.0))))));
end
code[a_, b_, c_] := N[(N[(c / N[(3.0 * a), $MachinePrecision]), $MachinePrecision] * N[(N[(3.0 * a), $MachinePrecision] / N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{c}{3 \cdot a} \cdot \frac{3 \cdot a}{\left(-b\right) - \sqrt{b \cdot b + c \cdot \left(a \cdot -3\right)}}
\end{array}
Derivation
  1. Initial program 15.8%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
  2. Taylor expanded in a around 0 15.8%

    \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{3 \cdot \left(c \cdot a\right)}}}{3 \cdot a} \]
  3. Step-by-step derivation
    1. flip-+15.7%

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} \cdot \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}}{3 \cdot a} \]
    2. add-sqr-sqrt16.2%

      \[\leadsto \frac{\frac{\left(-b\right) \cdot \left(-b\right) - \color{blue}{\left(b \cdot b - 3 \cdot \left(c \cdot a\right)\right)}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}{3 \cdot a} \]
  4. Applied egg-rr16.2%

    \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \left(b \cdot b - 3 \cdot \left(c \cdot a\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}}{3 \cdot a} \]
  5. Step-by-step derivation
    1. sqr-neg16.2%

      \[\leadsto \frac{\frac{\color{blue}{b \cdot b} - \left(b \cdot b - 3 \cdot \left(c \cdot a\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}{3 \cdot a} \]
    2. associate-+l-99.2%

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

      \[\leadsto \frac{\frac{\color{blue}{0} + 3 \cdot \left(c \cdot a\right)}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}{3 \cdot a} \]
    4. +-commutative99.2%

      \[\leadsto \frac{\frac{\color{blue}{3 \cdot \left(c \cdot a\right) + 0}}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}{3 \cdot a} \]
    5. *-commutative99.2%

      \[\leadsto \frac{\frac{\color{blue}{\left(c \cdot a\right) \cdot 3} + 0}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}}}{3 \cdot a} \]
    6. associate-*l*99.5%

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

      \[\leadsto \frac{\frac{c \cdot \left(a \cdot 3\right) + 0}{\left(-b\right) - \sqrt{\color{blue}{\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)}}}}{3 \cdot a} \]
    8. distribute-lft-neg-in99.5%

      \[\leadsto \frac{\frac{c \cdot \left(a \cdot 3\right) + 0}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(-3\right) \cdot \left(c \cdot a\right)}\right)}}}{3 \cdot a} \]
    9. metadata-eval99.5%

      \[\leadsto \frac{\frac{c \cdot \left(a \cdot 3\right) + 0}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, \color{blue}{-3} \cdot \left(c \cdot a\right)\right)}}}{3 \cdot a} \]
    10. *-commutative99.5%

      \[\leadsto \frac{\frac{c \cdot \left(a \cdot 3\right) + 0}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(c \cdot a\right) \cdot -3}\right)}}}{3 \cdot a} \]
    11. associate-*l*99.5%

      \[\leadsto \frac{\frac{c \cdot \left(a \cdot 3\right) + 0}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, \color{blue}{c \cdot \left(a \cdot -3\right)}\right)}}}{3 \cdot a} \]
  6. Simplified99.5%

    \[\leadsto \frac{\color{blue}{\frac{c \cdot \left(a \cdot 3\right) + 0}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}}}}{3 \cdot a} \]
  7. Step-by-step derivation
    1. div-inv99.4%

      \[\leadsto \color{blue}{\frac{c \cdot \left(a \cdot 3\right) + 0}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}} \cdot \frac{1}{3 \cdot a}} \]
    2. +-rgt-identity99.4%

      \[\leadsto \frac{\color{blue}{c \cdot \left(a \cdot 3\right)}}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}} \cdot \frac{1}{3 \cdot a} \]
    3. *-commutative99.4%

      \[\leadsto \frac{c \cdot \left(a \cdot 3\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}} \cdot \frac{1}{\color{blue}{a \cdot 3}} \]
  8. Applied egg-rr99.4%

    \[\leadsto \color{blue}{\frac{c \cdot \left(a \cdot 3\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}} \cdot \frac{1}{a \cdot 3}} \]
  9. Step-by-step derivation
    1. *-commutative99.4%

      \[\leadsto \color{blue}{\frac{1}{a \cdot 3} \cdot \frac{c \cdot \left(a \cdot 3\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}}} \]
    2. times-frac99.4%

      \[\leadsto \color{blue}{\frac{1 \cdot \left(c \cdot \left(a \cdot 3\right)\right)}{\left(a \cdot 3\right) \cdot \left(\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}\right)}} \]
    3. associate-*r/99.4%

      \[\leadsto \color{blue}{1 \cdot \frac{c \cdot \left(a \cdot 3\right)}{\left(a \cdot 3\right) \cdot \left(\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}\right)}} \]
    4. *-lft-identity99.4%

      \[\leadsto \color{blue}{\frac{c \cdot \left(a \cdot 3\right)}{\left(a \cdot 3\right) \cdot \left(\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}\right)}} \]
    5. times-frac99.4%

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

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

      \[\leadsto \frac{c}{a \cdot 3} \cdot \frac{a \cdot 3}{\left(-b\right) - \sqrt{\color{blue}{c \cdot \left(a \cdot -3\right) + b \cdot b}}} \]
    8. fma-def99.4%

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

    \[\leadsto \color{blue}{\frac{c}{a \cdot 3} \cdot \frac{a \cdot 3}{\left(-b\right) - \sqrt{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}}} \]
  11. Step-by-step derivation
    1. fma-udef99.4%

      \[\leadsto \frac{c}{a \cdot 3} \cdot \frac{a \cdot 3}{\left(-b\right) - \sqrt{\color{blue}{c \cdot \left(a \cdot -3\right) + b \cdot b}}} \]
  12. Applied egg-rr99.4%

    \[\leadsto \frac{c}{a \cdot 3} \cdot \frac{a \cdot 3}{\left(-b\right) - \sqrt{\color{blue}{c \cdot \left(a \cdot -3\right) + b \cdot b}}} \]
  13. Final simplification99.4%

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

Alternative 4: 90.6% accurate, 23.2× speedup?

\[\begin{array}{l} \\ -0.5 \cdot \frac{c}{b} \end{array} \]
(FPCore (a b c) :precision binary64 (* -0.5 (/ c b)))
double code(double a, double b, double c) {
	return -0.5 * (c / b);
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = (-0.5d0) * (c / b)
end function
public static double code(double a, double b, double c) {
	return -0.5 * (c / b);
}
def code(a, b, c):
	return -0.5 * (c / b)
function code(a, b, c)
	return Float64(-0.5 * Float64(c / b))
end
function tmp = code(a, b, c)
	tmp = -0.5 * (c / b);
end
code[a_, b_, c_] := N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
-0.5 \cdot \frac{c}{b}
\end{array}
Derivation
  1. Initial program 15.8%

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

    \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
  3. Final simplification91.9%

    \[\leadsto -0.5 \cdot \frac{c}{b} \]

Reproduce

?
herbie shell --seed 2023187 
(FPCore (a b c)
  :name "Cubic critical, wide range"
  :precision binary64
  :pre (and (and (and (< 4.930380657631324e-32 a) (< a 2.028240960365167e+31)) (and (< 4.930380657631324e-32 b) (< b 2.028240960365167e+31))) (and (< 4.930380657631324e-32 c) (< c 2.028240960365167e+31)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))