| Alternative 1 | |
|---|---|
| Accuracy | 42.4% |
| Cost | 64 |
\[1
\]
(FPCore (x) :precision binary64 (* (fmod (exp x) (sqrt (cos x))) (exp (- x))))
(FPCore (x) :precision binary64 (if (<= x 1.625e-219) 1.0 (exp (- x))))
double code(double x) {
return fmod(exp(x), sqrt(cos(x))) * exp(-x);
}
double code(double x) {
double tmp;
if (x <= 1.625e-219) {
tmp = 1.0;
} else {
tmp = exp(-x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod(exp(x), sqrt(cos(x))) * exp(-x)
end function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.625d-219) then
tmp = 1.0d0
else
tmp = exp(-x)
end if
code = tmp
end function
def code(x): return math.fmod(math.exp(x), math.sqrt(math.cos(x))) * math.exp(-x)
def code(x): tmp = 0 if x <= 1.625e-219: tmp = 1.0 else: tmp = math.exp(-x) return tmp
function code(x) return Float64(rem(exp(x), sqrt(cos(x))) * exp(Float64(-x))) end
function code(x) tmp = 0.0 if (x <= 1.625e-219) tmp = 1.0; else tmp = exp(Float64(-x)); end return tmp end
code[x_] := N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
code[x_] := If[LessEqual[x, 1.625e-219], 1.0, N[Exp[(-x)], $MachinePrecision]]
\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}
\begin{array}{l}
\mathbf{if}\;x \leq 1.625 \cdot 10^{-219}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;e^{-x}\\
\end{array}
if x < 1.62499999999999989e-219Initial program 8.8%
Simplified8.8%
[Start]8.8 | \[ \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}
\] |
|---|---|
exp-neg [=>]8.8 | \[ \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}}
\] |
associate-*r/ [=>]8.8 | \[ \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot 1}{e^{x}}}
\] |
*-rgt-identity [=>]8.8 | \[ \frac{\color{blue}{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}}{e^{x}}
\] |
Applied egg-rr8.8%
[Start]8.8 | \[ \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}
\] |
|---|---|
add-exp-log [=>]8.8 | \[ \frac{\color{blue}{e^{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}}}{e^{x}}
\] |
div-exp [=>]8.8 | \[ \color{blue}{e^{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x}}
\] |
Applied egg-rr8.8%
[Start]8.8 | \[ e^{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x}
\] |
|---|---|
add-cube-cbrt [=>]8.8 | \[ e^{\color{blue}{\left(\sqrt[3]{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x} \cdot \sqrt[3]{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x}\right) \cdot \sqrt[3]{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x}}}
\] |
pow3 [=>]8.8 | \[ e^{\color{blue}{{\left(\sqrt[3]{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x}\right)}^{3}}}
\] |
Taylor expanded in x around inf 77.8%
if 1.62499999999999989e-219 < x Initial program 5.1%
Simplified5.1%
[Start]5.1 | \[ \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}
\] |
|---|---|
exp-neg [=>]5.1 | \[ \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}}
\] |
associate-*r/ [=>]5.1 | \[ \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot 1}{e^{x}}}
\] |
*-rgt-identity [=>]5.1 | \[ \frac{\color{blue}{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}}{e^{x}}
\] |
Applied egg-rr5.1%
[Start]5.1 | \[ \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}
\] |
|---|---|
add-exp-log [=>]5.1 | \[ \frac{\color{blue}{e^{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}}}{e^{x}}
\] |
div-exp [=>]5.1 | \[ \color{blue}{e^{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x}}
\] |
Taylor expanded in x around inf 45.2%
Simplified45.2%
[Start]45.2 | \[ e^{-1 \cdot x}
\] |
|---|---|
mul-1-neg [=>]45.2 | \[ e^{\color{blue}{-x}}
\] |
Final simplification62.0%
| Alternative 1 | |
|---|---|
| Accuracy | 42.4% |
| Cost | 64 |
herbie shell --seed 2023136
(FPCore (x)
:name "expfmod (used to be hard to sample)"
:precision binary64
(* (fmod (exp x) (sqrt (cos x))) (exp (- x))))