?

Average Error: 43.9 → 0.2
Time: 15.8s
Precision: binary64
Cost: 13632

?

\[\left(\left(1.1102230246251565 \cdot 10^{-16} < a \land a < 9007199254740992\right) \land \left(1.1102230246251565 \cdot 10^{-16} < b \land b < 9007199254740992\right)\right) \land \left(1.1102230246251565 \cdot 10^{-16} < c \land c < 9007199254740992\right)\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
\[\frac{-c}{b + \sqrt{{b}^{2} + -3 \cdot \left(c \cdot a\right)}} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(FPCore (a b c)
 :precision binary64
 (/ (- c) (+ b (sqrt (+ (pow b 2.0) (* -3.0 (* c 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) {
	return -c / (b + sqrt((pow(b, 2.0) + (-3.0 * (c * 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
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = -c / (b + sqrt(((b ** 2.0d0) + ((-3.0d0) * (c * 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);
}
public static double code(double a, double b, double c) {
	return -c / (b + Math.sqrt((Math.pow(b, 2.0) + (-3.0 * (c * a)))));
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
def code(a, b, c):
	return -c / (b + math.sqrt((math.pow(b, 2.0) + (-3.0 * (c * 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 code(a, b, c)
	return Float64(Float64(-c) / Float64(b + sqrt(Float64((b ^ 2.0) + Float64(-3.0 * Float64(c * a))))))
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)
	tmp = -c / (b + sqrt(((b ^ 2.0) + (-3.0 * (c * 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]
code[a_, b_, c_] := N[((-c) / N[(b + N[Sqrt[N[(N[Power[b, 2.0], $MachinePrecision] + N[(-3.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\frac{-c}{b + \sqrt{{b}^{2} + -3 \cdot \left(c \cdot a\right)}}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 43.9

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

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

    [Start]43.9

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

    *-lft-identity [<=]43.9

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

    metadata-eval [<=]43.9

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

    times-frac [<=]43.9

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

    neg-mul-1 [<=]43.9

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

    distribute-rgt-neg-in [=>]43.9

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

    times-frac [=>]43.9

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

    *-commutative [=>]43.9

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

    \[\leadsto \color{blue}{\frac{\left(\left(b \cdot b - \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)\right) \cdot \frac{1}{a}\right) \cdot -0.3333333333333333}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}} \]
  4. Taylor expanded in b around 0 0.2

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

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

    [Start]0.2

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

    mul-1-neg [=>]0.2

    \[ \frac{\color{blue}{-c}}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}} \]
  6. Taylor expanded in a around 0 0.2

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

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

Alternatives

Alternative 1
Error0.2
Cost7296
\[\frac{-c}{b + \sqrt{b \cdot b + a \cdot \left(c \cdot -3\right)}} \]
Alternative 2
Error5.6
Cost896
\[\frac{-c}{b + \left(b + -1.5 \cdot \frac{c \cdot a}{b}\right)} \]
Alternative 3
Error5.6
Cost896
\[\frac{-c}{-1.5 \cdot \frac{c \cdot a}{b} + b \cdot 2} \]
Alternative 4
Error11.9
Cost320
\[-0.5 \cdot \frac{c}{b} \]

Error

Reproduce?

herbie shell --seed 2023045 
(FPCore (a b c)
  :name "Cubic critical, medium range"
  :precision binary64
  :pre (and (and (and (< 1.1102230246251565e-16 a) (< a 9007199254740992.0)) (and (< 1.1102230246251565e-16 b) (< b 9007199254740992.0))) (and (< 1.1102230246251565e-16 c) (< c 9007199254740992.0)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))