
(FPCore (x) :precision binary64 (* (fmod (exp x) (sqrt (cos x))) (exp (- x))))
double code(double x) {
return fmod(exp(x), sqrt(cos(x))) * exp(-x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod(exp(x), sqrt(cos(x))) * exp(-x)
end function
def code(x): return math.fmod(math.exp(x), math.sqrt(math.cos(x))) * math.exp(-x)
function code(x) return Float64(rem(exp(x), sqrt(cos(x))) * exp(Float64(-x))) end
code[x_] := N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (* (fmod (exp x) (sqrt (cos x))) (exp (- x))))
double code(double x) {
return fmod(exp(x), sqrt(cos(x))) * exp(-x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod(exp(x), sqrt(cos(x))) * exp(-x)
end function
def code(x): return math.fmod(math.exp(x), math.sqrt(math.cos(x))) * math.exp(-x)
function code(x) return Float64(rem(exp(x), sqrt(cos(x))) * exp(Float64(-x))) end
code[x_] := N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (exp (- x)))
(t_1 (fmod (exp x) (sqrt (cos x))))
(t_2 (* t_0 t_1)))
(if (or (<= t_2 0.0) (not (<= t_2 2.0))) t_0 (/ (log (exp t_1)) (exp x)))))
double code(double x) {
double t_0 = exp(-x);
double t_1 = fmod(exp(x), sqrt(cos(x)));
double t_2 = t_0 * t_1;
double tmp;
if ((t_2 <= 0.0) || !(t_2 <= 2.0)) {
tmp = t_0;
} else {
tmp = log(exp(t_1)) / exp(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = exp(-x)
t_1 = mod(exp(x), sqrt(cos(x)))
t_2 = t_0 * t_1
if ((t_2 <= 0.0d0) .or. (.not. (t_2 <= 2.0d0))) then
tmp = t_0
else
tmp = log(exp(t_1)) / exp(x)
end if
code = tmp
end function
def code(x): t_0 = math.exp(-x) t_1 = math.fmod(math.exp(x), math.sqrt(math.cos(x))) t_2 = t_0 * t_1 tmp = 0 if (t_2 <= 0.0) or not (t_2 <= 2.0): tmp = t_0 else: tmp = math.log(math.exp(t_1)) / math.exp(x) return tmp
function code(x) t_0 = exp(Float64(-x)) t_1 = rem(exp(x), sqrt(cos(x))) t_2 = Float64(t_0 * t_1) tmp = 0.0 if ((t_2 <= 0.0) || !(t_2 <= 2.0)) tmp = t_0; else tmp = Float64(log(exp(t_1)) / exp(x)); end return tmp end
code[x_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, Block[{t$95$1 = N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1), $MachinePrecision]}, If[Or[LessEqual[t$95$2, 0.0], N[Not[LessEqual[t$95$2, 2.0]], $MachinePrecision]], t$95$0, N[(N[Log[N[Exp[t$95$1], $MachinePrecision]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
t_1 := \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
t_2 := t\_0 \cdot t\_1\\
\mathbf{if}\;t\_2 \leq 0 \lor \neg \left(t\_2 \leq 2\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(e^{t\_1}\right)}{e^{x}}\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 0.0 or 2 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 3.4%
/-rgt-identity3.4%
associate-/r/3.4%
exp-neg3.4%
remove-double-neg3.4%
Simplified3.4%
Taylor expanded in x around 0 3.4%
add-exp-log3.4%
div-exp3.4%
Applied egg-rr3.4%
Taylor expanded in x around inf 62.1%
neg-mul-162.1%
Simplified62.1%
if 0.0 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 72.7%
/-rgt-identity72.7%
associate-/r/72.4%
exp-neg72.9%
remove-double-neg72.9%
Simplified72.9%
add-log-exp73.0%
Applied egg-rr73.0%
Final simplification62.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (exp (- x)))
(t_1 (fmod (exp x) (sqrt (cos x))))
(t_2 (* t_0 t_1)))
(if (or (<= t_2 0.0) (not (<= t_2 2.0))) t_0 (/ t_1 (exp x)))))
double code(double x) {
double t_0 = exp(-x);
double t_1 = fmod(exp(x), sqrt(cos(x)));
double t_2 = t_0 * t_1;
double tmp;
if ((t_2 <= 0.0) || !(t_2 <= 2.0)) {
tmp = t_0;
} else {
tmp = t_1 / exp(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = exp(-x)
t_1 = mod(exp(x), sqrt(cos(x)))
t_2 = t_0 * t_1
if ((t_2 <= 0.0d0) .or. (.not. (t_2 <= 2.0d0))) then
tmp = t_0
else
tmp = t_1 / exp(x)
end if
code = tmp
end function
def code(x): t_0 = math.exp(-x) t_1 = math.fmod(math.exp(x), math.sqrt(math.cos(x))) t_2 = t_0 * t_1 tmp = 0 if (t_2 <= 0.0) or not (t_2 <= 2.0): tmp = t_0 else: tmp = t_1 / math.exp(x) return tmp
function code(x) t_0 = exp(Float64(-x)) t_1 = rem(exp(x), sqrt(cos(x))) t_2 = Float64(t_0 * t_1) tmp = 0.0 if ((t_2 <= 0.0) || !(t_2 <= 2.0)) tmp = t_0; else tmp = Float64(t_1 / exp(x)); end return tmp end
code[x_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, Block[{t$95$1 = N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1), $MachinePrecision]}, If[Or[LessEqual[t$95$2, 0.0], N[Not[LessEqual[t$95$2, 2.0]], $MachinePrecision]], t$95$0, N[(t$95$1 / N[Exp[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
t_1 := \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
t_2 := t\_0 \cdot t\_1\\
\mathbf{if}\;t\_2 \leq 0 \lor \neg \left(t\_2 \leq 2\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{e^{x}}\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 0.0 or 2 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 3.4%
/-rgt-identity3.4%
associate-/r/3.4%
exp-neg3.4%
remove-double-neg3.4%
Simplified3.4%
Taylor expanded in x around 0 3.4%
add-exp-log3.4%
div-exp3.4%
Applied egg-rr3.4%
Taylor expanded in x around inf 62.1%
neg-mul-162.1%
Simplified62.1%
if 0.0 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 72.7%
/-rgt-identity72.7%
associate-/r/72.4%
exp-neg72.9%
remove-double-neg72.9%
Simplified72.9%
Final simplification62.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (cos x))))
(if (<= x 500.0)
(/
(fmod (exp x) (+ (* t_0 0.6666666666666666) (log (cbrt (exp t_0)))))
(exp x))
(exp (- x)))))
double code(double x) {
double t_0 = sqrt(cos(x));
double tmp;
if (x <= 500.0) {
tmp = fmod(exp(x), ((t_0 * 0.6666666666666666) + log(cbrt(exp(t_0))))) / exp(x);
} else {
tmp = exp(-x);
}
return tmp;
}
function code(x) t_0 = sqrt(cos(x)) tmp = 0.0 if (x <= 500.0) tmp = Float64(rem(exp(x), Float64(Float64(t_0 * 0.6666666666666666) + log(cbrt(exp(t_0))))) / exp(x)); else tmp = exp(Float64(-x)); end return tmp end
code[x_] := Block[{t$95$0 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 500.0], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[(t$95$0 * 0.6666666666666666), $MachinePrecision] + N[Log[N[Power[N[Exp[t$95$0], $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[Exp[(-x)], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\cos x}\\
\mathbf{if}\;x \leq 500:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(t\_0 \cdot 0.6666666666666666 + \log \left(\sqrt[3]{e^{t\_0}}\right)\right)\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;e^{-x}\\
\end{array}
\end{array}
if x < 500Initial program 10.4%
/-rgt-identity10.4%
associate-/r/10.4%
exp-neg10.4%
remove-double-neg10.4%
Simplified10.4%
add-log-exp10.4%
add-cube-cbrt51.7%
log-prod51.7%
pow251.7%
Applied egg-rr51.7%
unpow251.7%
log-prod51.7%
pow1/351.7%
log-pow51.7%
add-log-exp51.7%
pow1/351.8%
log-pow51.8%
add-log-exp51.8%
Applied egg-rr51.8%
distribute-rgt-out51.8%
metadata-eval51.8%
Simplified51.8%
if 500 < 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%
add-exp-log0.0%
div-exp0.0%
Applied egg-rr0.0%
Taylor expanded in x around inf 100.0%
neg-mul-1100.0%
Simplified100.0%
(FPCore (x)
:precision binary64
(if (<= x 500.0)
(/
(fmod (exp x) (+ (* (sqrt (cos x)) 0.6666666666666666) (log (cbrt E))))
(exp x))
(exp (- x))))
double code(double x) {
double tmp;
if (x <= 500.0) {
tmp = fmod(exp(x), ((sqrt(cos(x)) * 0.6666666666666666) + log(cbrt(((double) M_E))))) / exp(x);
} else {
tmp = exp(-x);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= 500.0) tmp = Float64(rem(exp(x), Float64(Float64(sqrt(cos(x)) * 0.6666666666666666) + log(cbrt(exp(1))))) / exp(x)); else tmp = exp(Float64(-x)); end return tmp end
code[x_] := If[LessEqual[x, 500.0], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[(N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision] * 0.6666666666666666), $MachinePrecision] + N[Log[N[Power[E, 1/3], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[Exp[(-x)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 500:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x} \cdot 0.6666666666666666 + \log \left(\sqrt[3]{e}\right)\right)\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;e^{-x}\\
\end{array}
\end{array}
if x < 500Initial program 10.4%
/-rgt-identity10.4%
associate-/r/10.4%
exp-neg10.4%
remove-double-neg10.4%
Simplified10.4%
add-log-exp10.4%
add-cube-cbrt51.7%
log-prod51.7%
pow251.7%
Applied egg-rr51.7%
unpow251.7%
log-prod51.7%
pow1/351.7%
log-pow51.7%
add-log-exp51.7%
pow1/351.8%
log-pow51.8%
add-log-exp51.8%
Applied egg-rr51.8%
distribute-rgt-out51.8%
metadata-eval51.8%
Simplified51.8%
Taylor expanded in x around 0 51.3%
exp-1-e51.3%
Simplified51.3%
if 500 < 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%
add-exp-log0.0%
div-exp0.0%
Applied egg-rr0.0%
Taylor expanded in x around inf 100.0%
neg-mul-1100.0%
Simplified100.0%
(FPCore (x) :precision binary64 (if (or (<= x -5e-310) (not (<= x 0.05))) (exp (- x)) (/ (fmod (exp x) (+ 1.0 (* -0.25 (pow x 2.0)))) (exp x))))
double code(double x) {
double tmp;
if ((x <= -5e-310) || !(x <= 0.05)) {
tmp = exp(-x);
} else {
tmp = fmod(exp(x), (1.0 + (-0.25 * pow(x, 2.0)))) / exp(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-5d-310)) .or. (.not. (x <= 0.05d0))) then
tmp = exp(-x)
else
tmp = mod(exp(x), (1.0d0 + ((-0.25d0) * (x ** 2.0d0)))) / exp(x)
end if
code = tmp
end function
def code(x): tmp = 0 if (x <= -5e-310) or not (x <= 0.05): tmp = math.exp(-x) else: tmp = math.fmod(math.exp(x), (1.0 + (-0.25 * math.pow(x, 2.0)))) / math.exp(x) return tmp
function code(x) tmp = 0.0 if ((x <= -5e-310) || !(x <= 0.05)) tmp = exp(Float64(-x)); else tmp = Float64(rem(exp(x), Float64(1.0 + Float64(-0.25 * (x ^ 2.0)))) / exp(x)); end return tmp end
code[x_] := If[Or[LessEqual[x, -5e-310], N[Not[LessEqual[x, 0.05]], $MachinePrecision]], N[Exp[(-x)], $MachinePrecision], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(1.0 + N[(-0.25 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-310} \lor \neg \left(x \leq 0.05\right):\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(1 + -0.25 \cdot {x}^{2}\right)\right)}{e^{x}}\\
\end{array}
\end{array}
if x < -4.999999999999985e-310 or 0.050000000000000003 < x Initial program 6.4%
/-rgt-identity6.4%
associate-/r/6.4%
exp-neg6.4%
remove-double-neg6.4%
Simplified6.4%
Taylor expanded in x around 0 6.4%
add-exp-log6.4%
div-exp6.4%
Applied egg-rr6.4%
Taylor expanded in x around inf 97.9%
neg-mul-197.9%
Simplified97.9%
if -4.999999999999985e-310 < x < 0.050000000000000003Initial program 10.4%
/-rgt-identity10.4%
associate-/r/10.4%
exp-neg10.4%
remove-double-neg10.4%
Simplified10.4%
Taylor expanded in x around 0 10.0%
Final simplification61.9%
(FPCore (x) :precision binary64 (if (or (<= x -5e-310) (not (<= x 0.05))) (exp (- x)) (* (fmod (exp x) (sqrt (cos x))) (- 1.0 x))))
double code(double x) {
double tmp;
if ((x <= -5e-310) || !(x <= 0.05)) {
tmp = exp(-x);
} else {
tmp = fmod(exp(x), sqrt(cos(x))) * (1.0 - x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-5d-310)) .or. (.not. (x <= 0.05d0))) then
tmp = exp(-x)
else
tmp = mod(exp(x), sqrt(cos(x))) * (1.0d0 - x)
end if
code = tmp
end function
def code(x): tmp = 0 if (x <= -5e-310) or not (x <= 0.05): tmp = math.exp(-x) else: tmp = math.fmod(math.exp(x), math.sqrt(math.cos(x))) * (1.0 - x) return tmp
function code(x) tmp = 0.0 if ((x <= -5e-310) || !(x <= 0.05)) tmp = exp(Float64(-x)); else tmp = Float64(rem(exp(x), sqrt(cos(x))) * Float64(1.0 - x)); end return tmp end
code[x_] := If[Or[LessEqual[x, -5e-310], N[Not[LessEqual[x, 0.05]], $MachinePrecision]], N[Exp[(-x)], $MachinePrecision], 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[(1.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-310} \lor \neg \left(x \leq 0.05\right):\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \left(1 - x\right)\\
\end{array}
\end{array}
if x < -4.999999999999985e-310 or 0.050000000000000003 < x Initial program 6.4%
/-rgt-identity6.4%
associate-/r/6.4%
exp-neg6.4%
remove-double-neg6.4%
Simplified6.4%
Taylor expanded in x around 0 6.4%
add-exp-log6.4%
div-exp6.4%
Applied egg-rr6.4%
Taylor expanded in x around inf 97.9%
neg-mul-197.9%
Simplified97.9%
if -4.999999999999985e-310 < x < 0.050000000000000003Initial program 10.4%
/-rgt-identity10.4%
associate-/r/10.4%
exp-neg10.4%
remove-double-neg10.4%
Simplified10.4%
Taylor expanded in x around 0 9.7%
+-commutative9.7%
mul-1-neg9.7%
unsub-neg9.7%
*-lft-identity9.7%
distribute-rgt-out--9.7%
Simplified9.7%
Final simplification61.7%
(FPCore (x) :precision binary64 (if (or (<= x -5e-310) (not (<= x 0.05))) (exp (- x)) (* (fmod (exp x) (+ 1.0 (* -0.25 (pow x 2.0)))) (- 1.0 x))))
double code(double x) {
double tmp;
if ((x <= -5e-310) || !(x <= 0.05)) {
tmp = exp(-x);
} else {
tmp = fmod(exp(x), (1.0 + (-0.25 * pow(x, 2.0)))) * (1.0 - x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-5d-310)) .or. (.not. (x <= 0.05d0))) then
tmp = exp(-x)
else
tmp = mod(exp(x), (1.0d0 + ((-0.25d0) * (x ** 2.0d0)))) * (1.0d0 - x)
end if
code = tmp
end function
def code(x): tmp = 0 if (x <= -5e-310) or not (x <= 0.05): tmp = math.exp(-x) else: tmp = math.fmod(math.exp(x), (1.0 + (-0.25 * math.pow(x, 2.0)))) * (1.0 - x) return tmp
function code(x) tmp = 0.0 if ((x <= -5e-310) || !(x <= 0.05)) tmp = exp(Float64(-x)); else tmp = Float64(rem(exp(x), Float64(1.0 + Float64(-0.25 * (x ^ 2.0)))) * Float64(1.0 - x)); end return tmp end
code[x_] := If[Or[LessEqual[x, -5e-310], N[Not[LessEqual[x, 0.05]], $MachinePrecision]], N[Exp[(-x)], $MachinePrecision], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(1.0 + N[(-0.25 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-310} \lor \neg \left(x \leq 0.05\right):\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(e^{x}\right) \bmod \left(1 + -0.25 \cdot {x}^{2}\right)\right) \cdot \left(1 - x\right)\\
\end{array}
\end{array}
if x < -4.999999999999985e-310 or 0.050000000000000003 < x Initial program 6.4%
/-rgt-identity6.4%
associate-/r/6.4%
exp-neg6.4%
remove-double-neg6.4%
Simplified6.4%
Taylor expanded in x around 0 6.4%
add-exp-log6.4%
div-exp6.4%
Applied egg-rr6.4%
Taylor expanded in x around inf 97.9%
neg-mul-197.9%
Simplified97.9%
if -4.999999999999985e-310 < x < 0.050000000000000003Initial program 10.4%
/-rgt-identity10.4%
associate-/r/10.4%
exp-neg10.4%
remove-double-neg10.4%
Simplified10.4%
Taylor expanded in x around 0 9.7%
+-commutative9.7%
mul-1-neg9.7%
unsub-neg9.7%
*-lft-identity9.7%
distribute-rgt-out--9.7%
Simplified9.7%
Taylor expanded in x around 0 9.7%
Final simplification61.7%
(FPCore (x) :precision binary64 (if (or (<= x -5e-310) (not (<= x 0.05))) (exp (- x)) (/ 1.0 (/ (exp x) (fmod (exp x) 1.0)))))
double code(double x) {
double tmp;
if ((x <= -5e-310) || !(x <= 0.05)) {
tmp = exp(-x);
} else {
tmp = 1.0 / (exp(x) / fmod(exp(x), 1.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-5d-310)) .or. (.not. (x <= 0.05d0))) then
tmp = exp(-x)
else
tmp = 1.0d0 / (exp(x) / mod(exp(x), 1.0d0))
end if
code = tmp
end function
def code(x): tmp = 0 if (x <= -5e-310) or not (x <= 0.05): tmp = math.exp(-x) else: tmp = 1.0 / (math.exp(x) / math.fmod(math.exp(x), 1.0)) return tmp
function code(x) tmp = 0.0 if ((x <= -5e-310) || !(x <= 0.05)) tmp = exp(Float64(-x)); else tmp = Float64(1.0 / Float64(exp(x) / rem(exp(x), 1.0))); end return tmp end
code[x_] := If[Or[LessEqual[x, -5e-310], N[Not[LessEqual[x, 0.05]], $MachinePrecision]], N[Exp[(-x)], $MachinePrecision], N[(1.0 / N[(N[Exp[x], $MachinePrecision] / N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-310} \lor \neg \left(x \leq 0.05\right):\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{e^{x}}{\left(\left(e^{x}\right) \bmod 1\right)}}\\
\end{array}
\end{array}
if x < -4.999999999999985e-310 or 0.050000000000000003 < x Initial program 6.4%
/-rgt-identity6.4%
associate-/r/6.4%
exp-neg6.4%
remove-double-neg6.4%
Simplified6.4%
Taylor expanded in x around 0 6.4%
add-exp-log6.4%
div-exp6.4%
Applied egg-rr6.4%
Taylor expanded in x around inf 97.9%
neg-mul-197.9%
Simplified97.9%
if -4.999999999999985e-310 < x < 0.050000000000000003Initial program 10.4%
/-rgt-identity10.4%
associate-/r/10.4%
exp-neg10.4%
remove-double-neg10.4%
Simplified10.4%
Taylor expanded in x around 0 9.4%
add-exp-log9.4%
div-exp9.4%
Applied egg-rr9.4%
exp-diff9.4%
add-exp-log9.4%
clear-num9.4%
Applied egg-rr9.4%
Final simplification61.6%
(FPCore (x) :precision binary64 (if (or (<= x -5e-310) (not (<= x 0.05))) (exp (- x)) (/ (fmod (exp x) 1.0) (exp x))))
double code(double x) {
double tmp;
if ((x <= -5e-310) || !(x <= 0.05)) {
tmp = exp(-x);
} else {
tmp = fmod(exp(x), 1.0) / exp(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-5d-310)) .or. (.not. (x <= 0.05d0))) then
tmp = exp(-x)
else
tmp = mod(exp(x), 1.0d0) / exp(x)
end if
code = tmp
end function
def code(x): tmp = 0 if (x <= -5e-310) or not (x <= 0.05): tmp = math.exp(-x) else: tmp = math.fmod(math.exp(x), 1.0) / math.exp(x) return tmp
function code(x) tmp = 0.0 if ((x <= -5e-310) || !(x <= 0.05)) tmp = exp(Float64(-x)); else tmp = Float64(rem(exp(x), 1.0) / exp(x)); end return tmp end
code[x_] := If[Or[LessEqual[x, -5e-310], N[Not[LessEqual[x, 0.05]], $MachinePrecision]], N[Exp[(-x)], $MachinePrecision], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], 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} \lor \neg \left(x \leq 0.05\right):\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod 1\right)}{e^{x}}\\
\end{array}
\end{array}
if x < -4.999999999999985e-310 or 0.050000000000000003 < x Initial program 6.4%
/-rgt-identity6.4%
associate-/r/6.4%
exp-neg6.4%
remove-double-neg6.4%
Simplified6.4%
Taylor expanded in x around 0 6.4%
add-exp-log6.4%
div-exp6.4%
Applied egg-rr6.4%
Taylor expanded in x around inf 97.9%
neg-mul-197.9%
Simplified97.9%
if -4.999999999999985e-310 < x < 0.050000000000000003Initial program 10.4%
/-rgt-identity10.4%
associate-/r/10.4%
exp-neg10.4%
remove-double-neg10.4%
Simplified10.4%
Taylor expanded in x around 0 9.4%
Final simplification61.6%
(FPCore (x) :precision binary64 (if (or (<= x -5e-310) (not (<= x 0.05))) (exp (- x)) (* (- 1.0 x) (fmod (exp x) 1.0))))
double code(double x) {
double tmp;
if ((x <= -5e-310) || !(x <= 0.05)) {
tmp = exp(-x);
} else {
tmp = (1.0 - x) * fmod(exp(x), 1.0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-5d-310)) .or. (.not. (x <= 0.05d0))) then
tmp = exp(-x)
else
tmp = (1.0d0 - x) * mod(exp(x), 1.0d0)
end if
code = tmp
end function
def code(x): tmp = 0 if (x <= -5e-310) or not (x <= 0.05): tmp = math.exp(-x) else: tmp = (1.0 - x) * math.fmod(math.exp(x), 1.0) return tmp
function code(x) tmp = 0.0 if ((x <= -5e-310) || !(x <= 0.05)) tmp = exp(Float64(-x)); else tmp = Float64(Float64(1.0 - x) * rem(exp(x), 1.0)); end return tmp end
code[x_] := If[Or[LessEqual[x, -5e-310], N[Not[LessEqual[x, 0.05]], $MachinePrecision]], N[Exp[(-x)], $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] * N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-310} \lor \neg \left(x \leq 0.05\right):\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\left(1 - x\right) \cdot \left(\left(e^{x}\right) \bmod 1\right)\\
\end{array}
\end{array}
if x < -4.999999999999985e-310 or 0.050000000000000003 < x Initial program 6.4%
/-rgt-identity6.4%
associate-/r/6.4%
exp-neg6.4%
remove-double-neg6.4%
Simplified6.4%
Taylor expanded in x around 0 6.4%
add-exp-log6.4%
div-exp6.4%
Applied egg-rr6.4%
Taylor expanded in x around inf 97.9%
neg-mul-197.9%
Simplified97.9%
if -4.999999999999985e-310 < x < 0.050000000000000003Initial program 10.4%
/-rgt-identity10.4%
associate-/r/10.4%
exp-neg10.4%
remove-double-neg10.4%
Simplified10.4%
Taylor expanded in x around 0 9.7%
+-commutative9.7%
mul-1-neg9.7%
unsub-neg9.7%
*-lft-identity9.7%
distribute-rgt-out--9.7%
Simplified9.7%
Taylor expanded in x around 0 9.4%
Final simplification61.6%
(FPCore (x) :precision binary64 (if (or (<= x -5e-310) (not (<= x 0.05))) (exp (- x)) (fmod (exp x) 1.0)))
double code(double x) {
double tmp;
if ((x <= -5e-310) || !(x <= 0.05)) {
tmp = exp(-x);
} else {
tmp = fmod(exp(x), 1.0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-5d-310)) .or. (.not. (x <= 0.05d0))) then
tmp = exp(-x)
else
tmp = mod(exp(x), 1.0d0)
end if
code = tmp
end function
def code(x): tmp = 0 if (x <= -5e-310) or not (x <= 0.05): tmp = math.exp(-x) else: tmp = math.fmod(math.exp(x), 1.0) return tmp
function code(x) tmp = 0.0 if ((x <= -5e-310) || !(x <= 0.05)) tmp = exp(Float64(-x)); else tmp = rem(exp(x), 1.0); end return tmp end
code[x_] := If[Or[LessEqual[x, -5e-310], N[Not[LessEqual[x, 0.05]], $MachinePrecision]], N[Exp[(-x)], $MachinePrecision], N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-310} \lor \neg \left(x \leq 0.05\right):\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(e^{x}\right) \bmod 1\right)\\
\end{array}
\end{array}
if x < -4.999999999999985e-310 or 0.050000000000000003 < x Initial program 6.4%
/-rgt-identity6.4%
associate-/r/6.4%
exp-neg6.4%
remove-double-neg6.4%
Simplified6.4%
Taylor expanded in x around 0 6.4%
add-exp-log6.4%
div-exp6.4%
Applied egg-rr6.4%
Taylor expanded in x around inf 97.9%
neg-mul-197.9%
Simplified97.9%
if -4.999999999999985e-310 < x < 0.050000000000000003Initial program 10.4%
/-rgt-identity10.4%
associate-/r/10.4%
exp-neg10.4%
remove-double-neg10.4%
Simplified10.4%
Taylor expanded in x around 0 9.4%
Taylor expanded in x around 0 9.4%
Final simplification61.6%
(FPCore (x) :precision binary64 (exp (- x)))
double code(double x) {
return exp(-x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = exp(-x)
end function
public static double code(double x) {
return Math.exp(-x);
}
def code(x): return math.exp(-x)
function code(x) return exp(Float64(-x)) end
function tmp = code(x) tmp = exp(-x); end
code[x_] := N[Exp[(-x)], $MachinePrecision]
\begin{array}{l}
\\
e^{-x}
\end{array}
Initial program 8.0%
/-rgt-identity8.0%
associate-/r/8.0%
exp-neg8.1%
remove-double-neg8.1%
Simplified8.1%
Taylor expanded in x around 0 7.7%
add-exp-log7.7%
div-exp7.7%
Applied egg-rr7.7%
Taylor expanded in x around inf 60.0%
neg-mul-160.0%
Simplified60.0%
herbie shell --seed 2024106
(FPCore (x)
:name "expfmod (used to be hard to sample)"
:precision binary64
(* (fmod (exp x) (sqrt (cos x))) (exp (- x))))