?

Average Accuracy: 31.6% → 99.1%
Time: 16.7s
Precision: binary64
Cost: 34624

?

\[\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(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
\[\begin{array}{l} t_0 := \mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)\\ \frac{\frac{\mathsf{fma}\left(-8, c \cdot \left(a \cdot \left(b \cdot b\right)\right), 16 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}{\left(b + \sqrt{t_0}\right) \cdot \mathsf{fma}\left(b, b, t_0\right)}}{a \cdot 2} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (fma c (* a -4.0) (* b b))))
   (/
    (/
     (fma -8.0 (* c (* a (* b b))) (* 16.0 (* (* c c) (* a a))))
     (* (+ b (sqrt t_0)) (fma b b t_0)))
    (* a 2.0))))
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) {
	double t_0 = fma(c, (a * -4.0), (b * b));
	return (fma(-8.0, (c * (a * (b * b))), (16.0 * ((c * c) * (a * a)))) / ((b + sqrt(t_0)) * fma(b, b, t_0))) / (a * 2.0);
}
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)
	t_0 = fma(c, Float64(a * -4.0), Float64(b * b))
	return Float64(Float64(fma(-8.0, Float64(c * Float64(a * Float64(b * b))), Float64(16.0 * Float64(Float64(c * c) * Float64(a * a)))) / Float64(Float64(b + sqrt(t_0)) * fma(b, b, t_0))) / Float64(a * 2.0))
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_] := Block[{t$95$0 = N[(c * N[(a * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(-8.0 * N[(c * N[(a * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(16.0 * N[(N[(c * c), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(b + N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision] * N[(b * b + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\begin{array}{l}
t_0 := \mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)\\
\frac{\frac{\mathsf{fma}\left(-8, c \cdot \left(a \cdot \left(b \cdot b\right)\right), 16 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}{\left(b + \sqrt{t_0}\right) \cdot \mathsf{fma}\left(b, b, t_0\right)}}{a \cdot 2}
\end{array}

Error?

Derivation?

  1. Initial program 31.6%

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

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

    [Start]31.6

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

    +-commutative [=>]31.6

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

    unsub-neg [=>]31.6

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

    fma-neg [=>]31.6

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

    *-commutative [=>]31.6

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

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

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

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

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

    *-commutative [<=]31.6

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

    metadata-eval [=>]31.6

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

    *-commutative [=>]31.6

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

    \[\leadsto \frac{\color{blue}{{\left({\left(\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)\right)}^{1.5}\right)}^{0.3333333333333333}} - b}{a \cdot 2} \]
  4. Simplified31.1%

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

    [Start]32.2

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

    unpow1/3 [=>]31.2

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

    fma-def [<=]31.1

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

    +-commutative [=>]31.1

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

    fma-def [=>]31.1

    \[ \frac{\sqrt[3]{{\color{blue}{\left(\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)\right)}}^{1.5}} - b}{a \cdot 2} \]
  5. Applied egg-rr32.8%

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

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

    [Start]32.8

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

    fma-def [=>]32.8

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

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

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

    [Start]99.1

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

    fma-def [=>]99.1

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

    unpow2 [=>]99.1

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

    unpow2 [=>]99.1

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

    unpow2 [=>]99.1

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

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

Alternatives

Alternative 1
Accuracy95.2%
Cost28288
\[\frac{\frac{\mathsf{fma}\left(-8, c \cdot \left(a \cdot \left(b \cdot b\right)\right), 16 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}{\mathsf{fma}\left(a \cdot a, 4 \cdot \frac{c}{\frac{b}{c}}, \mathsf{fma}\left(4, {b}^{3}, c \cdot \left(a \cdot \left(b \cdot -12\right)\right)\right)\right)}}{a \cdot 2} \]
Alternative 2
Accuracy93.7%
Cost20736
\[\left(\frac{\left(a \cdot \left(a \cdot -2\right)\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - a \cdot \frac{c \cdot c}{{b}^{3}} \]
Alternative 3
Accuracy93.7%
Cost20672
\[{\left(2 \cdot \mathsf{fma}\left(0.5, \frac{a}{b}, \frac{b}{c} \cdot -0.5 + c \cdot \frac{\left(a \cdot a\right) \cdot 0.5}{{b}^{3}}\right)\right)}^{-1} \]
Alternative 4
Accuracy90.6%
Cost7296
\[{\left(2 \cdot \left(\frac{b}{c} \cdot -0.5 + 0.5 \cdot \frac{a}{b}\right)\right)}^{-1} \]
Alternative 5
Accuracy90.5%
Cost7104
\[\frac{c + a \cdot {\left(\frac{c}{b}\right)}^{2}}{-b} \]
Alternative 6
Accuracy90.5%
Cost1024
\[\frac{-c}{b} - \frac{\frac{c \cdot \left(c \cdot a\right)}{b \cdot b}}{b} \]
Alternative 7
Accuracy81.1%
Cost256
\[\frac{-c}{b} \]
Alternative 8
Accuracy1.6%
Cost192
\[\frac{c}{b} \]

Error

Reproduce?

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