
(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 11 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 (fmod (exp x) (sqrt (cos x)))) (t_1 (* t_0 (exp (- x)))))
(if (<= t_1 0.0)
(fmod (exp x) (sqrt (+ (log (cbrt E)) (log (pow (cbrt E) 2.0)))))
(if (<= t_1 2.0)
(/ (pow (pow t_0 3.0) 0.3333333333333333) (exp x))
(/ (fmod 1.0 1.0) (+ x 1.0))))))
double code(double x) {
double t_0 = fmod(exp(x), sqrt(cos(x)));
double t_1 = t_0 * exp(-x);
double tmp;
if (t_1 <= 0.0) {
tmp = fmod(exp(x), sqrt((log(cbrt(((double) M_E))) + log(pow(cbrt(((double) M_E)), 2.0)))));
} else if (t_1 <= 2.0) {
tmp = pow(pow(t_0, 3.0), 0.3333333333333333) / exp(x);
} else {
tmp = fmod(1.0, 1.0) / (x + 1.0);
}
return tmp;
}
function code(x) t_0 = rem(exp(x), sqrt(cos(x))) t_1 = Float64(t_0 * exp(Float64(-x))) tmp = 0.0 if (t_1 <= 0.0) tmp = rem(exp(x), sqrt(Float64(log(cbrt(exp(1))) + log((cbrt(exp(1)) ^ 2.0))))); elseif (t_1 <= 2.0) tmp = Float64(((t_0 ^ 3.0) ^ 0.3333333333333333) / exp(x)); else tmp = Float64(rem(1.0, 1.0) / Float64(x + 1.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[(t$95$0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[(N[Log[N[Power[E, 1/3], $MachinePrecision]], $MachinePrecision] + N[Log[N[Power[N[Power[E, 1/3], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[(N[Power[N[Power[t$95$0, 3.0], $MachinePrecision], 0.3333333333333333], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[(x + 1.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 := t\_0 \cdot e^{-x}\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;\left(\left(e^{x}\right) \bmod \left(\sqrt{\log \left(\sqrt[3]{e}\right) + \log \left({\left(\sqrt[3]{e}\right)}^{2}\right)}\right)\right)\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;\frac{{\left({t\_0}^{3}\right)}^{0.3333333333333333}}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 \bmod 1\right)}{x + 1}\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 0.0Initial program 4.1%
/-rgt-identity4.1%
associate-/r/4.1%
exp-neg4.1%
remove-double-neg4.1%
Simplified4.1%
add-log-exp4.1%
add-cube-cbrt55.7%
log-prod55.7%
pow255.7%
Applied egg-rr55.7%
Taylor expanded in x around 0 55.7%
exp-1-e55.7%
Simplified55.7%
Taylor expanded in x around 0 55.7%
exp-1-e55.7%
Simplified55.7%
Taylor expanded in x around 0 55.7%
if 0.0 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 86.1%
/-rgt-identity86.1%
associate-/r/85.6%
exp-neg86.2%
remove-double-neg86.2%
Simplified86.2%
add-cbrt-cube85.3%
pow1/386.2%
pow386.2%
Applied egg-rr86.2%
if 2 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 0.0%
/-rgt-identity0.0%
associate-/r/0.0%
exp-neg0.0%
remove-double-neg0.0%
Simplified0.0%
add-cbrt-cube0.0%
pow30.0%
pow1/20.0%
pow-pow0.0%
metadata-eval0.0%
Applied egg-rr0.0%
Taylor expanded in x around 0 0.0%
+-commutative0.0%
Simplified0.0%
Taylor expanded in x around 0 0.0%
Taylor expanded in x around 0 100.0%
Final simplification65.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (exp (cos x)))))
(if (<= (* (fmod (exp x) (sqrt (cos x))) (exp (- x))) 2.0)
(/ (fmod (exp x) (sqrt (+ (log (pow t_0 2.0)) (log t_0)))) (exp x))
(/ (fmod 1.0 1.0) (+ x 1.0)))))
double code(double x) {
double t_0 = cbrt(exp(cos(x)));
double tmp;
if ((fmod(exp(x), sqrt(cos(x))) * exp(-x)) <= 2.0) {
tmp = fmod(exp(x), sqrt((log(pow(t_0, 2.0)) + log(t_0)))) / exp(x);
} else {
tmp = fmod(1.0, 1.0) / (x + 1.0);
}
return tmp;
}
function code(x) t_0 = cbrt(exp(cos(x))) tmp = 0.0 if (Float64(rem(exp(x), sqrt(cos(x))) * exp(Float64(-x))) <= 2.0) tmp = Float64(rem(exp(x), sqrt(Float64(log((t_0 ^ 2.0)) + log(t_0)))) / exp(x)); else tmp = Float64(rem(1.0, 1.0) / Float64(x + 1.0)); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[Exp[N[Cos[x], $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[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], 2.0], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[(N[Log[N[Power[t$95$0, 2.0], $MachinePrecision]], $MachinePrecision] + N[Log[t$95$0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{e^{\cos x}}\\
\mathbf{if}\;\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \leq 2:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\log \left({t\_0}^{2}\right) + \log t\_0}\right)\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 \bmod 1\right)}{x + 1}\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 9.9%
/-rgt-identity9.9%
associate-/r/9.9%
exp-neg9.9%
remove-double-neg9.9%
Simplified9.9%
add-log-exp9.9%
add-cube-cbrt57.7%
log-prod57.7%
pow257.7%
Applied egg-rr57.7%
if 2 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 0.0%
/-rgt-identity0.0%
associate-/r/0.0%
exp-neg0.0%
remove-double-neg0.0%
Simplified0.0%
add-cbrt-cube0.0%
pow30.0%
pow1/20.0%
pow-pow0.0%
metadata-eval0.0%
Applied egg-rr0.0%
Taylor expanded in x around 0 0.0%
+-commutative0.0%
Simplified0.0%
Taylor expanded in x around 0 0.0%
Taylor expanded in x around 0 100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (fmod (exp x) (sqrt (cos x))))
(t_1 (exp (- x)))
(t_2 (* t_0 t_1)))
(if (<= t_2 4e-14)
(*
t_1
(log (exp (fmod (* x (+ 1.0 (/ 1.0 x))) (+ 1.0 (* -0.25 (pow x 2.0)))))))
(if (<= t_2 2.0)
(/ (pow (pow t_0 3.0) 0.3333333333333333) (exp x))
(/ (fmod 1.0 1.0) (+ x 1.0))))))
double code(double x) {
double t_0 = fmod(exp(x), sqrt(cos(x)));
double t_1 = exp(-x);
double t_2 = t_0 * t_1;
double tmp;
if (t_2 <= 4e-14) {
tmp = t_1 * log(exp(fmod((x * (1.0 + (1.0 / x))), (1.0 + (-0.25 * pow(x, 2.0))))));
} else if (t_2 <= 2.0) {
tmp = pow(pow(t_0, 3.0), 0.3333333333333333) / exp(x);
} else {
tmp = fmod(1.0, 1.0) / (x + 1.0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = mod(exp(x), sqrt(cos(x)))
t_1 = exp(-x)
t_2 = t_0 * t_1
if (t_2 <= 4d-14) then
tmp = t_1 * log(exp(mod((x * (1.0d0 + (1.0d0 / x))), (1.0d0 + ((-0.25d0) * (x ** 2.0d0))))))
else if (t_2 <= 2.0d0) then
tmp = ((t_0 ** 3.0d0) ** 0.3333333333333333d0) / exp(x)
else
tmp = mod(1.0d0, 1.0d0) / (x + 1.0d0)
end if
code = tmp
end function
def code(x): t_0 = math.fmod(math.exp(x), math.sqrt(math.cos(x))) t_1 = math.exp(-x) t_2 = t_0 * t_1 tmp = 0 if t_2 <= 4e-14: tmp = t_1 * math.log(math.exp(math.fmod((x * (1.0 + (1.0 / x))), (1.0 + (-0.25 * math.pow(x, 2.0)))))) elif t_2 <= 2.0: tmp = math.pow(math.pow(t_0, 3.0), 0.3333333333333333) / math.exp(x) else: tmp = math.fmod(1.0, 1.0) / (x + 1.0) return tmp
function code(x) t_0 = rem(exp(x), sqrt(cos(x))) t_1 = exp(Float64(-x)) t_2 = Float64(t_0 * t_1) tmp = 0.0 if (t_2 <= 4e-14) tmp = Float64(t_1 * log(exp(rem(Float64(x * Float64(1.0 + Float64(1.0 / x))), Float64(1.0 + Float64(-0.25 * (x ^ 2.0))))))); elseif (t_2 <= 2.0) tmp = Float64(((t_0 ^ 3.0) ^ 0.3333333333333333) / exp(x)); else tmp = Float64(rem(1.0, 1.0) / Float64(x + 1.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[Exp[(-x)], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, 4e-14], N[(t$95$1 * N[Log[N[Exp[N[With[{TMP1 = N[(x * N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], TMP2 = N[(1.0 + N[(-0.25 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2.0], N[(N[Power[N[Power[t$95$0, 3.0], $MachinePrecision], 0.3333333333333333], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[(x + 1.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 := e^{-x}\\
t_2 := t\_0 \cdot t\_1\\
\mathbf{if}\;t\_2 \leq 4 \cdot 10^{-14}:\\
\;\;\;\;t\_1 \cdot \log \left(e^{\left(\left(x \cdot \left(1 + \frac{1}{x}\right)\right) \bmod \left(1 + -0.25 \cdot {x}^{2}\right)\right)}\right)\\
\mathbf{elif}\;t\_2 \leq 2:\\
\;\;\;\;\frac{{\left({t\_0}^{3}\right)}^{0.3333333333333333}}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 \bmod 1\right)}{x + 1}\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 4e-14Initial program 4.2%
add-log-exp4.2%
Applied egg-rr4.2%
Taylor expanded in x around 0 4.2%
Taylor expanded in x around 0 4.2%
+-commutative4.2%
Simplified4.2%
Taylor expanded in x around inf 13.1%
if 4e-14 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 90.0%
/-rgt-identity90.0%
associate-/r/89.6%
exp-neg90.1%
remove-double-neg90.1%
Simplified90.1%
add-cbrt-cube89.3%
pow1/390.1%
pow390.1%
Applied egg-rr90.1%
if 2 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 0.0%
/-rgt-identity0.0%
associate-/r/0.0%
exp-neg0.0%
remove-double-neg0.0%
Simplified0.0%
add-cbrt-cube0.0%
pow30.0%
pow1/20.0%
pow-pow0.0%
metadata-eval0.0%
Applied egg-rr0.0%
Taylor expanded in x around 0 0.0%
+-commutative0.0%
Simplified0.0%
Taylor expanded in x around 0 0.0%
Taylor expanded in x around 0 100.0%
Final simplification32.9%
(FPCore (x)
:precision binary64
(if (<= (* (fmod (exp x) (sqrt (cos x))) (exp (- x))) 2.0)
(/
(fmod
(exp x)
(sqrt (+ (log (pow (cbrt (exp (cos x))) 2.0)) (log (cbrt E)))))
(exp x))
(/ (fmod 1.0 1.0) (+ x 1.0))))
double code(double x) {
double tmp;
if ((fmod(exp(x), sqrt(cos(x))) * exp(-x)) <= 2.0) {
tmp = fmod(exp(x), sqrt((log(pow(cbrt(exp(cos(x))), 2.0)) + log(cbrt(((double) M_E)))))) / exp(x);
} else {
tmp = fmod(1.0, 1.0) / (x + 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(rem(exp(x), sqrt(cos(x))) * exp(Float64(-x))) <= 2.0) tmp = Float64(rem(exp(x), sqrt(Float64(log((cbrt(exp(cos(x))) ^ 2.0)) + log(cbrt(exp(1)))))) / exp(x)); else tmp = Float64(rem(1.0, 1.0) / Float64(x + 1.0)); end return tmp end
code[x_] := If[LessEqual[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], 2.0], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[(N[Log[N[Power[N[Power[N[Exp[N[Cos[x], $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision] + N[Log[N[Power[E, 1/3], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \leq 2:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\log \left({\left(\sqrt[3]{e^{\cos x}}\right)}^{2}\right) + \log \left(\sqrt[3]{e}\right)}\right)\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 \bmod 1\right)}{x + 1}\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 9.9%
/-rgt-identity9.9%
associate-/r/9.9%
exp-neg9.9%
remove-double-neg9.9%
Simplified9.9%
add-log-exp9.9%
add-cube-cbrt57.7%
log-prod57.7%
pow257.7%
Applied egg-rr57.7%
Taylor expanded in x around 0 56.4%
exp-1-e56.4%
Simplified56.4%
if 2 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 0.0%
/-rgt-identity0.0%
associate-/r/0.0%
exp-neg0.0%
remove-double-neg0.0%
Simplified0.0%
add-cbrt-cube0.0%
pow30.0%
pow1/20.0%
pow-pow0.0%
metadata-eval0.0%
Applied egg-rr0.0%
Taylor expanded in x around 0 0.0%
+-commutative0.0%
Simplified0.0%
Taylor expanded in x around 0 0.0%
Taylor expanded in x around 0 100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (fmod (exp x) (sqrt (cos x))))
(t_1 (exp (- x)))
(t_2 (* t_0 t_1)))
(if (<= t_2 4e-14)
(*
t_1
(log (exp (fmod (* x (+ 1.0 (/ 1.0 x))) (+ 1.0 (* -0.25 (pow x 2.0)))))))
(if (<= t_2 2.0) (/ t_0 (exp x)) (/ (fmod 1.0 1.0) (+ x 1.0))))))
double code(double x) {
double t_0 = fmod(exp(x), sqrt(cos(x)));
double t_1 = exp(-x);
double t_2 = t_0 * t_1;
double tmp;
if (t_2 <= 4e-14) {
tmp = t_1 * log(exp(fmod((x * (1.0 + (1.0 / x))), (1.0 + (-0.25 * pow(x, 2.0))))));
} else if (t_2 <= 2.0) {
tmp = t_0 / exp(x);
} else {
tmp = fmod(1.0, 1.0) / (x + 1.0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = mod(exp(x), sqrt(cos(x)))
t_1 = exp(-x)
t_2 = t_0 * t_1
if (t_2 <= 4d-14) then
tmp = t_1 * log(exp(mod((x * (1.0d0 + (1.0d0 / x))), (1.0d0 + ((-0.25d0) * (x ** 2.0d0))))))
else if (t_2 <= 2.0d0) then
tmp = t_0 / exp(x)
else
tmp = mod(1.0d0, 1.0d0) / (x + 1.0d0)
end if
code = tmp
end function
def code(x): t_0 = math.fmod(math.exp(x), math.sqrt(math.cos(x))) t_1 = math.exp(-x) t_2 = t_0 * t_1 tmp = 0 if t_2 <= 4e-14: tmp = t_1 * math.log(math.exp(math.fmod((x * (1.0 + (1.0 / x))), (1.0 + (-0.25 * math.pow(x, 2.0)))))) elif t_2 <= 2.0: tmp = t_0 / math.exp(x) else: tmp = math.fmod(1.0, 1.0) / (x + 1.0) return tmp
function code(x) t_0 = rem(exp(x), sqrt(cos(x))) t_1 = exp(Float64(-x)) t_2 = Float64(t_0 * t_1) tmp = 0.0 if (t_2 <= 4e-14) tmp = Float64(t_1 * log(exp(rem(Float64(x * Float64(1.0 + Float64(1.0 / x))), Float64(1.0 + Float64(-0.25 * (x ^ 2.0))))))); elseif (t_2 <= 2.0) tmp = Float64(t_0 / exp(x)); else tmp = Float64(rem(1.0, 1.0) / Float64(x + 1.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[Exp[(-x)], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, 4e-14], N[(t$95$1 * N[Log[N[Exp[N[With[{TMP1 = N[(x * N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], TMP2 = N[(1.0 + N[(-0.25 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2.0], N[(t$95$0 / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[(x + 1.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 := e^{-x}\\
t_2 := t\_0 \cdot t\_1\\
\mathbf{if}\;t\_2 \leq 4 \cdot 10^{-14}:\\
\;\;\;\;t\_1 \cdot \log \left(e^{\left(\left(x \cdot \left(1 + \frac{1}{x}\right)\right) \bmod \left(1 + -0.25 \cdot {x}^{2}\right)\right)}\right)\\
\mathbf{elif}\;t\_2 \leq 2:\\
\;\;\;\;\frac{t\_0}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 \bmod 1\right)}{x + 1}\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 4e-14Initial program 4.2%
add-log-exp4.2%
Applied egg-rr4.2%
Taylor expanded in x around 0 4.2%
Taylor expanded in x around 0 4.2%
+-commutative4.2%
Simplified4.2%
Taylor expanded in x around inf 13.1%
if 4e-14 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 90.0%
/-rgt-identity90.0%
associate-/r/89.6%
exp-neg90.1%
remove-double-neg90.1%
Simplified90.1%
if 2 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 0.0%
/-rgt-identity0.0%
associate-/r/0.0%
exp-neg0.0%
remove-double-neg0.0%
Simplified0.0%
add-cbrt-cube0.0%
pow30.0%
pow1/20.0%
pow-pow0.0%
metadata-eval0.0%
Applied egg-rr0.0%
Taylor expanded in x around 0 0.0%
+-commutative0.0%
Simplified0.0%
Taylor expanded in x around 0 0.0%
Taylor expanded in x around 0 100.0%
Final simplification32.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (fmod (exp x) (sqrt (cos x)))))
(if (<= (* t_0 (exp (- x))) 2.0)
(/ t_0 (exp x))
(/ (fmod 1.0 1.0) (+ x 1.0)))))
double code(double x) {
double t_0 = fmod(exp(x), sqrt(cos(x)));
double tmp;
if ((t_0 * exp(-x)) <= 2.0) {
tmp = t_0 / exp(x);
} else {
tmp = fmod(1.0, 1.0) / (x + 1.0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = mod(exp(x), sqrt(cos(x)))
if ((t_0 * exp(-x)) <= 2.0d0) then
tmp = t_0 / exp(x)
else
tmp = mod(1.0d0, 1.0d0) / (x + 1.0d0)
end if
code = tmp
end function
def code(x): t_0 = math.fmod(math.exp(x), math.sqrt(math.cos(x))) tmp = 0 if (t_0 * math.exp(-x)) <= 2.0: tmp = t_0 / math.exp(x) else: tmp = math.fmod(1.0, 1.0) / (x + 1.0) return tmp
function code(x) t_0 = rem(exp(x), sqrt(cos(x))) tmp = 0.0 if (Float64(t_0 * exp(Float64(-x))) <= 2.0) tmp = Float64(t_0 / exp(x)); else tmp = Float64(rem(1.0, 1.0) / Float64(x + 1.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]}, If[LessEqual[N[(t$95$0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], 2.0], N[(t$95$0 / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
\mathbf{if}\;t\_0 \cdot e^{-x} \leq 2:\\
\;\;\;\;\frac{t\_0}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 \bmod 1\right)}{x + 1}\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 9.9%
/-rgt-identity9.9%
associate-/r/9.9%
exp-neg9.9%
remove-double-neg9.9%
Simplified9.9%
if 2 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 0.0%
/-rgt-identity0.0%
associate-/r/0.0%
exp-neg0.0%
remove-double-neg0.0%
Simplified0.0%
add-cbrt-cube0.0%
pow30.0%
pow1/20.0%
pow-pow0.0%
metadata-eval0.0%
Applied egg-rr0.0%
Taylor expanded in x around 0 0.0%
+-commutative0.0%
Simplified0.0%
Taylor expanded in x around 0 0.0%
Taylor expanded in x around 0 100.0%
(FPCore (x)
:precision binary64
(if (<= x -5e-310)
(/
(fmod (exp x) (sqrt (+ (log (cbrt E)) (log (pow (cbrt E) 2.0)))))
(exp x))
(* (exp (- x)) (log (exp (fmod (+ x 1.0) (sqrt (cos x))))))))
double code(double x) {
double tmp;
if (x <= -5e-310) {
tmp = fmod(exp(x), sqrt((log(cbrt(((double) M_E))) + log(pow(cbrt(((double) M_E)), 2.0))))) / exp(x);
} else {
tmp = exp(-x) * log(exp(fmod((x + 1.0), sqrt(cos(x)))));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= -5e-310) tmp = Float64(rem(exp(x), sqrt(Float64(log(cbrt(exp(1))) + log((cbrt(exp(1)) ^ 2.0))))) / exp(x)); else tmp = Float64(exp(Float64(-x)) * log(exp(rem(Float64(x + 1.0), sqrt(cos(x)))))); end return tmp end
code[x_] := If[LessEqual[x, -5e-310], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[(N[Log[N[Power[E, 1/3], $MachinePrecision]], $MachinePrecision] + N[Log[N[Power[N[Power[E, 1/3], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[Exp[(-x)], $MachinePrecision] * N[Log[N[Exp[N[With[{TMP1 = N[(x + 1.0), $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\log \left(\sqrt[3]{e}\right) + \log \left({\left(\sqrt[3]{e}\right)}^{2}\right)}\right)\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;e^{-x} \cdot \log \left(e^{\left(\left(x + 1\right) \bmod \left(\sqrt{\cos x}\right)\right)}\right)\\
\end{array}
\end{array}
if x < -4.999999999999985e-310Initial program 8.4%
/-rgt-identity8.4%
associate-/r/8.4%
exp-neg8.4%
remove-double-neg8.4%
Simplified8.4%
add-log-exp8.4%
add-cube-cbrt100.0%
log-prod100.0%
pow2100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 100.0%
exp-1-e100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
exp-1-e100.0%
Simplified100.0%
if -4.999999999999985e-310 < x Initial program 8.0%
add-log-exp7.9%
Applied egg-rr7.9%
Taylor expanded in x around 0 37.1%
+-commutative6.2%
Simplified37.1%
Final simplification64.1%
(FPCore (x) :precision binary64 (if (<= x 0.5) (/ (fmod (exp x) (+ 1.0 (* -0.25 (* x x)))) (exp x)) (/ (fmod 1.0 1.0) (+ x 1.0))))
double code(double x) {
double tmp;
if (x <= 0.5) {
tmp = fmod(exp(x), (1.0 + (-0.25 * (x * x)))) / exp(x);
} else {
tmp = fmod(1.0, 1.0) / (x + 1.0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.5d0) then
tmp = mod(exp(x), (1.0d0 + ((-0.25d0) * (x * x)))) / exp(x)
else
tmp = mod(1.0d0, 1.0d0) / (x + 1.0d0)
end if
code = tmp
end function
def code(x): tmp = 0 if x <= 0.5: tmp = math.fmod(math.exp(x), (1.0 + (-0.25 * (x * x)))) / math.exp(x) else: tmp = math.fmod(1.0, 1.0) / (x + 1.0) return tmp
function code(x) tmp = 0.0 if (x <= 0.5) tmp = Float64(rem(exp(x), Float64(1.0 + Float64(-0.25 * Float64(x * x)))) / exp(x)); else tmp = Float64(rem(1.0, 1.0) / Float64(x + 1.0)); end return tmp end
code[x_] := If[LessEqual[x, 0.5], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(1.0 + N[(-0.25 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.5:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(1 + -0.25 \cdot \left(x \cdot x\right)\right)\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 \bmod 1\right)}{x + 1}\\
\end{array}
\end{array}
if x < 0.5Initial program 9.9%
/-rgt-identity9.9%
associate-/r/9.9%
exp-neg9.9%
remove-double-neg9.9%
Simplified9.9%
Taylor expanded in x around 0 9.0%
unpow29.0%
Applied egg-rr9.0%
if 0.5 < x Initial program 0.0%
/-rgt-identity0.0%
associate-/r/0.0%
exp-neg0.0%
remove-double-neg0.0%
Simplified0.0%
add-cbrt-cube0.0%
pow30.0%
pow1/20.0%
pow-pow0.0%
metadata-eval0.0%
Applied egg-rr0.0%
Taylor expanded in x around 0 0.0%
+-commutative0.0%
Simplified0.0%
Taylor expanded in x around 0 0.0%
Taylor expanded in x around 0 100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ 1.0 (* x (+ 1.0 (* x 0.5))))))
(if (<= x 0.5)
(/ (fmod t_0 (+ 1.0 (* -0.25 (* x x)))) t_0)
(/ (fmod 1.0 1.0) (+ x 1.0)))))
double code(double x) {
double t_0 = 1.0 + (x * (1.0 + (x * 0.5)));
double tmp;
if (x <= 0.5) {
tmp = fmod(t_0, (1.0 + (-0.25 * (x * x)))) / t_0;
} else {
tmp = fmod(1.0, 1.0) / (x + 1.0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 + (x * (1.0d0 + (x * 0.5d0)))
if (x <= 0.5d0) then
tmp = mod(t_0, (1.0d0 + ((-0.25d0) * (x * x)))) / t_0
else
tmp = mod(1.0d0, 1.0d0) / (x + 1.0d0)
end if
code = tmp
end function
def code(x): t_0 = 1.0 + (x * (1.0 + (x * 0.5))) tmp = 0 if x <= 0.5: tmp = math.fmod(t_0, (1.0 + (-0.25 * (x * x)))) / t_0 else: tmp = math.fmod(1.0, 1.0) / (x + 1.0) return tmp
function code(x) t_0 = Float64(1.0 + Float64(x * Float64(1.0 + Float64(x * 0.5)))) tmp = 0.0 if (x <= 0.5) tmp = Float64(rem(t_0, Float64(1.0 + Float64(-0.25 * Float64(x * x)))) / t_0); else tmp = Float64(rem(1.0, 1.0) / Float64(x + 1.0)); end return tmp end
code[x_] := Block[{t$95$0 = N[(1.0 + N[(x * N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 0.5], N[(N[With[{TMP1 = t$95$0, TMP2 = N[(1.0 + N[(-0.25 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + x \cdot \left(1 + x \cdot 0.5\right)\\
\mathbf{if}\;x \leq 0.5:\\
\;\;\;\;\frac{\left(t\_0 \bmod \left(1 + -0.25 \cdot \left(x \cdot x\right)\right)\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 \bmod 1\right)}{x + 1}\\
\end{array}
\end{array}
if x < 0.5Initial program 9.9%
/-rgt-identity9.9%
associate-/r/9.9%
exp-neg9.9%
remove-double-neg9.9%
Simplified9.9%
Taylor expanded in x around 0 9.0%
unpow29.0%
Applied egg-rr9.0%
Taylor expanded in x around 0 8.1%
*-commutative8.1%
Simplified8.1%
Taylor expanded in x around 0 8.8%
*-commutative8.1%
Simplified8.8%
if 0.5 < x Initial program 0.0%
/-rgt-identity0.0%
associate-/r/0.0%
exp-neg0.0%
remove-double-neg0.0%
Simplified0.0%
add-cbrt-cube0.0%
pow30.0%
pow1/20.0%
pow-pow0.0%
metadata-eval0.0%
Applied egg-rr0.0%
Taylor expanded in x around 0 0.0%
+-commutative0.0%
Simplified0.0%
Taylor expanded in x around 0 0.0%
Taylor expanded in x around 0 100.0%
(FPCore (x) :precision binary64 (/ (fmod (+ x 1.0) 1.0) (+ x 1.0)))
double code(double x) {
return fmod((x + 1.0), 1.0) / (x + 1.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod((x + 1.0d0), 1.0d0) / (x + 1.0d0)
end function
def code(x): return math.fmod((x + 1.0), 1.0) / (x + 1.0)
function code(x) return Float64(rem(Float64(x + 1.0), 1.0) / Float64(x + 1.0)) end
code[x_] := N[(N[With[{TMP1 = N[(x + 1.0), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(\left(x + 1\right) \bmod 1\right)}{x + 1}
\end{array}
Initial program 8.2%
/-rgt-identity8.2%
associate-/r/8.1%
exp-neg8.2%
remove-double-neg8.2%
Simplified8.2%
add-cbrt-cube8.1%
pow38.1%
pow1/28.1%
pow-pow8.1%
metadata-eval8.1%
Applied egg-rr8.1%
Taylor expanded in x around 0 6.4%
+-commutative6.4%
Simplified6.4%
Taylor expanded in x around 0 6.1%
Taylor expanded in x around 0 23.2%
+-commutative6.4%
Simplified23.2%
(FPCore (x) :precision binary64 (/ (fmod 1.0 1.0) (+ x 1.0)))
double code(double x) {
return fmod(1.0, 1.0) / (x + 1.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod(1.0d0, 1.0d0) / (x + 1.0d0)
end function
def code(x): return math.fmod(1.0, 1.0) / (x + 1.0)
function code(x) return Float64(rem(1.0, 1.0) / Float64(x + 1.0)) end
code[x_] := N[(N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 \bmod 1\right)}{x + 1}
\end{array}
Initial program 8.2%
/-rgt-identity8.2%
associate-/r/8.1%
exp-neg8.2%
remove-double-neg8.2%
Simplified8.2%
add-cbrt-cube8.1%
pow38.1%
pow1/28.1%
pow-pow8.1%
metadata-eval8.1%
Applied egg-rr8.1%
Taylor expanded in x around 0 6.4%
+-commutative6.4%
Simplified6.4%
Taylor expanded in x around 0 6.1%
Taylor expanded in x around 0 21.3%
herbie shell --seed 2024139
(FPCore (x)
:name "expfmod (used to be hard to sample)"
:precision binary64
(* (fmod (exp x) (sqrt (cos x))) (exp (- x))))