?

Average Error: 82.31% → 2.29%
Time: 14.8s
Precision: binary64
Cost: 41344

?

\[\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 := {\left(c \cdot a\right)}^{4}\\ \mathsf{fma}\left(-0.25, \frac{4 \cdot t_0 + t_0 \cdot 16}{a \cdot {b}^{7}}, \frac{\left(a \cdot \left(a \cdot -2\right)\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - a \cdot \left(\frac{c}{b} \cdot \frac{c}{b \cdot b}\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 (pow (* c a) 4.0)))
   (-
    (fma
     -0.25
     (/ (+ (* 4.0 t_0) (* t_0 16.0)) (* a (pow b 7.0)))
     (- (/ (* (* a (* a -2.0)) (pow c 3.0)) (pow b 5.0)) (/ c b)))
    (* a (* (/ c b) (/ c (* 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) {
	double t_0 = pow((c * a), 4.0);
	return fma(-0.25, (((4.0 * t_0) + (t_0 * 16.0)) / (a * pow(b, 7.0))), ((((a * (a * -2.0)) * pow(c, 3.0)) / pow(b, 5.0)) - (c / b))) - (a * ((c / b) * (c / (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)
	t_0 = Float64(c * a) ^ 4.0
	return Float64(fma(-0.25, Float64(Float64(Float64(4.0 * t_0) + Float64(t_0 * 16.0)) / Float64(a * (b ^ 7.0))), Float64(Float64(Float64(Float64(a * Float64(a * -2.0)) * (c ^ 3.0)) / (b ^ 5.0)) - Float64(c / b))) - Float64(a * Float64(Float64(c / b) * Float64(c / 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_] := Block[{t$95$0 = N[Power[N[(c * a), $MachinePrecision], 4.0], $MachinePrecision]}, N[(N[(-0.25 * N[(N[(N[(4.0 * t$95$0), $MachinePrecision] + N[(t$95$0 * 16.0), $MachinePrecision]), $MachinePrecision] / N[(a * N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(a * N[(a * -2.0), $MachinePrecision]), $MachinePrecision] * N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision] - N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a * N[(N[(c / b), $MachinePrecision] * N[(c / N[(b * b), $MachinePrecision]), $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 := {\left(c \cdot a\right)}^{4}\\
\mathsf{fma}\left(-0.25, \frac{4 \cdot t_0 + t_0 \cdot 16}{a \cdot {b}^{7}}, \frac{\left(a \cdot \left(a \cdot -2\right)\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - a \cdot \left(\frac{c}{b} \cdot \frac{c}{b \cdot b}\right)
\end{array}

Error?

Derivation?

  1. Initial program 82.31

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

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

    [Start]82.31

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

    *-commutative [=>]82.31

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

    \[\leadsto \color{blue}{-1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + \left(-0.25 \cdot \frac{{\left(-2 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-1 \cdot \frac{c}{b} + -2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}\right)\right)} \]
  4. Simplified2.29

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

    [Start]2.29

    \[ -1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + \left(-0.25 \cdot \frac{{\left(-2 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-1 \cdot \frac{c}{b} + -2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}\right)\right) \]

    +-commutative [=>]2.29

    \[ \color{blue}{\left(-0.25 \cdot \frac{{\left(-2 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-1 \cdot \frac{c}{b} + -2 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}\right)\right) + -1 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}} \]
  5. Applied egg-rr2.54

    \[\leadsto \mathsf{fma}\left(-0.25, \frac{4 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(c \cdot a\right)}^{4}\right)} - 1\right)} + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a \]
  6. Simplified2.29

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

    [Start]2.54

    \[ \mathsf{fma}\left(-0.25, \frac{4 \cdot \left(e^{\mathsf{log1p}\left({\left(c \cdot a\right)}^{4}\right)} - 1\right) + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a \]

    expm1-def [=>]2.29

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

    expm1-log1p [=>]2.29

    \[ \mathsf{fma}\left(-0.25, \frac{4 \cdot \color{blue}{{\left(c \cdot a\right)}^{4}} + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a \]
  7. Applied egg-rr2.63

    \[\leadsto \mathsf{fma}\left(-0.25, \frac{4 \cdot {\left(c \cdot a\right)}^{4} + 16 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(c \cdot a\right)}^{4}\right)} - 1\right)}}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a \]
  8. Simplified2.29

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

    [Start]2.63

    \[ \mathsf{fma}\left(-0.25, \frac{4 \cdot {\left(c \cdot a\right)}^{4} + 16 \cdot \left(e^{\mathsf{log1p}\left({\left(c \cdot a\right)}^{4}\right)} - 1\right)}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a \]

    expm1-def [=>]2.29

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

    expm1-log1p [=>]2.29

    \[ \mathsf{fma}\left(-0.25, \frac{4 \cdot {\left(c \cdot a\right)}^{4} + 16 \cdot \color{blue}{{\left(c \cdot a\right)}^{4}}}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \frac{c \cdot c}{{b}^{3}} \cdot a \]
  9. Applied egg-rr2.29

    \[\leadsto \mathsf{fma}\left(-0.25, \frac{4 \cdot {\left(c \cdot a\right)}^{4} + 16 \cdot {\left(c \cdot a\right)}^{4}}{a \cdot {b}^{7}}, \frac{\left(\left(a \cdot -2\right) \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{c}{b}\right) - \color{blue}{\left(\frac{c}{b \cdot b} \cdot \frac{c}{b}\right)} \cdot a \]
  10. Final simplification2.29

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

Alternatives

Alternative 1
Error3.04%
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
Error4.54%
Cost1024
\[\frac{-c}{b} - \frac{a}{\frac{b}{c} \cdot \frac{b \cdot b}{c}} \]
Alternative 3
Error9.49%
Cost256
\[\frac{-c}{b} \]
Alternative 4
Error96.73%
Cost64
\[0 \]

Error

Reproduce?

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