?

Average Accuracy: 18.9% → 99.5%
Time: 19.5s
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(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
\[\frac{\frac{-0.5}{a} \cdot \left(a \cdot \left(c \cdot 4\right)\right)}{b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
(FPCore (a b c)
 :precision binary64
 (/ (* (/ -0.5 a) (* a (* c 4.0))) (+ b (sqrt (fma c (* a -4.0) (* b b))))))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
double code(double a, double b, double c) {
	return ((-0.5 / a) * (a * (c * 4.0))) / (b + sqrt(fma(c, (a * -4.0), (b * b))));
}
function code(a, b, c)
	return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a))
end
function code(a, b, c)
	return Float64(Float64(Float64(-0.5 / a) * Float64(a * Float64(c * 4.0))) / Float64(b + sqrt(fma(c, Float64(a * -4.0), Float64(b * b)))))
end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
code[a_, b_, c_] := N[(N[(N[(-0.5 / a), $MachinePrecision] * N[(a * N[(c * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(b + N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\frac{\frac{-0.5}{a} \cdot \left(a \cdot \left(c \cdot 4\right)\right)}{b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}

Error?

Derivation?

  1. Initial program 18.9%

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

    \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}} \]
    Proof

    [Start]18.9

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

    *-commutative [=>]18.9

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

    \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\frac{{b}^{4} - \left(c \cdot \left(a \cdot -4\right)\right) \cdot \left(c \cdot \left(a \cdot -4\right)\right)}{b \cdot b - c \cdot \left(a \cdot -4\right)}}}}{a \cdot 2} \]
    Proof

    [Start]18.9

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

    sub-neg [=>]18.9

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

    flip-+ [=>]18.9

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

    pow2 [=>]18.9

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

    pow2 [=>]18.9

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

    pow-sqr [=>]18.8

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

    metadata-eval [=>]18.8

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

    distribute-lft-neg-in [=>]18.8

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

    distribute-lft-neg-in [=>]18.8

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

    *-commutative [=>]18.8

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

    *-commutative [=>]18.8

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

    distribute-rgt-neg-in [=>]18.8

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

    metadata-eval [=>]18.8

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

    *-commutative [=>]18.8

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

    *-commutative [=>]18.8

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

    distribute-rgt-neg-in [=>]18.8

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

    metadata-eval [=>]18.8

    \[ \frac{\left(-b\right) + \sqrt{\frac{{b}^{4} - \left(c \cdot \left(a \cdot -4\right)\right) \cdot \left(c \cdot \left(a \cdot \color{blue}{-4}\right)\right)}{b \cdot b - \left(-\left(4 \cdot a\right) \cdot c\right)}}}{a \cdot 2} \]
  4. Applied egg-rr19.3%

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

    [Start]18.8

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

    +-commutative [=>]18.8

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

    flip-+ [=>]18.7

    \[ \frac{\color{blue}{\frac{\sqrt{\frac{{b}^{4} - \left(c \cdot \left(a \cdot -4\right)\right) \cdot \left(c \cdot \left(a \cdot -4\right)\right)}{b \cdot b - c \cdot \left(a \cdot -4\right)}} \cdot \sqrt{\frac{{b}^{4} - \left(c \cdot \left(a \cdot -4\right)\right) \cdot \left(c \cdot \left(a \cdot -4\right)\right)}{b \cdot b - c \cdot \left(a \cdot -4\right)}} - \left(-b\right) \cdot \left(-b\right)}{\sqrt{\frac{{b}^{4} - \left(c \cdot \left(a \cdot -4\right)\right) \cdot \left(c \cdot \left(a \cdot -4\right)\right)}{b \cdot b - c \cdot \left(a \cdot -4\right)}} - \left(-b\right)}}}{a \cdot 2} \]
  5. Simplified19.4%

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

    [Start]19.3

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

    fma-def [<=]19.4

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

    +-commutative [<=]19.4

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

    *-commutative [=>]19.4

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

    fma-def [=>]19.4

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

    fma-def [<=]19.4

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

    +-commutative [<=]19.4

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

    *-commutative [=>]19.4

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

    fma-def [=>]19.4

    \[ \frac{\frac{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right) - b \cdot b}{b + \sqrt{\color{blue}{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)}}}}{a \cdot 2} \]
  6. Applied egg-rr19.4%

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

    [Start]19.4

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

    frac-2neg [=>]19.4

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

    div-inv [=>]19.4

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

    distribute-neg-frac [=>]19.4

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

    distribute-rgt-neg-in [=>]19.4

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

    metadata-eval [=>]19.4

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

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

    [Start]19.4

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

    *-commutative [<=]19.4

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

    associate-*r/ [=>]19.4

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

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

Alternatives

Alternative 1
Accuracy99.4%
Cost14016
\[\frac{\frac{c \cdot \left(a \cdot -4\right)}{b + \sqrt{\mathsf{fma}\left(a \cdot c, -4, b \cdot b\right)}}}{a \cdot 2} \]
Alternative 2
Accuracy95.0%
Cost7232
\[\frac{-c}{b} - a \cdot \frac{c \cdot c}{{b}^{3}} \]
Alternative 3
Accuracy89.7%
Cost256
\[\frac{-c}{b} \]
Alternative 4
Accuracy1.7%
Cost192
\[\frac{c}{b} \]

Error

Reproduce?

herbie shell --seed 2023135 
(FPCore (a b c)
  :name "Quadratic roots, 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) (* (* 4.0 a) c)))) (* 2.0 a)))