?

Average Error: 52.4 → 0.4
Time: 14.1s
Precision: binary64
Cost: 34624

?

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

Error?

Derivation?

  1. Initial program 52.4

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

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

    [Start]52.4

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

    *-commutative [=>]52.4

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

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(b - \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)}\right) \cdot \frac{-0.5}{a}\right)} - 1} \]
  4. Simplified52.4

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

    [Start]58.9

    \[ e^{\mathsf{log1p}\left(\left(b - \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)}\right) \cdot \frac{-0.5}{a}\right)} - 1 \]

    expm1-def [=>]56.3

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

    expm1-log1p [=>]52.4

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

    fma-def [<=]52.4

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

    +-commutative [=>]52.4

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

    fma-def [=>]52.4

    \[ \left(b - \sqrt{\color{blue}{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}\right) \cdot \frac{-0.5}{a} \]
  5. Applied egg-rr51.7

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

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

    [Start]51.7

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

    fma-def [<=]51.7

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

    +-commutative [=>]51.7

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

    fma-def [=>]51.6

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

    *-commutative [<=]51.6

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

    associate-*l* [=>]51.6

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

    fma-def [<=]51.6

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

    +-commutative [=>]51.6

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

    fma-def [=>]51.6

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

    fma-def [=>]51.6

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

    fma-def [<=]51.6

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

    +-commutative [=>]51.6

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

    fma-def [=>]51.6

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

    \[\leadsto \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(b, b, c \cdot \left(a \cdot -4\right)\right)}\right) \cdot \left(\left(a \cdot -2\right) \cdot \mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)\right)\right)} \]
  8. Simplified0.4

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

    [Start]0.4

    \[ \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(b, b, c \cdot \left(a \cdot -4\right)\right)}\right) \cdot \left(\left(a \cdot -2\right) \cdot \mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)\right)\right)} \]

    +-commutative [=>]0.4

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

    fma-def [=>]0.4

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

    unpow2 [=>]0.4

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

    unpow2 [=>]0.4

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

    associate-*r* [=>]0.4

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

    unpow2 [=>]0.4

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

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

Alternatives

Alternative 1
Error1.6
Cost34624
\[\left(\mathsf{fma}\left(-0.25, \frac{{a}^{3}}{\frac{{b}^{7}}{{c}^{4} \cdot 20}}, c \cdot \frac{a \cdot \left(a \cdot -2\right)}{\frac{{b}^{5}}{c \cdot c}}\right) - \frac{c}{b}\right) - a \cdot \left(\frac{c}{b} \cdot \frac{c}{b \cdot b}\right) \]
Alternative 2
Error2.1
Cost14528
\[\left(\frac{\left(a \cdot \left(a \cdot -2\right)\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{\frac{\left(c \cdot c\right) \cdot a}{b \cdot b}}{b} \]
Alternative 3
Error2.4
Cost14208
\[\frac{\frac{-0.5}{a}}{\mathsf{fma}\left(0.5, \frac{\frac{b}{c}}{a}, \frac{-0.5}{b}\right) + -0.5 \cdot \left(c \cdot \frac{a}{{b}^{3}}\right)} \]
Alternative 4
Error2.3
Cost8320
\[\frac{\frac{-0.5}{a}}{\left(\frac{0.5 \cdot \left(c \cdot a\right) - c \cdot a}{{b}^{3}} + 0.5 \cdot \frac{b}{c \cdot a}\right) + -0.5 \cdot \frac{1}{b}} \]
Alternative 5
Error3.2
Cost1024
\[\frac{-c}{b} - \frac{\frac{\left(c \cdot c\right) \cdot a}{b \cdot b}}{b} \]
Alternative 6
Error3.4
Cost960
\[\frac{\frac{-0.5}{a}}{\frac{b \cdot 0.5}{c \cdot a} + \frac{-0.5}{b}} \]
Alternative 7
Error6.3
Cost256
\[\frac{-c}{b} \]

Error

Reproduce?

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