
(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
(if (<= x -2e-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 <= -2e-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 <= -2e-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, -2e-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 -2 \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 < -1.999999999999994e-310Initial program 8.4%
/-rgt-identity8.4%
associate-/r/8.4%
exp-neg8.4%
remove-double-neg8.4%
Simplified8.4%
add-log-exp8.4%
add-cube-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 -1.999999999999994e-310 < x 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 37.3%
+-commutative37.3%
Simplified37.3%
Taylor expanded in x around inf 98.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (exp (cos x)))))
(if (<= x -2e-310)
(fmod 1.0 (sqrt (+ (log (pow t_0 2.0)) (log t_0))))
(/ (fmod x (sqrt (cos x))) (exp x)))))
double code(double x) {
double t_0 = cbrt(exp(cos(x)));
double tmp;
if (x <= -2e-310) {
tmp = fmod(1.0, sqrt((log(pow(t_0, 2.0)) + log(t_0))));
} else {
tmp = fmod(x, sqrt(cos(x))) / exp(x);
}
return tmp;
}
function code(x) t_0 = cbrt(exp(cos(x))) tmp = 0.0 if (x <= -2e-310) tmp = rem(1.0, sqrt(Float64(log((t_0 ^ 2.0)) + log(t_0)))); else tmp = Float64(rem(x, sqrt(cos(x))) / exp(x)); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[Exp[N[Cos[x], $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, -2e-310], N[With[{TMP1 = 1.0, 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[(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 := \sqrt[3]{e^{\cos x}}\\
\mathbf{if}\;x \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\left(1 \bmod \left(\sqrt{\log \left({t\_0}^{2}\right) + \log t\_0}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\\
\end{array}
\end{array}
if x < -1.999999999999994e-310Initial program 8.4%
Taylor expanded in x around 0 7.3%
Taylor expanded in x around 0 3.3%
add-log-exp8.4%
add-cube-cbrt99.1%
log-prod99.1%
pow299.1%
Applied egg-rr98.4%
if -1.999999999999994e-310 < x 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 37.3%
+-commutative37.3%
Simplified37.3%
Taylor expanded in x around inf 98.3%
(FPCore (x) :precision binary64 (if (<= x -1.15e-301) (/ (fmod (* x (+ 1.0 (/ 1.0 x))) (+ 1.0 (* -0.25 (pow x 2.0)))) (exp x)) (/ (fabs (fmod x (sqrt (cos x)))) (exp x))))
double code(double x) {
double tmp;
if (x <= -1.15e-301) {
tmp = fmod((x * (1.0 + (1.0 / x))), (1.0 + (-0.25 * pow(x, 2.0)))) / exp(x);
} else {
tmp = fabs(fmod(x, sqrt(cos(x)))) / exp(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.15d-301)) then
tmp = mod((x * (1.0d0 + (1.0d0 / x))), (1.0d0 + ((-0.25d0) * (x ** 2.0d0)))) / exp(x)
else
tmp = abs(mod(x, sqrt(cos(x)))) / exp(x)
end if
code = tmp
end function
def code(x): tmp = 0 if x <= -1.15e-301: tmp = math.fmod((x * (1.0 + (1.0 / x))), (1.0 + (-0.25 * math.pow(x, 2.0)))) / math.exp(x) else: tmp = math.fabs(math.fmod(x, math.sqrt(math.cos(x)))) / math.exp(x) return tmp
function code(x) tmp = 0.0 if (x <= -1.15e-301) tmp = Float64(rem(Float64(x * Float64(1.0 + Float64(1.0 / x))), Float64(1.0 + Float64(-0.25 * (x ^ 2.0)))) / exp(x)); else tmp = Float64(abs(rem(x, sqrt(cos(x)))) / exp(x)); end return tmp end
code[x_] := If[LessEqual[x, -1.15e-301], N[(N[With[{TMP1 = N[(x * N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], TMP2 = N[(1.0 + N[(-0.25 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[Abs[N[With[{TMP1 = x, TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.15 \cdot 10^{-301}:\\
\;\;\;\;\frac{\left(\left(x \cdot \left(1 + \frac{1}{x}\right)\right) \bmod \left(1 + -0.25 \cdot {x}^{2}\right)\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|\left(x \bmod \left(\sqrt{\cos x}\right)\right)\right|}{e^{x}}\\
\end{array}
\end{array}
if x < -1.1500000000000001e-301Initial program 8.5%
/-rgt-identity8.5%
associate-/r/8.5%
exp-neg8.5%
remove-double-neg8.5%
Simplified8.5%
Taylor expanded in x around 0 8.1%
+-commutative8.1%
Simplified8.1%
Taylor expanded in x around 0 8.1%
Taylor expanded in x around inf 17.8%
if -1.1500000000000001e-301 < x Initial program 5.8%
/-rgt-identity5.8%
associate-/r/5.8%
exp-neg5.8%
remove-double-neg5.8%
Simplified5.8%
Taylor expanded in x around 0 36.9%
+-commutative36.9%
Simplified36.9%
Taylor expanded in x around inf 97.1%
add-sqr-sqrt96.5%
sqrt-unprod64.3%
pow264.3%
Applied egg-rr64.3%
unpow264.3%
rem-sqrt-square97.1%
Simplified97.1%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ 1.0 (* -0.25 (pow x 2.0)))))
(if (<= x -1.15e-301)
(/ (fmod (* x (+ 1.0 (/ 1.0 x))) t_0) (exp x))
(if (<= x 0.6)
(fabs (fmod x (sqrt (cos x))))
(/ (fmod 1.0 t_0) (exp x))))))
double code(double x) {
double t_0 = 1.0 + (-0.25 * pow(x, 2.0));
double tmp;
if (x <= -1.15e-301) {
tmp = fmod((x * (1.0 + (1.0 / x))), t_0) / exp(x);
} else if (x <= 0.6) {
tmp = fabs(fmod(x, sqrt(cos(x))));
} else {
tmp = fmod(1.0, 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 = 1.0d0 + ((-0.25d0) * (x ** 2.0d0))
if (x <= (-1.15d-301)) then
tmp = mod((x * (1.0d0 + (1.0d0 / x))), t_0) / exp(x)
else if (x <= 0.6d0) then
tmp = abs(mod(x, sqrt(cos(x))))
else
tmp = mod(1.0d0, t_0) / exp(x)
end if
code = tmp
end function
def code(x): t_0 = 1.0 + (-0.25 * math.pow(x, 2.0)) tmp = 0 if x <= -1.15e-301: tmp = math.fmod((x * (1.0 + (1.0 / x))), t_0) / math.exp(x) elif x <= 0.6: tmp = math.fabs(math.fmod(x, math.sqrt(math.cos(x)))) else: tmp = math.fmod(1.0, t_0) / math.exp(x) return tmp
function code(x) t_0 = Float64(1.0 + Float64(-0.25 * (x ^ 2.0))) tmp = 0.0 if (x <= -1.15e-301) tmp = Float64(rem(Float64(x * Float64(1.0 + Float64(1.0 / x))), t_0) / exp(x)); elseif (x <= 0.6) tmp = abs(rem(x, sqrt(cos(x)))); else tmp = Float64(rem(1.0, t_0) / exp(x)); end return tmp end
code[x_] := Block[{t$95$0 = N[(1.0 + N[(-0.25 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.15e-301], 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], If[LessEqual[x, 0.6], N[Abs[N[With[{TMP1 = x, TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]], $MachinePrecision], N[(N[With[{TMP1 = 1.0, 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 := 1 + -0.25 \cdot {x}^{2}\\
\mathbf{if}\;x \leq -1.15 \cdot 10^{-301}:\\
\;\;\;\;\frac{\left(\left(x \cdot \left(1 + \frac{1}{x}\right)\right) \bmod t\_0\right)}{e^{x}}\\
\mathbf{elif}\;x \leq 0.6:\\
\;\;\;\;\left|\left(x \bmod \left(\sqrt{\cos x}\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 \bmod t\_0\right)}{e^{x}}\\
\end{array}
\end{array}
if x < -1.1500000000000001e-301Initial program 8.5%
/-rgt-identity8.5%
associate-/r/8.5%
exp-neg8.5%
remove-double-neg8.5%
Simplified8.5%
Taylor expanded in x around 0 8.1%
+-commutative8.1%
Simplified8.1%
Taylor expanded in x around 0 8.1%
Taylor expanded in x around inf 17.8%
if -1.1500000000000001e-301 < x < 0.599999999999999978Initial program 8.3%
/-rgt-identity8.3%
associate-/r/8.3%
exp-neg8.3%
remove-double-neg8.3%
Simplified8.3%
Taylor expanded in x around 0 8.3%
+-commutative8.3%
Simplified8.3%
Taylor expanded in x around inf 96.5%
add-sqr-sqrt95.7%
sqrt-unprod48.5%
pow248.5%
Applied egg-rr48.5%
unpow248.5%
rem-sqrt-square96.5%
Simplified96.5%
Taylor expanded in x around 0 96.7%
if 0.599999999999999978 < x Initial program 0.4%
/-rgt-identity0.4%
associate-/r/0.4%
exp-neg0.4%
remove-double-neg0.4%
Simplified0.4%
Taylor expanded in x around 0 98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in x around 0 98.2%
Taylor expanded in x around 0 98.3%
(FPCore (x) :precision binary64 (if (<= x -5e-309) (/ (fmod (* x (+ 1.0 (/ 1.0 x))) (+ 1.0 (* -0.25 (pow x 2.0)))) (exp x)) (/ (fmod x (sqrt (cos x))) (exp x))))
double code(double x) {
double tmp;
if (x <= -5e-309) {
tmp = fmod((x * (1.0 + (1.0 / x))), (1.0 + (-0.25 * pow(x, 2.0)))) / exp(x);
} else {
tmp = fmod(x, sqrt(cos(x))) / exp(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-5d-309)) then
tmp = mod((x * (1.0d0 + (1.0d0 / x))), (1.0d0 + ((-0.25d0) * (x ** 2.0d0)))) / exp(x)
else
tmp = mod(x, sqrt(cos(x))) / exp(x)
end if
code = tmp
end function
def code(x): tmp = 0 if x <= -5e-309: tmp = math.fmod((x * (1.0 + (1.0 / x))), (1.0 + (-0.25 * math.pow(x, 2.0)))) / math.exp(x) else: tmp = math.fmod(x, math.sqrt(math.cos(x))) / math.exp(x) return tmp
function code(x) tmp = 0.0 if (x <= -5e-309) tmp = Float64(rem(Float64(x * Float64(1.0 + Float64(1.0 / x))), Float64(1.0 + Float64(-0.25 * (x ^ 2.0)))) / exp(x)); else tmp = Float64(rem(x, sqrt(cos(x))) / exp(x)); end return tmp end
code[x_] := If[LessEqual[x, -5e-309], N[(N[With[{TMP1 = N[(x * N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], TMP2 = N[(1.0 + N[(-0.25 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / 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^{-309}:\\
\;\;\;\;\frac{\left(\left(x \cdot \left(1 + \frac{1}{x}\right)\right) \bmod \left(1 + -0.25 \cdot {x}^{2}\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.9999999999999995e-309Initial program 8.4%
/-rgt-identity8.4%
associate-/r/8.4%
exp-neg8.4%
remove-double-neg8.4%
Simplified8.4%
Taylor expanded in x around 0 8.0%
+-commutative8.0%
Simplified8.0%
Taylor expanded in x around 0 8.0%
Taylor expanded in x around inf 17.5%
if -4.9999999999999995e-309 < x 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 37.3%
+-commutative37.3%
Simplified37.3%
Taylor expanded in x around inf 98.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ 1.0 (* -0.25 (pow x 2.0)))))
(if (<= x -1e-15)
(/ (fmod (+ x 1.0) t_0) (+ x 1.0))
(if (<= x -1.55e-162)
(fmod 1.0 (* (pow x 2.0) (- (/ 1.0 (pow x 2.0)) 0.25)))
(if (<= x 0.6) (fmod x (sqrt (cos x))) (/ (fmod 1.0 t_0) (exp x)))))))
double code(double x) {
double t_0 = 1.0 + (-0.25 * pow(x, 2.0));
double tmp;
if (x <= -1e-15) {
tmp = fmod((x + 1.0), t_0) / (x + 1.0);
} else if (x <= -1.55e-162) {
tmp = fmod(1.0, (pow(x, 2.0) * ((1.0 / pow(x, 2.0)) - 0.25)));
} else if (x <= 0.6) {
tmp = fmod(x, sqrt(cos(x)));
} else {
tmp = fmod(1.0, 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 = 1.0d0 + ((-0.25d0) * (x ** 2.0d0))
if (x <= (-1d-15)) then
tmp = mod((x + 1.0d0), t_0) / (x + 1.0d0)
else if (x <= (-1.55d-162)) then
tmp = mod(1.0d0, ((x ** 2.0d0) * ((1.0d0 / (x ** 2.0d0)) - 0.25d0)))
else if (x <= 0.6d0) then
tmp = mod(x, sqrt(cos(x)))
else
tmp = mod(1.0d0, t_0) / exp(x)
end if
code = tmp
end function
def code(x): t_0 = 1.0 + (-0.25 * math.pow(x, 2.0)) tmp = 0 if x <= -1e-15: tmp = math.fmod((x + 1.0), t_0) / (x + 1.0) elif x <= -1.55e-162: tmp = math.fmod(1.0, (math.pow(x, 2.0) * ((1.0 / math.pow(x, 2.0)) - 0.25))) elif x <= 0.6: tmp = math.fmod(x, math.sqrt(math.cos(x))) else: tmp = math.fmod(1.0, t_0) / math.exp(x) return tmp
function code(x) t_0 = Float64(1.0 + Float64(-0.25 * (x ^ 2.0))) tmp = 0.0 if (x <= -1e-15) tmp = Float64(rem(Float64(x + 1.0), t_0) / Float64(x + 1.0)); elseif (x <= -1.55e-162) tmp = rem(1.0, Float64((x ^ 2.0) * Float64(Float64(1.0 / (x ^ 2.0)) - 0.25))); elseif (x <= 0.6) tmp = rem(x, sqrt(cos(x))); else tmp = Float64(rem(1.0, t_0) / exp(x)); end return tmp end
code[x_] := Block[{t$95$0 = N[(1.0 + N[(-0.25 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1e-15], N[(N[With[{TMP1 = N[(x + 1.0), $MachinePrecision], TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.55e-162], N[With[{TMP1 = 1.0, 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], If[LessEqual[x, 0.6], N[With[{TMP1 = x, TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision], N[(N[With[{TMP1 = 1.0, 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 := 1 + -0.25 \cdot {x}^{2}\\
\mathbf{if}\;x \leq -1 \cdot 10^{-15}:\\
\;\;\;\;\frac{\left(\left(x + 1\right) \bmod t\_0\right)}{x + 1}\\
\mathbf{elif}\;x \leq -1.55 \cdot 10^{-162}:\\
\;\;\;\;\left(1 \bmod \left({x}^{2} \cdot \left(\frac{1}{{x}^{2}} - 0.25\right)\right)\right)\\
\mathbf{elif}\;x \leq 0.6:\\
\;\;\;\;\left(x \bmod \left(\sqrt{\cos x}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 \bmod t\_0\right)}{e^{x}}\\
\end{array}
\end{array}
if x < -1.0000000000000001e-15Initial program 85.5%
/-rgt-identity85.5%
associate-/r/85.5%
exp-neg85.7%
remove-double-neg85.7%
Simplified85.7%
Taylor expanded in x around 0 79.5%
+-commutative79.5%
Simplified79.5%
Taylor expanded in x around 0 79.5%
Taylor expanded in x around 0 100.0%
+-commutative79.5%
Simplified100.0%
if -1.0000000000000001e-15 < x < -1.5499999999999999e-162Initial program 3.1%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around inf 12.6%
if -1.5499999999999999e-162 < x < 0.599999999999999978Initial program 6.5%
/-rgt-identity6.5%
associate-/r/6.5%
exp-neg6.5%
remove-double-neg6.5%
Simplified6.5%
Taylor expanded in x around 0 6.5%
+-commutative6.5%
Simplified6.5%
Taylor expanded in x around inf 63.0%
Taylor expanded in x around 0 63.2%
if 0.599999999999999978 < x Initial program 0.4%
/-rgt-identity0.4%
associate-/r/0.4%
exp-neg0.4%
remove-double-neg0.4%
Simplified0.4%
Taylor expanded in x around 0 98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in x around 0 98.2%
Taylor expanded in x around 0 98.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ 1.0 (* -0.25 (pow x 2.0)))))
(if (<= x -5e-309)
(/ (fmod (* x (+ 1.0 (/ 1.0 x))) t_0) (exp x))
(if (<= x 0.6) (fmod x (sqrt (cos x))) (/ (fmod 1.0 t_0) (exp x))))))
double code(double x) {
double t_0 = 1.0 + (-0.25 * pow(x, 2.0));
double tmp;
if (x <= -5e-309) {
tmp = fmod((x * (1.0 + (1.0 / x))), t_0) / exp(x);
} else if (x <= 0.6) {
tmp = fmod(x, sqrt(cos(x)));
} else {
tmp = fmod(1.0, 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 = 1.0d0 + ((-0.25d0) * (x ** 2.0d0))
if (x <= (-5d-309)) then
tmp = mod((x * (1.0d0 + (1.0d0 / x))), t_0) / exp(x)
else if (x <= 0.6d0) then
tmp = mod(x, sqrt(cos(x)))
else
tmp = mod(1.0d0, t_0) / exp(x)
end if
code = tmp
end function
def code(x): t_0 = 1.0 + (-0.25 * math.pow(x, 2.0)) tmp = 0 if x <= -5e-309: tmp = math.fmod((x * (1.0 + (1.0 / x))), t_0) / math.exp(x) elif x <= 0.6: tmp = math.fmod(x, math.sqrt(math.cos(x))) else: tmp = math.fmod(1.0, t_0) / math.exp(x) return tmp
function code(x) t_0 = Float64(1.0 + Float64(-0.25 * (x ^ 2.0))) tmp = 0.0 if (x <= -5e-309) tmp = Float64(rem(Float64(x * Float64(1.0 + Float64(1.0 / x))), t_0) / exp(x)); elseif (x <= 0.6) tmp = rem(x, sqrt(cos(x))); else tmp = Float64(rem(1.0, t_0) / exp(x)); end return tmp end
code[x_] := Block[{t$95$0 = N[(1.0 + N[(-0.25 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -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], If[LessEqual[x, 0.6], N[With[{TMP1 = x, TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision], N[(N[With[{TMP1 = 1.0, 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 := 1 + -0.25 \cdot {x}^{2}\\
\mathbf{if}\;x \leq -5 \cdot 10^{-309}:\\
\;\;\;\;\frac{\left(\left(x \cdot \left(1 + \frac{1}{x}\right)\right) \bmod t\_0\right)}{e^{x}}\\
\mathbf{elif}\;x \leq 0.6:\\
\;\;\;\;\left(x \bmod \left(\sqrt{\cos x}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 \bmod t\_0\right)}{e^{x}}\\
\end{array}
\end{array}
if x < -4.9999999999999995e-309Initial program 8.4%
/-rgt-identity8.4%
associate-/r/8.4%
exp-neg8.4%
remove-double-neg8.4%
Simplified8.4%
Taylor expanded in x around 0 8.0%
+-commutative8.0%
Simplified8.0%
Taylor expanded in x around 0 8.0%
Taylor expanded in x around inf 17.5%
if -4.9999999999999995e-309 < x < 0.599999999999999978Initial program 8.4%
/-rgt-identity8.4%
associate-/r/8.4%
exp-neg8.4%
remove-double-neg8.4%
Simplified8.4%
Taylor expanded in x around 0 8.4%
+-commutative8.4%
Simplified8.4%
Taylor expanded in x around inf 98.4%
Taylor expanded in x around 0 98.6%
if 0.599999999999999978 < x Initial program 0.4%
/-rgt-identity0.4%
associate-/r/0.4%
exp-neg0.4%
remove-double-neg0.4%
Simplified0.4%
Taylor expanded in x around 0 98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in x around 0 98.2%
Taylor expanded in x around 0 98.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ 1.0 (* -0.25 (pow x 2.0)))))
(if (<= x -2e-310)
(/ (fmod (+ x 1.0) t_0) (+ x 1.0))
(if (<= x 0.6) (fmod x (sqrt (cos x))) (/ (fmod 1.0 t_0) (exp x))))))
double code(double x) {
double t_0 = 1.0 + (-0.25 * pow(x, 2.0));
double tmp;
if (x <= -2e-310) {
tmp = fmod((x + 1.0), t_0) / (x + 1.0);
} else if (x <= 0.6) {
tmp = fmod(x, sqrt(cos(x)));
} else {
tmp = fmod(1.0, 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 = 1.0d0 + ((-0.25d0) * (x ** 2.0d0))
if (x <= (-2d-310)) then
tmp = mod((x + 1.0d0), t_0) / (x + 1.0d0)
else if (x <= 0.6d0) then
tmp = mod(x, sqrt(cos(x)))
else
tmp = mod(1.0d0, t_0) / exp(x)
end if
code = tmp
end function
def code(x): t_0 = 1.0 + (-0.25 * math.pow(x, 2.0)) tmp = 0 if x <= -2e-310: tmp = math.fmod((x + 1.0), t_0) / (x + 1.0) elif x <= 0.6: tmp = math.fmod(x, math.sqrt(math.cos(x))) else: tmp = math.fmod(1.0, t_0) / math.exp(x) return tmp
function code(x) t_0 = Float64(1.0 + Float64(-0.25 * (x ^ 2.0))) tmp = 0.0 if (x <= -2e-310) tmp = Float64(rem(Float64(x + 1.0), t_0) / Float64(x + 1.0)); elseif (x <= 0.6) tmp = rem(x, sqrt(cos(x))); else tmp = Float64(rem(1.0, t_0) / exp(x)); end return tmp end
code[x_] := Block[{t$95$0 = N[(1.0 + N[(-0.25 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2e-310], N[(N[With[{TMP1 = N[(x + 1.0), $MachinePrecision], TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.6], N[With[{TMP1 = x, TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision], N[(N[With[{TMP1 = 1.0, 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 := 1 + -0.25 \cdot {x}^{2}\\
\mathbf{if}\;x \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{\left(\left(x + 1\right) \bmod t\_0\right)}{x + 1}\\
\mathbf{elif}\;x \leq 0.6:\\
\;\;\;\;\left(x \bmod \left(\sqrt{\cos x}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 \bmod t\_0\right)}{e^{x}}\\
\end{array}
\end{array}
if x < -1.999999999999994e-310Initial program 8.4%
/-rgt-identity8.4%
associate-/r/8.4%
exp-neg8.4%
remove-double-neg8.4%
Simplified8.4%
Taylor expanded in x around 0 8.0%
+-commutative8.0%
Simplified8.0%
Taylor expanded in x around 0 8.0%
Taylor expanded in x around 0 9.3%
+-commutative8.0%
Simplified9.3%
if -1.999999999999994e-310 < x < 0.599999999999999978Initial program 8.4%
/-rgt-identity8.4%
associate-/r/8.4%
exp-neg8.4%
remove-double-neg8.4%
Simplified8.4%
Taylor expanded in x around 0 8.4%
+-commutative8.4%
Simplified8.4%
Taylor expanded in x around inf 98.4%
Taylor expanded in x around 0 98.6%
if 0.599999999999999978 < x Initial program 0.4%
/-rgt-identity0.4%
associate-/r/0.4%
exp-neg0.4%
remove-double-neg0.4%
Simplified0.4%
Taylor expanded in x around 0 98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in x around 0 98.2%
Taylor expanded in x around 0 98.3%
(FPCore (x)
:precision binary64
(if (<= x -2e-310)
(/ (fmod (+ x 1.0) (+ 1.0 (* -0.25 (pow x 2.0)))) (+ x 1.0))
(if (<= x 0.6)
(fmod x (sqrt (cos x)))
(/ (fmod (+ x 1.0) (+ 1.0 (* -0.25 (* x x)))) (exp x)))))
double code(double x) {
double tmp;
if (x <= -2e-310) {
tmp = fmod((x + 1.0), (1.0 + (-0.25 * pow(x, 2.0)))) / (x + 1.0);
} else if (x <= 0.6) {
tmp = fmod(x, sqrt(cos(x)));
} else {
tmp = fmod((x + 1.0), (1.0 + (-0.25 * (x * x)))) / exp(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-2d-310)) then
tmp = mod((x + 1.0d0), (1.0d0 + ((-0.25d0) * (x ** 2.0d0)))) / (x + 1.0d0)
else if (x <= 0.6d0) then
tmp = mod(x, sqrt(cos(x)))
else
tmp = mod((x + 1.0d0), (1.0d0 + ((-0.25d0) * (x * x)))) / exp(x)
end if
code = tmp
end function
def code(x): tmp = 0 if x <= -2e-310: tmp = math.fmod((x + 1.0), (1.0 + (-0.25 * math.pow(x, 2.0)))) / (x + 1.0) elif x <= 0.6: tmp = math.fmod(x, math.sqrt(math.cos(x))) else: tmp = math.fmod((x + 1.0), (1.0 + (-0.25 * (x * x)))) / math.exp(x) return tmp
function code(x) tmp = 0.0 if (x <= -2e-310) tmp = Float64(rem(Float64(x + 1.0), Float64(1.0 + Float64(-0.25 * (x ^ 2.0)))) / Float64(x + 1.0)); elseif (x <= 0.6) tmp = rem(x, sqrt(cos(x))); else tmp = Float64(rem(Float64(x + 1.0), Float64(1.0 + Float64(-0.25 * Float64(x * x)))) / exp(x)); end return tmp end
code[x_] := If[LessEqual[x, -2e-310], 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], If[LessEqual[x, 0.6], N[With[{TMP1 = x, TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision], N[(N[With[{TMP1 = N[(x + 1.0), $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]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{\left(\left(x + 1\right) \bmod \left(1 + -0.25 \cdot {x}^{2}\right)\right)}{x + 1}\\
\mathbf{elif}\;x \leq 0.6:\\
\;\;\;\;\left(x \bmod \left(\sqrt{\cos x}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(x + 1\right) \bmod \left(1 + -0.25 \cdot \left(x \cdot x\right)\right)\right)}{e^{x}}\\
\end{array}
\end{array}
if x < -1.999999999999994e-310Initial program 8.4%
/-rgt-identity8.4%
associate-/r/8.4%
exp-neg8.4%
remove-double-neg8.4%
Simplified8.4%
Taylor expanded in x around 0 8.0%
+-commutative8.0%
Simplified8.0%
Taylor expanded in x around 0 8.0%
Taylor expanded in x around 0 9.3%
+-commutative8.0%
Simplified9.3%
if -1.999999999999994e-310 < x < 0.599999999999999978Initial program 8.4%
/-rgt-identity8.4%
associate-/r/8.4%
exp-neg8.4%
remove-double-neg8.4%
Simplified8.4%
Taylor expanded in x around 0 8.4%
+-commutative8.4%
Simplified8.4%
Taylor expanded in x around inf 98.4%
Taylor expanded in x around 0 98.6%
if 0.599999999999999978 < x Initial program 0.4%
/-rgt-identity0.4%
associate-/r/0.4%
exp-neg0.4%
remove-double-neg0.4%
Simplified0.4%
Taylor expanded in x around 0 98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in x around 0 98.2%
unpow298.2%
Applied egg-rr98.2%
(FPCore (x) :precision binary64 (if (<= x 200.0) (fmod (+ x 1.0) (+ 1.0 (* -0.25 (pow x 2.0)))) (fmod 1.0 1.0)))
double code(double x) {
double tmp;
if (x <= 200.0) {
tmp = fmod((x + 1.0), (1.0 + (-0.25 * pow(x, 2.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 <= 200.0d0) then
tmp = mod((x + 1.0d0), (1.0d0 + ((-0.25d0) * (x ** 2.0d0))))
else
tmp = mod(1.0d0, 1.0d0)
end if
code = tmp
end function
def code(x): tmp = 0 if x <= 200.0: tmp = math.fmod((x + 1.0), (1.0 + (-0.25 * math.pow(x, 2.0)))) else: tmp = math.fmod(1.0, 1.0) return tmp
function code(x) tmp = 0.0 if (x <= 200.0) tmp = rem(Float64(x + 1.0), Float64(1.0 + Float64(-0.25 * (x ^ 2.0)))); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[x, 200.0], 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[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 200:\\
\;\;\;\;\left(\left(x + 1\right) \bmod \left(1 + -0.25 \cdot {x}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < 200Initial program 8.5%
/-rgt-identity8.5%
associate-/r/8.5%
exp-neg8.5%
remove-double-neg8.5%
Simplified8.5%
Taylor expanded in x around 0 8.2%
+-commutative8.2%
Simplified8.2%
Taylor expanded in x around 0 8.2%
Taylor expanded in x around 0 7.8%
if 200 < 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 simplification24.4%
(FPCore (x) :precision binary64 (/ (fmod (+ x 1.0) (+ 1.0 (* -0.25 (* x x)))) (exp x)))
double code(double x) {
return fmod((x + 1.0), (1.0 + (-0.25 * (x * x)))) / exp(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod((x + 1.0d0), (1.0d0 + ((-0.25d0) * (x * x)))) / exp(x)
end function
def code(x): return math.fmod((x + 1.0), (1.0 + (-0.25 * (x * x)))) / math.exp(x)
function code(x) return Float64(rem(Float64(x + 1.0), Float64(1.0 + Float64(-0.25 * Float64(x * x)))) / exp(x)) end
code[x_] := N[(N[With[{TMP1 = N[(x + 1.0), $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]
\begin{array}{l}
\\
\frac{\left(\left(x + 1\right) \bmod \left(1 + -0.25 \cdot \left(x \cdot x\right)\right)\right)}{e^{x}}
\end{array}
Initial program 6.9%
/-rgt-identity6.9%
associate-/r/6.9%
exp-neg6.9%
remove-double-neg6.9%
Simplified6.9%
Taylor expanded in x around 0 24.7%
+-commutative24.7%
Simplified24.7%
Taylor expanded in x around 0 24.7%
unpow224.7%
Applied egg-rr24.7%
(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.9%
Taylor expanded in x around 0 6.4%
Taylor expanded in x around 0 4.2%
Taylor expanded in x around 0 4.5%
Taylor expanded in x around 0 21.5%
herbie shell --seed 2024177
(FPCore (x)
:name "expfmod (used to be hard to sample)"
:precision binary64
(* (fmod (exp x) (sqrt (cos x))) (exp (- x))))