?

Average Accuracy: 56.0% → 99.3%
Time: 16.0s
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(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
\[-4 \cdot \frac{c \cdot a}{a \cdot \left(2 \cdot \left(b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}\right)\right)} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
(FPCore (a b c)
 :precision binary64
 (* -4.0 (/ (* c a) (* a (* 2.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 -4.0 * ((c * a) / (a * (2.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(-4.0 * Float64(Float64(c * a) / Float64(a * Float64(2.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[(-4.0 * N[(N[(c * a), $MachinePrecision] / N[(a * N[(2.0 * N[(b + N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
-4 \cdot \frac{c \cdot a}{a \cdot \left(2 \cdot \left(b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}\right)\right)}

Error?

Derivation?

  1. Initial program 56.0%

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

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

    [Start]56.0

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

    *-commutative [=>]56.0

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

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

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

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

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

    [Start]99.2

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

    pow-sqr [=>]99.3

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

    metadata-eval [=>]99.3

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

    unpow1/2 [=>]99.3

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

    fma-def [<=]99.3

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

    +-commutative [=>]99.3

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

    fma-def [=>]99.3

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

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

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

Alternatives

Alternative 1
Accuracy99.3%
Cost14016
\[\frac{c \cdot -4}{a \cdot 2} \cdot \frac{a}{b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \]
Alternative 2
Accuracy99.3%
Cost13888
\[\frac{a \cdot \left(c \cdot \frac{-2}{a}\right)}{b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}} \]
Alternative 3
Accuracy99.3%
Cost7744
\[\begin{array}{l} t_0 := \left(c \cdot a\right) \cdot -4\\ \frac{\frac{t_0}{b + \sqrt{b \cdot b + t_0}}}{a \cdot 2} \end{array} \]
Alternative 4
Accuracy85.2%
Cost7492
\[\begin{array}{l} \mathbf{if}\;b \leq 3.2:\\ \;\;\;\;\left(\sqrt{b \cdot b + a \cdot \left(c \cdot -4\right)} - b\right) \cdot \frac{0.5}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left(c \cdot a\right) \cdot -4}{-2 \cdot \frac{c \cdot a}{b} + 2 \cdot b}}{a \cdot 2}\\ \end{array} \]
Alternative 5
Accuracy85.2%
Cost7492
\[\begin{array}{l} \mathbf{if}\;b \leq 3.15:\\ \;\;\;\;\frac{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left(c \cdot a\right) \cdot -4}{-2 \cdot \frac{c \cdot a}{b} + 2 \cdot b}}{a \cdot 2}\\ \end{array} \]
Alternative 6
Accuracy81.8%
Cost1344
\[\frac{\frac{\left(c \cdot a\right) \cdot -4}{b + \left(b + -2 \cdot \left(a \cdot \frac{c}{b}\right)\right)}}{a \cdot 2} \]
Alternative 7
Accuracy81.8%
Cost1344
\[\frac{\frac{\left(c \cdot a\right) \cdot -4}{-2 \cdot \frac{c \cdot a}{b} + 2 \cdot b}}{a \cdot 2} \]
Alternative 8
Accuracy63.9%
Cost256
\[\frac{-c}{b} \]
Alternative 9
Accuracy1.6%
Cost192
\[\frac{c}{b} \]

Error

Reproduce?

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