?

Average Accuracy: 31.3% → 99.2%
Time: 19.8s
Precision: binary64
Cost: 14016

?

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

Error?

Derivation?

  1. Initial program 31.3%

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

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

    [Start]31.3

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

    +-commutative [=>]31.3

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

    flip-+ [=>]31.3

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

    add-sqr-sqrt [<=]32.2

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

    sqr-neg [=>]32.2

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

    associate--l- [=>]32.2

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

    +-commutative [<=]32.2

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

    fma-def [=>]32.1

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

    associate-*l* [=>]32.1

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

    add-sqr-sqrt [=>]0.0

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

    sqrt-unprod [=>]0.8

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

    sqr-neg [=>]0.8

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

    sqrt-prod [=>]1.6

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

    add-sqr-sqrt [<=]0.8

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

    unsub-neg [<=]0.8

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

    +-commutative [<=]0.8

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

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

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

    [Start]99.2

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

    associate-*r* [=>]99.2

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

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

Alternatives

Alternative 1
Accuracy99.2%
Cost14016
\[\frac{\frac{-3 \cdot \left(c \cdot a\right)}{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)}}}{a \cdot 3} \]
Alternative 2
Accuracy91.0%
Cost832
\[\frac{1}{-2 \cdot \frac{b}{c} + 1.5 \cdot \frac{a}{b}} \]
Alternative 3
Accuracy81.2%
Cost320
\[c \cdot \frac{-0.5}{b} \]
Alternative 4
Accuracy81.2%
Cost320
\[\frac{-0.5}{\frac{b}{c}} \]
Alternative 5
Accuracy81.4%
Cost320
\[\frac{c \cdot -0.5}{b} \]

Error

Reproduce?

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