
(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 13 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
(if (<= x -5e-310)
(/
(fmod (exp x) (sqrt (+ (log (pow (cbrt E) 2.0)) (log (cbrt E)))))
(exp x))
(/ (exp (pow (cbrt (log (fmod (+ x 1.0) (sqrt (cos x))))) 3.0)) (exp x))))
double code(double x) {
double tmp;
if (x <= -5e-310) {
tmp = fmod(exp(x), sqrt((log(pow(cbrt(((double) M_E)), 2.0)) + log(cbrt(((double) M_E)))))) / exp(x);
} else {
tmp = exp(pow(cbrt(log(fmod((x + 1.0), sqrt(cos(x))))), 3.0)) / exp(x);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= -5e-310) tmp = Float64(rem(exp(x), sqrt(Float64(log((cbrt(exp(1)) ^ 2.0)) + log(cbrt(exp(1)))))) / exp(x)); else tmp = Float64(exp((cbrt(log(rem(Float64(x + 1.0), sqrt(cos(x))))) ^ 3.0)) / exp(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[N[Power[E, 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[Exp[N[Power[N[Power[N[Log[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], 1/3], $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision] / N[Exp[x], $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({\left(\sqrt[3]{e}\right)}^{2}\right) + \log \left(\sqrt[3]{e}\right)}\right)\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{{\left(\sqrt[3]{\log \left(\left(x + 1\right) \bmod \left(\sqrt{\cos x}\right)\right)}\right)}^{3}}}{e^{x}}\\
\end{array}
\end{array}
if x < -4.999999999999985e-310Initial program 11.6%
/-rgt-identity11.6%
associate-/r/11.5%
exp-neg11.6%
remove-double-neg11.6%
Simplified11.6%
add-log-exp11.6%
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 4.8%
/-rgt-identity4.8%
associate-/r/4.8%
exp-neg4.8%
remove-double-neg4.8%
Simplified4.8%
add-exp-log4.8%
Applied egg-rr4.8%
add-cube-cbrt4.8%
pow34.8%
Applied egg-rr4.8%
Taylor expanded in x around 0 36.1%
+-commutative36.1%
Simplified36.1%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (cos x))))
(if (<= (* (fmod (exp x) t_0) (exp (- x))) 0.0)
(fmod (exp x) (sqrt (+ (log (pow (cbrt E) 2.0)) (log (cbrt E)))))
(/ (exp (pow (cbrt (log (fmod (+ x 1.0) t_0))) 3.0)) (exp x)))))
double code(double x) {
double t_0 = sqrt(cos(x));
double tmp;
if ((fmod(exp(x), t_0) * exp(-x)) <= 0.0) {
tmp = fmod(exp(x), sqrt((log(pow(cbrt(((double) M_E)), 2.0)) + log(cbrt(((double) M_E))))));
} else {
tmp = exp(pow(cbrt(log(fmod((x + 1.0), t_0))), 3.0)) / exp(x);
}
return tmp;
}
function code(x) t_0 = sqrt(cos(x)) tmp = 0.0 if (Float64(rem(exp(x), t_0) * exp(Float64(-x))) <= 0.0) tmp = rem(exp(x), sqrt(Float64(log((cbrt(exp(1)) ^ 2.0)) + log(cbrt(exp(1)))))); else tmp = Float64(exp((cbrt(log(rem(Float64(x + 1.0), t_0))) ^ 3.0)) / exp(x)); end return tmp end
code[x_] := Block[{t$95$0 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], 0.0], N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[(N[Log[N[Power[N[Power[E, 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[(N[Exp[N[Power[N[Power[N[Log[N[With[{TMP1 = N[(x + 1.0), $MachinePrecision], TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\cos x}\\
\mathbf{if}\;\left(\left(e^{x}\right) \bmod t\_0\right) \cdot e^{-x} \leq 0:\\
\;\;\;\;\left(\left(e^{x}\right) \bmod \left(\sqrt{\log \left({\left(\sqrt[3]{e}\right)}^{2}\right) + \log \left(\sqrt[3]{e}\right)}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{{\left(\sqrt[3]{\log \left(\left(x + 1\right) \bmod t\_0\right)}\right)}^{3}}}{e^{x}}\\
\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.4%
/-rgt-identity4.4%
associate-/r/4.4%
exp-neg4.4%
remove-double-neg4.4%
Simplified4.4%
add-log-exp4.4%
add-cube-cbrt46.5%
log-prod46.5%
pow246.5%
Applied egg-rr46.5%
Taylor expanded in x around 0 46.5%
exp-1-e46.5%
Simplified46.5%
Taylor expanded in x around 0 46.5%
exp-1-e46.5%
Simplified46.5%
Taylor expanded in x around 0 46.5%
if 0.0 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 15.7%
/-rgt-identity15.7%
associate-/r/15.6%
exp-neg15.7%
remove-double-neg15.7%
Simplified15.7%
add-exp-log15.7%
Applied egg-rr15.7%
add-cube-cbrt15.7%
pow315.7%
Applied egg-rr15.7%
Taylor expanded in x around 0 93.0%
+-commutative93.0%
Simplified93.0%
Final simplification58.1%
(FPCore (x) :precision binary64 (let* ((t_0 (* (fmod (exp x) (sqrt (cos x))) (exp (- x))))) (if (<= t_0 2.0) t_0 (fmod 1.0 1.0))))
double code(double x) {
double t_0 = fmod(exp(x), sqrt(cos(x))) * exp(-x);
double tmp;
if (t_0 <= 2.0) {
tmp = t_0;
} 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))) * exp(-x)
if (t_0 <= 2.0d0) then
tmp = t_0
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))) * math.exp(-x) tmp = 0 if t_0 <= 2.0: tmp = t_0 else: tmp = math.fmod(1.0, 1.0) return tmp
function code(x) t_0 = Float64(rem(exp(x), sqrt(cos(x))) * exp(Float64(-x))) tmp = 0.0 if (t_0 <= 2.0) tmp = t_0; else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := Block[{t$95$0 = 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]}, If[LessEqual[t$95$0, 2.0], t$95$0, 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) \cdot e^{-x}\\
\mathbf{if}\;t\_0 \leq 2:\\
\;\;\;\;t\_0\\
\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 9.1%
if 2 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 0.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 (/ (exp (pow (cbrt (log (fmod (+ x 1.0) (sqrt (cos x))))) 3.0)) (exp x)))
double code(double x) {
return exp(pow(cbrt(log(fmod((x + 1.0), sqrt(cos(x))))), 3.0)) / exp(x);
}
function code(x) return Float64(exp((cbrt(log(rem(Float64(x + 1.0), sqrt(cos(x))))) ^ 3.0)) / exp(x)) end
code[x_] := N[(N[Exp[N[Power[N[Power[N[Log[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], 1/3], $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{{\left(\sqrt[3]{\log \left(\left(x + 1\right) \bmod \left(\sqrt{\cos x}\right)\right)}\right)}^{3}}}{e^{x}}
\end{array}
Initial program 7.3%
/-rgt-identity7.3%
associate-/r/7.2%
exp-neg7.3%
remove-double-neg7.3%
Simplified7.3%
add-exp-log7.2%
Applied egg-rr7.2%
add-cube-cbrt7.2%
pow37.2%
Applied egg-rr7.2%
Taylor expanded in x around 0 26.6%
+-commutative26.6%
Simplified26.6%
(FPCore (x) :precision binary64 (/ (exp (log (fmod (+ x 1.0) (sqrt (cos x))))) (exp x)))
double code(double x) {
return exp(log(fmod((x + 1.0), sqrt(cos(x))))) / exp(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = exp(log(mod((x + 1.0d0), sqrt(cos(x))))) / exp(x)
end function
def code(x): return math.exp(math.log(math.fmod((x + 1.0), math.sqrt(math.cos(x))))) / math.exp(x)
function code(x) return Float64(exp(log(rem(Float64(x + 1.0), sqrt(cos(x))))) / exp(x)) end
code[x_] := N[(N[Exp[N[Log[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] / N[Exp[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{\log \left(\left(x + 1\right) \bmod \left(\sqrt{\cos x}\right)\right)}}{e^{x}}
\end{array}
Initial program 7.3%
/-rgt-identity7.3%
associate-/r/7.2%
exp-neg7.3%
remove-double-neg7.3%
Simplified7.3%
add-exp-log7.2%
Applied egg-rr7.2%
Taylor expanded in x around 0 26.6%
+-commutative26.6%
Simplified26.6%
(FPCore (x) :precision binary64 (if (<= x 0.1) (/ (fmod (exp x) (sqrt (cos x))) (exp x)) (fmod 1.0 1.0)))
double code(double x) {
double tmp;
if (x <= 0.1) {
tmp = fmod(exp(x), sqrt(cos(x))) / 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 <= 0.1d0) then
tmp = mod(exp(x), sqrt(cos(x))) / exp(x)
else
tmp = mod(1.0d0, 1.0d0)
end if
code = tmp
end function
def code(x): tmp = 0 if x <= 0.1: tmp = math.fmod(math.exp(x), math.sqrt(math.cos(x))) / math.exp(x) else: tmp = math.fmod(1.0, 1.0) return tmp
function code(x) tmp = 0.0 if (x <= 0.1) tmp = Float64(rem(exp(x), sqrt(cos(x))) / exp(x)); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[x, 0.1], 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], 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 0.1:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < 0.10000000000000001Initial program 9.1%
/-rgt-identity9.1%
associate-/r/9.1%
exp-neg9.1%
remove-double-neg9.1%
Simplified9.1%
if 0.10000000000000001 < x Initial program 0.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 0.1) (/ (fmod (exp x) (+ 1.0 (* -0.25 (* x x)))) (exp x)) (fmod 1.0 1.0)))
double code(double x) {
double tmp;
if (x <= 0.1) {
tmp = fmod(exp(x), (1.0 + (-0.25 * (x * x)))) / 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 <= 0.1d0) then
tmp = mod(exp(x), (1.0d0 + ((-0.25d0) * (x * x)))) / exp(x)
else
tmp = mod(1.0d0, 1.0d0)
end if
code = tmp
end function
def code(x): tmp = 0 if x <= 0.1: tmp = math.fmod(math.exp(x), (1.0 + (-0.25 * (x * x)))) / math.exp(x) else: tmp = math.fmod(1.0, 1.0) return tmp
function code(x) tmp = 0.0 if (x <= 0.1) tmp = Float64(rem(exp(x), Float64(1.0 + Float64(-0.25 * Float64(x * x)))) / exp(x)); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[x, 0.1], 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[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 0.1:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(1 + -0.25 \cdot \left(x \cdot x\right)\right)\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < 0.10000000000000001Initial program 9.1%
/-rgt-identity9.1%
associate-/r/9.1%
exp-neg9.1%
remove-double-neg9.1%
Simplified9.1%
Taylor expanded in x around 0 8.9%
unpow28.9%
Applied egg-rr8.9%
if 0.10000000000000001 < x Initial program 0.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 0.1) (/ (fmod (exp x) 1.0) (exp x)) (fmod 1.0 1.0)))
double code(double x) {
double tmp;
if (x <= 0.1) {
tmp = fmod(exp(x), 1.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 <= 0.1d0) then
tmp = mod(exp(x), 1.0d0) / exp(x)
else
tmp = mod(1.0d0, 1.0d0)
end if
code = tmp
end function
def code(x): tmp = 0 if x <= 0.1: tmp = math.fmod(math.exp(x), 1.0) / math.exp(x) else: tmp = math.fmod(1.0, 1.0) return tmp
function code(x) tmp = 0.0 if (x <= 0.1) tmp = Float64(rem(exp(x), 1.0) / exp(x)); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[x, 0.1], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = 1.0}, 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 0.1:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod 1\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < 0.10000000000000001Initial program 9.1%
/-rgt-identity9.1%
associate-/r/9.1%
exp-neg9.1%
remove-double-neg9.1%
Simplified9.1%
add-log-exp9.1%
add-cube-cbrt48.6%
log-prod48.6%
pow248.6%
Applied egg-rr48.6%
Taylor expanded in x around 0 48.3%
exp-1-e48.3%
Simplified48.3%
Taylor expanded in x around 0 48.3%
exp-1-e48.3%
Simplified48.3%
div-inv48.3%
sum-log48.3%
unpow248.3%
add-cube-cbrt8.8%
log-E8.8%
metadata-eval8.8%
rec-exp8.8%
Applied egg-rr8.8%
exp-neg8.8%
associate-*r/8.8%
*-rgt-identity8.8%
Simplified8.8%
if 0.10000000000000001 < x Initial program 0.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 0.1)
(/
(fmod (exp x) (+ 1.0 (* -0.25 (* x x))))
(+ 1.0 (* x (+ 1.0 (* x (+ 0.5 (* x 0.16666666666666666)))))))
(fmod 1.0 1.0)))
double code(double x) {
double tmp;
if (x <= 0.1) {
tmp = fmod(exp(x), (1.0 + (-0.25 * (x * x)))) / (1.0 + (x * (1.0 + (x * (0.5 + (x * 0.16666666666666666))))));
} else {
tmp = fmod(1.0, 1.0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.1d0) then
tmp = mod(exp(x), (1.0d0 + ((-0.25d0) * (x * x)))) / (1.0d0 + (x * (1.0d0 + (x * (0.5d0 + (x * 0.16666666666666666d0))))))
else
tmp = mod(1.0d0, 1.0d0)
end if
code = tmp
end function
def code(x): tmp = 0 if x <= 0.1: tmp = math.fmod(math.exp(x), (1.0 + (-0.25 * (x * x)))) / (1.0 + (x * (1.0 + (x * (0.5 + (x * 0.16666666666666666)))))) else: tmp = math.fmod(1.0, 1.0) return tmp
function code(x) tmp = 0.0 if (x <= 0.1) tmp = Float64(rem(exp(x), Float64(1.0 + Float64(-0.25 * Float64(x * x)))) / Float64(1.0 + Float64(x * Float64(1.0 + Float64(x * Float64(0.5 + Float64(x * 0.16666666666666666))))))); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[x, 0.1], 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[(1.0 + N[(x * N[(1.0 + N[(x * N[(0.5 + N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}
\mathbf{if}\;x \leq 0.1:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(1 + -0.25 \cdot \left(x \cdot x\right)\right)\right)}{1 + x \cdot \left(1 + x \cdot \left(0.5 + x \cdot 0.16666666666666666\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < 0.10000000000000001Initial program 9.1%
/-rgt-identity9.1%
associate-/r/9.1%
exp-neg9.1%
remove-double-neg9.1%
Simplified9.1%
Taylor expanded in x around 0 8.9%
unpow28.9%
Applied egg-rr8.9%
Taylor expanded in x around 0 8.4%
*-commutative8.4%
Simplified8.4%
if 0.10000000000000001 < x Initial program 0.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 0.1) (/ (fmod (exp x) (+ 1.0 (* -0.25 (* x x)))) (+ 1.0 (* x (+ 1.0 (* x 0.5))))) (fmod 1.0 1.0)))
double code(double x) {
double tmp;
if (x <= 0.1) {
tmp = fmod(exp(x), (1.0 + (-0.25 * (x * x)))) / (1.0 + (x * (1.0 + (x * 0.5))));
} else {
tmp = fmod(1.0, 1.0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.1d0) then
tmp = mod(exp(x), (1.0d0 + ((-0.25d0) * (x * x)))) / (1.0d0 + (x * (1.0d0 + (x * 0.5d0))))
else
tmp = mod(1.0d0, 1.0d0)
end if
code = tmp
end function
def code(x): tmp = 0 if x <= 0.1: tmp = math.fmod(math.exp(x), (1.0 + (-0.25 * (x * x)))) / (1.0 + (x * (1.0 + (x * 0.5)))) else: tmp = math.fmod(1.0, 1.0) return tmp
function code(x) tmp = 0.0 if (x <= 0.1) tmp = Float64(rem(exp(x), Float64(1.0 + Float64(-0.25 * Float64(x * x)))) / Float64(1.0 + Float64(x * Float64(1.0 + Float64(x * 0.5))))); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[x, 0.1], 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[(1.0 + N[(x * N[(1.0 + N[(x * 0.5), $MachinePrecision]), $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}
\mathbf{if}\;x \leq 0.1:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(1 + -0.25 \cdot \left(x \cdot x\right)\right)\right)}{1 + x \cdot \left(1 + x \cdot 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < 0.10000000000000001Initial program 9.1%
/-rgt-identity9.1%
associate-/r/9.1%
exp-neg9.1%
remove-double-neg9.1%
Simplified9.1%
Taylor expanded in x around 0 8.9%
unpow28.9%
Applied egg-rr8.9%
Taylor expanded in x around 0 8.2%
*-commutative8.2%
Simplified8.2%
if 0.10000000000000001 < x Initial program 0.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 0.1) (/ (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 <= 0.1) {
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 <= 0.1d0) 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 <= 0.1: 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 <= 0.1) 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, 0.1], 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 0.1:\\
\;\;\;\;\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 < 0.10000000000000001Initial program 9.1%
/-rgt-identity9.1%
associate-/r/9.1%
exp-neg9.1%
remove-double-neg9.1%
Simplified9.1%
Taylor expanded in x around 0 8.9%
unpow28.9%
Applied egg-rr8.9%
Taylor expanded in x around 0 7.9%
+-commutative7.9%
Simplified7.9%
if 0.10000000000000001 < x Initial program 0.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 0.1) (fmod (exp x) (+ 1.0 (* -0.25 (* x x)))) (fmod 1.0 1.0)))
double code(double x) {
double tmp;
if (x <= 0.1) {
tmp = fmod(exp(x), (1.0 + (-0.25 * (x * 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 <= 0.1d0) then
tmp = mod(exp(x), (1.0d0 + ((-0.25d0) * (x * x))))
else
tmp = mod(1.0d0, 1.0d0)
end if
code = tmp
end function
def code(x): tmp = 0 if x <= 0.1: tmp = math.fmod(math.exp(x), (1.0 + (-0.25 * (x * x)))) else: tmp = math.fmod(1.0, 1.0) return tmp
function code(x) tmp = 0.0 if (x <= 0.1) tmp = rem(exp(x), Float64(1.0 + Float64(-0.25 * Float64(x * x)))); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[x, 0.1], 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[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 0.1:\\
\;\;\;\;\left(\left(e^{x}\right) \bmod \left(1 + -0.25 \cdot \left(x \cdot x\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < 0.10000000000000001Initial program 9.1%
/-rgt-identity9.1%
associate-/r/9.1%
exp-neg9.1%
remove-double-neg9.1%
Simplified9.1%
Taylor expanded in x around 0 8.9%
unpow28.9%
Applied egg-rr8.9%
Taylor expanded in x around 0 7.4%
if 0.10000000000000001 < x Initial program 0.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 simplification26.2%
(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 7.3%
Taylor expanded in x around 0 5.9%
Taylor expanded in x around 0 4.3%
Taylor expanded in x around 0 4.6%
Taylor expanded in x around 0 23.8%
herbie shell --seed 2024150
(FPCore (x)
:name "expfmod (used to be hard to sample)"
:precision binary64
(* (fmod (exp x) (sqrt (cos x))) (exp (- x))))