
(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 16 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
(let* ((t_0 (log (fmod (exp x) (sqrt (cos x)))))
(t_1 (expm1 (- t_0 x)))
(t_2 (pow t_1 2.0))
(t_3 (- 1.0 t_1))
(t_4 (pow t_3 -0.5)))
(if (<= x -2e-311)
(- (/ 1.0 t_3) (/ t_2 (- 1.0 (expm1 (- (fabs t_0) x)))))
(fma t_4 t_4 (/ (- t_2) t_3)))))
double code(double x) {
double t_0 = log(fmod(exp(x), sqrt(cos(x))));
double t_1 = expm1((t_0 - x));
double t_2 = pow(t_1, 2.0);
double t_3 = 1.0 - t_1;
double t_4 = pow(t_3, -0.5);
double tmp;
if (x <= -2e-311) {
tmp = (1.0 / t_3) - (t_2 / (1.0 - expm1((fabs(t_0) - x))));
} else {
tmp = fma(t_4, t_4, (-t_2 / t_3));
}
return tmp;
}
function code(x) t_0 = log(rem(exp(x), sqrt(cos(x)))) t_1 = expm1(Float64(t_0 - x)) t_2 = t_1 ^ 2.0 t_3 = Float64(1.0 - t_1) t_4 = t_3 ^ -0.5 tmp = 0.0 if (x <= -2e-311) tmp = Float64(Float64(1.0 / t_3) - Float64(t_2 / Float64(1.0 - expm1(Float64(abs(t_0) - x))))); else tmp = fma(t_4, t_4, Float64(Float64(-t_2) / t_3)); end return tmp end
code[x_] := Block[{t$95$0 = N[Log[N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(Exp[N[(t$95$0 - x), $MachinePrecision]] - 1), $MachinePrecision]}, Block[{t$95$2 = N[Power[t$95$1, 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(1.0 - t$95$1), $MachinePrecision]}, Block[{t$95$4 = N[Power[t$95$3, -0.5], $MachinePrecision]}, If[LessEqual[x, -2e-311], N[(N[(1.0 / t$95$3), $MachinePrecision] - N[(t$95$2 / N[(1.0 - N[(Exp[N[(N[Abs[t$95$0], $MachinePrecision] - x), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$4 * t$95$4 + N[((-t$95$2) / t$95$3), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
t_1 := \mathsf{expm1}\left(t_0 - x\right)\\
t_2 := {t_1}^{2}\\
t_3 := 1 - t_1\\
t_4 := {t_3}^{-0.5}\\
\mathbf{if}\;x \leq -2 \cdot 10^{-311}:\\
\;\;\;\;\frac{1}{t_3} - \frac{t_2}{1 - \mathsf{expm1}\left(\left|t_0\right| - x\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_4, t_4, \frac{-t_2}{t_3}\right)\\
\end{array}
\end{array}
if x < -1.9999999999999e-311Initial program 12.3%
exp-neg12.4%
associate-*r/12.4%
*-rgt-identity12.4%
Simplified12.4%
expm1-log1p-u12.4%
expm1-udef12.4%
log1p-udef12.4%
add-exp-log12.4%
Applied egg-rr12.4%
associate--l+12.4%
Simplified12.4%
flip-+12.4%
metadata-eval12.4%
div-sub12.4%
Applied egg-rr12.4%
add-sqr-sqrt0.0%
sqrt-unprod26.6%
pow226.6%
Applied egg-rr26.6%
unpow226.6%
rem-sqrt-square26.6%
Simplified26.6%
if -1.9999999999999e-311 < x Initial program 6.8%
exp-neg6.8%
associate-*r/6.8%
*-rgt-identity6.8%
Simplified6.8%
expm1-log1p-u6.8%
expm1-udef6.7%
log1p-udef6.7%
add-exp-log6.7%
Applied egg-rr6.7%
associate--l+6.8%
Simplified6.8%
flip-+6.7%
metadata-eval6.7%
div-sub6.8%
Applied egg-rr6.8%
add-sqr-sqrt6.8%
fma-neg6.9%
Applied egg-rr6.9%
Final simplification14.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (log (fmod (exp x) (sqrt (cos x)))))
(t_1 (expm1 (- t_0 x)))
(t_2 (pow t_1 2.0))
(t_3 (- 1.0 t_1))
(t_4 (/ 1.0 t_3)))
(if (<= x -2e-311)
(- t_4 (/ t_2 (- 1.0 (expm1 (- (fabs t_0) x)))))
(- t_4 (cbrt (pow (/ t_2 t_3) 3.0))))))
double code(double x) {
double t_0 = log(fmod(exp(x), sqrt(cos(x))));
double t_1 = expm1((t_0 - x));
double t_2 = pow(t_1, 2.0);
double t_3 = 1.0 - t_1;
double t_4 = 1.0 / t_3;
double tmp;
if (x <= -2e-311) {
tmp = t_4 - (t_2 / (1.0 - expm1((fabs(t_0) - x))));
} else {
tmp = t_4 - cbrt(pow((t_2 / t_3), 3.0));
}
return tmp;
}
function code(x) t_0 = log(rem(exp(x), sqrt(cos(x)))) t_1 = expm1(Float64(t_0 - x)) t_2 = t_1 ^ 2.0 t_3 = Float64(1.0 - t_1) t_4 = Float64(1.0 / t_3) tmp = 0.0 if (x <= -2e-311) tmp = Float64(t_4 - Float64(t_2 / Float64(1.0 - expm1(Float64(abs(t_0) - x))))); else tmp = Float64(t_4 - cbrt((Float64(t_2 / t_3) ^ 3.0))); end return tmp end
code[x_] := Block[{t$95$0 = N[Log[N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(Exp[N[(t$95$0 - x), $MachinePrecision]] - 1), $MachinePrecision]}, Block[{t$95$2 = N[Power[t$95$1, 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(1.0 - t$95$1), $MachinePrecision]}, Block[{t$95$4 = N[(1.0 / t$95$3), $MachinePrecision]}, If[LessEqual[x, -2e-311], N[(t$95$4 - N[(t$95$2 / N[(1.0 - N[(Exp[N[(N[Abs[t$95$0], $MachinePrecision] - x), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$4 - N[Power[N[Power[N[(t$95$2 / t$95$3), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
t_1 := \mathsf{expm1}\left(t_0 - x\right)\\
t_2 := {t_1}^{2}\\
t_3 := 1 - t_1\\
t_4 := \frac{1}{t_3}\\
\mathbf{if}\;x \leq -2 \cdot 10^{-311}:\\
\;\;\;\;t_4 - \frac{t_2}{1 - \mathsf{expm1}\left(\left|t_0\right| - x\right)}\\
\mathbf{else}:\\
\;\;\;\;t_4 - \sqrt[3]{{\left(\frac{t_2}{t_3}\right)}^{3}}\\
\end{array}
\end{array}
if x < -1.9999999999999e-311Initial program 12.3%
exp-neg12.4%
associate-*r/12.4%
*-rgt-identity12.4%
Simplified12.4%
expm1-log1p-u12.4%
expm1-udef12.4%
log1p-udef12.4%
add-exp-log12.4%
Applied egg-rr12.4%
associate--l+12.4%
Simplified12.4%
flip-+12.4%
metadata-eval12.4%
div-sub12.4%
Applied egg-rr12.4%
add-sqr-sqrt0.0%
sqrt-unprod26.6%
pow226.6%
Applied egg-rr26.6%
unpow226.6%
rem-sqrt-square26.6%
Simplified26.6%
if -1.9999999999999e-311 < x Initial program 6.8%
exp-neg6.8%
associate-*r/6.8%
*-rgt-identity6.8%
Simplified6.8%
expm1-log1p-u6.8%
expm1-udef6.7%
log1p-udef6.7%
add-exp-log6.7%
Applied egg-rr6.7%
associate--l+6.8%
Simplified6.8%
flip-+6.7%
metadata-eval6.7%
div-sub6.8%
Applied egg-rr6.8%
add-sqr-sqrt0.0%
sqrt-unprod3.9%
pow23.9%
Applied egg-rr3.9%
unpow23.9%
rem-sqrt-square3.9%
Simplified3.9%
add-cbrt-cube3.9%
pow33.9%
Applied egg-rr6.9%
Final simplification14.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (fmod (exp x) (sqrt (cos x))))
(t_1 (log t_0))
(t_2 (expm1 (- t_1 x)))
(t_3 (/ 1.0 (- 1.0 t_2))))
(if (<= x -2e-311)
(- t_3 (/ (pow t_2 2.0) (- 1.0 (expm1 (- (fabs t_1) x)))))
(- t_3 (pow (/ t_2 (sqrt (- 2.0 (/ t_0 (exp x))))) 2.0)))))
double code(double x) {
double t_0 = fmod(exp(x), sqrt(cos(x)));
double t_1 = log(t_0);
double t_2 = expm1((t_1 - x));
double t_3 = 1.0 / (1.0 - t_2);
double tmp;
if (x <= -2e-311) {
tmp = t_3 - (pow(t_2, 2.0) / (1.0 - expm1((fabs(t_1) - x))));
} else {
tmp = t_3 - pow((t_2 / sqrt((2.0 - (t_0 / exp(x))))), 2.0);
}
return tmp;
}
def code(x): t_0 = math.fmod(math.exp(x), math.sqrt(math.cos(x))) t_1 = math.log(t_0) t_2 = math.expm1((t_1 - x)) t_3 = 1.0 / (1.0 - t_2) tmp = 0 if x <= -2e-311: tmp = t_3 - (math.pow(t_2, 2.0) / (1.0 - math.expm1((math.fabs(t_1) - x)))) else: tmp = t_3 - math.pow((t_2 / math.sqrt((2.0 - (t_0 / math.exp(x))))), 2.0) return tmp
function code(x) t_0 = rem(exp(x), sqrt(cos(x))) t_1 = log(t_0) t_2 = expm1(Float64(t_1 - x)) t_3 = Float64(1.0 / Float64(1.0 - t_2)) tmp = 0.0 if (x <= -2e-311) tmp = Float64(t_3 - Float64((t_2 ^ 2.0) / Float64(1.0 - expm1(Float64(abs(t_1) - x))))); else tmp = Float64(t_3 - (Float64(t_2 / sqrt(Float64(2.0 - Float64(t_0 / exp(x))))) ^ 2.0)); end return tmp end
code[x_] := Block[{t$95$0 = N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]}, Block[{t$95$1 = N[Log[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(Exp[N[(t$95$1 - x), $MachinePrecision]] - 1), $MachinePrecision]}, Block[{t$95$3 = N[(1.0 / N[(1.0 - t$95$2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2e-311], N[(t$95$3 - N[(N[Power[t$95$2, 2.0], $MachinePrecision] / N[(1.0 - N[(Exp[N[(N[Abs[t$95$1], $MachinePrecision] - x), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$3 - N[Power[N[(t$95$2 / N[Sqrt[N[(2.0 - N[(t$95$0 / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
t_1 := \log t_0\\
t_2 := \mathsf{expm1}\left(t_1 - x\right)\\
t_3 := \frac{1}{1 - t_2}\\
\mathbf{if}\;x \leq -2 \cdot 10^{-311}:\\
\;\;\;\;t_3 - \frac{{t_2}^{2}}{1 - \mathsf{expm1}\left(\left|t_1\right| - x\right)}\\
\mathbf{else}:\\
\;\;\;\;t_3 - {\left(\frac{t_2}{\sqrt{2 - \frac{t_0}{e^{x}}}}\right)}^{2}\\
\end{array}
\end{array}
if x < -1.9999999999999e-311Initial program 12.3%
exp-neg12.4%
associate-*r/12.4%
*-rgt-identity12.4%
Simplified12.4%
expm1-log1p-u12.4%
expm1-udef12.4%
log1p-udef12.4%
add-exp-log12.4%
Applied egg-rr12.4%
associate--l+12.4%
Simplified12.4%
flip-+12.4%
metadata-eval12.4%
div-sub12.4%
Applied egg-rr12.4%
add-sqr-sqrt0.0%
sqrt-unprod26.6%
pow226.6%
Applied egg-rr26.6%
unpow226.6%
rem-sqrt-square26.6%
Simplified26.6%
if -1.9999999999999e-311 < x Initial program 6.8%
exp-neg6.8%
associate-*r/6.8%
*-rgt-identity6.8%
Simplified6.8%
expm1-log1p-u6.8%
expm1-udef6.7%
log1p-udef6.7%
add-exp-log6.7%
Applied egg-rr6.7%
associate--l+6.8%
Simplified6.8%
flip-+6.7%
metadata-eval6.7%
div-sub6.8%
Applied egg-rr6.8%
add-sqr-sqrt0.0%
sqrt-unprod3.9%
pow23.9%
Applied egg-rr3.9%
unpow23.9%
rem-sqrt-square3.9%
Simplified3.9%
add-sqr-sqrt3.4%
Applied egg-rr6.9%
unpow26.9%
Simplified6.9%
Final simplification14.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (fmod (exp x) (sqrt (cos x))))
(t_1 (log t_0))
(t_2 (expm1 (- t_1 x)))
(t_3 (/ 1.0 (- 1.0 t_2))))
(if (<= x -2e-311)
(- t_3 (/ (pow (+ t_0 -1.0) 2.0) (- 2.0 (exp (fabs t_1)))))
(- t_3 (pow (/ t_2 (sqrt (- 2.0 (/ t_0 (exp x))))) 2.0)))))
double code(double x) {
double t_0 = fmod(exp(x), sqrt(cos(x)));
double t_1 = log(t_0);
double t_2 = expm1((t_1 - x));
double t_3 = 1.0 / (1.0 - t_2);
double tmp;
if (x <= -2e-311) {
tmp = t_3 - (pow((t_0 + -1.0), 2.0) / (2.0 - exp(fabs(t_1))));
} else {
tmp = t_3 - pow((t_2 / sqrt((2.0 - (t_0 / exp(x))))), 2.0);
}
return tmp;
}
def code(x): t_0 = math.fmod(math.exp(x), math.sqrt(math.cos(x))) t_1 = math.log(t_0) t_2 = math.expm1((t_1 - x)) t_3 = 1.0 / (1.0 - t_2) tmp = 0 if x <= -2e-311: tmp = t_3 - (math.pow((t_0 + -1.0), 2.0) / (2.0 - math.exp(math.fabs(t_1)))) else: tmp = t_3 - math.pow((t_2 / math.sqrt((2.0 - (t_0 / math.exp(x))))), 2.0) return tmp
function code(x) t_0 = rem(exp(x), sqrt(cos(x))) t_1 = log(t_0) t_2 = expm1(Float64(t_1 - x)) t_3 = Float64(1.0 / Float64(1.0 - t_2)) tmp = 0.0 if (x <= -2e-311) tmp = Float64(t_3 - Float64((Float64(t_0 + -1.0) ^ 2.0) / Float64(2.0 - exp(abs(t_1))))); else tmp = Float64(t_3 - (Float64(t_2 / sqrt(Float64(2.0 - Float64(t_0 / exp(x))))) ^ 2.0)); end return tmp end
code[x_] := Block[{t$95$0 = N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]}, Block[{t$95$1 = N[Log[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(Exp[N[(t$95$1 - x), $MachinePrecision]] - 1), $MachinePrecision]}, Block[{t$95$3 = N[(1.0 / N[(1.0 - t$95$2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2e-311], N[(t$95$3 - N[(N[Power[N[(t$95$0 + -1.0), $MachinePrecision], 2.0], $MachinePrecision] / N[(2.0 - N[Exp[N[Abs[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$3 - N[Power[N[(t$95$2 / N[Sqrt[N[(2.0 - N[(t$95$0 / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
t_1 := \log t_0\\
t_2 := \mathsf{expm1}\left(t_1 - x\right)\\
t_3 := \frac{1}{1 - t_2}\\
\mathbf{if}\;x \leq -2 \cdot 10^{-311}:\\
\;\;\;\;t_3 - \frac{{\left(t_0 + -1\right)}^{2}}{2 - e^{\left|t_1\right|}}\\
\mathbf{else}:\\
\;\;\;\;t_3 - {\left(\frac{t_2}{\sqrt{2 - \frac{t_0}{e^{x}}}}\right)}^{2}\\
\end{array}
\end{array}
if x < -1.9999999999999e-311Initial program 12.3%
exp-neg12.4%
associate-*r/12.4%
*-rgt-identity12.4%
Simplified12.4%
expm1-log1p-u12.4%
expm1-udef12.4%
log1p-udef12.4%
add-exp-log12.4%
Applied egg-rr12.4%
associate--l+12.4%
Simplified12.4%
flip-+12.4%
metadata-eval12.4%
div-sub12.4%
Applied egg-rr12.4%
add-sqr-sqrt0.0%
sqrt-unprod26.6%
pow226.6%
Applied egg-rr26.6%
unpow226.6%
rem-sqrt-square26.6%
Simplified26.6%
Taylor expanded in x around 0 24.8%
if -1.9999999999999e-311 < x Initial program 6.8%
exp-neg6.8%
associate-*r/6.8%
*-rgt-identity6.8%
Simplified6.8%
expm1-log1p-u6.8%
expm1-udef6.7%
log1p-udef6.7%
add-exp-log6.7%
Applied egg-rr6.7%
associate--l+6.8%
Simplified6.8%
flip-+6.7%
metadata-eval6.7%
div-sub6.8%
Applied egg-rr6.8%
add-sqr-sqrt0.0%
sqrt-unprod3.9%
pow23.9%
Applied egg-rr3.9%
unpow23.9%
rem-sqrt-square3.9%
Simplified3.9%
add-sqr-sqrt3.4%
Applied egg-rr6.9%
unpow26.9%
Simplified6.9%
Final simplification14.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (fmod (exp x) (sqrt (cos x)))) (t_1 (log t_0)))
(if (<= x -2e-311)
(-
(/ 1.0 (- 1.0 (expm1 (- t_1 x))))
(/ (pow (+ t_0 -1.0) 2.0) (- 2.0 (exp (fabs t_1)))))
(/ (log (exp t_0)) (exp x)))))
double code(double x) {
double t_0 = fmod(exp(x), sqrt(cos(x)));
double t_1 = log(t_0);
double tmp;
if (x <= -2e-311) {
tmp = (1.0 / (1.0 - expm1((t_1 - x)))) - (pow((t_0 + -1.0), 2.0) / (2.0 - exp(fabs(t_1))));
} else {
tmp = log(exp(t_0)) / exp(x);
}
return tmp;
}
def code(x): t_0 = math.fmod(math.exp(x), math.sqrt(math.cos(x))) t_1 = math.log(t_0) tmp = 0 if x <= -2e-311: tmp = (1.0 / (1.0 - math.expm1((t_1 - x)))) - (math.pow((t_0 + -1.0), 2.0) / (2.0 - math.exp(math.fabs(t_1)))) else: tmp = math.log(math.exp(t_0)) / math.exp(x) return tmp
function code(x) t_0 = rem(exp(x), sqrt(cos(x))) t_1 = log(t_0) tmp = 0.0 if (x <= -2e-311) tmp = Float64(Float64(1.0 / Float64(1.0 - expm1(Float64(t_1 - x)))) - Float64((Float64(t_0 + -1.0) ^ 2.0) / Float64(2.0 - exp(abs(t_1))))); else tmp = Float64(log(exp(t_0)) / exp(x)); end return tmp end
code[x_] := Block[{t$95$0 = N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]}, Block[{t$95$1 = N[Log[t$95$0], $MachinePrecision]}, If[LessEqual[x, -2e-311], N[(N[(1.0 / N[(1.0 - N[(Exp[N[(t$95$1 - x), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Power[N[(t$95$0 + -1.0), $MachinePrecision], 2.0], $MachinePrecision] / N[(2.0 - N[Exp[N[Abs[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Log[N[Exp[t$95$0], $MachinePrecision]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
t_1 := \log t_0\\
\mathbf{if}\;x \leq -2 \cdot 10^{-311}:\\
\;\;\;\;\frac{1}{1 - \mathsf{expm1}\left(t_1 - x\right)} - \frac{{\left(t_0 + -1\right)}^{2}}{2 - e^{\left|t_1\right|}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(e^{t_0}\right)}{e^{x}}\\
\end{array}
\end{array}
if x < -1.9999999999999e-311Initial program 12.3%
exp-neg12.4%
associate-*r/12.4%
*-rgt-identity12.4%
Simplified12.4%
expm1-log1p-u12.4%
expm1-udef12.4%
log1p-udef12.4%
add-exp-log12.4%
Applied egg-rr12.4%
associate--l+12.4%
Simplified12.4%
flip-+12.4%
metadata-eval12.4%
div-sub12.4%
Applied egg-rr12.4%
add-sqr-sqrt0.0%
sqrt-unprod26.6%
pow226.6%
Applied egg-rr26.6%
unpow226.6%
rem-sqrt-square26.6%
Simplified26.6%
Taylor expanded in x around 0 24.8%
if -1.9999999999999e-311 < x Initial program 6.8%
exp-neg6.8%
associate-*r/6.8%
*-rgt-identity6.8%
Simplified6.8%
add-log-exp6.8%
Applied egg-rr6.8%
Final simplification14.1%
(FPCore (x) :precision binary64 (let* ((t_0 (expm1 (- (log (fmod (exp x) (sqrt (cos x)))) x)))) (/ (+ (pow t_0 2.0) -1.0) (+ t_0 -1.0))))
double code(double x) {
double t_0 = expm1((log(fmod(exp(x), sqrt(cos(x)))) - x));
return (pow(t_0, 2.0) + -1.0) / (t_0 + -1.0);
}
def code(x): t_0 = math.expm1((math.log(math.fmod(math.exp(x), math.sqrt(math.cos(x)))) - x)) return (math.pow(t_0, 2.0) + -1.0) / (t_0 + -1.0)
function code(x) t_0 = expm1(Float64(log(rem(exp(x), sqrt(cos(x)))) - x)) return Float64(Float64((t_0 ^ 2.0) + -1.0) / Float64(t_0 + -1.0)) end
code[x_] := Block[{t$95$0 = N[(Exp[N[(N[Log[N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]], $MachinePrecision] - x), $MachinePrecision]] - 1), $MachinePrecision]}, N[(N[(N[Power[t$95$0, 2.0], $MachinePrecision] + -1.0), $MachinePrecision] / N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\\
\frac{{t_0}^{2} + -1}{t_0 + -1}
\end{array}
\end{array}
Initial program 9.0%
exp-neg9.0%
associate-*r/9.0%
*-rgt-identity9.0%
Simplified9.0%
expm1-log1p-u9.0%
expm1-udef9.0%
log1p-udef9.0%
add-exp-log9.0%
Applied egg-rr9.0%
associate--l+9.0%
Simplified9.0%
+-commutative9.0%
flip-+9.0%
pow29.0%
add-exp-log9.0%
expm1-def9.0%
log-div9.0%
add-log-exp9.0%
metadata-eval9.0%
Applied egg-rr9.1%
Final simplification9.1%
(FPCore (x) :precision binary64 (+ (+ 1.0 (+ 1.0 (+ (/ (fmod (exp x) (sqrt (cos x))) (exp x)) -1.0))) -1.0))
double code(double x) {
return (1.0 + (1.0 + ((fmod(exp(x), sqrt(cos(x))) / exp(x)) + -1.0))) + -1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 + (1.0d0 + ((mod(exp(x), sqrt(cos(x))) / exp(x)) + (-1.0d0)))) + (-1.0d0)
end function
def code(x): return (1.0 + (1.0 + ((math.fmod(math.exp(x), math.sqrt(math.cos(x))) / math.exp(x)) + -1.0))) + -1.0
function code(x) return Float64(Float64(1.0 + Float64(1.0 + Float64(Float64(rem(exp(x), sqrt(cos(x))) / exp(x)) + -1.0))) + -1.0) end
code[x_] := N[(N[(1.0 + N[(1.0 + N[(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] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(1 + \left(1 + \left(\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} + -1\right)\right)\right) + -1
\end{array}
Initial program 9.0%
exp-neg9.0%
associate-*r/9.0%
*-rgt-identity9.0%
Simplified9.0%
expm1-log1p-u9.0%
expm1-udef9.0%
log1p-udef9.0%
add-exp-log9.0%
Applied egg-rr9.0%
expm1-log1p-u9.0%
expm1-udef9.0%
log1p-udef9.0%
add-exp-log9.0%
Applied egg-rr9.0%
associate--l+9.0%
Simplified9.0%
Final simplification9.0%
(FPCore (x) :precision binary64 (+ 1.0 (+ (/ (fmod (exp x) (sqrt (cos x))) (exp x)) -1.0)))
double code(double x) {
return 1.0 + ((fmod(exp(x), sqrt(cos(x))) / exp(x)) + -1.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 + ((mod(exp(x), sqrt(cos(x))) / exp(x)) + (-1.0d0))
end function
def code(x): return 1.0 + ((math.fmod(math.exp(x), math.sqrt(math.cos(x))) / math.exp(x)) + -1.0)
function code(x) return Float64(1.0 + Float64(Float64(rem(exp(x), sqrt(cos(x))) / exp(x)) + -1.0)) end
code[x_] := N[(1.0 + N[(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] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} + -1\right)
\end{array}
Initial program 9.0%
exp-neg9.0%
associate-*r/9.0%
*-rgt-identity9.0%
Simplified9.0%
expm1-log1p-u9.0%
expm1-udef9.0%
log1p-udef9.0%
add-exp-log9.0%
Applied egg-rr9.0%
associate--l+9.0%
Simplified9.0%
Final simplification9.0%
(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(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}
\\
\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}
\end{array}
Initial program 9.0%
exp-neg9.0%
associate-*r/9.0%
*-rgt-identity9.0%
Simplified9.0%
Final simplification9.0%
(FPCore (x) :precision binary64 (+ 1.0 (+ (/ (fmod (exp x) (+ 1.0 (* (* x x) -0.25))) (exp x)) -1.0)))
double code(double x) {
return 1.0 + ((fmod(exp(x), (1.0 + ((x * x) * -0.25))) / exp(x)) + -1.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 + ((mod(exp(x), (1.0d0 + ((x * x) * (-0.25d0)))) / exp(x)) + (-1.0d0))
end function
def code(x): return 1.0 + ((math.fmod(math.exp(x), (1.0 + ((x * x) * -0.25))) / math.exp(x)) + -1.0)
function code(x) return Float64(1.0 + Float64(Float64(rem(exp(x), Float64(1.0 + Float64(Float64(x * x) * -0.25))) / exp(x)) + -1.0)) end
code[x_] := N[(1.0 + N[(N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(\frac{\left(\left(e^{x}\right) \bmod \left(1 + \left(x \cdot x\right) \cdot -0.25\right)\right)}{e^{x}} + -1\right)
\end{array}
Initial program 9.0%
exp-neg9.0%
associate-*r/9.0%
*-rgt-identity9.0%
Simplified9.0%
expm1-log1p-u9.0%
expm1-udef9.0%
log1p-udef9.0%
add-exp-log9.0%
Applied egg-rr9.0%
associate--l+9.0%
Simplified9.0%
Taylor expanded in x around 0 8.7%
*-commutative8.7%
unpow28.7%
Simplified8.7%
Final simplification8.7%
(FPCore (x) :precision binary64 (/ (fmod (exp x) (+ 1.0 (* (* x x) -0.25))) (exp x)))
double code(double x) {
return fmod(exp(x), (1.0 + ((x * x) * -0.25))) / exp(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod(exp(x), (1.0d0 + ((x * x) * (-0.25d0)))) / exp(x)
end function
def code(x): return math.fmod(math.exp(x), (1.0 + ((x * x) * -0.25))) / math.exp(x)
function code(x) return Float64(rem(exp(x), Float64(1.0 + Float64(Float64(x * x) * -0.25))) / exp(x)) end
code[x_] := N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(\left(e^{x}\right) \bmod \left(1 + \left(x \cdot x\right) \cdot -0.25\right)\right)}{e^{x}}
\end{array}
Initial program 9.0%
exp-neg9.0%
associate-*r/9.0%
*-rgt-identity9.0%
Simplified9.0%
Taylor expanded in x around 0 8.7%
*-commutative8.7%
unpow28.7%
Simplified8.7%
Final simplification8.7%
(FPCore (x) :precision binary64 (+ 1.0 (+ (/ (fmod (exp x) 1.0) (exp x)) -1.0)))
double code(double x) {
return 1.0 + ((fmod(exp(x), 1.0) / exp(x)) + -1.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 + ((mod(exp(x), 1.0d0) / exp(x)) + (-1.0d0))
end function
def code(x): return 1.0 + ((math.fmod(math.exp(x), 1.0) / math.exp(x)) + -1.0)
function code(x) return Float64(1.0 + Float64(Float64(rem(exp(x), 1.0) / exp(x)) + -1.0)) end
code[x_] := N[(1.0 + N[(N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(\frac{\left(\left(e^{x}\right) \bmod 1\right)}{e^{x}} + -1\right)
\end{array}
Initial program 9.0%
exp-neg9.0%
associate-*r/9.0%
*-rgt-identity9.0%
Simplified9.0%
expm1-log1p-u9.0%
expm1-udef9.0%
log1p-udef9.0%
add-exp-log9.0%
Applied egg-rr9.0%
associate--l+9.0%
Simplified9.0%
Taylor expanded in x around 0 8.2%
Final simplification8.2%
(FPCore (x) :precision binary64 (/ (fmod (exp x) 1.0) (exp x)))
double code(double x) {
return fmod(exp(x), 1.0) / exp(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod(exp(x), 1.0d0) / exp(x)
end function
def code(x): return math.fmod(math.exp(x), 1.0) / math.exp(x)
function code(x) return Float64(rem(exp(x), 1.0) / exp(x)) end
code[x_] := N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(\left(e^{x}\right) \bmod 1\right)}{e^{x}}
\end{array}
Initial program 9.0%
exp-neg9.0%
associate-*r/9.0%
*-rgt-identity9.0%
Simplified9.0%
Taylor expanded in x around 0 8.2%
Final simplification8.2%
(FPCore (x) :precision binary64 (/ (fmod (exp x) 1.0) (/ (+ x 1.0) (- 1.0 (* x x)))))
double code(double x) {
return fmod(exp(x), 1.0) / ((x + 1.0) / (1.0 - (x * x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod(exp(x), 1.0d0) / ((x + 1.0d0) / (1.0d0 - (x * x)))
end function
def code(x): return math.fmod(math.exp(x), 1.0) / ((x + 1.0) / (1.0 - (x * x)))
function code(x) return Float64(rem(exp(x), 1.0) / Float64(Float64(x + 1.0) / Float64(1.0 - Float64(x * x)))) end
code[x_] := N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[(N[(x + 1.0), $MachinePrecision] / N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(\left(e^{x}\right) \bmod 1\right)}{\frac{x + 1}{1 - x \cdot x}}
\end{array}
Initial program 9.0%
exp-neg9.0%
associate-*r/9.0%
*-rgt-identity9.0%
Simplified9.0%
Taylor expanded in x around 0 8.2%
Taylor expanded in x around 0 7.4%
+-commutative7.4%
*-lft-identity7.4%
associate-*r*7.4%
neg-mul-17.4%
distribute-rgt-out7.4%
unsub-neg7.4%
Simplified7.4%
flip--7.4%
associate-*r/7.4%
metadata-eval7.4%
+-commutative7.4%
Applied egg-rr7.4%
associate-/l*7.4%
Simplified7.4%
Final simplification7.4%
(FPCore (x) :precision binary64 (* (fmod (exp x) 1.0) (- 1.0 x)))
double code(double x) {
return fmod(exp(x), 1.0) * (1.0 - x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod(exp(x), 1.0d0) * (1.0d0 - x)
end function
def code(x): return math.fmod(math.exp(x), 1.0) * (1.0 - x)
function code(x) return Float64(rem(exp(x), 1.0) * Float64(1.0 - x)) end
code[x_] := N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(e^{x}\right) \bmod 1\right) \cdot \left(1 - x\right)
\end{array}
Initial program 9.0%
exp-neg9.0%
associate-*r/9.0%
*-rgt-identity9.0%
Simplified9.0%
Taylor expanded in x around 0 8.2%
Taylor expanded in x around 0 7.4%
+-commutative7.4%
*-lft-identity7.4%
associate-*r*7.4%
neg-mul-17.4%
distribute-rgt-out7.4%
unsub-neg7.4%
Simplified7.4%
Final simplification7.4%
(FPCore (x) :precision binary64 (fmod (exp x) 1.0))
double code(double x) {
return fmod(exp(x), 1.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod(exp(x), 1.0d0)
end function
def code(x): return math.fmod(math.exp(x), 1.0)
function code(x) return rem(exp(x), 1.0) end
code[x_] := N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]
\begin{array}{l}
\\
\left(\left(e^{x}\right) \bmod 1\right)
\end{array}
Initial program 9.0%
exp-neg9.0%
associate-*r/9.0%
*-rgt-identity9.0%
Simplified9.0%
Taylor expanded in x around 0 8.2%
Taylor expanded in x around 0 6.7%
Final simplification6.7%
herbie shell --seed 2023271
(FPCore (x)
:name "expfmod (used to be hard to sample)"
:precision binary64
(* (fmod (exp x) (sqrt (cos x))) (exp (- x))))