
(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 (fmod (exp x) (sqrt (cos x))))
(t_1 (+ 1.0 (/ t_0 (exp x))))
(t_2 (exp (- x)))
(t_3 (* t_0 t_2)))
(if (or (<= t_3 0.0) (not (<= t_3 2.0)))
t_2
(/ (+ (pow t_1 2.0) -1.0) (- t_1 -1.0)))))
double code(double x) {
double t_0 = fmod(exp(x), sqrt(cos(x)));
double t_1 = 1.0 + (t_0 / exp(x));
double t_2 = exp(-x);
double t_3 = t_0 * t_2;
double tmp;
if ((t_3 <= 0.0) || !(t_3 <= 2.0)) {
tmp = t_2;
} else {
tmp = (pow(t_1, 2.0) + -1.0) / (t_1 - -1.0);
}
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) :: t_3
real(8) :: tmp
t_0 = mod(exp(x), sqrt(cos(x)))
t_1 = 1.0d0 + (t_0 / exp(x))
t_2 = exp(-x)
t_3 = t_0 * t_2
if ((t_3 <= 0.0d0) .or. (.not. (t_3 <= 2.0d0))) then
tmp = t_2
else
tmp = ((t_1 ** 2.0d0) + (-1.0d0)) / (t_1 - (-1.0d0))
end if
code = tmp
end function
def code(x): t_0 = math.fmod(math.exp(x), math.sqrt(math.cos(x))) t_1 = 1.0 + (t_0 / math.exp(x)) t_2 = math.exp(-x) t_3 = t_0 * t_2 tmp = 0 if (t_3 <= 0.0) or not (t_3 <= 2.0): tmp = t_2 else: tmp = (math.pow(t_1, 2.0) + -1.0) / (t_1 - -1.0) return tmp
function code(x) t_0 = rem(exp(x), sqrt(cos(x))) t_1 = Float64(1.0 + Float64(t_0 / exp(x))) t_2 = exp(Float64(-x)) t_3 = Float64(t_0 * t_2) tmp = 0.0 if ((t_3 <= 0.0) || !(t_3 <= 2.0)) tmp = t_2; else tmp = Float64(Float64((t_1 ^ 2.0) + -1.0) / Float64(t_1 - -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]}, Block[{t$95$1 = N[(1.0 + N[(t$95$0 / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Exp[(-x)], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 * t$95$2), $MachinePrecision]}, If[Or[LessEqual[t$95$3, 0.0], N[Not[LessEqual[t$95$3, 2.0]], $MachinePrecision]], t$95$2, N[(N[(N[Power[t$95$1, 2.0], $MachinePrecision] + -1.0), $MachinePrecision] / N[(t$95$1 - -1.0), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
t_1 := 1 + \frac{t_0}{e^{x}}\\
t_2 := e^{-x}\\
t_3 := t_0 \cdot t_2\\
\mathbf{if}\;t_3 \leq 0 \lor \neg \left(t_3 \leq 2\right):\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\frac{{t_1}^{2} + -1}{t_1 - -1}\\
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (exp (- x)))
(t_1 (fmod (exp x) (sqrt (cos x))))
(t_2 (* t_1 t_0))
(t_3 (/ t_1 (exp x))))
(if (or (<= t_2 0.0) (not (<= t_2 2.0)))
t_0
(/ (- 1.0 (pow (+ 1.0 t_3) 2.0)) (- -2.0 t_3)))))
double code(double x) {
double t_0 = exp(-x);
double t_1 = fmod(exp(x), sqrt(cos(x)));
double t_2 = t_1 * t_0;
double t_3 = t_1 / exp(x);
double tmp;
if ((t_2 <= 0.0) || !(t_2 <= 2.0)) {
tmp = t_0;
} else {
tmp = (1.0 - pow((1.0 + t_3), 2.0)) / (-2.0 - t_3);
}
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) :: t_3
real(8) :: tmp
t_0 = exp(-x)
t_1 = mod(exp(x), sqrt(cos(x)))
t_2 = t_1 * t_0
t_3 = t_1 / exp(x)
if ((t_2 <= 0.0d0) .or. (.not. (t_2 <= 2.0d0))) then
tmp = t_0
else
tmp = (1.0d0 - ((1.0d0 + t_3) ** 2.0d0)) / ((-2.0d0) - t_3)
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_1 * t_0 t_3 = t_1 / math.exp(x) tmp = 0 if (t_2 <= 0.0) or not (t_2 <= 2.0): tmp = t_0 else: tmp = (1.0 - math.pow((1.0 + t_3), 2.0)) / (-2.0 - t_3) return tmp
function code(x) t_0 = exp(Float64(-x)) t_1 = rem(exp(x), sqrt(cos(x))) t_2 = Float64(t_1 * t_0) t_3 = Float64(t_1 / exp(x)) tmp = 0.0 if ((t_2 <= 0.0) || !(t_2 <= 2.0)) tmp = t_0; else tmp = Float64(Float64(1.0 - (Float64(1.0 + t_3) ^ 2.0)) / Float64(-2.0 - t_3)); 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$1 * t$95$0), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 / N[Exp[x], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$2, 0.0], N[Not[LessEqual[t$95$2, 2.0]], $MachinePrecision]], t$95$0, N[(N[(1.0 - N[Power[N[(1.0 + t$95$3), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(-2.0 - t$95$3), $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_1 \cdot t_0\\
t_3 := \frac{t_1}{e^{x}}\\
\mathbf{if}\;t_2 \leq 0 \lor \neg \left(t_2 \leq 2\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - {\left(1 + t_3\right)}^{2}}{-2 - t_3}\\
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (fmod (exp x) (sqrt (cos x))))
(t_1 (exp (- x)))
(t_2 (* t_0 t_1)))
(if (or (<= t_2 0.0) (not (<= t_2 2.0)))
t_1
(pow (exp 0.3333333333333333) (* (- (log (log (exp t_0))) x) 3.0)))))
double code(double x) {
double t_0 = fmod(exp(x), sqrt(cos(x)));
double t_1 = exp(-x);
double t_2 = t_0 * t_1;
double tmp;
if ((t_2 <= 0.0) || !(t_2 <= 2.0)) {
tmp = t_1;
} else {
tmp = pow(exp(0.3333333333333333), ((log(log(exp(t_0))) - x) * 3.0));
}
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 = mod(exp(x), sqrt(cos(x)))
t_1 = exp(-x)
t_2 = t_0 * t_1
if ((t_2 <= 0.0d0) .or. (.not. (t_2 <= 2.0d0))) then
tmp = t_1
else
tmp = exp(0.3333333333333333d0) ** ((log(log(exp(t_0))) - x) * 3.0d0)
end if
code = tmp
end function
def code(x): t_0 = math.fmod(math.exp(x), math.sqrt(math.cos(x))) t_1 = math.exp(-x) t_2 = t_0 * t_1 tmp = 0 if (t_2 <= 0.0) or not (t_2 <= 2.0): tmp = t_1 else: tmp = math.pow(math.exp(0.3333333333333333), ((math.log(math.log(math.exp(t_0))) - x) * 3.0)) return tmp
function code(x) t_0 = rem(exp(x), sqrt(cos(x))) t_1 = exp(Float64(-x)) t_2 = Float64(t_0 * t_1) tmp = 0.0 if ((t_2 <= 0.0) || !(t_2 <= 2.0)) tmp = t_1; else tmp = exp(0.3333333333333333) ^ Float64(Float64(log(log(exp(t_0))) - x) * 3.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]}, Block[{t$95$1 = N[Exp[(-x)], $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$1, N[Power[N[Exp[0.3333333333333333], $MachinePrecision], N[(N[(N[Log[N[Log[N[Exp[t$95$0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision] - x), $MachinePrecision] * 3.0), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
t_1 := e^{-x}\\
t_2 := t_0 \cdot t_1\\
\mathbf{if}\;t_2 \leq 0 \lor \neg \left(t_2 \leq 2\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;{\left(e^{0.3333333333333333}\right)}^{\left(\left(\log \log \left(e^{t_0}\right) - x\right) \cdot 3\right)}\\
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (fmod (exp x) (sqrt (cos x))))
(t_1 (exp (- x)))
(t_2 (* t_0 t_1)))
(if (or (<= t_2 0.0) (not (<= t_2 2.0))) t_1 (/ (log (exp t_0)) (exp x)))))
double code(double x) {
double t_0 = fmod(exp(x), sqrt(cos(x)));
double t_1 = exp(-x);
double t_2 = t_0 * t_1;
double tmp;
if ((t_2 <= 0.0) || !(t_2 <= 2.0)) {
tmp = t_1;
} else {
tmp = log(exp(t_0)) / 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 = mod(exp(x), sqrt(cos(x)))
t_1 = exp(-x)
t_2 = t_0 * t_1
if ((t_2 <= 0.0d0) .or. (.not. (t_2 <= 2.0d0))) then
tmp = t_1
else
tmp = log(exp(t_0)) / exp(x)
end if
code = tmp
end function
def code(x): t_0 = math.fmod(math.exp(x), math.sqrt(math.cos(x))) t_1 = math.exp(-x) t_2 = t_0 * t_1 tmp = 0 if (t_2 <= 0.0) or not (t_2 <= 2.0): tmp = t_1 else: tmp = math.log(math.exp(t_0)) / math.exp(x) return tmp
function code(x) t_0 = rem(exp(x), sqrt(cos(x))) t_1 = exp(Float64(-x)) t_2 = Float64(t_0 * t_1) tmp = 0.0 if ((t_2 <= 0.0) || !(t_2 <= 2.0)) tmp = t_1; else tmp = Float64(log(exp(t_0)) / exp(x)); 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]}, Block[{t$95$1 = N[Exp[(-x)], $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$1, N[(N[Log[N[Exp[t$95$0], $MachinePrecision]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
t_1 := e^{-x}\\
t_2 := t_0 \cdot t_1\\
\mathbf{if}\;t_2 \leq 0 \lor \neg \left(t_2 \leq 2\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(e^{t_0}\right)}{e^{x}}\\
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (fmod (exp x) (sqrt (cos x))))
(t_1 (exp (- x)))
(t_2 (* t_0 t_1)))
(if (or (<= t_2 0.0) (not (<= t_2 2.0)))
t_1
(+ (+ 1.0 (/ t_0 (exp x))) -1.0))))
double code(double x) {
double t_0 = fmod(exp(x), sqrt(cos(x)));
double t_1 = exp(-x);
double t_2 = t_0 * t_1;
double tmp;
if ((t_2 <= 0.0) || !(t_2 <= 2.0)) {
tmp = t_1;
} else {
tmp = (1.0 + (t_0 / exp(x))) + -1.0;
}
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 = mod(exp(x), sqrt(cos(x)))
t_1 = exp(-x)
t_2 = t_0 * t_1
if ((t_2 <= 0.0d0) .or. (.not. (t_2 <= 2.0d0))) then
tmp = t_1
else
tmp = (1.0d0 + (t_0 / exp(x))) + (-1.0d0)
end if
code = tmp
end function
def code(x): t_0 = math.fmod(math.exp(x), math.sqrt(math.cos(x))) t_1 = math.exp(-x) t_2 = t_0 * t_1 tmp = 0 if (t_2 <= 0.0) or not (t_2 <= 2.0): tmp = t_1 else: tmp = (1.0 + (t_0 / math.exp(x))) + -1.0 return tmp
function code(x) t_0 = rem(exp(x), sqrt(cos(x))) t_1 = exp(Float64(-x)) t_2 = Float64(t_0 * t_1) tmp = 0.0 if ((t_2 <= 0.0) || !(t_2 <= 2.0)) tmp = t_1; else tmp = Float64(Float64(1.0 + Float64(t_0 / exp(x))) + -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]}, Block[{t$95$1 = N[Exp[(-x)], $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$1, N[(N[(1.0 + N[(t$95$0 / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
t_1 := e^{-x}\\
t_2 := t_0 \cdot t_1\\
\mathbf{if}\;t_2 \leq 0 \lor \neg \left(t_2 \leq 2\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{t_0}{e^{x}}\right) + -1\\
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (fmod (exp x) (sqrt (cos x))))
(t_1 (exp (- x)))
(t_2 (* t_0 t_1)))
(if (or (<= t_2 0.0) (not (<= t_2 2.0))) t_1 (/ 1.0 (/ (exp x) t_0)))))
double code(double x) {
double t_0 = fmod(exp(x), sqrt(cos(x)));
double t_1 = exp(-x);
double t_2 = t_0 * t_1;
double tmp;
if ((t_2 <= 0.0) || !(t_2 <= 2.0)) {
tmp = t_1;
} else {
tmp = 1.0 / (exp(x) / t_0);
}
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 = mod(exp(x), sqrt(cos(x)))
t_1 = exp(-x)
t_2 = t_0 * t_1
if ((t_2 <= 0.0d0) .or. (.not. (t_2 <= 2.0d0))) then
tmp = t_1
else
tmp = 1.0d0 / (exp(x) / t_0)
end if
code = tmp
end function
def code(x): t_0 = math.fmod(math.exp(x), math.sqrt(math.cos(x))) t_1 = math.exp(-x) t_2 = t_0 * t_1 tmp = 0 if (t_2 <= 0.0) or not (t_2 <= 2.0): tmp = t_1 else: tmp = 1.0 / (math.exp(x) / t_0) return tmp
function code(x) t_0 = rem(exp(x), sqrt(cos(x))) t_1 = exp(Float64(-x)) t_2 = Float64(t_0 * t_1) tmp = 0.0 if ((t_2 <= 0.0) || !(t_2 <= 2.0)) tmp = t_1; else tmp = Float64(1.0 / Float64(exp(x) / t_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]}, Block[{t$95$1 = N[Exp[(-x)], $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$1, N[(1.0 / N[(N[Exp[x], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
t_1 := e^{-x}\\
t_2 := t_0 \cdot t_1\\
\mathbf{if}\;t_2 \leq 0 \lor \neg \left(t_2 \leq 2\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{e^{x}}{t_0}}\\
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (fmod (exp x) (sqrt (cos x))))
(t_1 (exp (- x)))
(t_2 (* t_0 t_1)))
(if (or (<= t_2 0.0) (not (<= t_2 2.0))) t_1 (/ t_0 (exp x)))))
double code(double x) {
double t_0 = fmod(exp(x), sqrt(cos(x)));
double t_1 = exp(-x);
double t_2 = t_0 * t_1;
double tmp;
if ((t_2 <= 0.0) || !(t_2 <= 2.0)) {
tmp = t_1;
} else {
tmp = t_0 / 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 = mod(exp(x), sqrt(cos(x)))
t_1 = exp(-x)
t_2 = t_0 * t_1
if ((t_2 <= 0.0d0) .or. (.not. (t_2 <= 2.0d0))) then
tmp = t_1
else
tmp = t_0 / exp(x)
end if
code = tmp
end function
def code(x): t_0 = math.fmod(math.exp(x), math.sqrt(math.cos(x))) t_1 = math.exp(-x) t_2 = t_0 * t_1 tmp = 0 if (t_2 <= 0.0) or not (t_2 <= 2.0): tmp = t_1 else: tmp = t_0 / math.exp(x) return tmp
function code(x) t_0 = rem(exp(x), sqrt(cos(x))) t_1 = exp(Float64(-x)) t_2 = Float64(t_0 * t_1) tmp = 0.0 if ((t_2 <= 0.0) || !(t_2 <= 2.0)) tmp = t_1; else tmp = Float64(t_0 / exp(x)); 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]}, Block[{t$95$1 = N[Exp[(-x)], $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$1, N[(t$95$0 / N[Exp[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
t_1 := e^{-x}\\
t_2 := t_0 \cdot t_1\\
\mathbf{if}\;t_2 \leq 0 \lor \neg \left(t_2 \leq 2\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{e^{x}}\\
\end{array}
\end{array}
(FPCore (x) :precision binary64 (exp (* 3.0 (log (+ 1.0 (expm1 (* x -0.3333333333333333)))))))
double code(double x) {
return exp((3.0 * log((1.0 + expm1((x * -0.3333333333333333))))));
}
public static double code(double x) {
return Math.exp((3.0 * Math.log((1.0 + Math.expm1((x * -0.3333333333333333))))));
}
def code(x): return math.exp((3.0 * math.log((1.0 + math.expm1((x * -0.3333333333333333))))))
function code(x) return exp(Float64(3.0 * log(Float64(1.0 + expm1(Float64(x * -0.3333333333333333)))))) end
code[x_] := N[Exp[N[(3.0 * N[Log[N[(1.0 + N[(Exp[N[(x * -0.3333333333333333), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{3 \cdot \log \left(1 + \mathsf{expm1}\left(x \cdot -0.3333333333333333\right)\right)}
\end{array}
(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}
herbie shell --seed 2023343
(FPCore (x)
:name "expfmod (used to be hard to sample)"
:precision binary64
(* (fmod (exp x) (sqrt (cos x))) (exp (- x))))