?

Average Accuracy: 18.2% → 99.0%
Time: 16.6s
Precision: binary64
Cost: 40256

?

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

Error?

Derivation?

  1. Initial program 18.2%

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

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

    [Start]18.2

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

    *-commutative [=>]18.2

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

    \[\leadsto \frac{\color{blue}{\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, 4 \cdot \left(a \cdot c\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} \]
    Proof

    [Start]18.2

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

    +-commutative [=>]18.2

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

    flip-+ [=>]18.2

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

    add-sqr-sqrt [=>]0.0

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

    sqrt-unprod [=>]0.4

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

    sqr-neg [=>]0.4

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

    sqrt-prod [=>]1.7

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

    add-sqr-sqrt [<=]0.4

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

    unsub-neg [<=]0.4

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

    +-commutative [<=]0.4

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

    add-sqr-sqrt [=>]0.0

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

    associate-/r* [=>]0.0

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

    \[\leadsto \frac{\frac{\frac{\color{blue}{-4 \cdot \left(c \cdot a\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} \]
  5. Final simplification99.0%

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

Alternatives

Alternative 1
Accuracy96.8%
Cost14528
\[\left(\frac{\left(a \cdot \left(a \cdot -2\right)\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{\frac{\frac{a}{b}}{b}}{\frac{\frac{b}{c}}{c}} \]
Alternative 2
Accuracy95.2%
Cost7232
\[\frac{-c}{b} - a \cdot \frac{c \cdot c}{{b}^{3}} \]
Alternative 3
Accuracy94.7%
Cost1728
\[\frac{-2 \cdot \left(\frac{c \cdot c}{b \cdot b} \cdot \frac{a \cdot a}{b}\right) + -2 \cdot \frac{c \cdot a}{b}}{a \cdot 2} \]
Alternative 4
Accuracy94.6%
Cost1600
\[\left(-2 \cdot \left(\frac{c \cdot c}{\frac{b \cdot b}{a} \cdot \frac{b}{a}} + \frac{c}{\frac{b}{a}}\right)\right) \cdot \frac{0.5}{a} \]
Alternative 5
Accuracy90.1%
Cost256
\[\frac{-c}{b} \]

Error

Reproduce?

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