
(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 12 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 (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))))
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);
}
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 = rem(1.0, 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[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $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}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 7.6%
/-rgt-identity7.6%
associate-/r/7.6%
exp-neg7.6%
remove-double-neg7.6%
Simplified7.6%
add-log-exp7.6%
add-cube-cbrt49.6%
log-prod49.6%
pow249.6%
Applied egg-rr49.6%
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%
Taylor expanded in x around 0 0.0%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 100.0%
(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)))
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);
}
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 = rem(1.0, 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[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $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}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 7.6%
/-rgt-identity7.6%
associate-/r/7.6%
exp-neg7.6%
remove-double-neg7.6%
Simplified7.6%
add-log-exp7.6%
add-cube-cbrt49.6%
log-prod49.6%
pow249.6%
Applied egg-rr49.6%
Taylor expanded in x around 0 49.1%
exp-1-e49.1%
Simplified49.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%
Taylor expanded in x around 0 0.0%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (fmod (exp x) (sqrt (cos x)))))
(if (<= (* t_0 (exp (- x))) 2.0)
(log (exp (/ t_0 (exp x))))
(fmod 1.0 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 = log(exp((t_0 / exp(x))));
} else {
tmp = fmod(1.0, 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 = log(exp((t_0 / exp(x))))
else
tmp = mod(1.0d0, 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 = math.log(math.exp((t_0 / math.exp(x)))) else: tmp = math.fmod(1.0, 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 = log(exp(Float64(t_0 / exp(x)))); else tmp = rem(1.0, 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[Log[N[Exp[N[(t$95$0 / N[Exp[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $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:\\
\;\;\;\;\log \left(e^{\frac{t\_0}{e^{x}}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 7.6%
/-rgt-identity7.6%
associate-/r/7.6%
exp-neg7.6%
remove-double-neg7.6%
Simplified7.6%
add-log-exp7.6%
Applied egg-rr7.6%
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%
Taylor expanded in x around 0 0.0%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 100.0%
(FPCore (x) :precision binary64 (if (<= (* (fmod (exp x) (sqrt (cos x))) (exp (- x))) 2.0) (/ (fmod (exp x) (pow (cbrt (cos x)) 1.5)) (exp x)) (fmod 1.0 1.0)))
double code(double x) {
double tmp;
if ((fmod(exp(x), sqrt(cos(x))) * exp(-x)) <= 2.0) {
tmp = fmod(exp(x), pow(cbrt(cos(x)), 1.5)) / exp(x);
} else {
tmp = fmod(1.0, 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), (cbrt(cos(x)) ^ 1.5)) / exp(x)); else tmp = rem(1.0, 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[Power[N[Power[N[Cos[x], $MachinePrecision], 1/3], $MachinePrecision], 1.5], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $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({\left(\sqrt[3]{\cos x}\right)}^{1.5}\right)\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 7.6%
/-rgt-identity7.6%
associate-/r/7.6%
exp-neg7.6%
remove-double-neg7.6%
Simplified7.6%
pow1/27.6%
add-cube-cbrt7.6%
pow37.6%
pow-pow7.6%
metadata-eval7.6%
Applied egg-rr7.6%
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%
Taylor expanded in x around 0 0.0%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 100.0%
(FPCore (x) :precision binary64 (let* ((t_0 (fmod (exp x) (sqrt (cos x))))) (if (<= (* t_0 (exp (- x))) 2.0) (exp (- (log t_0) x)) (fmod 1.0 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 = exp((log(t_0) - x));
} else {
tmp = fmod(1.0, 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 = exp((log(t_0) - x))
else
tmp = mod(1.0d0, 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 = math.exp((math.log(t_0) - x)) else: tmp = math.fmod(1.0, 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 = exp(Float64(log(t_0) - x)); else tmp = rem(1.0, 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[Exp[N[(N[Log[t$95$0], $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision], N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $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:\\
\;\;\;\;e^{\log t\_0 - x}\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 7.6%
/-rgt-identity7.6%
associate-/r/7.6%
exp-neg7.6%
remove-double-neg7.6%
Simplified7.6%
add-exp-log7.6%
div-exp7.6%
Applied egg-rr7.6%
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%
Taylor expanded in x around 0 0.0%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 100.0%
(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))))
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);
}
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)
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) 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 = rem(1.0, 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[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $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}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 7.6%
/-rgt-identity7.6%
associate-/r/7.6%
exp-neg7.6%
remove-double-neg7.6%
Simplified7.6%
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%
Taylor expanded in x around 0 0.0%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 100.0%
(FPCore (x)
:precision binary64
(if (<= x 10.0)
(/
(fmod (exp x) (sqrt (+ (log (cbrt E)) (log (pow (cbrt E) 2.0)))))
(exp x))
(fmod 1.0 1.0)))
double code(double x) {
double tmp;
if (x <= 10.0) {
tmp = fmod(exp(x), sqrt((log(cbrt(((double) M_E))) + log(pow(cbrt(((double) M_E)), 2.0))))) / exp(x);
} else {
tmp = fmod(1.0, 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 10.0) tmp = Float64(rem(exp(x), sqrt(Float64(log(cbrt(exp(1))) + log((cbrt(exp(1)) ^ 2.0))))) / exp(x)); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[x, 10.0], 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[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10:\\
\;\;\;\;\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}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < 10Initial program 7.6%
/-rgt-identity7.6%
associate-/r/7.6%
exp-neg7.6%
remove-double-neg7.6%
Simplified7.6%
add-log-exp7.6%
add-cube-cbrt49.6%
log-prod49.6%
pow249.6%
Applied egg-rr49.6%
Taylor expanded in x around 0 49.1%
exp-1-e49.1%
Simplified49.1%
Taylor expanded in x around 0 49.1%
exp-1-e49.1%
Simplified49.1%
if 10 < x Initial program 0.0%
/-rgt-identity0.0%
associate-/r/0.0%
exp-neg0.0%
remove-double-neg0.0%
Simplified0.0%
Taylor expanded in x around 0 0.0%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 100.0%
Final simplification60.6%
(FPCore (x) :precision binary64 (if (<= x 10.0) (fmod (exp x) (sqrt (+ (log (cbrt E)) (log (pow (cbrt E) 2.0))))) (fmod 1.0 1.0)))
double code(double x) {
double tmp;
if (x <= 10.0) {
tmp = fmod(exp(x), sqrt((log(cbrt(((double) M_E))) + log(pow(cbrt(((double) M_E)), 2.0)))));
} else {
tmp = fmod(1.0, 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 10.0) tmp = rem(exp(x), sqrt(Float64(log(cbrt(exp(1))) + log((cbrt(exp(1)) ^ 2.0))))); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[x, 10.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], N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10:\\
\;\;\;\;\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{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < 10Initial program 7.6%
/-rgt-identity7.6%
associate-/r/7.6%
exp-neg7.6%
remove-double-neg7.6%
Simplified7.6%
add-log-exp7.6%
add-cube-cbrt49.6%
log-prod49.6%
pow249.6%
Applied egg-rr49.6%
Taylor expanded in x around 0 49.1%
exp-1-e49.1%
Simplified49.1%
Taylor expanded in x around 0 49.1%
exp-1-e49.1%
Simplified49.1%
Taylor expanded in x around 0 48.1%
if 10 < x Initial program 0.0%
/-rgt-identity0.0%
associate-/r/0.0%
exp-neg0.0%
remove-double-neg0.0%
Simplified0.0%
Taylor expanded in x around 0 0.0%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 100.0%
Final simplification59.9%
(FPCore (x) :precision binary64 (if (<= x 10.0) (/ (fmod (exp x) (+ 1.0 (* -0.25 (pow x 2.0)))) (exp x)) (fmod 1.0 1.0)))
double code(double x) {
double tmp;
if (x <= 10.0) {
tmp = fmod(exp(x), (1.0 + (-0.25 * pow(x, 2.0)))) / exp(x);
} else {
tmp = fmod(1.0, 1.0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 10.0d0) then
tmp = mod(exp(x), (1.0d0 + ((-0.25d0) * (x ** 2.0d0)))) / exp(x)
else
tmp = mod(1.0d0, 1.0d0)
end if
code = tmp
end function
def code(x): tmp = 0 if x <= 10.0: tmp = math.fmod(math.exp(x), (1.0 + (-0.25 * math.pow(x, 2.0)))) / math.exp(x) else: tmp = math.fmod(1.0, 1.0) return tmp
function code(x) tmp = 0.0 if (x <= 10.0) tmp = Float64(rem(exp(x), Float64(1.0 + Float64(-0.25 * (x ^ 2.0)))) / exp(x)); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[x, 10.0], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(1.0 + N[(-0.25 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(1 + -0.25 \cdot {x}^{2}\right)\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < 10Initial program 7.6%
/-rgt-identity7.6%
associate-/r/7.6%
exp-neg7.6%
remove-double-neg7.6%
Simplified7.6%
Taylor expanded in x around 0 7.2%
if 10 < x Initial program 0.0%
/-rgt-identity0.0%
associate-/r/0.0%
exp-neg0.0%
remove-double-neg0.0%
Simplified0.0%
Taylor expanded in x around 0 0.0%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 100.0%
(FPCore (x) :precision binary64 (if (<= x 10.0) (/ (fmod (+ x 1.0) (+ 1.0 (* -0.25 (pow x 2.0)))) (+ x 1.0)) (fmod 1.0 1.0)))
double code(double x) {
double tmp;
if (x <= 10.0) {
tmp = fmod((x + 1.0), (1.0 + (-0.25 * pow(x, 2.0)))) / (x + 1.0);
} else {
tmp = fmod(1.0, 1.0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 10.0d0) then
tmp = mod((x + 1.0d0), (1.0d0 + ((-0.25d0) * (x ** 2.0d0)))) / (x + 1.0d0)
else
tmp = mod(1.0d0, 1.0d0)
end if
code = tmp
end function
def code(x): tmp = 0 if x <= 10.0: tmp = math.fmod((x + 1.0), (1.0 + (-0.25 * math.pow(x, 2.0)))) / (x + 1.0) else: tmp = math.fmod(1.0, 1.0) return tmp
function code(x) tmp = 0.0 if (x <= 10.0) tmp = Float64(rem(Float64(x + 1.0), Float64(1.0 + Float64(-0.25 * (x ^ 2.0)))) / Float64(x + 1.0)); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[x, 10.0], N[(N[With[{TMP1 = N[(x + 1.0), $MachinePrecision], TMP2 = N[(1.0 + N[(-0.25 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10:\\
\;\;\;\;\frac{\left(\left(x + 1\right) \bmod \left(1 + -0.25 \cdot {x}^{2}\right)\right)}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < 10Initial program 7.6%
/-rgt-identity7.6%
associate-/r/7.6%
exp-neg7.6%
remove-double-neg7.6%
Simplified7.6%
Taylor expanded in x around 0 6.5%
+-commutative6.5%
Simplified6.5%
Taylor expanded in x around 0 6.5%
Taylor expanded in x around 0 7.0%
+-commutative6.5%
Simplified7.0%
if 10 < x Initial program 0.0%
/-rgt-identity0.0%
associate-/r/0.0%
exp-neg0.0%
remove-double-neg0.0%
Simplified0.0%
Taylor expanded in x around 0 0.0%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 100.0%
(FPCore (x) :precision binary64 (if (<= x 10.0) (/ (fmod (exp x) (+ 1.0 (* -0.25 (* x x)))) (+ x 1.0)) (fmod 1.0 1.0)))
double code(double x) {
double tmp;
if (x <= 10.0) {
tmp = fmod(exp(x), (1.0 + (-0.25 * (x * x)))) / (x + 1.0);
} else {
tmp = fmod(1.0, 1.0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 10.0d0) then
tmp = mod(exp(x), (1.0d0 + ((-0.25d0) * (x * x)))) / (x + 1.0d0)
else
tmp = mod(1.0d0, 1.0d0)
end if
code = tmp
end function
def code(x): tmp = 0 if x <= 10.0: tmp = math.fmod(math.exp(x), (1.0 + (-0.25 * (x * x)))) / (x + 1.0) else: tmp = math.fmod(1.0, 1.0) return tmp
function code(x) tmp = 0.0 if (x <= 10.0) tmp = Float64(rem(exp(x), Float64(1.0 + Float64(-0.25 * Float64(x * x)))) / Float64(x + 1.0)); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[x, 10.0], 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[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(1 + -0.25 \cdot \left(x \cdot x\right)\right)\right)}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < 10Initial program 7.6%
/-rgt-identity7.6%
associate-/r/7.6%
exp-neg7.6%
remove-double-neg7.6%
Simplified7.6%
Taylor expanded in x around 0 6.5%
+-commutative6.5%
Simplified6.5%
Taylor expanded in x around 0 6.5%
unpow26.5%
Applied egg-rr6.5%
if 10 < x Initial program 0.0%
/-rgt-identity0.0%
associate-/r/0.0%
exp-neg0.0%
remove-double-neg0.0%
Simplified0.0%
Taylor expanded in x around 0 0.0%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 100.0%
(FPCore (x) :precision binary64 (fmod 1.0 1.0))
double code(double x) {
return fmod(1.0, 1.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod(1.0d0, 1.0d0)
end function
def code(x): return math.fmod(1.0, 1.0)
function code(x) return rem(1.0, 1.0) end
code[x_] := N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]
\begin{array}{l}
\\
\left(1 \bmod 1\right)
\end{array}
Initial program 5.9%
/-rgt-identity5.9%
associate-/r/5.9%
exp-neg5.9%
remove-double-neg5.9%
Simplified5.9%
Taylor expanded in x around 0 4.7%
Taylor expanded in x around 0 4.4%
Taylor expanded in x around 0 4.4%
Taylor expanded in x around 0 26.1%
herbie shell --seed 2024155
(FPCore (x)
:name "expfmod (used to be hard to sample)"
:precision binary64
(* (fmod (exp x) (sqrt (cos x))) (exp (- x))))