?

Average Accuracy: 17.9% → 99.5%
Time: 14.2s
Precision: binary64
Cost: 13952

?

\[\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{2}{a} \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\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
 (/ (* (/ 2.0 a) (* a c)) (- (- b) (sqrt (fma b b (* c (* a -4.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) {
	return ((2.0 / a) * (a * c)) / (-b - sqrt(fma(b, b, (c * (a * -4.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)
	return Float64(Float64(Float64(2.0 / a) * Float64(a * c)) / Float64(Float64(-b) - sqrt(fma(b, b, Float64(c * Float64(a * -4.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_] := N[(N[(N[(2.0 / a), $MachinePrecision] * N[(a * c), $MachinePrecision]), $MachinePrecision] / N[((-b) - N[Sqrt[N[(b * b + N[(c * N[(a * -4.0), $MachinePrecision]), $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{2}{a} \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)}}

Error?

Derivation?

  1. Initial program 17.9%

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

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

    [Start]17.9

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

    *-commutative [=>]17.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.4%

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

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

    [Start]18.4

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

    associate-/l/ [=>]18.4

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

    fma-def [<=]18.4

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

    +-commutative [=>]18.4

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

    fma-def [=>]18.4

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

    distribute-lft-neg-in [<=]18.4

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

    rem-square-sqrt [=>]18.4

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

    fma-def [<=]18.4

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

    +-commutative [=>]18.4

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

    fma-def [=>]18.4

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

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

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

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

    [Start]99.3

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

    *-commutative [=>]99.3

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

    *-commutative [=>]99.3

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

    associate-/r* [=>]99.3

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

    metadata-eval [=>]99.3

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

    metadata-eval [<=]99.3

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

    associate-/r* [<=]99.3

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

    associate-/l/ [<=]99.3

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

    associate-*l/ [=>]99.3

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

    associate-*r* [=>]99.3

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

    *-commutative [<=]99.3

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

    /-rgt-identity [<=]99.3

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

    associate-*r/ [=>]99.5

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

    /-rgt-identity [=>]99.5

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

    associate-/l/ [=>]99.5

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

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

Alternatives

Alternative 1
Accuracy99.4%
Cost7808
\[\frac{\frac{\left(a \cdot c\right) \cdot 4}{\left(-b\right) - \sqrt{c \cdot \left(a \cdot -4\right) + b \cdot b}}}{2 \cdot a} \]
Alternative 2
Accuracy95.4%
Cost7232
\[\left(-\frac{c}{b}\right) - a \cdot \frac{c \cdot c}{{b}^{3}} \]
Alternative 3
Accuracy95.2%
Cost1600
\[\frac{-2 \cdot \left(\frac{c \cdot c}{\frac{b \cdot b}{a} \cdot \frac{b}{a}} + a \cdot \frac{c}{b}\right)}{2 \cdot a} \]
Alternative 4
Accuracy95.1%
Cost1344
\[\frac{\frac{\left(a \cdot c\right) \cdot 4}{b \cdot -2 - -2 \cdot \frac{a \cdot c}{b}}}{2 \cdot a} \]
Alternative 5
Accuracy90.4%
Cost256
\[-\frac{c}{b} \]
Alternative 6
Accuracy1.7%
Cost192
\[\frac{c}{b} \]

Error

Reproduce?

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