
(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 -4e-310)
(/
(fmod (exp x) (sqrt (+ (log (pow (cbrt E) 2.0)) (log (cbrt E)))))
(exp x))
(/ (log (exp (fmod (+ x 1.0) (sqrt (cos x))))) (exp x))))
double code(double x) {
double tmp;
if (x <= -4e-310) {
tmp = fmod(exp(x), sqrt((log(pow(cbrt(((double) M_E)), 2.0)) + log(cbrt(((double) M_E)))))) / exp(x);
} else {
tmp = log(exp(fmod((x + 1.0), sqrt(cos(x))))) / exp(x);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= -4e-310) tmp = Float64(rem(exp(x), sqrt(Float64(log((cbrt(exp(1)) ^ 2.0)) + log(cbrt(exp(1)))))) / exp(x)); else tmp = Float64(log(exp(rem(Float64(x + 1.0), sqrt(cos(x))))) / exp(x)); end return tmp end
code[x_] := If[LessEqual[x, -4e-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[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] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \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{\log \left(e^{\left(\left(x + 1\right) \bmod \left(\sqrt{\cos x}\right)\right)}\right)}{e^{x}}\\
\end{array}
\end{array}
if x < -3.999999999999988e-310Initial program 8.9%
/-rgt-identity8.9%
associate-/r/8.9%
exp-neg9.0%
remove-double-neg9.0%
Simplified9.0%
add-log-exp9.0%
add-cube-cbrt96.9%
log-prod96.9%
pow296.9%
Applied egg-rr96.9%
Taylor expanded in x around 0 96.9%
exp-1-e96.9%
Simplified96.9%
Taylor expanded in x around 0 96.9%
exp-1-e96.9%
Simplified96.9%
if -3.999999999999988e-310 < x Initial program 5.1%
/-rgt-identity5.1%
associate-/r/5.1%
exp-neg5.1%
remove-double-neg5.1%
Simplified5.1%
add-log-exp5.1%
Applied egg-rr5.1%
Taylor expanded in x around 0 42.8%
+-commutative42.8%
Simplified42.8%
(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 8.7%
/-rgt-identity8.7%
associate-/r/8.7%
exp-neg8.7%
remove-double-neg8.7%
Simplified8.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%
Taylor expanded in x around 0 0.1%
Taylor expanded in x around 0 3.7%
Taylor expanded in x around 0 7.7%
Taylor expanded in x around 0 95.4%
(FPCore (x) :precision binary64 (if (<= x -4e-310) (fmod (exp x) (sqrt (+ (log (pow (cbrt E) 2.0)) (log (cbrt E))))) (/ (log (exp (fmod (+ x 1.0) (sqrt (cos x))))) (exp x))))
double code(double x) {
double tmp;
if (x <= -4e-310) {
tmp = fmod(exp(x), sqrt((log(pow(cbrt(((double) M_E)), 2.0)) + log(cbrt(((double) M_E))))));
} else {
tmp = log(exp(fmod((x + 1.0), sqrt(cos(x))))) / exp(x);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= -4e-310) tmp = rem(exp(x), sqrt(Float64(log((cbrt(exp(1)) ^ 2.0)) + log(cbrt(exp(1)))))); else tmp = Float64(log(exp(rem(Float64(x + 1.0), sqrt(cos(x))))) / exp(x)); end return tmp end
code[x_] := If[LessEqual[x, -4e-310], 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[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] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\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{\log \left(e^{\left(\left(x + 1\right) \bmod \left(\sqrt{\cos x}\right)\right)}\right)}{e^{x}}\\
\end{array}
\end{array}
if x < -3.999999999999988e-310Initial program 8.9%
/-rgt-identity8.9%
associate-/r/8.9%
exp-neg9.0%
remove-double-neg9.0%
Simplified9.0%
add-log-exp9.0%
add-cube-cbrt96.9%
log-prod96.9%
pow296.9%
Applied egg-rr96.9%
Taylor expanded in x around 0 96.9%
exp-1-e96.9%
Simplified96.9%
Taylor expanded in x around 0 96.9%
exp-1-e96.9%
Simplified96.9%
Taylor expanded in x around 0 94.4%
if -3.999999999999988e-310 < x Initial program 5.1%
/-rgt-identity5.1%
associate-/r/5.1%
exp-neg5.1%
remove-double-neg5.1%
Simplified5.1%
add-log-exp5.1%
Applied egg-rr5.1%
Taylor expanded in x around 0 42.8%
+-commutative42.8%
Simplified42.8%
Final simplification62.5%
(FPCore (x) :precision binary64 (if (<= x -1.55e-162) (/ (fmod (exp x) (* (pow x 2.0) (- (/ 1.0 (pow x 2.0)) 0.25))) (exp x)) (/ (log (exp (fmod (+ x 1.0) (sqrt (cos x))))) (exp x))))
double code(double x) {
double tmp;
if (x <= -1.55e-162) {
tmp = fmod(exp(x), (pow(x, 2.0) * ((1.0 / pow(x, 2.0)) - 0.25))) / exp(x);
} else {
tmp = log(exp(fmod((x + 1.0), sqrt(cos(x))))) / exp(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.55d-162)) then
tmp = mod(exp(x), ((x ** 2.0d0) * ((1.0d0 / (x ** 2.0d0)) - 0.25d0))) / exp(x)
else
tmp = log(exp(mod((x + 1.0d0), sqrt(cos(x))))) / exp(x)
end if
code = tmp
end function
def code(x): tmp = 0 if x <= -1.55e-162: tmp = math.fmod(math.exp(x), (math.pow(x, 2.0) * ((1.0 / math.pow(x, 2.0)) - 0.25))) / math.exp(x) else: tmp = math.log(math.exp(math.fmod((x + 1.0), math.sqrt(math.cos(x))))) / math.exp(x) return tmp
function code(x) tmp = 0.0 if (x <= -1.55e-162) tmp = Float64(rem(exp(x), Float64((x ^ 2.0) * Float64(Float64(1.0 / (x ^ 2.0)) - 0.25))) / exp(x)); else tmp = Float64(log(exp(rem(Float64(x + 1.0), sqrt(cos(x))))) / exp(x)); end return tmp end
code[x_] := If[LessEqual[x, -1.55e-162], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[Power[x, 2.0], $MachinePrecision] * N[(N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] - 0.25), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(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] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \cdot 10^{-162}:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left({x}^{2} \cdot \left(\frac{1}{{x}^{2}} - 0.25\right)\right)\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(e^{\left(\left(x + 1\right) \bmod \left(\sqrt{\cos x}\right)\right)}\right)}{e^{x}}\\
\end{array}
\end{array}
if x < -1.5499999999999999e-162Initial program 13.1%
/-rgt-identity13.1%
associate-/r/13.1%
exp-neg13.2%
remove-double-neg13.2%
Simplified13.2%
Taylor expanded in x around 0 13.2%
Taylor expanded in x around inf 19.3%
if -1.5499999999999999e-162 < x Initial program 4.7%
/-rgt-identity4.7%
associate-/r/4.7%
exp-neg4.7%
remove-double-neg4.7%
Simplified4.7%
add-log-exp4.7%
Applied egg-rr4.7%
Taylor expanded in x around 0 34.6%
+-commutative34.6%
Simplified34.6%
(FPCore (x) :precision binary64 (if (<= x -1.55e-162) (/ (fmod (exp x) (* (pow x 2.0) (- (/ 1.0 (pow x 2.0)) 0.25))) (exp x)) (/ (fmod 1.0 (sqrt (cos x))) (exp x))))
double code(double x) {
double tmp;
if (x <= -1.55e-162) {
tmp = fmod(exp(x), (pow(x, 2.0) * ((1.0 / pow(x, 2.0)) - 0.25))) / exp(x);
} else {
tmp = fmod(1.0, sqrt(cos(x))) / exp(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.55d-162)) then
tmp = mod(exp(x), ((x ** 2.0d0) * ((1.0d0 / (x ** 2.0d0)) - 0.25d0))) / exp(x)
else
tmp = mod(1.0d0, sqrt(cos(x))) / exp(x)
end if
code = tmp
end function
def code(x): tmp = 0 if x <= -1.55e-162: tmp = math.fmod(math.exp(x), (math.pow(x, 2.0) * ((1.0 / math.pow(x, 2.0)) - 0.25))) / math.exp(x) else: tmp = math.fmod(1.0, math.sqrt(math.cos(x))) / math.exp(x) return tmp
function code(x) tmp = 0.0 if (x <= -1.55e-162) tmp = Float64(rem(exp(x), Float64((x ^ 2.0) * Float64(Float64(1.0 / (x ^ 2.0)) - 0.25))) / exp(x)); else tmp = Float64(rem(1.0, sqrt(cos(x))) / exp(x)); end return tmp end
code[x_] := If[LessEqual[x, -1.55e-162], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[Power[x, 2.0], $MachinePrecision] * N[(N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] - 0.25), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = 1.0, 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 -1.55 \cdot 10^{-162}:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left({x}^{2} \cdot \left(\frac{1}{{x}^{2}} - 0.25\right)\right)\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\\
\end{array}
\end{array}
if x < -1.5499999999999999e-162Initial program 13.1%
/-rgt-identity13.1%
associate-/r/13.1%
exp-neg13.2%
remove-double-neg13.2%
Simplified13.2%
Taylor expanded in x around 0 13.2%
Taylor expanded in x around inf 19.3%
if -1.5499999999999999e-162 < x Initial program 4.7%
/-rgt-identity4.7%
associate-/r/4.7%
exp-neg4.7%
remove-double-neg4.7%
Simplified4.7%
Taylor expanded in x around 0 33.6%
(FPCore (x) :precision binary64 (if (<= x 5e-6) (/ (fmod (exp x) (+ 1.0 (* -0.25 (* x x)))) (exp x)) (fmod 1.0 1.0)))
double code(double x) {
double tmp;
if (x <= 5e-6) {
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 <= 5d-6) 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 <= 5e-6: 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 <= 5e-6) 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, 5e-6], 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 5 \cdot 10^{-6}:\\
\;\;\;\;\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 < 5.00000000000000041e-6Initial program 8.6%
/-rgt-identity8.6%
associate-/r/8.6%
exp-neg8.6%
remove-double-neg8.6%
Simplified8.6%
Taylor expanded in x around 0 8.6%
unpow28.6%
Applied egg-rr8.6%
if 5.00000000000000041e-6 < 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 5e-6) (/ (fmod (exp x) 1.0) (exp x)) (fmod 1.0 1.0)))
double code(double x) {
double tmp;
if (x <= 5e-6) {
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 <= 5d-6) 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 <= 5e-6: 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 <= 5e-6) 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, 5e-6], 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 5 \cdot 10^{-6}:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod 1\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < 5.00000000000000041e-6Initial program 8.6%
/-rgt-identity8.6%
associate-/r/8.6%
exp-neg8.6%
remove-double-neg8.6%
Simplified8.6%
Taylor expanded in x around 0 8.6%
Taylor expanded in x around 0 8.4%
if 5.00000000000000041e-6 < 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 5e-6)
(*
(fmod (+ 1.0 (* x (+ 1.0 (* x 0.5)))) (+ 1.0 (* (pow x 2.0) -0.25)))
(- 1.0 x))
(fmod 1.0 1.0)))
double code(double x) {
double tmp;
if (x <= 5e-6) {
tmp = fmod((1.0 + (x * (1.0 + (x * 0.5)))), (1.0 + (pow(x, 2.0) * -0.25))) * (1.0 - 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 <= 5d-6) then
tmp = mod((1.0d0 + (x * (1.0d0 + (x * 0.5d0)))), (1.0d0 + ((x ** 2.0d0) * (-0.25d0)))) * (1.0d0 - x)
else
tmp = mod(1.0d0, 1.0d0)
end if
code = tmp
end function
def code(x): tmp = 0 if x <= 5e-6: tmp = math.fmod((1.0 + (x * (1.0 + (x * 0.5)))), (1.0 + (math.pow(x, 2.0) * -0.25))) * (1.0 - x) else: tmp = math.fmod(1.0, 1.0) return tmp
function code(x) tmp = 0.0 if (x <= 5e-6) tmp = Float64(rem(Float64(1.0 + Float64(x * Float64(1.0 + Float64(x * 0.5)))), Float64(1.0 + Float64((x ^ 2.0) * -0.25))) * Float64(1.0 - x)); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[x, 5e-6], N[(N[With[{TMP1 = N[(1.0 + N[(x * N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], TMP2 = N[(1.0 + N[(N[Power[x, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1.0 - 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 5 \cdot 10^{-6}:\\
\;\;\;\;\left(\left(1 + x \cdot \left(1 + x \cdot 0.5\right)\right) \bmod \left(1 + {x}^{2} \cdot -0.25\right)\right) \cdot \left(1 - x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < 5.00000000000000041e-6Initial program 8.6%
/-rgt-identity8.6%
associate-/r/8.6%
exp-neg8.6%
remove-double-neg8.6%
Simplified8.6%
Taylor expanded in x around 0 7.7%
+-commutative7.7%
mul-1-neg7.7%
unsub-neg7.7%
*-lft-identity7.7%
distribute-rgt-out--7.6%
Simplified7.6%
Taylor expanded in x around 0 7.6%
Taylor expanded in x around 0 7.7%
*-commutative7.7%
Simplified7.7%
if 5.00000000000000041e-6 < 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 simplification29.3%
(FPCore (x) :precision binary64 (if (<= x 5e-6) (* (fmod (exp x) (+ 1.0 (* -0.25 (* x x)))) (- 1.0 x)) (fmod 1.0 1.0)))
double code(double x) {
double tmp;
if (x <= 5e-6) {
tmp = fmod(exp(x), (1.0 + (-0.25 * (x * x)))) * (1.0 - 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 <= 5d-6) then
tmp = mod(exp(x), (1.0d0 + ((-0.25d0) * (x * x)))) * (1.0d0 - x)
else
tmp = mod(1.0d0, 1.0d0)
end if
code = tmp
end function
def code(x): tmp = 0 if x <= 5e-6: tmp = math.fmod(math.exp(x), (1.0 + (-0.25 * (x * x)))) * (1.0 - x) else: tmp = math.fmod(1.0, 1.0) return tmp
function code(x) tmp = 0.0 if (x <= 5e-6) tmp = Float64(rem(exp(x), Float64(1.0 + Float64(-0.25 * Float64(x * x)))) * Float64(1.0 - x)); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[x, 5e-6], 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 - 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 5 \cdot 10^{-6}:\\
\;\;\;\;\left(\left(e^{x}\right) \bmod \left(1 + -0.25 \cdot \left(x \cdot x\right)\right)\right) \cdot \left(1 - x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < 5.00000000000000041e-6Initial program 8.6%
/-rgt-identity8.6%
associate-/r/8.6%
exp-neg8.6%
remove-double-neg8.6%
Simplified8.6%
Taylor expanded in x around 0 7.7%
+-commutative7.7%
mul-1-neg7.7%
unsub-neg7.7%
*-lft-identity7.7%
distribute-rgt-out--7.6%
Simplified7.6%
Taylor expanded in x around 0 7.6%
unpow28.6%
Applied egg-rr7.6%
if 5.00000000000000041e-6 < 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 5e-6) (* (fmod (exp x) 1.0) (- 1.0 x)) (fmod 1.0 1.0)))
double code(double x) {
double tmp;
if (x <= 5e-6) {
tmp = fmod(exp(x), 1.0) * (1.0 - 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 <= 5d-6) then
tmp = mod(exp(x), 1.0d0) * (1.0d0 - x)
else
tmp = mod(1.0d0, 1.0d0)
end if
code = tmp
end function
def code(x): tmp = 0 if x <= 5e-6: tmp = math.fmod(math.exp(x), 1.0) * (1.0 - x) else: tmp = math.fmod(1.0, 1.0) return tmp
function code(x) tmp = 0.0 if (x <= 5e-6) tmp = Float64(rem(exp(x), 1.0) * Float64(1.0 - x)); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[x, 5e-6], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision], 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 5 \cdot 10^{-6}:\\
\;\;\;\;\left(\left(e^{x}\right) \bmod 1\right) \cdot \left(1 - x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < 5.00000000000000041e-6Initial program 8.6%
/-rgt-identity8.6%
associate-/r/8.6%
exp-neg8.6%
remove-double-neg8.6%
Simplified8.6%
Taylor expanded in x around 0 7.7%
+-commutative7.7%
mul-1-neg7.7%
unsub-neg7.7%
*-lft-identity7.7%
distribute-rgt-out--7.6%
Simplified7.6%
Taylor expanded in x around 0 7.6%
Taylor expanded in x around 0 7.4%
if 5.00000000000000041e-6 < 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 -1e-156) (fmod 1.0 (* (pow x 2.0) -0.25)) (fmod 1.0 1.0)))
double code(double x) {
double tmp;
if (x <= -1e-156) {
tmp = fmod(1.0, (pow(x, 2.0) * -0.25));
} else {
tmp = fmod(1.0, 1.0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1d-156)) then
tmp = mod(1.0d0, ((x ** 2.0d0) * (-0.25d0)))
else
tmp = mod(1.0d0, 1.0d0)
end if
code = tmp
end function
def code(x): tmp = 0 if x <= -1e-156: tmp = math.fmod(1.0, (math.pow(x, 2.0) * -0.25)) else: tmp = math.fmod(1.0, 1.0) return tmp
function code(x) tmp = 0.0 if (x <= -1e-156) tmp = rem(1.0, Float64((x ^ 2.0) * -0.25)); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[x, -1e-156], N[With[{TMP1 = 1.0, TMP2 = N[(N[Power[x, 2.0], $MachinePrecision] * -0.25), $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 -1 \cdot 10^{-156}:\\
\;\;\;\;\left(1 \bmod \left({x}^{2} \cdot -0.25\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < -1.00000000000000004e-156Initial program 13.1%
/-rgt-identity13.1%
associate-/r/13.1%
exp-neg13.2%
remove-double-neg13.2%
Simplified13.2%
Taylor expanded in x around 0 8.8%
Taylor expanded in x around 0 4.4%
Taylor expanded in x around 0 10.2%
Taylor expanded in x around inf 11.9%
if -1.00000000000000004e-156 < x Initial program 4.7%
/-rgt-identity4.7%
associate-/r/4.7%
exp-neg4.7%
remove-double-neg4.7%
Simplified4.7%
Taylor expanded in x around 0 4.4%
Taylor expanded in x around 0 4.4%
Taylor expanded in x around 0 4.4%
Taylor expanded in x around 0 33.5%
Final simplification28.7%
(FPCore (x) :precision binary64 (if (<= x 5e-6) (fmod 1.0 (+ 1.0 (* -0.25 (* x x)))) (fmod 1.0 1.0)))
double code(double x) {
double tmp;
if (x <= 5e-6) {
tmp = fmod(1.0, (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 <= 5d-6) then
tmp = mod(1.0d0, (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 <= 5e-6: tmp = math.fmod(1.0, (1.0 + (-0.25 * (x * x)))) else: tmp = math.fmod(1.0, 1.0) return tmp
function code(x) tmp = 0.0 if (x <= 5e-6) tmp = rem(1.0, 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, 5e-6], N[With[{TMP1 = 1.0, 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 5 \cdot 10^{-6}:\\
\;\;\;\;\left(1 \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 < 5.00000000000000041e-6Initial program 8.6%
/-rgt-identity8.6%
associate-/r/8.6%
exp-neg8.6%
remove-double-neg8.6%
Simplified8.6%
Taylor expanded in x around 0 7.1%
Taylor expanded in x around 0 4.8%
Taylor expanded in x around 0 6.5%
unpow28.6%
Applied egg-rr6.5%
if 5.00000000000000041e-6 < 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 6.6%
/-rgt-identity6.6%
associate-/r/6.5%
exp-neg6.6%
remove-double-neg6.6%
Simplified6.6%
Taylor expanded in x around 0 5.4%
Taylor expanded in x around 0 4.4%
Taylor expanded in x around 0 5.7%
Taylor expanded in x around 0 26.8%
herbie shell --seed 2024160
(FPCore (x)
:name "expfmod (used to be hard to sample)"
:precision binary64
(* (fmod (exp x) (sqrt (cos x))) (exp (- x))))