?

Average Error: 52.9 → 0.5
Time: 15.2s
Precision: binary64
Cost: 13888

?

\[\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} \]
\[\left(3 \cdot c\right) \cdot \frac{1}{-3 \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(FPCore (a b c)
 :precision binary64
 (* (* 3.0 c) (/ 1.0 (* -3.0 (+ b (sqrt (fma a (* c -3.0) (* b b))))))))
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 (3.0 * c) * (1.0 / (-3.0 * (b + sqrt(fma(a, (c * -3.0), (b * b))))));
}
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(3.0 * c) * Float64(1.0 / Float64(-3.0 * Float64(b + sqrt(fma(a, Float64(c * -3.0), Float64(b * b)))))))
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[(N[(3.0 * c), $MachinePrecision] * N[(1.0 / N[(-3.0 * N[(b + N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\left(3 \cdot c\right) \cdot \frac{1}{-3 \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)}

Error?

Derivation?

  1. Initial program 52.9

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

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

    [Start]52.9

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

    *-lft-identity [<=]52.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 [<=]52.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 [<=]52.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 [<=]52.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 [=>]52.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 [=>]52.9

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

    *-commutative [=>]52.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-rr52.6

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

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

    [Start]52.6

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

    times-frac [=>]52.6

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

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

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

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

    [Start]0.5

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

    unpow-1 [=>]0.5

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

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

Alternatives

Alternative 1
Error0.5
Cost13888
\[\left(3 \cdot c\right) \cdot \left(\frac{1}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}} \cdot -0.3333333333333333\right) \]
Alternative 2
Error0.5
Cost7488
\[\left(3 \cdot c\right) \cdot \frac{-0.3333333333333333}{b + \sqrt{b \cdot b + a \cdot \left(c \cdot -3\right)}} \]
Alternative 3
Error2.8
Cost7424
\[\left(-0.375 \cdot \left(c \cdot c\right)\right) \cdot \frac{a}{{b}^{3}} + -0.5 \cdot \frac{c}{b} \]
Alternative 4
Error3.0
Cost1216
\[\left(3 \cdot c\right) \cdot \frac{1}{-3 \cdot \left(-1.5 \cdot \frac{c \cdot a}{b} + b \cdot 2\right)} \]
Alternative 5
Error3.0
Cost1088
\[\left(3 \cdot c\right) \cdot \frac{-0.3333333333333333}{-1.5 \cdot \frac{c \cdot a}{b} + b \cdot 2} \]
Alternative 6
Error3.0
Cost1088
\[\left(3 \cdot c\right) \cdot \frac{1}{b \cdot -6 + \frac{c \cdot a}{b} \cdot 4.5} \]
Alternative 7
Error6.0
Cost320
\[c \cdot \frac{-0.5}{b} \]
Alternative 8
Error6.0
Cost320
\[\frac{-0.5}{\frac{b}{c}} \]
Alternative 9
Error5.8
Cost320
\[\frac{c \cdot -0.5}{b} \]

Error

Reproduce?

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