
(FPCore (x) :precision binary64 (* (fmod (exp x) (sqrt (cos x))) (exp (- x))))
double code(double x) {
return fmod(exp(x), sqrt(cos(x))) * exp(-x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod(exp(x), sqrt(cos(x))) * exp(-x)
end function
def code(x): return math.fmod(math.exp(x), math.sqrt(math.cos(x))) * math.exp(-x)
function code(x) return Float64(rem(exp(x), sqrt(cos(x))) * exp(Float64(-x))) 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]
\begin{array}{l}
\\
\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 1 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (* (fmod (exp x) (sqrt (cos x))) (exp (- x))))
double code(double x) {
return fmod(exp(x), sqrt(cos(x))) * exp(-x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod(exp(x), sqrt(cos(x))) * exp(-x)
end function
def code(x): return math.fmod(math.exp(x), math.sqrt(math.cos(x))) * math.exp(-x)
function code(x) return Float64(rem(exp(x), sqrt(cos(x))) * exp(Float64(-x))) 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]
\begin{array}{l}
\\
\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}
\end{array}
(FPCore (x) :precision binary64 (pow E (- x)))
double code(double x) {
return pow(((double) M_E), -x);
}
public static double code(double x) {
return Math.pow(Math.E, -x);
}
def code(x): return math.pow(math.e, -x)
function code(x) return exp(1) ^ Float64(-x) end
function tmp = code(x) tmp = 2.71828182845904523536 ^ -x; end
code[x_] := N[Power[E, (-x)], $MachinePrecision]
\begin{array}{l}
\\
{e}^{\left(-x\right)}
\end{array}
Initial program 5.7%
/-rgt-identity5.7%
associate-/r/5.7%
exp-neg5.8%
remove-double-neg5.8%
Simplified5.8%
add-exp-log5.8%
*-un-lft-identity5.8%
exp-prod5.8%
exp-1-e5.8%
log-div5.8%
add-log-exp5.8%
Applied egg-rr5.8%
add-cbrt-cube5.7%
pow1/35.8%
pow-to-exp5.8%
pow35.8%
log-pow5.8%
Applied egg-rr5.8%
rem-log-exp5.8%
associate-*l*5.8%
*-commutative5.8%
Applied egg-rr5.8%
Taylor expanded in x around inf 63.0%
neg-mul-163.0%
Simplified63.0%
Final simplification63.0%
herbie shell --seed 2024026
(FPCore (x)
:name "expfmod (used to be hard to sample)"
:precision binary64
(* (fmod (exp x) (sqrt (cos x))) (exp (- x))))