?

Average Error: 44.51% → 0.86%
Time: 20.7s
Precision: binary64
Cost: 14016

?

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

Error?

Derivation?

  1. Initial program 44.51

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

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

    [Start]44.51

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

    *-lft-identity [<=]44.51

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

    metadata-eval [<=]44.51

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

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

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

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

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

    *-commutative [=>]44.52

    \[ \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-rr43.24

    \[\leadsto \frac{\color{blue}{\frac{\left({b}^{4} - {\left(\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)\right)}^{2}\right) \cdot \frac{1}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}}{b \cdot b + \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}}{a} \cdot -0.3333333333333333 \]
  4. Taylor expanded in b around 0 1.21

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

    \[\leadsto \color{blue}{\frac{-0.3333333333333333}{a \cdot \left(\left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right) \cdot \frac{\mathsf{fma}\left(b, b, \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)\right)}{\mathsf{fma}\left(6, c \cdot \left(a \cdot \left(b \cdot b\right)\right), {\left(c \cdot a\right)}^{2} \cdot -9\right)}\right)}} \]
  6. Simplified1.12

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

    [Start]1.13

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

    associate-/r* [=>]1.12

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

    associate-*r* [=>]1.12

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

    *-commutative [=>]1.12

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

    unpow2 [<=]1.12

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

    associate-*l* [=>]1.12

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

    unpow2 [=>]1.12

    \[ \frac{\frac{-0.3333333333333333}{a}}{\left(b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}\right) \cdot \frac{\mathsf{fma}\left(b, b, \mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)\right)}{\mathsf{fma}\left(6, a \cdot \left(c \cdot \color{blue}{\left(b \cdot b\right)}\right), {\left(c \cdot a\right)}^{2} \cdot -9\right)}} \]
  7. Taylor expanded in b around 0 0.86

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

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

Alternatives

Alternative 1
Error15.42%
Cost13764
\[\begin{array}{l} \mathbf{if}\;b \leq 0.11:\\ \;\;\;\;\frac{\frac{b - \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}{a}}{-3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-0.3333333333333333}{a}}{\frac{1}{b} + \mathsf{fma}\left(0.6666666666666666, \frac{b}{a \cdot c}, \frac{0.16666666666666666 \cdot \left(\left(a \cdot b\right) \cdot -9\right)}{a \cdot \left(b \cdot b\right)}\right)}\\ \end{array} \]
Alternative 2
Error15.43%
Cost13764
\[\begin{array}{l} \mathbf{if}\;b \leq 0.108:\\ \;\;\;\;\frac{\frac{b - \sqrt{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}}{-3}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-0.3333333333333333}{a}}{\frac{1}{b} + \mathsf{fma}\left(0.6666666666666666, \frac{b}{a \cdot c}, \frac{0.16666666666666666 \cdot \left(\left(a \cdot b\right) \cdot -9\right)}{a \cdot \left(b \cdot b\right)}\right)}\\ \end{array} \]
Alternative 3
Error15.42%
Cost8260
\[\begin{array}{l} \mathbf{if}\;b \leq 0.11:\\ \;\;\;\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-0.3333333333333333}{a}}{\frac{1}{b} + \mathsf{fma}\left(0.6666666666666666, \frac{b}{a \cdot c}, \frac{0.16666666666666666 \cdot \left(\left(a \cdot b\right) \cdot -9\right)}{a \cdot \left(b \cdot b\right)}\right)}\\ \end{array} \]
Alternative 4
Error15.46%
Cost7492
\[\begin{array}{l} \mathbf{if}\;b \leq 0.108:\\ \;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{b \cdot b + a \cdot \left(c \cdot -3\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-0.3333333333333333}{a}}{0.16666666666666666 \cdot \frac{\left(a \cdot c\right) \cdot -6 + -3 \cdot \left(a \cdot c\right)}{c \cdot \left(a \cdot b\right)} + \left(\frac{1}{b} + 0.6666666666666666 \cdot \frac{b}{a \cdot c}\right)}\\ \end{array} \]
Alternative 5
Error15.46%
Cost7492
\[\begin{array}{l} \mathbf{if}\;b \leq 0.108:\\ \;\;\;\;\frac{-0.3333333333333333 \cdot \left(b - \sqrt{b \cdot b + a \cdot \left(c \cdot -3\right)}\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-0.3333333333333333}{a}}{0.16666666666666666 \cdot \frac{\left(a \cdot c\right) \cdot -6 + -3 \cdot \left(a \cdot c\right)}{c \cdot \left(a \cdot b\right)} + \left(\frac{1}{b} + 0.6666666666666666 \cdot \frac{b}{a \cdot c}\right)}\\ \end{array} \]
Alternative 6
Error15.45%
Cost7492
\[\begin{array}{l} \mathbf{if}\;b \leq 0.11:\\ \;\;\;\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-0.3333333333333333}{a}}{0.16666666666666666 \cdot \frac{\left(a \cdot c\right) \cdot -6 + -3 \cdot \left(a \cdot c\right)}{c \cdot \left(a \cdot b\right)} + \left(\frac{1}{b} + 0.6666666666666666 \cdot \frac{b}{a \cdot c}\right)}\\ \end{array} \]
Alternative 7
Error18.38%
Cost2240
\[\frac{\frac{-0.3333333333333333}{a}}{0.16666666666666666 \cdot \frac{\left(a \cdot c\right) \cdot -6 + -3 \cdot \left(a \cdot c\right)}{c \cdot \left(a \cdot b\right)} + \left(\frac{1}{b} + 0.6666666666666666 \cdot \frac{b}{a \cdot c}\right)} \]
Alternative 8
Error35.77%
Cost320
\[-0.5 \cdot \frac{c}{b} \]

Error

Reproduce?

herbie shell --seed 2023089 
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :precision binary64
  :pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))