
(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 10 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 (+ (* 2.0 (* J (log1p (expm1 (* l (cos (* K 0.5))))))) U))
double code(double J, double l, double K, double U) {
return (2.0 * (J * log1p(expm1((l * cos((K * 0.5))))))) + U;
}
public static double code(double J, double l, double K, double U) {
return (2.0 * (J * Math.log1p(Math.expm1((l * Math.cos((K * 0.5))))))) + U;
}
def code(J, l, K, U): return (2.0 * (J * math.log1p(math.expm1((l * math.cos((K * 0.5))))))) + U
function code(J, l, K, U) return Float64(Float64(2.0 * Float64(J * log1p(expm1(Float64(l * cos(Float64(K * 0.5))))))) + U) end
code[J_, l_, K_, U_] := N[(N[(2.0 * N[(J * N[Log[1 + N[(Exp[N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\right) + U
\end{array}
Initial program 86.9%
Taylor expanded in l around 0 65.5%
log1p-expm1-u99.5%
*-commutative99.5%
metadata-eval99.5%
div-inv99.5%
div-inv99.5%
metadata-eval99.5%
Applied egg-rr99.5%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.05) (+ (* 2.0 (* J (* l (cos (* 0.5 K))))) U) (+ (* 2.0 (* J (log1p (expm1 l)))) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.05) {
tmp = (2.0 * (J * (l * cos((0.5 * K))))) + U;
} else {
tmp = (2.0 * (J * log1p(expm1(l)))) + U;
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= 0.05) {
tmp = (2.0 * (J * (l * Math.cos((0.5 * K))))) + U;
} else {
tmp = (2.0 * (J * Math.log1p(Math.expm1(l)))) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.05: tmp = (2.0 * (J * (l * math.cos((0.5 * K))))) + U else: tmp = (2.0 * (J * math.log1p(math.expm1(l)))) + U return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.05) tmp = Float64(Float64(2.0 * Float64(J * Float64(l * cos(Float64(0.5 * K))))) + U); else tmp = Float64(Float64(2.0 * Float64(J * log1p(expm1(l)))) + U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.05], N[(N[(2.0 * N[(J * N[(l * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(2.0 * N[(J * N[Log[1 + N[(Exp[l] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.05:\\
\;\;\;\;2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) + U\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell\right)\right)\right) + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < 0.050000000000000003Initial program 83.7%
Taylor expanded in l around 0 67.7%
if 0.050000000000000003 < (cos.f64 (/.f64 K 2)) Initial program 88.1%
Taylor expanded in l around 0 64.6%
log1p-expm1-u100.0%
*-commutative100.0%
metadata-eval100.0%
div-inv100.0%
div-inv100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in K around 0 97.3%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ (* (* J (* 0.3333333333333333 (pow l 3.0))) (cos (/ K 2.0))) U))
(t_1 (+ (* 2.0 (* J (log1p (expm1 l)))) U)))
(if (<= l -2.5e+108)
t_0
(if (<= l -21500000.0)
t_1
(if (<= l 2.15e-16)
(+ (* 2.0 (* J (* l (cos (* 0.5 K))))) U)
(if (<= l 6e+83) t_1 t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = ((J * (0.3333333333333333 * pow(l, 3.0))) * cos((K / 2.0))) + U;
double t_1 = (2.0 * (J * log1p(expm1(l)))) + U;
double tmp;
if (l <= -2.5e+108) {
tmp = t_0;
} else if (l <= -21500000.0) {
tmp = t_1;
} else if (l <= 2.15e-16) {
tmp = (2.0 * (J * (l * cos((0.5 * K))))) + U;
} else if (l <= 6e+83) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = ((J * (0.3333333333333333 * Math.pow(l, 3.0))) * Math.cos((K / 2.0))) + U;
double t_1 = (2.0 * (J * Math.log1p(Math.expm1(l)))) + U;
double tmp;
if (l <= -2.5e+108) {
tmp = t_0;
} else if (l <= -21500000.0) {
tmp = t_1;
} else if (l <= 2.15e-16) {
tmp = (2.0 * (J * (l * Math.cos((0.5 * K))))) + U;
} else if (l <= 6e+83) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = ((J * (0.3333333333333333 * math.pow(l, 3.0))) * math.cos((K / 2.0))) + U t_1 = (2.0 * (J * math.log1p(math.expm1(l)))) + U tmp = 0 if l <= -2.5e+108: tmp = t_0 elif l <= -21500000.0: tmp = t_1 elif l <= 2.15e-16: tmp = (2.0 * (J * (l * math.cos((0.5 * K))))) + U elif l <= 6e+83: tmp = t_1 else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(Float64(Float64(J * Float64(0.3333333333333333 * (l ^ 3.0))) * cos(Float64(K / 2.0))) + U) t_1 = Float64(Float64(2.0 * Float64(J * log1p(expm1(l)))) + U) tmp = 0.0 if (l <= -2.5e+108) tmp = t_0; elseif (l <= -21500000.0) tmp = t_1; elseif (l <= 2.15e-16) tmp = Float64(Float64(2.0 * Float64(J * Float64(l * cos(Float64(0.5 * K))))) + U); elseif (l <= 6e+83) tmp = t_1; else tmp = t_0; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[(J * N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * N[(J * N[Log[1 + N[(Exp[l] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -2.5e+108], t$95$0, If[LessEqual[l, -21500000.0], t$95$1, If[LessEqual[l, 2.15e-16], N[(N[(2.0 * N[(J * N[(l * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 6e+83], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
t_1 := 2 \cdot \left(J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell\right)\right)\right) + U\\
\mathbf{if}\;\ell \leq -2.5 \cdot 10^{+108}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -21500000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq 2.15 \cdot 10^{-16}:\\
\;\;\;\;2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) + U\\
\mathbf{elif}\;\ell \leq 6 \cdot 10^{+83}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -2.49999999999999995e108 or 5.9999999999999999e83 < l Initial program 100.0%
Taylor expanded in l around 0 100.0%
Taylor expanded in l around inf 100.0%
if -2.49999999999999995e108 < l < -2.15e7 or 2.1499999999999999e-16 < l < 5.9999999999999999e83Initial program 100.0%
Taylor expanded in l around 0 15.1%
log1p-expm1-u100.0%
*-commutative100.0%
metadata-eval100.0%
div-inv100.0%
div-inv100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in K around 0 76.9%
if -2.15e7 < l < 2.1499999999999999e-16Initial program 74.2%
Taylor expanded in l around 0 98.3%
(FPCore (J l K U)
:precision binary64
(if (<= (/ K 2.0) 2e-10)
(+ (* 2.0 (* J (log1p (expm1 l)))) U)
(+
(* (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* 2.0 l))) (cos (/ K 2.0)))
U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 2e-10) {
tmp = (2.0 * (J * log1p(expm1(l)))) + U;
} else {
tmp = ((J * ((0.3333333333333333 * pow(l, 3.0)) + (2.0 * l))) * cos((K / 2.0))) + U;
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 2e-10) {
tmp = (2.0 * (J * Math.log1p(Math.expm1(l)))) + U;
} else {
tmp = ((J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (2.0 * l))) * Math.cos((K / 2.0))) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (K / 2.0) <= 2e-10: tmp = (2.0 * (J * math.log1p(math.expm1(l)))) + U else: tmp = ((J * ((0.3333333333333333 * math.pow(l, 3.0)) + (2.0 * l))) * math.cos((K / 2.0))) + U return tmp
function code(J, l, K, U) tmp = 0.0 if (Float64(K / 2.0) <= 2e-10) tmp = Float64(Float64(2.0 * Float64(J * log1p(expm1(l)))) + U); else tmp = Float64(Float64(Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(2.0 * l))) * cos(Float64(K / 2.0))) + U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 2e-10], N[(N[(2.0 * N[(J * N[Log[1 + N[(Exp[l] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;2 \cdot \left(J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell\right)\right)\right) + U\\
\mathbf{else}:\\
\;\;\;\;\left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\end{array}
\end{array}
if (/.f64 K 2) < 2.00000000000000007e-10Initial program 86.8%
Taylor expanded in l around 0 65.5%
log1p-expm1-u99.9%
*-commutative99.9%
metadata-eval99.9%
div-inv99.9%
div-inv99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in K around 0 86.1%
if 2.00000000000000007e-10 < (/.f64 K 2) Initial program 87.1%
Taylor expanded in l around 0 85.8%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.02) (+ (* 2.0 (* J (* l (cos (* 0.5 K))))) U) (+ (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* 2.0 l))) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.02) {
tmp = (2.0 * (J * (l * cos((0.5 * K))))) + U;
} else {
tmp = (J * ((0.3333333333333333 * pow(l, 3.0)) + (2.0 * 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 (cos((k / 2.0d0)) <= (-0.02d0)) then
tmp = (2.0d0 * (j * (l * cos((0.5d0 * k))))) + u
else
tmp = (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (2.0d0 * l))) + u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= -0.02) {
tmp = (2.0 * (J * (l * Math.cos((0.5 * K))))) + U;
} else {
tmp = (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (2.0 * l))) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.02: tmp = (2.0 * (J * (l * math.cos((0.5 * K))))) + U else: tmp = (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (2.0 * l))) + U return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.02) tmp = Float64(Float64(2.0 * Float64(J * Float64(l * cos(Float64(0.5 * K))))) + U); else tmp = Float64(Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(2.0 * l))) + U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.02) tmp = (2.0 * (J * (l * cos((0.5 * K))))) + U; else tmp = (J * ((0.3333333333333333 * (l ^ 3.0)) + (2.0 * l))) + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.02], N[(N[(2.0 * N[(J * N[(l * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
\;\;\;\;2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) + U\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right) + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.0200000000000000004Initial program 85.4%
Taylor expanded in l around 0 68.6%
if -0.0200000000000000004 < (cos.f64 (/.f64 K 2)) Initial program 87.4%
Taylor expanded in l around 0 84.2%
Taylor expanded in K around 0 80.7%
(FPCore (J l K U)
:precision binary64
(if (<= l -3e+47)
(* 2.0 (* J (* l (cos (* 0.5 K)))))
(if (<= l -800.0)
(* -4.0 (+ J (* -0.125 (* J (pow K 2.0)))))
(+ (* 2.0 (* J l)) U))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -3e+47) {
tmp = 2.0 * (J * (l * cos((0.5 * K))));
} else if (l <= -800.0) {
tmp = -4.0 * (J + (-0.125 * (J * pow(K, 2.0))));
} else {
tmp = (2.0 * (J * 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 <= (-3d+47)) then
tmp = 2.0d0 * (j * (l * cos((0.5d0 * k))))
else if (l <= (-800.0d0)) then
tmp = (-4.0d0) * (j + ((-0.125d0) * (j * (k ** 2.0d0))))
else
tmp = (2.0d0 * (j * l)) + u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -3e+47) {
tmp = 2.0 * (J * (l * Math.cos((0.5 * K))));
} else if (l <= -800.0) {
tmp = -4.0 * (J + (-0.125 * (J * Math.pow(K, 2.0))));
} else {
tmp = (2.0 * (J * l)) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -3e+47: tmp = 2.0 * (J * (l * math.cos((0.5 * K)))) elif l <= -800.0: tmp = -4.0 * (J + (-0.125 * (J * math.pow(K, 2.0)))) else: tmp = (2.0 * (J * l)) + U return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -3e+47) tmp = Float64(2.0 * Float64(J * Float64(l * cos(Float64(0.5 * K))))); elseif (l <= -800.0) tmp = Float64(-4.0 * Float64(J + Float64(-0.125 * Float64(J * (K ^ 2.0))))); else tmp = Float64(Float64(2.0 * Float64(J * l)) + U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -3e+47) tmp = 2.0 * (J * (l * cos((0.5 * K)))); elseif (l <= -800.0) tmp = -4.0 * (J + (-0.125 * (J * (K ^ 2.0)))); else tmp = (2.0 * (J * l)) + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -3e+47], N[(2.0 * N[(J * N[(l * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -800.0], N[(-4.0 * N[(J + N[(-0.125 * N[(J * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3 \cdot 10^{+47}:\\
\;\;\;\;2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right)\\
\mathbf{elif}\;\ell \leq -800:\\
\;\;\;\;-4 \cdot \left(J + -0.125 \cdot \left(J \cdot {K}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(J \cdot \ell\right) + U\\
\end{array}
\end{array}
if l < -3.0000000000000001e47Initial program 100.0%
Taylor expanded in l around 0 40.6%
Taylor expanded in J around inf 40.3%
if -3.0000000000000001e47 < l < -800Initial program 100.0%
Applied egg-rr3.2%
Taylor expanded in J around inf 3.4%
Taylor expanded in K around 0 37.9%
if -800 < l Initial program 82.4%
Taylor expanded in l around 0 77.3%
Taylor expanded in K around 0 66.9%
(FPCore (J l K U) :precision binary64 (if (<= l -4.5e+47) (* 2.0 (* J (* l (cos (* 0.5 K))))) (if (<= l -620.0) (+ (* 0.5 (* J (pow K 2.0))) U) (+ (* 2.0 (* J l)) U))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -4.5e+47) {
tmp = 2.0 * (J * (l * cos((0.5 * K))));
} else if (l <= -620.0) {
tmp = (0.5 * (J * pow(K, 2.0))) + U;
} else {
tmp = (2.0 * (J * 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 <= (-4.5d+47)) then
tmp = 2.0d0 * (j * (l * cos((0.5d0 * k))))
else if (l <= (-620.0d0)) then
tmp = (0.5d0 * (j * (k ** 2.0d0))) + u
else
tmp = (2.0d0 * (j * l)) + u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -4.5e+47) {
tmp = 2.0 * (J * (l * Math.cos((0.5 * K))));
} else if (l <= -620.0) {
tmp = (0.5 * (J * Math.pow(K, 2.0))) + U;
} else {
tmp = (2.0 * (J * l)) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -4.5e+47: tmp = 2.0 * (J * (l * math.cos((0.5 * K)))) elif l <= -620.0: tmp = (0.5 * (J * math.pow(K, 2.0))) + U else: tmp = (2.0 * (J * l)) + U return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -4.5e+47) tmp = Float64(2.0 * Float64(J * Float64(l * cos(Float64(0.5 * K))))); elseif (l <= -620.0) tmp = Float64(Float64(0.5 * Float64(J * (K ^ 2.0))) + U); else tmp = Float64(Float64(2.0 * Float64(J * l)) + U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -4.5e+47) tmp = 2.0 * (J * (l * cos((0.5 * K)))); elseif (l <= -620.0) tmp = (0.5 * (J * (K ^ 2.0))) + U; else tmp = (2.0 * (J * l)) + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -4.5e+47], N[(2.0 * N[(J * N[(l * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -620.0], N[(N[(0.5 * N[(J * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4.5 \cdot 10^{+47}:\\
\;\;\;\;2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right)\\
\mathbf{elif}\;\ell \leq -620:\\
\;\;\;\;0.5 \cdot \left(J \cdot {K}^{2}\right) + U\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(J \cdot \ell\right) + U\\
\end{array}
\end{array}
if l < -4.49999999999999979e47Initial program 100.0%
Taylor expanded in l around 0 40.6%
Taylor expanded in J around inf 40.3%
if -4.49999999999999979e47 < l < -620Initial program 100.0%
Applied egg-rr3.2%
Taylor expanded in K around 0 37.7%
Taylor expanded in K around inf 37.2%
if -620 < l Initial program 82.4%
Taylor expanded in l around 0 77.3%
Taylor expanded in K around 0 66.9%
(FPCore (J l K U) :precision binary64 (+ (* 2.0 (* J (* l (cos (* 0.5 K))))) U))
double code(double J, double l, double K, double U) {
return (2.0 * (J * (l * cos((0.5 * K))))) + 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 = (2.0d0 * (j * (l * cos((0.5d0 * k))))) + u
end function
public static double code(double J, double l, double K, double U) {
return (2.0 * (J * (l * Math.cos((0.5 * K))))) + U;
}
def code(J, l, K, U): return (2.0 * (J * (l * math.cos((0.5 * K))))) + U
function code(J, l, K, U) return Float64(Float64(2.0 * Float64(J * Float64(l * cos(Float64(0.5 * K))))) + U) end
function tmp = code(J, l, K, U) tmp = (2.0 * (J * (l * cos((0.5 * K))))) + U; end
code[J_, l_, K_, U_] := N[(N[(2.0 * N[(J * N[(l * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) + U
\end{array}
Initial program 86.9%
Taylor expanded in l around 0 65.5%
(FPCore (J l K U) :precision binary64 (+ (* 2.0 (* J l)) U))
double code(double J, double l, double K, double U) {
return (2.0 * (J * 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 = (2.0d0 * (j * l)) + u
end function
public static double code(double J, double l, double K, double U) {
return (2.0 * (J * l)) + U;
}
def code(J, l, K, U): return (2.0 * (J * l)) + U
function code(J, l, K, U) return Float64(Float64(2.0 * Float64(J * l)) + U) end
function tmp = code(J, l, K, U) tmp = (2.0 * (J * l)) + U; end
code[J_, l_, K_, U_] := N[(N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(J \cdot \ell\right) + U
\end{array}
Initial program 86.9%
Taylor expanded in l around 0 65.5%
Taylor expanded in K around 0 54.9%
(FPCore (J l K U) :precision binary64 U)
double code(double J, double l, double K, double U) {
return 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 = u
end function
public static double code(double J, double l, double K, double U) {
return U;
}
def code(J, l, K, U): return U
function code(J, l, K, U) return U end
function tmp = code(J, l, K, U) tmp = U; end
code[J_, l_, K_, U_] := U
\begin{array}{l}
\\
U
\end{array}
Initial program 86.9%
Applied egg-rr27.7%
Taylor expanded in J around 0 38.7%
herbie shell --seed 2024034 -o generate:simplify
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))