?

Average Accuracy: 30.8% → 95.8%
Time: 24.6s
Precision: binary64
Cost: 53504

?

\[\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} \]
\[\mathsf{fma}\left(-0.5, \frac{c}{b}, \mathsf{fma}\left(\frac{-0.16666666666666666}{a}, \frac{{\left(c \cdot a\right)}^{4} \cdot 6.328125}{{b}^{7}}, \mathsf{fma}\left(-0.375, \frac{a}{{b}^{3}} \cdot \left(c \cdot c\right), -0.5625 \cdot \left(\frac{a}{{b}^{5}} \cdot \left(a \cdot {c}^{3}\right)\right)\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
 (fma
  -0.5
  (/ c b)
  (fma
   (/ -0.16666666666666666 a)
   (/ (* (pow (* c a) 4.0) 6.328125) (pow b 7.0))
   (fma
    -0.375
    (* (/ a (pow b 3.0)) (* c c))
    (* -0.5625 (* (/ a (pow b 5.0)) (* a (pow c 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 fma(-0.5, (c / b), fma((-0.16666666666666666 / a), ((pow((c * a), 4.0) * 6.328125) / pow(b, 7.0)), fma(-0.375, ((a / pow(b, 3.0)) * (c * c)), (-0.5625 * ((a / pow(b, 5.0)) * (a * pow(c, 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 fma(-0.5, Float64(c / b), fma(Float64(-0.16666666666666666 / a), Float64(Float64((Float64(c * a) ^ 4.0) * 6.328125) / (b ^ 7.0)), fma(-0.375, Float64(Float64(a / (b ^ 3.0)) * Float64(c * c)), Float64(-0.5625 * Float64(Float64(a / (b ^ 5.0)) * Float64(a * (c ^ 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[(-0.5 * N[(c / b), $MachinePrecision] + N[(N[(-0.16666666666666666 / a), $MachinePrecision] * N[(N[(N[Power[N[(c * a), $MachinePrecision], 4.0], $MachinePrecision] * 6.328125), $MachinePrecision] / N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision] + N[(-0.375 * N[(N[(a / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision] * N[(c * c), $MachinePrecision]), $MachinePrecision] + N[(-0.5625 * N[(N[(a / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision] * N[(a * N[Power[c, 3.0], $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}
\mathsf{fma}\left(-0.5, \frac{c}{b}, \mathsf{fma}\left(\frac{-0.16666666666666666}{a}, \frac{{\left(c \cdot a\right)}^{4} \cdot 6.328125}{{b}^{7}}, \mathsf{fma}\left(-0.375, \frac{a}{{b}^{3}} \cdot \left(c \cdot c\right), -0.5625 \cdot \left(\frac{a}{{b}^{5}} \cdot \left(a \cdot {c}^{3}\right)\right)\right)\right)\right)

Error?

Derivation?

  1. Initial program 30.8%

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

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

    [Start]30.8

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

    /-rgt-identity [<=]30.8

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

    metadata-eval [<=]30.8

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

    associate-/l* [<=]30.8

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

    associate-*r/ [<=]30.8

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

    *-commutative [=>]30.8

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

    associate-*l/ [=>]30.8

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

    associate-*r/ [<=]30.8

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

    metadata-eval [=>]30.8

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

    metadata-eval [<=]30.8

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

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

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

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

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

    metadata-eval [=>]30.8

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

    neg-mul-1 [=>]30.8

    \[ -0.3333333333333333 \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\color{blue}{-1 \cdot a}} \]
  3. Taylor expanded in b around inf 95.3%

    \[\leadsto -0.3333333333333333 \cdot \color{blue}{\left(1.6875 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(1.125 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + \left(1.5 \cdot \frac{c}{b} + 0.5 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}}\right)\right)\right)} \]
  4. Simplified95.5%

    \[\leadsto -0.3333333333333333 \cdot \color{blue}{\mathsf{fma}\left(1.6875, \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}, \mathsf{fma}\left(1.125, \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}, \mathsf{fma}\left(1.5, \frac{c}{b}, \frac{0.5 \cdot \left({\left(\left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right) \cdot -1.125\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)\right)}{a \cdot {b}^{7}}\right)\right)\right)} \]
    Proof

    [Start]95.3

    \[ -0.3333333333333333 \cdot \left(1.6875 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(1.125 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + \left(1.5 \cdot \frac{c}{b} + 0.5 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}}\right)\right)\right) \]

    fma-def [=>]95.3

    \[ -0.3333333333333333 \cdot \color{blue}{\mathsf{fma}\left(1.6875, \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}, 1.125 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + \left(1.5 \cdot \frac{c}{b} + 0.5 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}}\right)\right)} \]

    unpow2 [=>]95.3

    \[ -0.3333333333333333 \cdot \mathsf{fma}\left(1.6875, \frac{{c}^{3} \cdot \color{blue}{\left(a \cdot a\right)}}{{b}^{5}}, 1.125 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + \left(1.5 \cdot \frac{c}{b} + 0.5 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}}\right)\right) \]

    fma-def [=>]95.3

    \[ -0.3333333333333333 \cdot \mathsf{fma}\left(1.6875, \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}, \color{blue}{\mathsf{fma}\left(1.125, \frac{{c}^{2} \cdot a}{{b}^{3}}, 1.5 \cdot \frac{c}{b} + 0.5 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}}\right)}\right) \]

    *-commutative [=>]95.3

    \[ -0.3333333333333333 \cdot \mathsf{fma}\left(1.6875, \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}, \mathsf{fma}\left(1.125, \frac{\color{blue}{a \cdot {c}^{2}}}{{b}^{3}}, 1.5 \cdot \frac{c}{b} + 0.5 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}}\right)\right) \]

    unpow2 [=>]95.3

    \[ -0.3333333333333333 \cdot \mathsf{fma}\left(1.6875, \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}, \mathsf{fma}\left(1.125, \frac{a \cdot \color{blue}{\left(c \cdot c\right)}}{{b}^{3}}, 1.5 \cdot \frac{c}{b} + 0.5 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}}\right)\right) \]

    fma-def [=>]95.5

    \[ -0.3333333333333333 \cdot \mathsf{fma}\left(1.6875, \frac{{c}^{3} \cdot \left(a \cdot a\right)}{{b}^{5}}, \mathsf{fma}\left(1.125, \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}, \color{blue}{\mathsf{fma}\left(1.5, \frac{c}{b}, 0.5 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}}\right)}\right)\right) \]
  5. Taylor expanded in c around 0 95.7%

    \[\leadsto \color{blue}{-0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(-0.16666666666666666 \cdot \frac{{c}^{4} \cdot \left(1.265625 \cdot {a}^{4} + 5.0625 \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)\right)} \]
  6. Simplified95.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5, \frac{c}{b}, \mathsf{fma}\left(\frac{-0.16666666666666666}{a}, \frac{{\left(c \cdot a\right)}^{4} \cdot 6.328125}{{b}^{7}}, \mathsf{fma}\left(-0.375, \frac{a}{{b}^{3}} \cdot \left(c \cdot c\right), -0.5625 \cdot \left(\frac{a}{{b}^{5}} \cdot \left(a \cdot {c}^{3}\right)\right)\right)\right)\right)} \]
    Proof

    [Start]95.7

    \[ -0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(-0.16666666666666666 \cdot \frac{{c}^{4} \cdot \left(1.265625 \cdot {a}^{4} + 5.0625 \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)\right) \]

    +-commutative [=>]95.7

    \[ -0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \color{blue}{\left(\left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right) + -0.16666666666666666 \cdot \frac{{c}^{4} \cdot \left(1.265625 \cdot {a}^{4} + 5.0625 \cdot {a}^{4}\right)}{a \cdot {b}^{7}}\right)} \]

    associate-+r+ [=>]95.7

    \[ \color{blue}{\left(-0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)\right) + -0.16666666666666666 \cdot \frac{{c}^{4} \cdot \left(1.265625 \cdot {a}^{4} + 5.0625 \cdot {a}^{4}\right)}{a \cdot {b}^{7}}} \]

    associate-+r+ [=>]95.7

    \[ \color{blue}{\left(\left(-0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + -0.5 \cdot \frac{c}{b}\right) + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)} + -0.16666666666666666 \cdot \frac{{c}^{4} \cdot \left(1.265625 \cdot {a}^{4} + 5.0625 \cdot {a}^{4}\right)}{a \cdot {b}^{7}} \]

    associate-/r* [=>]95.7

    \[ \left(\left(-0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + -0.5 \cdot \frac{c}{b}\right) + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right) + -0.16666666666666666 \cdot \color{blue}{\frac{\frac{{c}^{4} \cdot \left(1.265625 \cdot {a}^{4} + 5.0625 \cdot {a}^{4}\right)}{a}}{{b}^{7}}} \]

    associate-*r/ [=>]95.7

    \[ \left(\left(-0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + -0.5 \cdot \frac{c}{b}\right) + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right) + \color{blue}{\frac{-0.16666666666666666 \cdot \frac{{c}^{4} \cdot \left(1.265625 \cdot {a}^{4} + 5.0625 \cdot {a}^{4}\right)}{a}}{{b}^{7}}} \]
  7. Final simplification95.8%

    \[\leadsto \mathsf{fma}\left(-0.5, \frac{c}{b}, \mathsf{fma}\left(\frac{-0.16666666666666666}{a}, \frac{{\left(c \cdot a\right)}^{4} \cdot 6.328125}{{b}^{7}}, \mathsf{fma}\left(-0.375, \frac{a}{{b}^{3}} \cdot \left(c \cdot c\right), -0.5625 \cdot \left(\frac{a}{{b}^{5}} \cdot \left(a \cdot {c}^{3}\right)\right)\right)\right)\right) \]

Alternatives

Alternative 1
Accuracy95.7%
Cost47296
\[\mathsf{fma}\left(-0.5625, \left(c \cdot c\right) \cdot \left(c \cdot \frac{a \cdot a}{{b}^{5}}\right), \mathsf{fma}\left(-0.16666666666666666, \frac{{\left(c \cdot a\right)}^{4}}{\frac{a \cdot {b}^{7}}{6.328125}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}\right)\right)\right) \]
Alternative 2
Accuracy94.0%
Cost33536
\[\mathsf{fma}\left(-0.5625, a \cdot \left(a \cdot \frac{{c}^{3}}{{b}^{5}}\right), \mathsf{fma}\left(-0.375, \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}, \frac{-0.5}{\frac{b}{c}}\right)\right) \]
Alternative 3
Accuracy94.3%
Cost33536
\[\mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{c \cdot c}{\frac{{b}^{3}}{a}}\right)\right) \]
Alternative 4
Accuracy91.1%
Cost13696
\[\mathsf{fma}\left(-0.375, a \cdot \frac{c \cdot c}{{b}^{3}}, -0.5 \cdot \frac{c}{b}\right) \]
Alternative 5
Accuracy90.8%
Cost1600
\[\frac{-0.5 \cdot \frac{c \cdot a}{b} + -0.375 \cdot \left(\frac{c \cdot c}{b \cdot b} \cdot \frac{a \cdot a}{b}\right)}{a} \]
Alternative 6
Accuracy81.5%
Cost320
\[c \cdot \frac{-0.5}{b} \]
Alternative 7
Accuracy81.5%
Cost320
\[\frac{-0.5}{\frac{b}{c}} \]
Alternative 8
Accuracy81.7%
Cost320
\[\frac{-0.5 \cdot c}{b} \]

Error

Reproduce?

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