
(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 9 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 (+ 1.0 (* x (+ 1.0 (* x (+ 0.5 (* x 0.16666666666666666)))))))
(t_1 (cbrt (exp (cos x)))))
(if (<= x -1.5e-8)
(/ (fmod t_0 (+ 1.0 (* -0.25 (pow x 2.0)))) t_0)
(if (<= x -5e-310)
(fmod 1.0 (sqrt (+ (log (pow t_1 2.0)) (log t_1))))
(/ (fmod x (sqrt (cos x))) (exp x))))))
double code(double x) {
double t_0 = 1.0 + (x * (1.0 + (x * (0.5 + (x * 0.16666666666666666)))));
double t_1 = cbrt(exp(cos(x)));
double tmp;
if (x <= -1.5e-8) {
tmp = fmod(t_0, (1.0 + (-0.25 * pow(x, 2.0)))) / t_0;
} else if (x <= -5e-310) {
tmp = fmod(1.0, sqrt((log(pow(t_1, 2.0)) + log(t_1))));
} else {
tmp = fmod(x, sqrt(cos(x))) / exp(x);
}
return tmp;
}
function code(x) t_0 = Float64(1.0 + Float64(x * Float64(1.0 + Float64(x * Float64(0.5 + Float64(x * 0.16666666666666666)))))) t_1 = cbrt(exp(cos(x))) tmp = 0.0 if (x <= -1.5e-8) tmp = Float64(rem(t_0, Float64(1.0 + Float64(-0.25 * (x ^ 2.0)))) / t_0); elseif (x <= -5e-310) tmp = rem(1.0, sqrt(Float64(log((t_1 ^ 2.0)) + log(t_1)))); else tmp = Float64(rem(x, sqrt(cos(x))) / exp(x)); end return tmp end
code[x_] := Block[{t$95$0 = N[(1.0 + N[(x * N[(1.0 + N[(x * N[(0.5 + N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Exp[N[Cos[x], $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, -1.5e-8], N[(N[With[{TMP1 = t$95$0, TMP2 = N[(1.0 + N[(-0.25 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[x, -5e-310], N[With[{TMP1 = 1.0, TMP2 = N[Sqrt[N[(N[Log[N[Power[t$95$1, 2.0], $MachinePrecision]], $MachinePrecision] + N[Log[t$95$1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision], N[(N[With[{TMP1 = x, TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + x \cdot \left(1 + x \cdot \left(0.5 + x \cdot 0.16666666666666666\right)\right)\\
t_1 := \sqrt[3]{e^{\cos x}}\\
\mathbf{if}\;x \leq -1.5 \cdot 10^{-8}:\\
\;\;\;\;\frac{\left(t\_0 \bmod \left(1 + -0.25 \cdot {x}^{2}\right)\right)}{t\_0}\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(1 \bmod \left(\sqrt{\log \left({t\_1}^{2}\right) + \log t\_1}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\\
\end{array}
\end{array}
if x < -1.49999999999999987e-8Initial program 82.8%
/-rgt-identity82.8%
associate-/r/82.3%
exp-neg83.3%
remove-double-neg83.3%
Simplified83.3%
Taylor expanded in x around 0 65.0%
*-commutative65.0%
Simplified65.0%
Taylor expanded in x around 0 65.0%
Taylor expanded in x around 0 85.3%
*-commutative65.0%
Simplified85.3%
if -1.49999999999999987e-8 < x < -4.999999999999985e-310Initial program 7.8%
/-rgt-identity7.8%
associate-/r/7.7%
exp-neg7.8%
remove-double-neg7.8%
Simplified7.8%
Taylor expanded in x around 0 6.8%
Taylor expanded in x around 0 3.2%
add-log-exp7.8%
add-cube-cbrt100.0%
log-prod100.0%
pow2100.0%
Applied egg-rr100.0%
if -4.999999999999985e-310 < x Initial program 5.3%
/-rgt-identity5.3%
associate-/r/5.3%
exp-neg5.3%
remove-double-neg5.3%
Simplified5.3%
Taylor expanded in x around 0 39.5%
+-commutative39.5%
Simplified39.5%
Taylor expanded in x around inf 98.2%
(FPCore (x)
:precision binary64
(if (<= x -5e-310)
(/
(fmod
(exp x)
(sqrt (+ (log (pow (cbrt (exp (cos x))) 2.0)) (log (cbrt E)))))
(exp x))
(/ (fmod x (sqrt (cos x))) (exp x))))
double code(double x) {
double tmp;
if (x <= -5e-310) {
tmp = fmod(exp(x), sqrt((log(pow(cbrt(exp(cos(x))), 2.0)) + log(cbrt(((double) M_E)))))) / exp(x);
} else {
tmp = fmod(x, sqrt(cos(x))) / exp(x);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= -5e-310) tmp = Float64(rem(exp(x), sqrt(Float64(log((cbrt(exp(cos(x))) ^ 2.0)) + log(cbrt(exp(1)))))) / exp(x)); else tmp = Float64(rem(x, sqrt(cos(x))) / 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[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 = x, TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $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^{\cos x}}\right)}^{2}\right) + \log \left(\sqrt[3]{e}\right)}\right)\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\\
\end{array}
\end{array}
if x < -4.999999999999985e-310Initial program 11.9%
/-rgt-identity11.9%
associate-/r/11.8%
exp-neg11.9%
remove-double-neg11.9%
Simplified11.9%
add-log-exp11.9%
add-cube-cbrt99.1%
log-prod99.1%
pow299.1%
Applied egg-rr99.1%
Taylor expanded in x around 0 99.1%
exp-1-e99.1%
Simplified99.1%
if -4.999999999999985e-310 < x Initial program 5.3%
/-rgt-identity5.3%
associate-/r/5.3%
exp-neg5.3%
remove-double-neg5.3%
Simplified5.3%
Taylor expanded in x around 0 39.5%
+-commutative39.5%
Simplified39.5%
Taylor expanded in x around inf 98.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (cos x))))
(if (<= x -6.8e-267)
(/ (fmod (* x (+ 1.0 (/ 1.0 x))) t_0) (exp x))
(/ (fabs (fmod x t_0)) (exp x)))))
double code(double x) {
double t_0 = sqrt(cos(x));
double tmp;
if (x <= -6.8e-267) {
tmp = fmod((x * (1.0 + (1.0 / x))), t_0) / exp(x);
} else {
tmp = fabs(fmod(x, t_0)) / exp(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(cos(x))
if (x <= (-6.8d-267)) then
tmp = mod((x * (1.0d0 + (1.0d0 / x))), t_0) / exp(x)
else
tmp = abs(mod(x, t_0)) / exp(x)
end if
code = tmp
end function
def code(x): t_0 = math.sqrt(math.cos(x)) tmp = 0 if x <= -6.8e-267: tmp = math.fmod((x * (1.0 + (1.0 / x))), t_0) / math.exp(x) else: tmp = math.fabs(math.fmod(x, t_0)) / math.exp(x) return tmp
function code(x) t_0 = sqrt(cos(x)) tmp = 0.0 if (x <= -6.8e-267) tmp = Float64(rem(Float64(x * Float64(1.0 + Float64(1.0 / x))), t_0) / exp(x)); else tmp = Float64(abs(rem(x, t_0)) / exp(x)); end return tmp end
code[x_] := Block[{t$95$0 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -6.8e-267], N[(N[With[{TMP1 = N[(x * N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[Abs[N[With[{TMP1 = x, TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\cos x}\\
\mathbf{if}\;x \leq -6.8 \cdot 10^{-267}:\\
\;\;\;\;\frac{\left(\left(x \cdot \left(1 + \frac{1}{x}\right)\right) \bmod t\_0\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|\left(x \bmod t\_0\right)\right|}{e^{x}}\\
\end{array}
\end{array}
if x < -6.80000000000000041e-267Initial program 12.6%
/-rgt-identity12.6%
associate-/r/12.5%
exp-neg12.6%
remove-double-neg12.6%
Simplified12.6%
Taylor expanded in x around 0 10.6%
+-commutative10.6%
Simplified10.6%
Taylor expanded in x around inf 26.4%
if -6.80000000000000041e-267 < x Initial program 5.2%
/-rgt-identity5.2%
associate-/r/5.2%
exp-neg5.2%
remove-double-neg5.2%
Simplified5.2%
Taylor expanded in x around 0 37.6%
+-commutative37.6%
Simplified37.6%
Taylor expanded in x around inf 93.3%
add-sqr-sqrt92.7%
sqrt-unprod65.4%
pow265.4%
Applied egg-rr65.4%
add-sqr-sqrt65.2%
sqrt-prod65.4%
rem-sqrt-square65.4%
sqrt-pow193.3%
metadata-eval93.3%
pow193.3%
Applied egg-rr93.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (cos x))))
(if (<= x -5.5e-309)
(/ (fmod (* x (+ 1.0 (/ 1.0 x))) t_0) (exp x))
(/ (fmod x t_0) (exp x)))))
double code(double x) {
double t_0 = sqrt(cos(x));
double tmp;
if (x <= -5.5e-309) {
tmp = fmod((x * (1.0 + (1.0 / x))), t_0) / exp(x);
} else {
tmp = fmod(x, t_0) / exp(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(cos(x))
if (x <= (-5.5d-309)) then
tmp = mod((x * (1.0d0 + (1.0d0 / x))), t_0) / exp(x)
else
tmp = mod(x, t_0) / exp(x)
end if
code = tmp
end function
def code(x): t_0 = math.sqrt(math.cos(x)) tmp = 0 if x <= -5.5e-309: tmp = math.fmod((x * (1.0 + (1.0 / x))), t_0) / math.exp(x) else: tmp = math.fmod(x, t_0) / math.exp(x) return tmp
function code(x) t_0 = sqrt(cos(x)) tmp = 0.0 if (x <= -5.5e-309) tmp = Float64(rem(Float64(x * Float64(1.0 + Float64(1.0 / x))), t_0) / exp(x)); else tmp = Float64(rem(x, t_0) / exp(x)); end return tmp end
code[x_] := Block[{t$95$0 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -5.5e-309], N[(N[With[{TMP1 = N[(x * N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = x, TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\cos x}\\
\mathbf{if}\;x \leq -5.5 \cdot 10^{-309}:\\
\;\;\;\;\frac{\left(\left(x \cdot \left(1 + \frac{1}{x}\right)\right) \bmod t\_0\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x \bmod t\_0\right)}{e^{x}}\\
\end{array}
\end{array}
if x < -5.5e-309Initial program 11.9%
/-rgt-identity11.9%
associate-/r/11.8%
exp-neg11.9%
remove-double-neg11.9%
Simplified11.9%
Taylor expanded in x around 0 10.0%
+-commutative10.0%
Simplified10.0%
Taylor expanded in x around inf 24.7%
if -5.5e-309 < x Initial program 5.3%
/-rgt-identity5.3%
associate-/r/5.3%
exp-neg5.3%
remove-double-neg5.3%
Simplified5.3%
Taylor expanded in x around 0 39.5%
+-commutative39.5%
Simplified39.5%
Taylor expanded in x around inf 98.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ 1.0 (* x (+ 1.0 (* x (+ 0.5 (* x 0.16666666666666666))))))))
(if (<= x -5e-310)
(/ (fmod t_0 (+ 1.0 (* -0.25 (pow x 2.0)))) t_0)
(/ (fmod x (sqrt (cos x))) (exp x)))))
double code(double x) {
double t_0 = 1.0 + (x * (1.0 + (x * (0.5 + (x * 0.16666666666666666)))));
double tmp;
if (x <= -5e-310) {
tmp = fmod(t_0, (1.0 + (-0.25 * pow(x, 2.0)))) / t_0;
} else {
tmp = fmod(x, sqrt(cos(x))) / exp(x);
}
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 + (x * 0.16666666666666666d0)))))
if (x <= (-5d-310)) then
tmp = mod(t_0, (1.0d0 + ((-0.25d0) * (x ** 2.0d0)))) / t_0
else
tmp = mod(x, sqrt(cos(x))) / exp(x)
end if
code = tmp
end function
def code(x): t_0 = 1.0 + (x * (1.0 + (x * (0.5 + (x * 0.16666666666666666))))) tmp = 0 if x <= -5e-310: tmp = math.fmod(t_0, (1.0 + (-0.25 * math.pow(x, 2.0)))) / t_0 else: tmp = math.fmod(x, math.sqrt(math.cos(x))) / math.exp(x) return tmp
function code(x) t_0 = Float64(1.0 + Float64(x * Float64(1.0 + Float64(x * Float64(0.5 + Float64(x * 0.16666666666666666)))))) tmp = 0.0 if (x <= -5e-310) tmp = Float64(rem(t_0, Float64(1.0 + Float64(-0.25 * (x ^ 2.0)))) / t_0); else tmp = Float64(rem(x, sqrt(cos(x))) / exp(x)); end return tmp end
code[x_] := Block[{t$95$0 = N[(1.0 + N[(x * N[(1.0 + N[(x * N[(0.5 + N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5e-310], N[(N[With[{TMP1 = t$95$0, TMP2 = N[(1.0 + N[(-0.25 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[With[{TMP1 = x, TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + x \cdot \left(1 + x \cdot \left(0.5 + x \cdot 0.16666666666666666\right)\right)\\
\mathbf{if}\;x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{\left(t\_0 \bmod \left(1 + -0.25 \cdot {x}^{2}\right)\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\\
\end{array}
\end{array}
if x < -4.999999999999985e-310Initial program 11.9%
/-rgt-identity11.9%
associate-/r/11.8%
exp-neg11.9%
remove-double-neg11.9%
Simplified11.9%
Taylor expanded in x around 0 10.9%
*-commutative10.9%
Simplified10.9%
Taylor expanded in x around 0 10.9%
Taylor expanded in x around 0 12.0%
*-commutative10.9%
Simplified12.0%
if -4.999999999999985e-310 < x Initial program 5.3%
/-rgt-identity5.3%
associate-/r/5.3%
exp-neg5.3%
remove-double-neg5.3%
Simplified5.3%
Taylor expanded in x around 0 39.5%
+-commutative39.5%
Simplified39.5%
Taylor expanded in x around inf 98.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ 1.0 (* x (+ 1.0 (* x (+ 0.5 (* x 0.16666666666666666))))))))
(if (<= x -5e-310)
(/ (fmod t_0 (+ 1.0 (* -0.25 (pow x 2.0)))) t_0)
(/ (fmod x 1.0) (exp x)))))
double code(double x) {
double t_0 = 1.0 + (x * (1.0 + (x * (0.5 + (x * 0.16666666666666666)))));
double tmp;
if (x <= -5e-310) {
tmp = fmod(t_0, (1.0 + (-0.25 * pow(x, 2.0)))) / t_0;
} else {
tmp = fmod(x, 1.0) / exp(x);
}
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 + (x * 0.16666666666666666d0)))))
if (x <= (-5d-310)) then
tmp = mod(t_0, (1.0d0 + ((-0.25d0) * (x ** 2.0d0)))) / t_0
else
tmp = mod(x, 1.0d0) / exp(x)
end if
code = tmp
end function
def code(x): t_0 = 1.0 + (x * (1.0 + (x * (0.5 + (x * 0.16666666666666666))))) tmp = 0 if x <= -5e-310: tmp = math.fmod(t_0, (1.0 + (-0.25 * math.pow(x, 2.0)))) / t_0 else: tmp = math.fmod(x, 1.0) / math.exp(x) return tmp
function code(x) t_0 = Float64(1.0 + Float64(x * Float64(1.0 + Float64(x * Float64(0.5 + Float64(x * 0.16666666666666666)))))) tmp = 0.0 if (x <= -5e-310) tmp = Float64(rem(t_0, Float64(1.0 + Float64(-0.25 * (x ^ 2.0)))) / t_0); else tmp = Float64(rem(x, 1.0) / exp(x)); end return tmp end
code[x_] := Block[{t$95$0 = N[(1.0 + N[(x * N[(1.0 + N[(x * N[(0.5 + N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5e-310], N[(N[With[{TMP1 = t$95$0, TMP2 = N[(1.0 + N[(-0.25 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[With[{TMP1 = x, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + x \cdot \left(1 + x \cdot \left(0.5 + x \cdot 0.16666666666666666\right)\right)\\
\mathbf{if}\;x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{\left(t\_0 \bmod \left(1 + -0.25 \cdot {x}^{2}\right)\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x \bmod 1\right)}{e^{x}}\\
\end{array}
\end{array}
if x < -4.999999999999985e-310Initial program 11.9%
/-rgt-identity11.9%
associate-/r/11.8%
exp-neg11.9%
remove-double-neg11.9%
Simplified11.9%
Taylor expanded in x around 0 10.9%
*-commutative10.9%
Simplified10.9%
Taylor expanded in x around 0 10.9%
Taylor expanded in x around 0 12.0%
*-commutative10.9%
Simplified12.0%
if -4.999999999999985e-310 < x Initial program 5.3%
/-rgt-identity5.3%
associate-/r/5.3%
exp-neg5.3%
remove-double-neg5.3%
Simplified5.3%
Taylor expanded in x around 0 39.5%
+-commutative39.5%
Simplified39.5%
Taylor expanded in x around inf 98.2%
Taylor expanded in x around 0 98.2%
Taylor expanded in x around 0 98.2%
(FPCore (x)
:precision binary64
(if (<= x -5e-310)
(/
(fmod (exp x) 1.0)
(+ 1.0 (* x (+ 1.0 (* x (+ 0.5 (* x 0.16666666666666666)))))))
(/ (fmod x 1.0) (exp x))))
double code(double x) {
double tmp;
if (x <= -5e-310) {
tmp = fmod(exp(x), 1.0) / (1.0 + (x * (1.0 + (x * (0.5 + (x * 0.16666666666666666))))));
} else {
tmp = fmod(x, 1.0) / exp(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-5d-310)) then
tmp = mod(exp(x), 1.0d0) / (1.0d0 + (x * (1.0d0 + (x * (0.5d0 + (x * 0.16666666666666666d0))))))
else
tmp = mod(x, 1.0d0) / exp(x)
end if
code = tmp
end function
def code(x): tmp = 0 if x <= -5e-310: tmp = math.fmod(math.exp(x), 1.0) / (1.0 + (x * (1.0 + (x * (0.5 + (x * 0.16666666666666666)))))) else: tmp = math.fmod(x, 1.0) / math.exp(x) return tmp
function code(x) tmp = 0.0 if (x <= -5e-310) tmp = Float64(rem(exp(x), 1.0) / Float64(1.0 + Float64(x * Float64(1.0 + Float64(x * Float64(0.5 + Float64(x * 0.16666666666666666))))))); else tmp = Float64(rem(x, 1.0) / exp(x)); end return tmp end
code[x_] := If[LessEqual[x, -5e-310], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = 1.0}, 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[(N[With[{TMP1 = x, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $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 1\right)}{1 + x \cdot \left(1 + x \cdot \left(0.5 + x \cdot 0.16666666666666666\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x \bmod 1\right)}{e^{x}}\\
\end{array}
\end{array}
if x < -4.999999999999985e-310Initial program 11.9%
/-rgt-identity11.9%
associate-/r/11.8%
exp-neg11.9%
remove-double-neg11.9%
Simplified11.9%
Taylor expanded in x around 0 10.9%
*-commutative10.9%
Simplified10.9%
Taylor expanded in x around 0 10.9%
Taylor expanded in x around 0 10.9%
if -4.999999999999985e-310 < x Initial program 5.3%
/-rgt-identity5.3%
associate-/r/5.3%
exp-neg5.3%
remove-double-neg5.3%
Simplified5.3%
Taylor expanded in x around 0 39.5%
+-commutative39.5%
Simplified39.5%
Taylor expanded in x around inf 98.2%
Taylor expanded in x around 0 98.2%
Taylor expanded in x around 0 98.2%
(FPCore (x) :precision binary64 (/ (fmod x 1.0) (exp x)))
double code(double x) {
return fmod(x, 1.0) / exp(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod(x, 1.0d0) / exp(x)
end function
def code(x): return math.fmod(x, 1.0) / math.exp(x)
function code(x) return Float64(rem(x, 1.0) / exp(x)) end
code[x_] := N[(N[With[{TMP1 = x, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \bmod 1\right)}{e^{x}}
\end{array}
Initial program 8.1%
/-rgt-identity8.1%
associate-/r/8.1%
exp-neg8.1%
remove-double-neg8.1%
Simplified8.1%
Taylor expanded in x around 0 26.8%
+-commutative26.8%
Simplified26.8%
Taylor expanded in x around inf 56.9%
Taylor expanded in x around 0 56.9%
Taylor expanded in x around 0 56.9%
(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 8.1%
/-rgt-identity8.1%
associate-/r/8.1%
exp-neg8.1%
remove-double-neg8.1%
Simplified8.1%
Taylor expanded in x around 0 6.0%
Taylor expanded in x around 0 4.4%
Taylor expanded in x around 0 4.7%
Taylor expanded in x around 0 23.3%
herbie shell --seed 2024144
(FPCore (x)
:name "expfmod (used to be hard to sample)"
:precision binary64
(* (fmod (exp x) (sqrt (cos x))) (exp (- x))))