
(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 13 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
(let* ((t_0 (cos (/ K 2.0)))
(t_1 (- (exp l) (exp (- l))))
(t_2 (+ (* (* J t_1) t_0) U)))
(if (<= t_1 -5000000.0)
t_2
(if (<= t_1 0.0) (+ (* (* J (* 2.0 l)) t_0) U) t_2))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = exp(l) - exp(-l);
double t_2 = ((J * t_1) * t_0) + U;
double tmp;
if (t_1 <= -5000000.0) {
tmp = t_2;
} else if (t_1 <= 0.0) {
tmp = ((J * (2.0 * l)) * t_0) + U;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = exp(l) - exp(-l)
t_2 = ((j * t_1) * t_0) + u
if (t_1 <= (-5000000.0d0)) then
tmp = t_2
else if (t_1 <= 0.0d0) then
tmp = ((j * (2.0d0 * l)) * t_0) + u
else
tmp = t_2
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = Math.exp(l) - Math.exp(-l);
double t_2 = ((J * t_1) * t_0) + U;
double tmp;
if (t_1 <= -5000000.0) {
tmp = t_2;
} else if (t_1 <= 0.0) {
tmp = ((J * (2.0 * l)) * t_0) + U;
} else {
tmp = t_2;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = math.exp(l) - math.exp(-l) t_2 = ((J * t_1) * t_0) + U tmp = 0 if t_1 <= -5000000.0: tmp = t_2 elif t_1 <= 0.0: tmp = ((J * (2.0 * l)) * t_0) + U else: tmp = t_2 return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(exp(l) - exp(Float64(-l))) t_2 = Float64(Float64(Float64(J * t_1) * t_0) + U) tmp = 0.0 if (t_1 <= -5000000.0) tmp = t_2; elseif (t_1 <= 0.0) tmp = Float64(Float64(Float64(J * Float64(2.0 * l)) * t_0) + U); else tmp = t_2; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = exp(l) - exp(-l); t_2 = ((J * t_1) * t_0) + U; tmp = 0.0; if (t_1 <= -5000000.0) tmp = t_2; elseif (t_1 <= 0.0) tmp = ((J * (2.0 * l)) * t_0) + U; else tmp = t_2; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(J * t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[t$95$1, -5000000.0], t$95$2, If[LessEqual[t$95$1, 0.0], N[(N[(N[(J * N[(2.0 * l), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := e^{\ell} - e^{-\ell}\\
t_2 := \left(J \cdot t\_1\right) \cdot t\_0 + U\\
\mathbf{if}\;t\_1 \leq -5000000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\left(J \cdot \left(2 \cdot \ell\right)\right) \cdot t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -5e6 or 0.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -5e6 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0Initial program 78.1%
Taylor expanded in l around 0 99.9%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.02) (+ (* (* J (* 0.3333333333333333 (pow l 3.0))) -4.0) U) (+ (* J (- (exp l) (exp (- l)))) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.02) {
tmp = ((J * (0.3333333333333333 * pow(l, 3.0))) * -4.0) + U;
} else {
tmp = (J * (exp(l) - 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 (cos((k / 2.0d0)) <= (-0.02d0)) then
tmp = ((j * (0.3333333333333333d0 * (l ** 3.0d0))) * (-4.0d0)) + u
else
tmp = (j * (exp(l) - exp(-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 = ((J * (0.3333333333333333 * Math.pow(l, 3.0))) * -4.0) + U;
} else {
tmp = (J * (Math.exp(l) - Math.exp(-l))) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.02: tmp = ((J * (0.3333333333333333 * math.pow(l, 3.0))) * -4.0) + U else: tmp = (J * (math.exp(l) - math.exp(-l))) + U return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.02) tmp = Float64(Float64(Float64(J * Float64(0.3333333333333333 * (l ^ 3.0))) * -4.0) + U); else tmp = Float64(Float64(J * Float64(exp(l) - exp(Float64(-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 = ((J * (0.3333333333333333 * (l ^ 3.0))) * -4.0) + U; else tmp = (J * (exp(l) - exp(-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[(N[(J * N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision] + U), $MachinePrecision], N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
\;\;\;\;\left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\right) \cdot -4 + U\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(e^{\ell} - e^{-\ell}\right) + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.0200000000000000004Initial program 90.9%
Taylor expanded in l around 0 83.5%
Taylor expanded in l around inf 74.6%
Applied egg-rr74.6%
if -0.0200000000000000004 < (cos.f64 (/.f64 K 2)) Initial program 90.4%
Taylor expanded in K around 0 90.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1 (+ (* (* J (* 0.3333333333333333 (pow l 3.0))) t_0) U))
(t_2 (+ (* J (- (exp l) (exp (- l)))) U)))
(if (<= l -3.95e+102)
t_1
(if (<= l -0.00295)
t_2
(if (<= l 0.0058)
(+ (* (* J (* 2.0 l)) t_0) U)
(if (<= l 2.2e+89) t_2 t_1))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = ((J * (0.3333333333333333 * pow(l, 3.0))) * t_0) + U;
double t_2 = (J * (exp(l) - exp(-l))) + U;
double tmp;
if (l <= -3.95e+102) {
tmp = t_1;
} else if (l <= -0.00295) {
tmp = t_2;
} else if (l <= 0.0058) {
tmp = ((J * (2.0 * l)) * t_0) + U;
} else if (l <= 2.2e+89) {
tmp = t_2;
} 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) :: t_2
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = ((j * (0.3333333333333333d0 * (l ** 3.0d0))) * t_0) + u
t_2 = (j * (exp(l) - exp(-l))) + u
if (l <= (-3.95d+102)) then
tmp = t_1
else if (l <= (-0.00295d0)) then
tmp = t_2
else if (l <= 0.0058d0) then
tmp = ((j * (2.0d0 * l)) * t_0) + u
else if (l <= 2.2d+89) then
tmp = t_2
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.cos((K / 2.0));
double t_1 = ((J * (0.3333333333333333 * Math.pow(l, 3.0))) * t_0) + U;
double t_2 = (J * (Math.exp(l) - Math.exp(-l))) + U;
double tmp;
if (l <= -3.95e+102) {
tmp = t_1;
} else if (l <= -0.00295) {
tmp = t_2;
} else if (l <= 0.0058) {
tmp = ((J * (2.0 * l)) * t_0) + U;
} else if (l <= 2.2e+89) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = ((J * (0.3333333333333333 * math.pow(l, 3.0))) * t_0) + U t_2 = (J * (math.exp(l) - math.exp(-l))) + U tmp = 0 if l <= -3.95e+102: tmp = t_1 elif l <= -0.00295: tmp = t_2 elif l <= 0.0058: tmp = ((J * (2.0 * l)) * t_0) + U elif l <= 2.2e+89: tmp = t_2 else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(Float64(Float64(J * Float64(0.3333333333333333 * (l ^ 3.0))) * t_0) + U) t_2 = Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) + U) tmp = 0.0 if (l <= -3.95e+102) tmp = t_1; elseif (l <= -0.00295) tmp = t_2; elseif (l <= 0.0058) tmp = Float64(Float64(Float64(J * Float64(2.0 * l)) * t_0) + U); elseif (l <= 2.2e+89) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = ((J * (0.3333333333333333 * (l ^ 3.0))) * t_0) + U; t_2 = (J * (exp(l) - exp(-l))) + U; tmp = 0.0; if (l <= -3.95e+102) tmp = t_1; elseif (l <= -0.00295) tmp = t_2; elseif (l <= 0.0058) tmp = ((J * (2.0 * l)) * t_0) + U; elseif (l <= 2.2e+89) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(J * N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision]}, Block[{t$95$2 = N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -3.95e+102], t$95$1, If[LessEqual[l, -0.00295], t$95$2, If[LessEqual[l, 0.0058], N[(N[(N[(J * N[(2.0 * l), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 2.2e+89], t$95$2, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\right) \cdot t\_0 + U\\
t_2 := J \cdot \left(e^{\ell} - e^{-\ell}\right) + U\\
\mathbf{if}\;\ell \leq -3.95 \cdot 10^{+102}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq -0.00295:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\ell \leq 0.0058:\\
\;\;\;\;\left(J \cdot \left(2 \cdot \ell\right)\right) \cdot t\_0 + U\\
\mathbf{elif}\;\ell \leq 2.2 \cdot 10^{+89}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if l < -3.9500000000000001e102 or 2.2e89 < l Initial program 100.0%
Taylor expanded in l around 0 99.0%
Taylor expanded in l around inf 99.0%
if -3.9500000000000001e102 < l < -0.00294999999999999993 or 0.0058 < l < 2.2e89Initial program 100.0%
Taylor expanded in K around 0 74.0%
if -0.00294999999999999993 < l < 0.0058Initial program 78.1%
Taylor expanded in l around 0 99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.12)
(+ (* 2.0 (* J (* l -1.0))) U)
(if (<= t_0 0.995)
(* U (+ 1.0 (* 0.6666666666666666 (/ (* J l) U))))
(+ (* 2.0 (* J l)) U)))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= -0.12) {
tmp = (2.0 * (J * (l * -1.0))) + U;
} else if (t_0 <= 0.995) {
tmp = U * (1.0 + (0.6666666666666666 * ((J * l) / 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) :: t_0
real(8) :: tmp
t_0 = cos((k / 2.0d0))
if (t_0 <= (-0.12d0)) then
tmp = (2.0d0 * (j * (l * (-1.0d0)))) + u
else if (t_0 <= 0.995d0) then
tmp = u * (1.0d0 + (0.6666666666666666d0 * ((j * l) / 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 t_0 = Math.cos((K / 2.0));
double tmp;
if (t_0 <= -0.12) {
tmp = (2.0 * (J * (l * -1.0))) + U;
} else if (t_0 <= 0.995) {
tmp = U * (1.0 + (0.6666666666666666 * ((J * l) / U)));
} else {
tmp = (2.0 * (J * l)) + U;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) tmp = 0 if t_0 <= -0.12: tmp = (2.0 * (J * (l * -1.0))) + U elif t_0 <= 0.995: tmp = U * (1.0 + (0.6666666666666666 * ((J * l) / U))) else: tmp = (2.0 * (J * l)) + U return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= -0.12) tmp = Float64(Float64(2.0 * Float64(J * Float64(l * -1.0))) + U); elseif (t_0 <= 0.995) tmp = Float64(U * Float64(1.0 + Float64(0.6666666666666666 * Float64(Float64(J * l) / U)))); else tmp = Float64(Float64(2.0 * Float64(J * l)) + U); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); tmp = 0.0; if (t_0 <= -0.12) tmp = (2.0 * (J * (l * -1.0))) + U; elseif (t_0 <= 0.995) tmp = U * (1.0 + (0.6666666666666666 * ((J * l) / U))); else tmp = (2.0 * (J * l)) + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -0.12], N[(N[(2.0 * N[(J * N[(l * -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, 0.995], N[(U * N[(1.0 + N[(0.6666666666666666 * N[(N[(J * l), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.12:\\
\;\;\;\;2 \cdot \left(J \cdot \left(\ell \cdot -1\right)\right) + U\\
\mathbf{elif}\;t\_0 \leq 0.995:\\
\;\;\;\;U \cdot \left(1 + 0.6666666666666666 \cdot \frac{J \cdot \ell}{U}\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(J \cdot \ell\right) + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.12Initial program 90.3%
Taylor expanded in l around 0 66.4%
Applied egg-rr59.0%
if -0.12 < (cos.f64 (/.f64 K 2)) < 0.994999999999999996Initial program 88.8%
Taylor expanded in l around 0 56.4%
Applied egg-rr47.4%
Taylor expanded in U around inf 53.1%
if 0.994999999999999996 < (cos.f64 (/.f64 K 2)) Initial program 91.5%
Taylor expanded in l around 0 63.5%
Taylor expanded in K around 0 63.5%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.02) (+ (* (* J (* 0.3333333333333333 (pow l 3.0))) -4.0) U) (+ (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.02) {
tmp = ((J * (0.3333333333333333 * pow(l, 3.0))) * -4.0) + U;
} else {
tmp = (J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.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) :: tmp
if (cos((k / 2.0d0)) <= (-0.02d0)) then
tmp = ((j * (0.3333333333333333d0 * (l ** 3.0d0))) * (-4.0d0)) + u
else
tmp = (j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0))))) + 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 = ((J * (0.3333333333333333 * Math.pow(l, 3.0))) * -4.0) + U;
} else {
tmp = (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))))) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.02: tmp = ((J * (0.3333333333333333 * math.pow(l, 3.0))) * -4.0) + U else: tmp = (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0))))) + U return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.02) tmp = Float64(Float64(Float64(J * Float64(0.3333333333333333 * (l ^ 3.0))) * -4.0) + U); else tmp = Float64(Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))) + U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.02) tmp = ((J * (0.3333333333333333 * (l ^ 3.0))) * -4.0) + U; else tmp = (J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0))))) + 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[(N[(J * N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision] + U), $MachinePrecision], N[(N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
\;\;\;\;\left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\right) \cdot -4 + U\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right) + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.0200000000000000004Initial program 90.9%
Taylor expanded in l around 0 83.5%
Taylor expanded in l around inf 74.6%
Applied egg-rr74.6%
if -0.0200000000000000004 < (cos.f64 (/.f64 K 2)) Initial program 90.4%
Taylor expanded in l around 0 83.6%
Taylor expanded in K around 0 80.3%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.02) (+ (* (* J (* 0.3333333333333333 (pow l 3.0))) -4.0) U) (+ (* 9.0 (* J (pow l 3.0))) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.02) {
tmp = ((J * (0.3333333333333333 * pow(l, 3.0))) * -4.0) + U;
} else {
tmp = (9.0 * (J * pow(l, 3.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) :: tmp
if (cos((k / 2.0d0)) <= (-0.02d0)) then
tmp = ((j * (0.3333333333333333d0 * (l ** 3.0d0))) * (-4.0d0)) + u
else
tmp = (9.0d0 * (j * (l ** 3.0d0))) + 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 = ((J * (0.3333333333333333 * Math.pow(l, 3.0))) * -4.0) + U;
} else {
tmp = (9.0 * (J * Math.pow(l, 3.0))) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.02: tmp = ((J * (0.3333333333333333 * math.pow(l, 3.0))) * -4.0) + U else: tmp = (9.0 * (J * math.pow(l, 3.0))) + U return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.02) tmp = Float64(Float64(Float64(J * Float64(0.3333333333333333 * (l ^ 3.0))) * -4.0) + U); else tmp = Float64(Float64(9.0 * Float64(J * (l ^ 3.0))) + U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.02) tmp = ((J * (0.3333333333333333 * (l ^ 3.0))) * -4.0) + U; else tmp = (9.0 * (J * (l ^ 3.0))) + 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[(N[(J * N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision] + U), $MachinePrecision], N[(N[(9.0 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
\;\;\;\;\left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\right) \cdot -4 + U\\
\mathbf{else}:\\
\;\;\;\;9 \cdot \left(J \cdot {\ell}^{3}\right) + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.0200000000000000004Initial program 90.9%
Taylor expanded in l around 0 83.5%
Taylor expanded in l around inf 74.6%
Applied egg-rr74.6%
if -0.0200000000000000004 < (cos.f64 (/.f64 K 2)) Initial program 90.4%
Taylor expanded in l around 0 83.6%
Taylor expanded in l around inf 74.2%
Applied egg-rr74.2%
Taylor expanded in J around 0 74.2%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.02) (+ (* 2.0 (* J (* l -1.0))) U) (+ (* 0.3333333333333333 (* J (pow l 3.0))) 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 * -1.0))) + U;
} else {
tmp = (0.3333333333333333 * (J * pow(l, 3.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) :: tmp
if (cos((k / 2.0d0)) <= (-0.02d0)) then
tmp = (2.0d0 * (j * (l * (-1.0d0)))) + u
else
tmp = (0.3333333333333333d0 * (j * (l ** 3.0d0))) + 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 * -1.0))) + U;
} else {
tmp = (0.3333333333333333 * (J * Math.pow(l, 3.0))) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.02: tmp = (2.0 * (J * (l * -1.0))) + U else: tmp = (0.3333333333333333 * (J * math.pow(l, 3.0))) + 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 * -1.0))) + U); else tmp = Float64(Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))) + 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 * -1.0))) + U; else tmp = (0.3333333333333333 * (J * (l ^ 3.0))) + 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 * -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $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 -1\right)\right) + U\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right) + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.0200000000000000004Initial program 90.9%
Taylor expanded in l around 0 65.4%
Applied egg-rr58.5%
if -0.0200000000000000004 < (cos.f64 (/.f64 K 2)) Initial program 90.4%
Taylor expanded in l around 0 83.6%
Taylor expanded in l around inf 74.2%
Taylor expanded in K around 0 74.2%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.02) (+ (* 2.0 (* J (* l -1.0))) U) (+ (* 9.0 (* J (pow l 3.0))) 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 * -1.0))) + U;
} else {
tmp = (9.0 * (J * pow(l, 3.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) :: tmp
if (cos((k / 2.0d0)) <= (-0.02d0)) then
tmp = (2.0d0 * (j * (l * (-1.0d0)))) + u
else
tmp = (9.0d0 * (j * (l ** 3.0d0))) + 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 * -1.0))) + U;
} else {
tmp = (9.0 * (J * Math.pow(l, 3.0))) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.02: tmp = (2.0 * (J * (l * -1.0))) + U else: tmp = (9.0 * (J * math.pow(l, 3.0))) + 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 * -1.0))) + U); else tmp = Float64(Float64(9.0 * Float64(J * (l ^ 3.0))) + 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 * -1.0))) + U; else tmp = (9.0 * (J * (l ^ 3.0))) + 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 * -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(9.0 * N[(J * N[Power[l, 3.0], $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 -1\right)\right) + U\\
\mathbf{else}:\\
\;\;\;\;9 \cdot \left(J \cdot {\ell}^{3}\right) + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.0200000000000000004Initial program 90.9%
Taylor expanded in l around 0 65.4%
Applied egg-rr58.5%
if -0.0200000000000000004 < (cos.f64 (/.f64 K 2)) Initial program 90.4%
Taylor expanded in l around 0 83.6%
Taylor expanded in l around inf 74.2%
Applied egg-rr74.2%
Taylor expanded in J around 0 74.2%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* 0.6666666666666666 (* J l))))
(if (<= l -9.5e+61)
t_0
(if (<= l -700.0) (* U U) (if (<= l 4.1e-26) U t_0)))))
double code(double J, double l, double K, double U) {
double t_0 = 0.6666666666666666 * (J * l);
double tmp;
if (l <= -9.5e+61) {
tmp = t_0;
} else if (l <= -700.0) {
tmp = U * U;
} else if (l <= 4.1e-26) {
tmp = U;
} else {
tmp = t_0;
}
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 = 0.6666666666666666d0 * (j * l)
if (l <= (-9.5d+61)) then
tmp = t_0
else if (l <= (-700.0d0)) then
tmp = u * u
else if (l <= 4.1d-26) then
tmp = u
else
tmp = t_0
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = 0.6666666666666666 * (J * l);
double tmp;
if (l <= -9.5e+61) {
tmp = t_0;
} else if (l <= -700.0) {
tmp = U * U;
} else if (l <= 4.1e-26) {
tmp = U;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = 0.6666666666666666 * (J * l) tmp = 0 if l <= -9.5e+61: tmp = t_0 elif l <= -700.0: tmp = U * U elif l <= 4.1e-26: tmp = U else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(0.6666666666666666 * Float64(J * l)) tmp = 0.0 if (l <= -9.5e+61) tmp = t_0; elseif (l <= -700.0) tmp = Float64(U * U); elseif (l <= 4.1e-26) tmp = U; else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = 0.6666666666666666 * (J * l); tmp = 0.0; if (l <= -9.5e+61) tmp = t_0; elseif (l <= -700.0) tmp = U * U; elseif (l <= 4.1e-26) tmp = U; else tmp = t_0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(0.6666666666666666 * N[(J * l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -9.5e+61], t$95$0, If[LessEqual[l, -700.0], N[(U * U), $MachinePrecision], If[LessEqual[l, 4.1e-26], U, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.6666666666666666 \cdot \left(J \cdot \ell\right)\\
\mathbf{if}\;\ell \leq -9.5 \cdot 10^{+61}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -700:\\
\;\;\;\;U \cdot U\\
\mathbf{elif}\;\ell \leq 4.1 \cdot 10^{-26}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -9.49999999999999959e61 or 4.0999999999999999e-26 < l Initial program 97.7%
Taylor expanded in l around 0 38.7%
Applied egg-rr30.0%
Taylor expanded in J around inf 30.0%
if -9.49999999999999959e61 < l < -700Initial program 100.0%
Applied egg-rr3.2%
Applied egg-rr27.3%
if -700 < l < 4.0999999999999999e-26Initial program 80.4%
Applied egg-rr56.0%
Taylor expanded in J around 0 79.5%
(FPCore (J l K U) :precision binary64 (if (<= l -6.2e-28) (* J (+ (* 0.6666666666666666 l) (/ U J))) (+ (* 2.0 (* J l)) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -6.2e-28) {
tmp = J * ((0.6666666666666666 * l) + (U / J));
} 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 <= (-6.2d-28)) then
tmp = j * ((0.6666666666666666d0 * l) + (u / j))
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 <= -6.2e-28) {
tmp = J * ((0.6666666666666666 * l) + (U / J));
} else {
tmp = (2.0 * (J * l)) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -6.2e-28: tmp = J * ((0.6666666666666666 * l) + (U / J)) else: tmp = (2.0 * (J * l)) + U return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -6.2e-28) tmp = Float64(J * Float64(Float64(0.6666666666666666 * l) + Float64(U / J))); 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 <= -6.2e-28) tmp = J * ((0.6666666666666666 * l) + (U / J)); else tmp = (2.0 * (J * l)) + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -6.2e-28], N[(J * N[(N[(0.6666666666666666 * l), $MachinePrecision] + N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6.2 \cdot 10^{-28}:\\
\;\;\;\;J \cdot \left(0.6666666666666666 \cdot \ell + \frac{U}{J}\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(J \cdot \ell\right) + U\\
\end{array}
\end{array}
if l < -6.19999999999999984e-28Initial program 97.3%
Taylor expanded in l around 0 38.7%
Applied egg-rr27.6%
Taylor expanded in J around inf 35.3%
if -6.19999999999999984e-28 < l Initial program 87.9%
Taylor expanded in l around 0 71.4%
Taylor expanded in K around 0 63.8%
(FPCore (J l K U) :precision binary64 (if (<= l -400.0) (* U U) (if (<= l 1.65e-20) U (* U U))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -400.0) {
tmp = U * U;
} else if (l <= 1.65e-20) {
tmp = U;
} else {
tmp = U * 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 <= (-400.0d0)) then
tmp = u * u
else if (l <= 1.65d-20) then
tmp = u
else
tmp = u * u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -400.0) {
tmp = U * U;
} else if (l <= 1.65e-20) {
tmp = U;
} else {
tmp = U * U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -400.0: tmp = U * U elif l <= 1.65e-20: tmp = U else: tmp = U * U return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -400.0) tmp = Float64(U * U); elseif (l <= 1.65e-20) tmp = U; else tmp = Float64(U * U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -400.0) tmp = U * U; elseif (l <= 1.65e-20) tmp = U; else tmp = U * U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -400.0], N[(U * U), $MachinePrecision], If[LessEqual[l, 1.65e-20], U, N[(U * U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -400:\\
\;\;\;\;U \cdot U\\
\mathbf{elif}\;\ell \leq 1.65 \cdot 10^{-20}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;U \cdot U\\
\end{array}
\end{array}
if l < -400 or 1.65e-20 < l Initial program 98.7%
Applied egg-rr2.7%
Applied egg-rr15.4%
if -400 < l < 1.65e-20Initial program 79.7%
Applied egg-rr55.5%
Taylor expanded in J around 0 78.8%
(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 90.5%
Taylor expanded in l around 0 62.2%
Taylor expanded in K around 0 53.7%
(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 90.5%
Applied egg-rr25.4%
Taylor expanded in J around 0 35.2%
herbie shell --seed 2024052 -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))