?

Average Error: 82.24% → 0.13%
Time: 14.3s
Precision: binary64
Cost: 7296

?

\[\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} \]
\[\frac{-c}{b + \sqrt{b \cdot b + -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 (+ (* b b) (* -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(((b * b) + (-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 * b) + ((-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(((b * b) + (-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(((b * b) + (-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(Float64(b * b) + 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 * b) + (-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[(b * b), $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 \cdot b + -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 82.24

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

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

    [Start]82.24

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

    *-lft-identity [<=]82.24

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

    metadata-eval [<=]82.24

    \[ \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 [<=]82.24

    \[ \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 [<=]82.24

    \[ \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 [=>]82.24

    \[ \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 [=>]82.24

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

    *-commutative [=>]82.24

    \[ \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-rr81.77

    \[\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.13

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

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

    [Start]0.13

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

    mul-1-neg [=>]0.13

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

    \[\leadsto \frac{-c}{b + \sqrt{\color{blue}{b \cdot b + a \cdot \left(c \cdot -3\right)}}} \]
  7. Taylor expanded in a around 0 0.13

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

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

Alternatives

Alternative 1
Error4.37%
Cost896
\[\frac{-c}{b + \left(b + -1.5 \cdot \frac{c \cdot a}{b}\right)} \]
Alternative 2
Error4.36%
Cost896
\[\frac{-c}{-1.5 \cdot \frac{c \cdot a}{b} + b \cdot 2} \]
Alternative 3
Error9.83%
Cost320
\[c \cdot \frac{-0.5}{b} \]
Alternative 4
Error9.51%
Cost320
\[\frac{c \cdot -0.5}{b} \]

Error

Reproduce?

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