?

Average Accuracy: 18.2% → 99.4%
Time: 18.8s
Precision: binary64
Cost: 14016

?

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

Error?

Derivation?

  1. Initial program 18.2%

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

    \[\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]18.2

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

    +-commutative [=>]18.2

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

    flip-+ [=>]18.2

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

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

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

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

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

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

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

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

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

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

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

    \[ \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. Simplified18.7%

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

    [Start]18.7

    \[ \frac{\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} \]

    fma-udef [=>]18.7

    \[ \frac{\frac{b \cdot b - \color{blue}{\left(b \cdot 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} \]

    fma-udef [<=]18.7

    \[ \frac{\frac{b \cdot b - \color{blue}{\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} \]

    associate-*r* [=>]18.7

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

    *-commutative [=>]18.7

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

    fma-def [<=]18.7

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

    +-commutative [=>]18.7

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

    fma-def [=>]18.7

    \[ \frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \left(a \cdot 3\right) \cdot c\right)}{b + \sqrt{\color{blue}{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}}}}{3 \cdot a} \]
  4. 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(c, a \cdot -3, b \cdot b\right)}}}{3 \cdot a} \]
  5. Simplified99.4%

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

    [Start]99.2

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

    *-commutative [=>]99.2

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

    associate-*l* [=>]99.4

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

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

Alternatives

Alternative 1
Accuracy99.2%
Cost14016
\[\frac{\frac{-3 \cdot \left(c \cdot a\right)}{b + \sqrt{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}}}{a \cdot 3} \]
Alternative 2
Accuracy95.2%
Cost7488
\[\mathsf{fma}\left(-0.375, \frac{c \cdot c}{b \cdot \frac{b \cdot b}{a}}, -0.5 \cdot \frac{c}{b}\right) \]
Alternative 3
Accuracy94.7%
Cost1344
\[\frac{\frac{-3 \cdot \left(c \cdot a\right)}{-1.5 \cdot \frac{c \cdot a}{b} + b \cdot 2}}{a \cdot 3} \]
Alternative 4
Accuracy94.9%
Cost1344
\[\frac{\frac{c \cdot \left(a \cdot -3\right)}{-1.5 \cdot \frac{c \cdot a}{b} + b \cdot 2}}{a \cdot 3} \]
Alternative 5
Accuracy89.8%
Cost320
\[c \cdot \frac{-0.5}{b} \]
Alternative 6
Accuracy89.8%
Cost320
\[\frac{-0.5}{\frac{b}{c}} \]
Alternative 7
Accuracy90.2%
Cost320
\[\frac{c \cdot -0.5}{b} \]
Alternative 8
Accuracy3.3%
Cost64
\[0 \]

Error

Reproduce?

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