Average Error: 52.2 → 0.1
Time: 14.6s
Precision: binary64
Cost: 13632
\[\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}^{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 52.2

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

    \[\leadsto \color{blue}{\left(b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right) \cdot \frac{-0.3333333333333333}{a}} \]
    Proof
    (*.f64 (-.f64 b (sqrt.f64 (fma.f64 a (*.f64 c -3) (*.f64 b b)))) (/.f64 -1/3 a)): 0 points increase in error, 0 points decrease in error
    (*.f64 (-.f64 b (sqrt.f64 (fma.f64 a (*.f64 c (Rewrite<= metadata-eval (neg.f64 3))) (*.f64 b b)))) (/.f64 -1/3 a)): 31 points increase in error, 0 points decrease in error
    (*.f64 (-.f64 b (sqrt.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 a (*.f64 c (neg.f64 3))) (*.f64 b b))))) (/.f64 -1/3 a)): 0 points increase in error, 31 points decrease in error
    (*.f64 (-.f64 b (sqrt.f64 (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 (*.f64 c (neg.f64 3)) a)) (*.f64 b b)))) (/.f64 -1/3 a)): 31 points increase in error, 0 points decrease in error
    (*.f64 (-.f64 b (sqrt.f64 (+.f64 (Rewrite<= associate-*r*_binary64 (*.f64 c (*.f64 (neg.f64 3) a))) (*.f64 b b)))) (/.f64 -1/3 a)): 0 points increase in error, 31 points decrease in error
    (*.f64 (-.f64 b (sqrt.f64 (+.f64 (*.f64 c (Rewrite<= distribute-lft-neg-in_binary64 (neg.f64 (*.f64 3 a)))) (*.f64 b b)))) (/.f64 -1/3 a)): 31 points increase in error, 0 points decrease in error
    (*.f64 (-.f64 b (sqrt.f64 (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 (neg.f64 (*.f64 3 a)) c)) (*.f64 b b)))) (/.f64 -1/3 a)): 31 points increase in error, 0 points decrease in error
    (*.f64 (-.f64 b (sqrt.f64 (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 b b) (*.f64 (neg.f64 (*.f64 3 a)) c))))) (/.f64 -1/3 a)): 0 points increase in error, 31 points decrease in error
    (*.f64 (-.f64 b (sqrt.f64 (Rewrite<= cancel-sign-sub-inv_binary64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c))))) (/.f64 -1/3 a)): 31 points increase in error, 0 points decrease in error
    (*.f64 (Rewrite=> sub-neg_binary64 (+.f64 b (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))))) (/.f64 -1/3 a)): 0 points increase in error, 31 points decrease in error
    (*.f64 (+.f64 (Rewrite<= /-rgt-identity_binary64 (/.f64 b 1)) (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c))))) (/.f64 -1/3 a)): 31 points increase in error, 0 points decrease in error
    (*.f64 (+.f64 (/.f64 b (Rewrite<= metadata-eval (/.f64 -1 -1))) (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c))))) (/.f64 -1/3 a)): 0 points increase in error, 31 points decrease in error
    (*.f64 (+.f64 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 b -1) -1)) (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c))))) (/.f64 -1/3 a)): 31 points increase in error, 0 points decrease in error
    (*.f64 (+.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 -1 b)) -1) (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c))))) (/.f64 -1/3 a)): 0 points increase in error, 31 points decrease in error
    (*.f64 (+.f64 (/.f64 (Rewrite<= neg-mul-1_binary64 (neg.f64 b)) -1) (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c))))) (/.f64 -1/3 a)): 31 points increase in error, 0 points decrease in error
    (*.f64 (+.f64 (/.f64 (neg.f64 b) -1) (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c))))) (/.f64 (Rewrite<= metadata-eval (/.f64 -1 3)) a)): 0 points increase in error, 31 points decrease in error
    (*.f64 (+.f64 (/.f64 (neg.f64 b) -1) (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c))))) (Rewrite<= associate-/r*_binary64 (/.f64 -1 (*.f64 3 a)))): 0 points increase in error, 31 points decrease in error
    (Rewrite<= *-commutative_binary64 (*.f64 (/.f64 -1 (*.f64 3 a)) (+.f64 (/.f64 (neg.f64 b) -1) (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c))))))): 0 points increase in error, 31 points decrease in error
    (Rewrite<= distribute-lft-out_binary64 (+.f64 (*.f64 (/.f64 -1 (*.f64 3 a)) (/.f64 (neg.f64 b) -1)) (*.f64 (/.f64 -1 (*.f64 3 a)) (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c))))))): 31 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 (/.f64 -1 (*.f64 3 a)) (/.f64 (Rewrite=> neg-mul-1_binary64 (*.f64 -1 b)) -1)) (*.f64 (/.f64 -1 (*.f64 3 a)) (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))))): 31 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 (/.f64 -1 (*.f64 3 a)) (/.f64 (Rewrite=> *-commutative_binary64 (*.f64 b -1)) -1)) (*.f64 (/.f64 -1 (*.f64 3 a)) (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))))): 31 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 (/.f64 -1 (*.f64 3 a)) (Rewrite=> associate-/l*_binary64 (/.f64 b (/.f64 -1 -1)))) (*.f64 (/.f64 -1 (*.f64 3 a)) (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))))): 0 points increase in error, 31 points decrease in error
    (+.f64 (*.f64 (/.f64 -1 (*.f64 3 a)) (/.f64 b (Rewrite=> metadata-eval 1))) (*.f64 (/.f64 -1 (*.f64 3 a)) (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))))): 31 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 (/.f64 -1 (*.f64 3 a)) (Rewrite=> /-rgt-identity_binary64 b)) (*.f64 (/.f64 -1 (*.f64 3 a)) (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))))): 0 points increase in error, 31 points decrease in error
    (Rewrite<= distribute-lft-in_binary64 (*.f64 (/.f64 -1 (*.f64 3 a)) (+.f64 b (neg.f64 (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c))))))): 31 points increase in error, 0 points decrease in error
    (*.f64 (/.f64 -1 (*.f64 3 a)) (Rewrite<= sub-neg_binary64 (-.f64 b (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))))): 0 points increase in error, 31 points decrease in error
    (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 -1 (-.f64 b (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c))))) (*.f64 3 a))): 31 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= neg-mul-1_binary64 (neg.f64 (-.f64 b (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))))) (*.f64 3 a)): 0 points increase in error, 31 points decrease in error
    (/.f64 (Rewrite<= sub0-neg_binary64 (-.f64 0 (-.f64 b (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))))) (*.f64 3 a)): 31 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 0 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c))))) (*.f64 3 a)): 0 points increase in error, 31 points decrease in error
    (/.f64 (+.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 b)) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)): 31 points increase in error, 0 points decrease in error
  3. Applied egg-rr51.8

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

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

    \[\leadsto \frac{\color{blue}{-c}}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}} \]
    Proof
    (/.f64 (neg.f64 c) (+.f64 b (sqrt.f64 (fma.f64 a (*.f64 c -3) (*.f64 b b))))): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= mul-1-neg_binary64 (*.f64 -1 c)) (+.f64 b (sqrt.f64 (fma.f64 a (*.f64 c -3) (*.f64 b b))))): 0 points increase in error, 2 points decrease in error
  6. Taylor expanded in a around 0 0.1

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

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

Alternatives

Alternative 1
Error0.1
Cost7296
\[\frac{-c}{b + \sqrt{b \cdot b + a \cdot \left(c \cdot -3\right)}} \]
Alternative 2
Error3.0
Cost896
\[\frac{-c}{b + \left(b + -1.5 \cdot \frac{c \cdot a}{b}\right)} \]
Alternative 3
Error3.0
Cost896
\[\frac{-c}{-1.5 \cdot \frac{c \cdot a}{b} + b \cdot 2} \]
Alternative 4
Error6.7
Cost320
\[\frac{-0.5}{\frac{b}{c}} \]
Alternative 5
Error6.5
Cost320
\[\frac{c \cdot -0.5}{b} \]
Alternative 6
Error61.9
Cost64
\[0 \]

Error

Reproduce

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