?

Average Accuracy: 31.9% → 99.2%
Time: 19.5s
Precision: binary64
Cost: 14528

?

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

Error?

Derivation?

  1. Initial program 31.9%

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

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

    [Start]31.9

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

    remove-double-neg [<=]31.9

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

    sub-neg [<=]31.9

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

    div-sub [=>]31.4

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

    neg-mul-1 [=>]31.4

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

    associate-*l/ [<=]31.7

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

    distribute-frac-neg [=>]31.7

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

    fma-neg [=>]33.2

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

    /-rgt-identity [<=]33.2

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

    metadata-eval [<=]33.2

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

    associate-/l* [<=]33.2

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

    *-commutative [<=]33.2

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

    neg-mul-1 [<=]33.2

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

    fma-neg [<=]31.7

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

    neg-mul-1 [=>]31.7

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

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

    [Start]31.9

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

    flip-- [=>]31.9

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

    frac-times [=>]31.9

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

    associate-/l* [=>]31.9

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

    add-sqr-sqrt [<=]32.8

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

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

    [Start]32.8

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

    sub-neg [=>]32.8

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

    +-commutative [=>]32.8

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

    fma-udef [=>]32.8

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

    distribute-neg-in [=>]32.8

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

    associate-+l+ [=>]99.1

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

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

    [Start]99.1

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

    div-inv [=>]99.2

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

    *-commutative [=>]99.2

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

    metadata-eval [=>]99.2

    \[ \frac{\left(-a \cdot \left(c \cdot -3\right)\right) + \left(\left(-b \cdot b\right) + b \cdot b\right)}{\left(a \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)\right) \cdot \color{blue}{-3}} \]
  6. Final simplification99.2%

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

Alternatives

Alternative 1
Accuracy99.1%
Cost14464
\[\frac{c \cdot \left(a \cdot 3\right) + \left(b \cdot b\right) \cdot 0}{\left(-\sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right) - b} \cdot \frac{0.3333333333333333}{a} \]
Alternative 2
Accuracy99.1%
Cost14016
\[\frac{3 \cdot \left(a \cdot c\right)}{\frac{a \cdot \left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right)}{-0.3333333333333333}} \]
Alternative 3
Accuracy90.6%
Cost832
\[\frac{1}{-2 \cdot \frac{b}{c} + 1.5 \cdot \frac{a}{b}} \]
Alternative 4
Accuracy80.9%
Cost320
\[-0.5 \cdot \frac{c}{b} \]

Error

Reproduce?

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