| Alternative 1 | |
|---|---|
| Accuracy | 83.9% |
| Cost | 7432 |
(FPCore (a b_2 c) :precision binary64 (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -6e+34)
(/ (* -0.5 c) b_2)
(if (<= b_2 -7.4e-277)
(/
(/ -1.0 (/ 1.0 (/ c (/ (- b_2 (sqrt (fma b_2 b_2 (* c (- a))))) a))))
a)
(if (<= b_2 4e+111)
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* c a)))) a)
(/ (- (- (/ (* c 0.5) (/ b_2 a)) b_2) b_2) a)))))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 tmp;
if (b_2 <= -6e+34) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= -7.4e-277) {
tmp = (-1.0 / (1.0 / (c / ((b_2 - sqrt(fma(b_2, b_2, (c * -a)))) / a)))) / a;
} else if (b_2 <= 4e+111) {
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = ((((c * 0.5) / (b_2 / a)) - b_2) - b_2) / a;
}
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) tmp = 0.0 if (b_2 <= -6e+34) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= -7.4e-277) tmp = Float64(Float64(-1.0 / Float64(1.0 / Float64(c / Float64(Float64(b_2 - sqrt(fma(b_2, b_2, Float64(c * Float64(-a))))) / a)))) / a); elseif (b_2 <= 4e+111) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a)))) / a); else tmp = Float64(Float64(Float64(Float64(Float64(c * 0.5) / Float64(b_2 / a)) - b_2) - b_2) / a); 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_] := If[LessEqual[b$95$2, -6e+34], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, -7.4e-277], N[(N[(-1.0 / N[(1.0 / N[(c / N[(N[(b$95$2 - N[Sqrt[N[(b$95$2 * b$95$2 + N[(c * (-a)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 4e+111], N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(N[(N[(N[(c * 0.5), $MachinePrecision] / N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] - b$95$2), $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision]]]]
\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
\mathbf{if}\;b_2 \leq -6 \cdot 10^{+34}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{elif}\;b_2 \leq -7.4 \cdot 10^{-277}:\\
\;\;\;\;\frac{\frac{-1}{\frac{1}{\frac{c}{\frac{b_2 - \sqrt{\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right)}}{a}}}}}{a}\\
\mathbf{elif}\;b_2 \leq 4 \cdot 10^{+111}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{c \cdot 0.5}{\frac{b_2}{a}} - b_2\right) - b_2}{a}\\
\end{array}
if b_2 < -6.00000000000000037e34Initial program 11.6%
Taylor expanded in b_2 around -inf 92.8%
Applied egg-rr92.9%
[Start]92.8 | \[ -0.5 \cdot \frac{c}{b_2}
\] |
|---|---|
associate-*r/ [=>]92.9 | \[ \color{blue}{\frac{-0.5 \cdot c}{b_2}}
\] |
if -6.00000000000000037e34 < b_2 < -7.3999999999999997e-277Initial program 53.2%
Applied egg-rr52.2%
[Start]53.2 | \[ \frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\] |
|---|---|
flip-- [=>]53.1 | \[ \frac{\color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}
\] |
frac-2neg [=>]53.1 | \[ \frac{\color{blue}{\frac{-\left(\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{-\left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}}{a}
\] |
add-sqr-sqrt [=>]53.1 | \[ \frac{\frac{-\left(\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{-\left(\color{blue}{\sqrt{-b_2} \cdot \sqrt{-b_2}} + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}{a}
\] |
sqrt-unprod [=>]53.0 | \[ \frac{\frac{-\left(\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{-\left(\color{blue}{\sqrt{\left(-b_2\right) \cdot \left(-b_2\right)}} + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}{a}
\] |
sqr-neg [=>]53.0 | \[ \frac{\frac{-\left(\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{-\left(\sqrt{\color{blue}{b_2 \cdot b_2}} + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}{a}
\] |
sqrt-prod [=>]0.0 | \[ \frac{\frac{-\left(\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{-\left(\color{blue}{\sqrt{b_2} \cdot \sqrt{b_2}} + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}{a}
\] |
add-sqr-sqrt [<=]49.4 | \[ \frac{\frac{-\left(\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{-\left(\color{blue}{b_2} + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}{a}
\] |
distribute-neg-out [<=]49.4 | \[ \frac{\frac{-\left(\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{\color{blue}{\left(-b_2\right) + \left(-\sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}}{a}
\] |
sub-neg [<=]49.4 | \[ \frac{\frac{-\left(\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{\color{blue}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}
\] |
flip-- [=>]49.3 | \[ \frac{\frac{-\left(\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{\color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}}{a}
\] |
div-inv [=>]49.2 | \[ \frac{\frac{-\left(\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{\color{blue}{\left(\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}}{a}
\] |
Taylor expanded in a around 0 53.1%
Applied egg-rr73.3%
[Start]53.1 | \[ \frac{\frac{-1}{\frac{1}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}
\] |
|---|---|
flip-+ [=>]53.1 | \[ \frac{\frac{-1}{\frac{1}{\color{blue}{\frac{b_2 \cdot b_2 - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{b_2 - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}}}{a}
\] |
div-inv [=>]53.0 | \[ \frac{\frac{-1}{\frac{1}{\color{blue}{\left(b_2 \cdot b_2 - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{b_2 - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}}}{a}
\] |
add-sqr-sqrt [<=]53.0 | \[ \frac{\frac{-1}{\frac{1}{\left(b_2 \cdot b_2 - \color{blue}{\left(b_2 \cdot b_2 - a \cdot c\right)}\right) \cdot \frac{1}{b_2 - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}}{a}
\] |
associate--r- [=>]73.3 | \[ \frac{\frac{-1}{\frac{1}{\color{blue}{\left(\left(b_2 \cdot b_2 - b_2 \cdot b_2\right) + a \cdot c\right)} \cdot \frac{1}{b_2 - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}}{a}
\] |
+-commutative [=>]73.3 | \[ \frac{\frac{-1}{\frac{1}{\color{blue}{\left(a \cdot c + \left(b_2 \cdot b_2 - b_2 \cdot b_2\right)\right)} \cdot \frac{1}{b_2 - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}}{a}
\] |
Simplified77.6%
[Start]73.3 | \[ \frac{\frac{-1}{\frac{1}{\left(a \cdot c + \left(b_2 \cdot b_2 - b_2 \cdot b_2\right)\right) \cdot \frac{1}{b_2 - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}}{a}
\] |
|---|---|
associate-*r/ [=>]73.3 | \[ \frac{\frac{-1}{\frac{1}{\color{blue}{\frac{\left(a \cdot c + \left(b_2 \cdot b_2 - b_2 \cdot b_2\right)\right) \cdot 1}{b_2 - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}}}{a}
\] |
*-rgt-identity [=>]73.3 | \[ \frac{\frac{-1}{\frac{1}{\frac{\color{blue}{a \cdot c + \left(b_2 \cdot b_2 - b_2 \cdot b_2\right)}}{b_2 - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}}{a}
\] |
+-commutative [=>]73.3 | \[ \frac{\frac{-1}{\frac{1}{\frac{\color{blue}{\left(b_2 \cdot b_2 - b_2 \cdot b_2\right) + a \cdot c}}{b_2 - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}}{a}
\] |
+-inverses [=>]73.3 | \[ \frac{\frac{-1}{\frac{1}{\frac{\color{blue}{0} + a \cdot c}{b_2 - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}}{a}
\] |
+-lft-identity [=>]73.3 | \[ \frac{\frac{-1}{\frac{1}{\frac{\color{blue}{a \cdot c}}{b_2 - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}}{a}
\] |
*-commutative [=>]73.3 | \[ \frac{\frac{-1}{\frac{1}{\frac{\color{blue}{c \cdot a}}{b_2 - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}}{a}
\] |
associate-/l* [=>]77.6 | \[ \frac{\frac{-1}{\frac{1}{\color{blue}{\frac{c}{\frac{b_2 - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}}}}}}{a}
\] |
fma-neg [=>]77.6 | \[ \frac{\frac{-1}{\frac{1}{\frac{c}{\frac{b_2 - \sqrt{\color{blue}{\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)}}}{a}}}}}{a}
\] |
distribute-lft-neg-in [=>]77.6 | \[ \frac{\frac{-1}{\frac{1}{\frac{c}{\frac{b_2 - \sqrt{\mathsf{fma}\left(b_2, b_2, \color{blue}{\left(-a\right) \cdot c}\right)}}{a}}}}}{a}
\] |
*-commutative [=>]77.6 | \[ \frac{\frac{-1}{\frac{1}{\frac{c}{\frac{b_2 - \sqrt{\mathsf{fma}\left(b_2, b_2, \color{blue}{c \cdot \left(-a\right)}\right)}}{a}}}}}{a}
\] |
if -7.3999999999999997e-277 < b_2 < 3.99999999999999983e111Initial program 85.5%
if 3.99999999999999983e111 < b_2 Initial program 22.7%
Taylor expanded in b_2 around inf 82.7%
Simplified93.4%
[Start]82.7 | \[ \frac{\left(-b_2\right) - \left(b_2 + -0.5 \cdot \frac{c \cdot a}{b_2}\right)}{a}
\] |
|---|---|
associate-/l* [=>]93.4 | \[ \frac{\left(-b_2\right) - \left(b_2 + -0.5 \cdot \color{blue}{\frac{c}{\frac{b_2}{a}}}\right)}{a}
\] |
associate-*r/ [=>]93.4 | \[ \frac{\left(-b_2\right) - \left(b_2 + \color{blue}{\frac{-0.5 \cdot c}{\frac{b_2}{a}}}\right)}{a}
\] |
*-commutative [=>]93.4 | \[ \frac{\left(-b_2\right) - \left(b_2 + \frac{\color{blue}{c \cdot -0.5}}{\frac{b_2}{a}}\right)}{a}
\] |
Final simplification87.1%
| Alternative 1 | |
|---|---|
| Accuracy | 83.9% |
| Cost | 7432 |
| Alternative 2 | |
|---|---|
| Accuracy | 78.6% |
| Cost | 7240 |
| Alternative 3 | |
|---|---|
| Accuracy | 64.5% |
| Cost | 836 |
| Alternative 4 | |
|---|---|
| Accuracy | 42.7% |
| Cost | 452 |
| Alternative 5 | |
|---|---|
| Accuracy | 42.7% |
| Cost | 452 |
| Alternative 6 | |
|---|---|
| Accuracy | 64.5% |
| Cost | 452 |
| Alternative 7 | |
|---|---|
| Accuracy | 7.5% |
| Cost | 256 |
herbie shell --seed 2023131
(FPCore (a b_2 c)
:name "quad2m (problem 3.2.1, negative)"
:precision binary64
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))