| Alternative 1 | |
|---|---|
| Error | 7.4 |
| Cost | 7564 |
(FPCore (a b_2 c) :precision binary64 (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
(FPCore (a b_2 c)
:precision binary64
(let* ((t_0 (sqrt (- (* b_2 b_2) (* a c)))))
(if (<= b_2 -3.05e+41)
(/ (* b_2 -2.0) a)
(if (<= b_2 -1.65e-141)
(/ (- t_0 b_2) a)
(if (<= b_2 1e+138)
(/ (- c) (+ b_2 t_0))
(fma -0.125 (* (pow (/ c b_2) 2.0) (/ a b_2)) (* (/ c b_2) -0.5)))))))double code(double a, double b_2, double c) {
return (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a;
}
double code(double a, double b_2, double c) {
double t_0 = sqrt(((b_2 * b_2) - (a * c)));
double tmp;
if (b_2 <= -3.05e+41) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= -1.65e-141) {
tmp = (t_0 - b_2) / a;
} else if (b_2 <= 1e+138) {
tmp = -c / (b_2 + t_0);
} else {
tmp = fma(-0.125, (pow((c / b_2), 2.0) * (a / b_2)), ((c / b_2) * -0.5));
}
return tmp;
}
function code(a, b_2, c) return Float64(Float64(Float64(-b_2) + sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a) end
function code(a, b_2, c) t_0 = sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c))) tmp = 0.0 if (b_2 <= -3.05e+41) tmp = Float64(Float64(b_2 * -2.0) / a); elseif (b_2 <= -1.65e-141) tmp = Float64(Float64(t_0 - b_2) / a); elseif (b_2 <= 1e+138) tmp = Float64(Float64(-c) / Float64(b_2 + t_0)); else tmp = fma(-0.125, Float64((Float64(c / b_2) ^ 2.0) * Float64(a / b_2)), Float64(Float64(c / b_2) * -0.5)); end return tmp end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) + N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
code[a_, b$95$2_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b$95$2, -3.05e+41], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, -1.65e-141], N[(N[(t$95$0 - b$95$2), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 1e+138], N[((-c) / N[(b$95$2 + t$95$0), $MachinePrecision]), $MachinePrecision], N[(-0.125 * N[(N[Power[N[(c / b$95$2), $MachinePrecision], 2.0], $MachinePrecision] * N[(a / b$95$2), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]]]]
\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
t_0 := \sqrt{b_2 \cdot b_2 - a \cdot c}\\
\mathbf{if}\;b_2 \leq -3.05 \cdot 10^{+41}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{elif}\;b_2 \leq -1.65 \cdot 10^{-141}:\\
\;\;\;\;\frac{t_0 - b_2}{a}\\
\mathbf{elif}\;b_2 \leq 10^{+138}:\\
\;\;\;\;\frac{-c}{b_2 + t_0}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.125, {\left(\frac{c}{b_2}\right)}^{2} \cdot \frac{a}{b_2}, \frac{c}{b_2} \cdot -0.5\right)\\
\end{array}
if b_2 < -3.04999999999999999e41Initial program 36.7
Simplified36.7
[Start]36.7 | \[ \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\] |
|---|---|
+-commutative [=>]36.7 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a}
\] |
unsub-neg [=>]36.7 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}
\] |
Taylor expanded in b_2 around -inf 6.5
Simplified6.5
[Start]6.5 | \[ \frac{-2 \cdot b_2}{a}
\] |
|---|---|
*-commutative [=>]6.5 | \[ \frac{\color{blue}{b_2 \cdot -2}}{a}
\] |
if -3.04999999999999999e41 < b_2 < -1.65e-141Initial program 5.9
Simplified5.9
[Start]5.9 | \[ \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\] |
|---|---|
+-commutative [=>]5.9 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a}
\] |
unsub-neg [=>]5.9 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}
\] |
if -1.65e-141 < b_2 < 1e138Initial program 30.2
Simplified30.2
[Start]30.2 | \[ \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\] |
|---|---|
+-commutative [=>]30.2 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a}
\] |
unsub-neg [=>]30.2 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}
\] |
Applied egg-rr30.3
Applied egg-rr31.0
Simplified35.7
[Start]31.0 | \[ \frac{\frac{1}{a}}{\frac{b_2 + \sqrt{\mathsf{fma}\left(b_2, b_2, a \cdot \left(-c\right)\right)}}{b_2 \cdot b_2 - \mathsf{fma}\left(b_2, b_2, a \cdot c\right)}}
\] |
|---|---|
remove-double-neg [<=]31.0 | \[ \frac{\frac{1}{a}}{\frac{\color{blue}{\left(-\left(-b_2\right)\right)} + \sqrt{\mathsf{fma}\left(b_2, b_2, a \cdot \left(-c\right)\right)}}{b_2 \cdot b_2 - \mathsf{fma}\left(b_2, b_2, a \cdot c\right)}}
\] |
+-commutative [<=]31.0 | \[ \frac{\frac{1}{a}}{\frac{\color{blue}{\sqrt{\mathsf{fma}\left(b_2, b_2, a \cdot \left(-c\right)\right)} + \left(-\left(-b_2\right)\right)}}{b_2 \cdot b_2 - \mathsf{fma}\left(b_2, b_2, a \cdot c\right)}}
\] |
sub-neg [<=]31.0 | \[ \frac{\frac{1}{a}}{\frac{\color{blue}{\sqrt{\mathsf{fma}\left(b_2, b_2, a \cdot \left(-c\right)\right)} - \left(-b_2\right)}}{b_2 \cdot b_2 - \mathsf{fma}\left(b_2, b_2, a \cdot c\right)}}
\] |
sqr-neg [<=]31.0 | \[ \frac{\frac{1}{a}}{\frac{\sqrt{\mathsf{fma}\left(b_2, b_2, a \cdot \left(-c\right)\right)} - \left(-b_2\right)}{\color{blue}{\left(-b_2\right) \cdot \left(-b_2\right)} - \mathsf{fma}\left(b_2, b_2, a \cdot c\right)}}
\] |
fma-udef [=>]31.0 | \[ \frac{\frac{1}{a}}{\frac{\sqrt{\mathsf{fma}\left(b_2, b_2, a \cdot \left(-c\right)\right)} - \left(-b_2\right)}{\left(-b_2\right) \cdot \left(-b_2\right) - \color{blue}{\left(b_2 \cdot b_2 + a \cdot c\right)}}}
\] |
sqr-neg [<=]31.0 | \[ \frac{\frac{1}{a}}{\frac{\sqrt{\mathsf{fma}\left(b_2, b_2, a \cdot \left(-c\right)\right)} - \left(-b_2\right)}{\left(-b_2\right) \cdot \left(-b_2\right) - \left(\color{blue}{\left(-b_2\right) \cdot \left(-b_2\right)} + a \cdot c\right)}}
\] |
+-commutative [=>]31.0 | \[ \frac{\frac{1}{a}}{\frac{\sqrt{\mathsf{fma}\left(b_2, b_2, a \cdot \left(-c\right)\right)} - \left(-b_2\right)}{\left(-b_2\right) \cdot \left(-b_2\right) - \color{blue}{\left(a \cdot c + \left(-b_2\right) \cdot \left(-b_2\right)\right)}}}
\] |
associate--r+ [=>]31.0 | \[ \frac{\frac{1}{a}}{\frac{\sqrt{\mathsf{fma}\left(b_2, b_2, a \cdot \left(-c\right)\right)} - \left(-b_2\right)}{\color{blue}{\left(\left(-b_2\right) \cdot \left(-b_2\right) - a \cdot c\right) - \left(-b_2\right) \cdot \left(-b_2\right)}}}
\] |
unsub-neg [<=]31.0 | \[ \frac{\frac{1}{a}}{\frac{\sqrt{\mathsf{fma}\left(b_2, b_2, a \cdot \left(-c\right)\right)} - \left(-b_2\right)}{\color{blue}{\left(\left(-b_2\right) \cdot \left(-b_2\right) + \left(-a \cdot c\right)\right)} - \left(-b_2\right) \cdot \left(-b_2\right)}}
\] |
sqr-neg [=>]31.0 | \[ \frac{\frac{1}{a}}{\frac{\sqrt{\mathsf{fma}\left(b_2, b_2, a \cdot \left(-c\right)\right)} - \left(-b_2\right)}{\left(\color{blue}{b_2 \cdot b_2} + \left(-a \cdot c\right)\right) - \left(-b_2\right) \cdot \left(-b_2\right)}}
\] |
distribute-rgt-neg-out [<=]31.0 | \[ \frac{\frac{1}{a}}{\frac{\sqrt{\mathsf{fma}\left(b_2, b_2, a \cdot \left(-c\right)\right)} - \left(-b_2\right)}{\left(b_2 \cdot b_2 + \color{blue}{a \cdot \left(-c\right)}\right) - \left(-b_2\right) \cdot \left(-b_2\right)}}
\] |
fma-udef [<=]31.0 | \[ \frac{\frac{1}{a}}{\frac{\sqrt{\mathsf{fma}\left(b_2, b_2, a \cdot \left(-c\right)\right)} - \left(-b_2\right)}{\color{blue}{\mathsf{fma}\left(b_2, b_2, a \cdot \left(-c\right)\right)} - \left(-b_2\right) \cdot \left(-b_2\right)}}
\] |
Applied egg-rr37.2
Simplified15.6
[Start]37.2 | \[ \frac{b_2}{a} \cdot \frac{b_2}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}} + \left(-\frac{\mathsf{fma}\left(b_2, b_2, c \cdot a\right)}{a \cdot \left(b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}\right)}\right)
\] |
|---|---|
sub-neg [<=]37.2 | \[ \color{blue}{\frac{b_2}{a} \cdot \frac{b_2}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}} - \frac{\mathsf{fma}\left(b_2, b_2, c \cdot a\right)}{a \cdot \left(b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}\right)}}
\] |
associate-*r/ [=>]37.7 | \[ \color{blue}{\frac{\frac{b_2}{a} \cdot b_2}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}} - \frac{\mathsf{fma}\left(b_2, b_2, c \cdot a\right)}{a \cdot \left(b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}\right)}
\] |
associate-*l/ [=>]37.7 | \[ \frac{\color{blue}{\frac{b_2 \cdot b_2}{a}}}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}} - \frac{\mathsf{fma}\left(b_2, b_2, c \cdot a\right)}{a \cdot \left(b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}\right)}
\] |
associate-/r* [<=]36.4 | \[ \color{blue}{\frac{b_2 \cdot b_2}{a \cdot \left(b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}\right)}} - \frac{\mathsf{fma}\left(b_2, b_2, c \cdot a\right)}{a \cdot \left(b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}\right)}
\] |
div-sub [<=]35.7 | \[ \color{blue}{\frac{b_2 \cdot b_2 - \mathsf{fma}\left(b_2, b_2, c \cdot a\right)}{a \cdot \left(b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}\right)}}
\] |
associate-/r* [=>]31.0 | \[ \color{blue}{\frac{\frac{b_2 \cdot b_2 - \mathsf{fma}\left(b_2, b_2, c \cdot a\right)}{a}}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}}
\] |
fma-udef [=>]31.0 | \[ \frac{\frac{b_2 \cdot b_2 - \color{blue}{\left(b_2 \cdot b_2 + c \cdot a\right)}}{a}}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}
\] |
associate--r+ [=>]15.6 | \[ \frac{\frac{\color{blue}{\left(b_2 \cdot b_2 - b_2 \cdot b_2\right) - c \cdot a}}{a}}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}
\] |
+-inverses [=>]15.6 | \[ \frac{\frac{\color{blue}{0} - c \cdot a}{a}}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}
\] |
neg-sub0 [<=]15.6 | \[ \frac{\frac{\color{blue}{-c \cdot a}}{a}}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}
\] |
distribute-lft-neg-in [=>]15.6 | \[ \frac{\frac{\color{blue}{\left(-c\right) \cdot a}}{a}}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}
\] |
*-commutative [=>]15.6 | \[ \frac{\frac{\color{blue}{a \cdot \left(-c\right)}}{a}}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}
\] |
Taylor expanded in a around 0 10.5
Simplified10.5
[Start]10.5 | \[ \frac{-1 \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}
\] |
|---|---|
mul-1-neg [=>]10.5 | \[ \frac{\color{blue}{-c}}{b_2 + \sqrt{b_2 \cdot b_2 - c \cdot a}}
\] |
if 1e138 < b_2 Initial program 62.4
Simplified62.4
[Start]62.4 | \[ \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\] |
|---|---|
+-commutative [=>]62.4 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a}
\] |
unsub-neg [=>]62.4 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}
\] |
Taylor expanded in b_2 around inf 19.5
Simplified16.5
[Start]19.5 | \[ -0.125 \cdot \frac{{c}^{2} \cdot a}{{b_2}^{3}} + -0.5 \cdot \frac{c}{b_2}
\] |
|---|---|
fma-def [=>]19.5 | \[ \color{blue}{\mathsf{fma}\left(-0.125, \frac{{c}^{2} \cdot a}{{b_2}^{3}}, -0.5 \cdot \frac{c}{b_2}\right)}
\] |
associate-/l* [=>]16.5 | \[ \mathsf{fma}\left(-0.125, \color{blue}{\frac{{c}^{2}}{\frac{{b_2}^{3}}{a}}}, -0.5 \cdot \frac{c}{b_2}\right)
\] |
unpow2 [=>]16.5 | \[ \mathsf{fma}\left(-0.125, \frac{\color{blue}{c \cdot c}}{\frac{{b_2}^{3}}{a}}, -0.5 \cdot \frac{c}{b_2}\right)
\] |
Applied egg-rr2.1
Final simplification7.3
| Alternative 1 | |
|---|---|
| Error | 7.4 |
| Cost | 7564 |
| Alternative 2 | |
|---|---|
| Error | 10.5 |
| Cost | 7368 |
| Alternative 3 | |
|---|---|
| Error | 13.3 |
| Cost | 7304 |
| Alternative 4 | |
|---|---|
| Error | 13.3 |
| Cost | 7176 |
| Alternative 5 | |
|---|---|
| Error | 36.4 |
| Cost | 452 |
| Alternative 6 | |
|---|---|
| Error | 22.2 |
| Cost | 452 |
| Alternative 7 | |
|---|---|
| Error | 22.2 |
| Cost | 452 |
| Alternative 8 | |
|---|---|
| Error | 53.2 |
| Cost | 388 |
| Alternative 9 | |
|---|---|
| Error | 56.3 |
| Cost | 64 |
herbie shell --seed 2023034
(FPCore (a b_2 c)
:name "quad2p (problem 3.2.1, positive)"
:precision binary64
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))