
(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
(let* ((t_0 (- (exp l) (exp (- l)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 0.0)))
(+ (* (* t_0 J) (cos (/ K 2.0))) U)
(+ U (* 2.0 (* J (* l (cos (* K 0.5)))))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 0.0)) {
tmp = ((t_0 * J) * cos((K / 2.0))) + U;
} else {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 0.0)) {
tmp = ((t_0 * J) * Math.cos((K / 2.0))) + U;
} else {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= 0.0): tmp = ((t_0 * J) * math.cos((K / 2.0))) + U else: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 0.0)) tmp = Float64(Float64(Float64(t_0 * J) * cos(Float64(K / 2.0))) + U); else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); tmp = 0.0; if ((t_0 <= -Inf) || ~((t_0 <= 0.0))) tmp = ((t_0 * J) * cos((K / 2.0))) + U; else tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); 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[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], N[(N[(N[(t$95$0 * J), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t\_0 \leq -\infty \lor \neg \left(t\_0 \leq 0\right):\\
\;\;\;\;\left(t\_0 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 0.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0Initial program 72.5%
Taylor expanded in l around 0 99.9%
Final simplification100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* K 0.5)))
(t_1 (+ U (* (pow l 3.0) (* J (* t_0 0.3333333333333333)))))
(t_2 (+ (* (- (exp l) (exp (- l))) J) U)))
(if (<= l -2.15e+74)
t_1
(if (<= l -0.00033)
t_2
(if (<= l 1.5e-21)
(+ U (* 2.0 (* J (* l t_0))))
(if (<= l 6.6e+45) t_2 t_1))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K * 0.5));
double t_1 = U + (pow(l, 3.0) * (J * (t_0 * 0.3333333333333333)));
double t_2 = ((exp(l) - exp(-l)) * J) + U;
double tmp;
if (l <= -2.15e+74) {
tmp = t_1;
} else if (l <= -0.00033) {
tmp = t_2;
} else if (l <= 1.5e-21) {
tmp = U + (2.0 * (J * (l * t_0)));
} else if (l <= 6.6e+45) {
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 * 0.5d0))
t_1 = u + ((l ** 3.0d0) * (j * (t_0 * 0.3333333333333333d0)))
t_2 = ((exp(l) - exp(-l)) * j) + u
if (l <= (-2.15d+74)) then
tmp = t_1
else if (l <= (-0.00033d0)) then
tmp = t_2
else if (l <= 1.5d-21) then
tmp = u + (2.0d0 * (j * (l * t_0)))
else if (l <= 6.6d+45) 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 * 0.5));
double t_1 = U + (Math.pow(l, 3.0) * (J * (t_0 * 0.3333333333333333)));
double t_2 = ((Math.exp(l) - Math.exp(-l)) * J) + U;
double tmp;
if (l <= -2.15e+74) {
tmp = t_1;
} else if (l <= -0.00033) {
tmp = t_2;
} else if (l <= 1.5e-21) {
tmp = U + (2.0 * (J * (l * t_0)));
} else if (l <= 6.6e+45) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K * 0.5)) t_1 = U + (math.pow(l, 3.0) * (J * (t_0 * 0.3333333333333333))) t_2 = ((math.exp(l) - math.exp(-l)) * J) + U tmp = 0 if l <= -2.15e+74: tmp = t_1 elif l <= -0.00033: tmp = t_2 elif l <= 1.5e-21: tmp = U + (2.0 * (J * (l * t_0))) elif l <= 6.6e+45: tmp = t_2 else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = cos(Float64(K * 0.5)) t_1 = Float64(U + Float64((l ^ 3.0) * Float64(J * Float64(t_0 * 0.3333333333333333)))) t_2 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) tmp = 0.0 if (l <= -2.15e+74) tmp = t_1; elseif (l <= -0.00033) tmp = t_2; elseif (l <= 1.5e-21) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * t_0)))); elseif (l <= 6.6e+45) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K * 0.5)); t_1 = U + ((l ^ 3.0) * (J * (t_0 * 0.3333333333333333))); t_2 = ((exp(l) - exp(-l)) * J) + U; tmp = 0.0; if (l <= -2.15e+74) tmp = t_1; elseif (l <= -0.00033) tmp = t_2; elseif (l <= 1.5e-21) tmp = U + (2.0 * (J * (l * t_0))); elseif (l <= 6.6e+45) 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 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * N[(t$95$0 * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -2.15e+74], t$95$1, If[LessEqual[l, -0.00033], t$95$2, If[LessEqual[l, 1.5e-21], N[(U + N[(2.0 * N[(J * N[(l * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6.6e+45], t$95$2, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
t_1 := U + {\ell}^{3} \cdot \left(J \cdot \left(t\_0 \cdot 0.3333333333333333\right)\right)\\
t_2 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{if}\;\ell \leq -2.15 \cdot 10^{+74}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq -0.00033:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\ell \leq 1.5 \cdot 10^{-21}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot t\_0\right)\right)\\
\mathbf{elif}\;\ell \leq 6.6 \cdot 10^{+45}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if l < -2.15e74 or 6.6000000000000001e45 < l Initial program 100.0%
Taylor expanded in l around 0 91.6%
Taylor expanded in l around inf 91.6%
*-commutative91.6%
associate-*r*91.6%
associate-*l*91.6%
*-commutative91.6%
associate-*r*91.6%
*-commutative91.6%
associate-*l*91.6%
Simplified91.6%
if -2.15e74 < l < -3.3e-4 or 1.49999999999999996e-21 < l < 6.6000000000000001e45Initial program 100.0%
Taylor expanded in K around 0 79.4%
if -3.3e-4 < l < 1.49999999999999996e-21Initial program 72.3%
Taylor expanded in l around 0 99.9%
Final simplification93.9%
(FPCore (J l K U)
:precision binary64
(if (<= l 1.5e-21)
(+
U
(* (cos (/ K 2.0)) (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0)))))))
(if (<= l 6.6e+45)
(+ (* (- (exp l) (exp (- l))) J) U)
(+ U (* (pow l 3.0) (* J (* (cos (* K 0.5)) 0.3333333333333333)))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= 1.5e-21) {
tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))))));
} else if (l <= 6.6e+45) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} else {
tmp = U + (pow(l, 3.0) * (J * (cos((K * 0.5)) * 0.3333333333333333)));
}
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 <= 1.5d-21) then
tmp = u + (cos((k / 2.0d0)) * (j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0))))))
else if (l <= 6.6d+45) then
tmp = ((exp(l) - exp(-l)) * j) + u
else
tmp = u + ((l ** 3.0d0) * (j * (cos((k * 0.5d0)) * 0.3333333333333333d0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= 1.5e-21) {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))))));
} else if (l <= 6.6e+45) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} else {
tmp = U + (Math.pow(l, 3.0) * (J * (Math.cos((K * 0.5)) * 0.3333333333333333)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= 1.5e-21: tmp = U + (math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0)))))) elif l <= 6.6e+45: tmp = ((math.exp(l) - math.exp(-l)) * J) + U else: tmp = U + (math.pow(l, 3.0) * (J * (math.cos((K * 0.5)) * 0.3333333333333333))) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= 1.5e-21) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))))); elseif (l <= 6.6e+45) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); else tmp = Float64(U + Float64((l ^ 3.0) * Float64(J * Float64(cos(Float64(K * 0.5)) * 0.3333333333333333)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= 1.5e-21) tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0)))))); elseif (l <= 6.6e+45) tmp = ((exp(l) - exp(-l)) * J) + U; else tmp = U + ((l ^ 3.0) * (J * (cos((K * 0.5)) * 0.3333333333333333))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, 1.5e-21], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6.6e+45], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.5 \cdot 10^{-21}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\right)\\
\mathbf{elif}\;\ell \leq 6.6 \cdot 10^{+45}:\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{else}:\\
\;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot \left(\cos \left(K \cdot 0.5\right) \cdot 0.3333333333333333\right)\right)\\
\end{array}
\end{array}
if l < 1.49999999999999996e-21Initial program 82.4%
Taylor expanded in l around 0 92.8%
if 1.49999999999999996e-21 < l < 6.6000000000000001e45Initial program 100.0%
Taylor expanded in K around 0 88.2%
if 6.6000000000000001e45 < l Initial program 100.0%
Taylor expanded in l around 0 90.6%
Taylor expanded in l around inf 90.6%
*-commutative90.6%
associate-*r*90.6%
associate-*l*90.6%
*-commutative90.6%
associate-*r*90.6%
*-commutative90.6%
associate-*l*90.6%
Simplified90.6%
Final simplification92.1%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.01) (+ U (* 2.0 (* J (* l (cos (* K 0.5)))))) (+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.01) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.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) :: tmp
if (cos((k / 2.0d0)) <= (-0.01d0)) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
else
tmp = u + (j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0)))))
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.01) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.01: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) else: tmp = U + (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0))))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.01) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); else tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.01) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); else tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 84.7%
Taylor expanded in l around 0 52.9%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 87.9%
Taylor expanded in l around 0 89.0%
Taylor expanded in K around 0 85.6%
Final simplification76.8%
(FPCore (J l K U) :precision binary64 (if (or (<= l -0.000118) (not (<= l 1.5e-21))) (+ (* (- (exp l) (exp (- l))) J) U) (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -0.000118) || !(l <= 1.5e-21)) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} else {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
}
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 <= (-0.000118d0)) .or. (.not. (l <= 1.5d-21))) then
tmp = ((exp(l) - exp(-l)) * j) + u
else
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -0.000118) || !(l <= 1.5e-21)) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} else {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -0.000118) or not (l <= 1.5e-21): tmp = ((math.exp(l) - math.exp(-l)) * J) + U else: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -0.000118) || !(l <= 1.5e-21)) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -0.000118) || ~((l <= 1.5e-21))) tmp = ((exp(l) - exp(-l)) * J) + U; else tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -0.000118], N[Not[LessEqual[l, 1.5e-21]], $MachinePrecision]], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -0.000118 \lor \neg \left(\ell \leq 1.5 \cdot 10^{-21}\right):\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if l < -1.18e-4 or 1.49999999999999996e-21 < l Initial program 100.0%
Taylor expanded in K around 0 69.1%
if -1.18e-4 < l < 1.49999999999999996e-21Initial program 72.3%
Taylor expanded in l around 0 99.9%
Final simplification83.6%
(FPCore (J l K U) :precision binary64 (if (or (<= l -650.0) (not (<= l 155000.0))) (+ U (* (pow l 3.0) (* J 0.3333333333333333))) (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -650.0) || !(l <= 155000.0)) {
tmp = U + (pow(l, 3.0) * (J * 0.3333333333333333));
} else {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
}
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 <= (-650.0d0)) .or. (.not. (l <= 155000.0d0))) then
tmp = u + ((l ** 3.0d0) * (j * 0.3333333333333333d0))
else
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -650.0) || !(l <= 155000.0)) {
tmp = U + (Math.pow(l, 3.0) * (J * 0.3333333333333333));
} else {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -650.0) or not (l <= 155000.0): tmp = U + (math.pow(l, 3.0) * (J * 0.3333333333333333)) else: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -650.0) || !(l <= 155000.0)) tmp = Float64(U + Float64((l ^ 3.0) * Float64(J * 0.3333333333333333))); else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -650.0) || ~((l <= 155000.0))) tmp = U + ((l ^ 3.0) * (J * 0.3333333333333333)); else tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -650.0], N[Not[LessEqual[l, 155000.0]], $MachinePrecision]], N[(U + N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -650 \lor \neg \left(\ell \leq 155000\right):\\
\;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if l < -650 or 155000 < l Initial program 100.0%
Taylor expanded in l around 0 78.0%
Taylor expanded in l around inf 78.0%
*-commutative78.0%
associate-*r*78.0%
associate-*l*78.0%
*-commutative78.0%
associate-*r*78.0%
*-commutative78.0%
associate-*l*78.0%
Simplified78.0%
Taylor expanded in K around 0 53.3%
if -650 < l < 155000Initial program 73.6%
Taylor expanded in l around 0 98.6%
Final simplification75.6%
(FPCore (J l K U) :precision binary64 (if (or (<= l -2.5) (not (<= l 7.5))) (+ U (* (pow l 3.0) (* J 0.3333333333333333))) (+ U (* l (* J 2.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.5) || !(l <= 7.5)) {
tmp = U + (pow(l, 3.0) * (J * 0.3333333333333333));
} else {
tmp = U + (l * (J * 2.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) :: tmp
if ((l <= (-2.5d0)) .or. (.not. (l <= 7.5d0))) then
tmp = u + ((l ** 3.0d0) * (j * 0.3333333333333333d0))
else
tmp = u + (l * (j * 2.0d0))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.5) || !(l <= 7.5)) {
tmp = U + (Math.pow(l, 3.0) * (J * 0.3333333333333333));
} else {
tmp = U + (l * (J * 2.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -2.5) or not (l <= 7.5): tmp = U + (math.pow(l, 3.0) * (J * 0.3333333333333333)) else: tmp = U + (l * (J * 2.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -2.5) || !(l <= 7.5)) tmp = Float64(U + Float64((l ^ 3.0) * Float64(J * 0.3333333333333333))); else tmp = Float64(U + Float64(l * Float64(J * 2.0))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -2.5) || ~((l <= 7.5))) tmp = U + ((l ^ 3.0) * (J * 0.3333333333333333)); else tmp = U + (l * (J * 2.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -2.5], N[Not[LessEqual[l, 7.5]], $MachinePrecision]], N[(U + N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.5 \lor \neg \left(\ell \leq 7.5\right):\\
\;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(J \cdot 2\right)\\
\end{array}
\end{array}
if l < -2.5 or 7.5 < l Initial program 100.0%
Taylor expanded in l around 0 77.4%
Taylor expanded in l around inf 77.4%
*-commutative77.4%
associate-*r*77.4%
associate-*l*77.4%
*-commutative77.4%
associate-*r*77.4%
*-commutative77.4%
associate-*l*77.4%
Simplified77.4%
Taylor expanded in K around 0 52.9%
if -2.5 < l < 7.5Initial program 73.4%
Taylor expanded in l around 0 99.3%
associate-*r*99.3%
Simplified99.3%
Taylor expanded in K around 0 85.6%
associate-*r*85.6%
*-commutative85.6%
*-commutative85.6%
Simplified85.6%
Final simplification68.9%
(FPCore (J l K U) :precision binary64 (if (or (<= l -690.0) (not (<= l 1350000.0))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -690.0) || !(l <= 1350000.0)) {
tmp = U * U;
} else {
tmp = 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 <= (-690.0d0)) .or. (.not. (l <= 1350000.0d0))) then
tmp = u * u
else
tmp = u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -690.0) || !(l <= 1350000.0)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -690.0) or not (l <= 1350000.0): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -690.0) || !(l <= 1350000.0)) tmp = Float64(U * U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -690.0) || ~((l <= 1350000.0))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -690.0], N[Not[LessEqual[l, 1350000.0]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -690 \lor \neg \left(\ell \leq 1350000\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -690 or 1.35e6 < l Initial program 100.0%
Applied egg-rr13.8%
if -690 < l < 1.35e6Initial program 73.8%
Taylor expanded in J around 0 71.4%
Final simplification42.4%
(FPCore (J l K U) :precision binary64 (+ U (* l (* J 2.0))))
double code(double J, double l, double K, double U) {
return U + (l * (J * 2.0));
}
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 + (l * (j * 2.0d0))
end function
public static double code(double J, double l, double K, double U) {
return U + (l * (J * 2.0));
}
def code(J, l, K, U): return U + (l * (J * 2.0))
function code(J, l, K, U) return Float64(U + Float64(l * Float64(J * 2.0))) end
function tmp = code(J, l, K, U) tmp = U + (l * (J * 2.0)); end
code[J_, l_, K_, U_] := N[(U + N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \ell \cdot \left(J \cdot 2\right)
\end{array}
Initial program 87.0%
Taylor expanded in l around 0 60.6%
associate-*r*60.6%
Simplified60.6%
Taylor expanded in K around 0 50.4%
associate-*r*50.4%
*-commutative50.4%
*-commutative50.4%
Simplified50.4%
Final simplification50.4%
(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 87.0%
Taylor expanded in J around 0 36.8%
(FPCore (J l K U) :precision binary64 1.0)
double code(double J, double l, double K, double U) {
return 1.0;
}
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 = 1.0d0
end function
public static double code(double J, double l, double K, double U) {
return 1.0;
}
def code(J, l, K, U): return 1.0
function code(J, l, K, U) return 1.0 end
function tmp = code(J, l, K, U) tmp = 1.0; end
code[J_, l_, K_, U_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 87.0%
Applied egg-rr2.5%
*-inverses2.5%
Simplified2.5%
herbie shell --seed 2024111
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))