
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
Initial program 85.8%
(FPCore (J l K U) :precision binary64 (let* ((t_0 (* J (- (exp l) (exp (- l))))) (t_1 (* t_0 (cos (/ K 2.0))))) (if (<= t_1 -2e+262) t_1 (if (<= t_1 1e+127) (+ t_0 U) t_1))))
double code(double J, double l, double K, double U) {
double t_0 = J * (exp(l) - exp(-l));
double t_1 = t_0 * cos((K / 2.0));
double tmp;
if (t_1 <= -2e+262) {
tmp = t_1;
} else if (t_1 <= 1e+127) {
tmp = t_0 + U;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = j * (exp(l) - exp(-l))
t_1 = t_0 * cos((k / 2.0d0))
if (t_1 <= (-2d+262)) then
tmp = t_1
else if (t_1 <= 1d+127) then
tmp = t_0 + u
else
tmp = t_1
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = J * (Math.exp(l) - Math.exp(-l));
double t_1 = t_0 * Math.cos((K / 2.0));
double tmp;
if (t_1 <= -2e+262) {
tmp = t_1;
} else if (t_1 <= 1e+127) {
tmp = t_0 + U;
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = J * (math.exp(l) - math.exp(-l)) t_1 = t_0 * math.cos((K / 2.0)) tmp = 0 if t_1 <= -2e+262: tmp = t_1 elif t_1 <= 1e+127: tmp = t_0 + U else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = Float64(J * Float64(exp(l) - exp(Float64(-l)))) t_1 = Float64(t_0 * cos(Float64(K / 2.0))) tmp = 0.0 if (t_1 <= -2e+262) tmp = t_1; elseif (t_1 <= 1e+127) tmp = Float64(t_0 + U); else tmp = t_1; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = J * (exp(l) - exp(-l)); t_1 = t_0 * cos((K / 2.0)); tmp = 0.0; if (t_1 <= -2e+262) tmp = t_1; elseif (t_1 <= 1e+127) tmp = t_0 + U; else tmp = t_1; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+262], t$95$1, If[LessEqual[t$95$1, 1e+127], N[(t$95$0 + U), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
t_1 := t\_0 \cdot \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+262}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_1 \leq 10^{+127}:\\
\;\;\;\;t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) < -2e262 or 9.99999999999999955e126 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) Initial program 99.2%
Taylor expanded in J around 0
Applied rewrites99.2%
if -2e262 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) < 9.99999999999999955e126Initial program 72.6%
Taylor expanded in J around 0
Applied rewrites72.2%
(FPCore (J l K U) :precision binary64 (let* ((t_0 (- (exp l) (exp (- l)))) (t_1 (* J t_0))) (if (<= t_0 -0.002) t_1 (if (<= t_0 0.004) (+ t_0 U) t_1))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double t_1 = J * t_0;
double tmp;
if (t_0 <= -0.002) {
tmp = t_1;
} else if (t_0 <= 0.004) {
tmp = t_0 + U;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = exp(l) - exp(-l)
t_1 = j * t_0
if (t_0 <= (-0.002d0)) then
tmp = t_1
else if (t_0 <= 0.004d0) then
tmp = t_0 + u
else
tmp = t_1
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.exp(l) - Math.exp(-l);
double t_1 = J * t_0;
double tmp;
if (t_0 <= -0.002) {
tmp = t_1;
} else if (t_0 <= 0.004) {
tmp = t_0 + U;
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) t_1 = J * t_0 tmp = 0 if t_0 <= -0.002: tmp = t_1 elif t_0 <= 0.004: tmp = t_0 + U else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) t_1 = Float64(J * t_0) tmp = 0.0 if (t_0 <= -0.002) tmp = t_1; elseif (t_0 <= 0.004) tmp = Float64(t_0 + U); else tmp = t_1; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); t_1 = J * t_0; tmp = 0.0; if (t_0 <= -0.002) tmp = t_1; elseif (t_0 <= 0.004) tmp = t_0 + U; else tmp = t_1; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(J * t$95$0), $MachinePrecision]}, If[LessEqual[t$95$0, -0.002], t$95$1, If[LessEqual[t$95$0, 0.004], N[(t$95$0 + U), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
t_1 := J \cdot t\_0\\
\mathbf{if}\;t\_0 \leq -0.002:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0.004:\\
\;\;\;\;t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -2e-3 or 0.0040000000000000001 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 99.9%
Taylor expanded in J around 0
Applied rewrites76.3%
Taylor expanded in J around 0
Applied rewrites76.3%
if -2e-3 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0040000000000000001Initial program 71.8%
Taylor expanded in J around 0
Applied rewrites71.0%
Taylor expanded in J around 0
Applied rewrites70.8%
(FPCore (J l K U) :precision binary64 (if (<= (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U) 1e+307) (+ (- l) U) (exp l)))
double code(double J, double l, double K, double U) {
double tmp;
if ((((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U) <= 1e+307) {
tmp = -l + U;
} else {
tmp = exp(l);
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u) <= 1d+307) then
tmp = -l + u
else
tmp = exp(l)
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U) <= 1e+307) {
tmp = -l + U;
} else {
tmp = Math.exp(l);
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U) <= 1e+307: tmp = -l + U else: tmp = math.exp(l) return tmp
function code(J, l, K, U) tmp = 0.0 if (Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) <= 1e+307) tmp = Float64(Float64(-l) + U); else tmp = exp(l); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U) <= 1e+307) tmp = -l + U; else tmp = exp(l); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], 1e+307], N[((-l) + U), $MachinePrecision], N[Exp[l], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \leq 10^{+307}:\\
\;\;\;\;\left(-\ell\right) + U\\
\mathbf{else}:\\
\;\;\;\;e^{\ell}\\
\end{array}
\end{array}
if (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U) < 9.99999999999999986e306Initial program 81.3%
Taylor expanded in J around 0
Applied rewrites75.6%
Taylor expanded in J around 0
Applied rewrites63.8%
Taylor expanded in l around 0
Applied rewrites43.2%
if 9.99999999999999986e306 < (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U) Initial program 100.0%
Taylor expanded in J around -inf
Applied rewrites59.7%
(FPCore (J l K U) :precision binary64 (let* ((t_0 (- (exp l) (exp (- l))))) (if (<= (cos (/ K 2.0)) 0.02) (+ t_0 U) (+ (* J t_0) U))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double tmp;
if (cos((K / 2.0)) <= 0.02) {
tmp = t_0 + U;
} else {
tmp = (J * t_0) + U;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = exp(l) - exp(-l)
if (cos((k / 2.0d0)) <= 0.02d0) then
tmp = t_0 + u
else
tmp = (j * t_0) + u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.exp(l) - Math.exp(-l);
double tmp;
if (Math.cos((K / 2.0)) <= 0.02) {
tmp = t_0 + U;
} else {
tmp = (J * t_0) + U;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) tmp = 0 if math.cos((K / 2.0)) <= 0.02: tmp = t_0 + U else: tmp = (J * t_0) + U return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.02) tmp = Float64(t_0 + U); else tmp = Float64(Float64(J * t_0) + U); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); tmp = 0.0; if (cos((K / 2.0)) <= 0.02) tmp = t_0 + U; else tmp = (J * t_0) + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.02], N[(t$95$0 + U), $MachinePrecision], N[(N[(J * t$95$0), $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.02:\\
\;\;\;\;t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;J \cdot t\_0 + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.0200000000000000004Initial program 81.6%
Taylor expanded in J around 0
Applied rewrites32.5%
Taylor expanded in J around 0
Applied rewrites61.2%
if 0.0200000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 87.1%
Taylor expanded in J around 0
Applied rewrites87.0%
(FPCore (J l K U) :precision binary64 (let* ((t_0 (exp (- l)))) (if (<= J -2.1e+34) (+ t_0 U) (+ (- (exp l) t_0) U))))
double code(double J, double l, double K, double U) {
double t_0 = exp(-l);
double tmp;
if (J <= -2.1e+34) {
tmp = t_0 + U;
} else {
tmp = (exp(l) - t_0) + U;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = exp(-l)
if (j <= (-2.1d+34)) then
tmp = t_0 + u
else
tmp = (exp(l) - t_0) + u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.exp(-l);
double tmp;
if (J <= -2.1e+34) {
tmp = t_0 + U;
} else {
tmp = (Math.exp(l) - t_0) + U;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(-l) tmp = 0 if J <= -2.1e+34: tmp = t_0 + U else: tmp = (math.exp(l) - t_0) + U return tmp
function code(J, l, K, U) t_0 = exp(Float64(-l)) tmp = 0.0 if (J <= -2.1e+34) tmp = Float64(t_0 + U); else tmp = Float64(Float64(exp(l) - t_0) + U); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(-l); tmp = 0.0; if (J <= -2.1e+34) tmp = t_0 + U; else tmp = (exp(l) - t_0) + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Exp[(-l)], $MachinePrecision]}, If[LessEqual[J, -2.1e+34], N[(t$95$0 + U), $MachinePrecision], N[(N[(N[Exp[l], $MachinePrecision] - t$95$0), $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-\ell}\\
\mathbf{if}\;J \leq -2.1 \cdot 10^{+34}:\\
\;\;\;\;t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;\left(e^{\ell} - t\_0\right) + U\\
\end{array}
\end{array}
if J < -2.10000000000000017e34Initial program 68.9%
Taylor expanded in J around 0
Applied rewrites56.9%
Taylor expanded in l around 0
Applied rewrites38.6%
if -2.10000000000000017e34 < J Initial program 91.6%
Taylor expanded in J around 0
Applied rewrites79.4%
Taylor expanded in J around 0
Applied rewrites73.6%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (exp (- l))))
(if (<= l -1e+72)
(- (exp l) t_0)
(if (<= l -20000.0)
t_0
(if (<= l 4600000000000.0) (+ (- l) U) (+ (exp l) U))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(-l);
double tmp;
if (l <= -1e+72) {
tmp = exp(l) - t_0;
} else if (l <= -20000.0) {
tmp = t_0;
} else if (l <= 4600000000000.0) {
tmp = -l + U;
} else {
tmp = exp(l) + U;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = exp(-l)
if (l <= (-1d+72)) then
tmp = exp(l) - t_0
else if (l <= (-20000.0d0)) then
tmp = t_0
else if (l <= 4600000000000.0d0) then
tmp = -l + u
else
tmp = exp(l) + u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.exp(-l);
double tmp;
if (l <= -1e+72) {
tmp = Math.exp(l) - t_0;
} else if (l <= -20000.0) {
tmp = t_0;
} else if (l <= 4600000000000.0) {
tmp = -l + U;
} else {
tmp = Math.exp(l) + U;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(-l) tmp = 0 if l <= -1e+72: tmp = math.exp(l) - t_0 elif l <= -20000.0: tmp = t_0 elif l <= 4600000000000.0: tmp = -l + U else: tmp = math.exp(l) + U return tmp
function code(J, l, K, U) t_0 = exp(Float64(-l)) tmp = 0.0 if (l <= -1e+72) tmp = Float64(exp(l) - t_0); elseif (l <= -20000.0) tmp = t_0; elseif (l <= 4600000000000.0) tmp = Float64(Float64(-l) + U); else tmp = Float64(exp(l) + U); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(-l); tmp = 0.0; if (l <= -1e+72) tmp = exp(l) - t_0; elseif (l <= -20000.0) tmp = t_0; elseif (l <= 4600000000000.0) tmp = -l + U; else tmp = exp(l) + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Exp[(-l)], $MachinePrecision]}, If[LessEqual[l, -1e+72], N[(N[Exp[l], $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[l, -20000.0], t$95$0, If[LessEqual[l, 4600000000000.0], N[((-l) + U), $MachinePrecision], N[(N[Exp[l], $MachinePrecision] + U), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-\ell}\\
\mathbf{if}\;\ell \leq -1 \cdot 10^{+72}:\\
\;\;\;\;e^{\ell} - t\_0\\
\mathbf{elif}\;\ell \leq -20000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq 4600000000000:\\
\;\;\;\;\left(-\ell\right) + U\\
\mathbf{else}:\\
\;\;\;\;e^{\ell} + U\\
\end{array}
\end{array}
if l < -9.99999999999999944e71Initial program 100.0%
Taylor expanded in J around 0
Applied rewrites77.8%
Taylor expanded in J around 0
Applied rewrites64.4%
Taylor expanded in J around 0
Applied rewrites64.4%
if -9.99999999999999944e71 < l < -2e4Initial program 100.0%
Taylor expanded in J around 0
Applied rewrites81.8%
Taylor expanded in J around 0
Applied rewrites18.2%
Taylor expanded in l around 0
Applied rewrites81.8%
if -2e4 < l < 4.6e12Initial program 72.8%
Taylor expanded in J around 0
Applied rewrites71.2%
Taylor expanded in J around 0
Applied rewrites69.7%
Taylor expanded in l around 0
Applied rewrites61.7%
if 4.6e12 < l Initial program 100.0%
Taylor expanded in J around 0
Applied rewrites74.2%
Taylor expanded in J around 0
Applied rewrites54.5%
Taylor expanded in l around 0
Applied rewrites54.5%
(FPCore (J l K U) :precision binary64 (if (<= l -20000.0) (exp (- l)) (if (<= l 4600000000000.0) (+ (- l) U) (+ (exp l) U))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -20000.0) {
tmp = exp(-l);
} else if (l <= 4600000000000.0) {
tmp = -l + U;
} else {
tmp = exp(l) + U;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (l <= (-20000.0d0)) then
tmp = exp(-l)
else if (l <= 4600000000000.0d0) then
tmp = -l + u
else
tmp = exp(l) + u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -20000.0) {
tmp = Math.exp(-l);
} else if (l <= 4600000000000.0) {
tmp = -l + U;
} else {
tmp = Math.exp(l) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -20000.0: tmp = math.exp(-l) elif l <= 4600000000000.0: tmp = -l + U else: tmp = math.exp(l) + U return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -20000.0) tmp = exp(Float64(-l)); elseif (l <= 4600000000000.0) tmp = Float64(Float64(-l) + U); else tmp = Float64(exp(l) + U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -20000.0) tmp = exp(-l); elseif (l <= 4600000000000.0) tmp = -l + U; else tmp = exp(l) + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -20000.0], N[Exp[(-l)], $MachinePrecision], If[LessEqual[l, 4600000000000.0], N[((-l) + U), $MachinePrecision], N[(N[Exp[l], $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -20000:\\
\;\;\;\;e^{-\ell}\\
\mathbf{elif}\;\ell \leq 4600000000000:\\
\;\;\;\;\left(-\ell\right) + U\\
\mathbf{else}:\\
\;\;\;\;e^{\ell} + U\\
\end{array}
\end{array}
if l < -2e4Initial program 100.0%
Taylor expanded in J around 0
Applied rewrites78.6%
Taylor expanded in J around 0
Applied rewrites55.4%
Taylor expanded in l around 0
Applied rewrites44.6%
if -2e4 < l < 4.6e12Initial program 72.8%
Taylor expanded in J around 0
Applied rewrites71.2%
Taylor expanded in J around 0
Applied rewrites69.7%
Taylor expanded in l around 0
Applied rewrites61.7%
if 4.6e12 < l Initial program 100.0%
Taylor expanded in J around 0
Applied rewrites74.2%
Taylor expanded in J around 0
Applied rewrites54.5%
Taylor expanded in l around 0
Applied rewrites54.5%
(FPCore (J l K U) :precision binary64 (if (<= l -20000.0) (exp (- l)) (if (<= l 4600000000000.0) (+ (- l) U) (exp l))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -20000.0) {
tmp = exp(-l);
} else if (l <= 4600000000000.0) {
tmp = -l + U;
} else {
tmp = exp(l);
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (l <= (-20000.0d0)) then
tmp = exp(-l)
else if (l <= 4600000000000.0d0) then
tmp = -l + u
else
tmp = exp(l)
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -20000.0) {
tmp = Math.exp(-l);
} else if (l <= 4600000000000.0) {
tmp = -l + U;
} else {
tmp = Math.exp(l);
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -20000.0: tmp = math.exp(-l) elif l <= 4600000000000.0: tmp = -l + U else: tmp = math.exp(l) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -20000.0) tmp = exp(Float64(-l)); elseif (l <= 4600000000000.0) tmp = Float64(Float64(-l) + U); else tmp = exp(l); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -20000.0) tmp = exp(-l); elseif (l <= 4600000000000.0) tmp = -l + U; else tmp = exp(l); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -20000.0], N[Exp[(-l)], $MachinePrecision], If[LessEqual[l, 4600000000000.0], N[((-l) + U), $MachinePrecision], N[Exp[l], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -20000:\\
\;\;\;\;e^{-\ell}\\
\mathbf{elif}\;\ell \leq 4600000000000:\\
\;\;\;\;\left(-\ell\right) + U\\
\mathbf{else}:\\
\;\;\;\;e^{\ell}\\
\end{array}
\end{array}
if l < -2e4Initial program 100.0%
Taylor expanded in J around 0
Applied rewrites78.6%
Taylor expanded in J around 0
Applied rewrites55.4%
Taylor expanded in l around 0
Applied rewrites44.6%
if -2e4 < l < 4.6e12Initial program 72.8%
Taylor expanded in J around 0
Applied rewrites71.2%
Taylor expanded in J around 0
Applied rewrites69.7%
Taylor expanded in l around 0
Applied rewrites61.7%
if 4.6e12 < l Initial program 100.0%
Taylor expanded in J around -inf
Applied rewrites54.5%
(FPCore (J l K U) :precision binary64 (+ (- l) U))
double code(double J, double l, double K, double U) {
return -l + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = -l + u
end function
public static double code(double J, double l, double K, double U) {
return -l + U;
}
def code(J, l, K, U): return -l + U
function code(J, l, K, U) return Float64(Float64(-l) + U) end
function tmp = code(J, l, K, U) tmp = -l + U; end
code[J_, l_, K_, U_] := N[((-l) + U), $MachinePrecision]
\begin{array}{l}
\\
\left(-\ell\right) + U
\end{array}
Initial program 85.8%
Taylor expanded in J around 0
Applied rewrites73.6%
Taylor expanded in J around 0
Applied rewrites62.7%
Taylor expanded in l around 0
Applied rewrites33.7%
(FPCore (J l K U) :precision binary64 (- l))
double code(double J, double l, double K, double U) {
return -l;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = -l
end function
public static double code(double J, double l, double K, double U) {
return -l;
}
def code(J, l, K, U): return -l
function code(J, l, K, U) return Float64(-l) end
function tmp = code(J, l, K, U) tmp = -l; end
code[J_, l_, K_, U_] := (-l)
\begin{array}{l}
\\
-\ell
\end{array}
Initial program 85.8%
Taylor expanded in J around 0
Applied rewrites73.6%
Taylor expanded in J around 0
Applied rewrites62.7%
Taylor expanded in l around 0
Applied rewrites37.2%
Taylor expanded in l around 0
Applied rewrites3.0%
herbie shell --seed 2024321
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
:pre (TRUE)
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))