Average Error: 52.8 → 0.4
Time: 16.4s
Precision: binary64
Cost: 7744
\[\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)\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
\[\begin{array}{l} t_0 := c \cdot \left(a \cdot -3\right)\\ \frac{\frac{t_0}{b + \sqrt{b \cdot b + t_0}}}{a \cdot 3} \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
 (let* ((t_0 (* c (* a -3.0))))
   (/ (/ t_0 (+ b (sqrt (+ (* b b) t_0)))) (* a 3.0))))
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 t_0 = c * (a * -3.0);
	return (t_0 / (b + sqrt(((b * b) + t_0)))) / (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 = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: t_0
    t_0 = c * (a * (-3.0d0))
    code = (t_0 / (b + sqrt(((b * b) + t_0)))) / (a * 3.0d0)
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);
}
public static double code(double a, double b, double c) {
	double t_0 = c * (a * -3.0);
	return (t_0 / (b + Math.sqrt(((b * b) + t_0)))) / (a * 3.0);
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
def code(a, b, c):
	t_0 = c * (a * -3.0)
	return (t_0 / (b + math.sqrt(((b * b) + t_0)))) / (a * 3.0)
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 code(a, b, c)
	t_0 = Float64(c * Float64(a * -3.0))
	return Float64(Float64(t_0 / Float64(b + sqrt(Float64(Float64(b * b) + t_0)))) / Float64(a * 3.0))
end
function tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
end
function tmp = code(a, b, c)
	t_0 = c * (a * -3.0);
	tmp = (t_0 / (b + sqrt(((b * b) + t_0)))) / (a * 3.0);
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]
code[a_, b_, c_] := Block[{t$95$0 = N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$0 / N[(b + N[Sqrt[N[(N[(b * b), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\begin{array}{l}
t_0 := c \cdot \left(a \cdot -3\right)\\
\frac{\frac{t_0}{b + \sqrt{b \cdot b + t_0}}}{a \cdot 3}
\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 52.8

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

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

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

    [Start]54.4

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

    associate-/r* [<=]54.4

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

    *-commutative [=>]54.4

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

    *-commutative [=>]54.4

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

    associate-*r/ [=>]54.4

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

    associate--r- [=>]52.9

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

    *-commutative [=>]52.9

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

    *-commutative [=>]52.9

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

    *-commutative [=>]52.9

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

    *-commutative [=>]52.9

    \[ \frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, c \cdot \left(a \cdot 3\right)\right)}{\frac{\left(\left(b \cdot b - b \cdot b\right) + c \cdot \left(a \cdot 3\right)\right) \cdot 1}{b - \sqrt{b \cdot b - c \cdot \color{blue}{\left(a \cdot 3\right)}}}}}{3 \cdot a} \]
  4. Applied egg-rr52.5

    \[\leadsto \frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, c \cdot \left(a \cdot 3\right)\right)}{\frac{\left(\left(b \cdot b - b \cdot b\right) + c \cdot \left(a \cdot 3\right)\right) \cdot 1}{\color{blue}{\frac{\left(c \cdot 3\right) \cdot a}{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}}}}}{3 \cdot a} \]
  5. Applied egg-rr0.5

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

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

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

Alternatives

Alternative 1
Error0.6
Cost7744
\[\frac{a}{a \cdot 3} \cdot \frac{-3 \cdot c}{b + \sqrt{b \cdot b + c \cdot \left(a \cdot -3\right)}} \]
Alternative 2
Error3.0
Cost7488
\[\mathsf{fma}\left(-0.5, \frac{c}{b}, \frac{c}{b} \cdot \frac{-0.375 \cdot \left(a \cdot c\right)}{b \cdot b}\right) \]
Alternative 3
Error3.0
Cost960
\[\frac{c}{b} \cdot \left(-0.5 + \frac{-0.375 \cdot \left(a \cdot c\right)}{b \cdot b}\right) \]
Alternative 4
Error6.2
Cost320
\[c \cdot \frac{-0.5}{b} \]
Alternative 5
Error6.0
Cost320
\[\frac{c \cdot -0.5}{b} \]

Error

Reproduce

herbie shell --seed 2023011 
(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)))