
(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 9 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 -1e+144) (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 <= -1e+144) || !(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;
}
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 ((t_0 <= (-1d+144)) .or. (.not. (t_0 <= 0.0d0))) then
tmp = ((t_0 * j) * cos((k / 2.0d0))) + 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 t_0 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_0 <= -1e+144) || !(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 <= -1e+144) 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 <= -1e+144) || !(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 <= -1e+144) || ~((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, -1e+144], 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 -1 \cdot 10^{+144} \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))) < -1.00000000000000002e144 or 0.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -1.00000000000000002e144 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0Initial program 73.6%
Taylor expanded in l around 0 99.9%
Final simplification100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ U (* (cos (/ K 2.0)) (* (pow l 3.0) (* J 0.3333333333333333)))))
(t_1 (+ (* (- (exp l) (exp (- l))) J) U)))
(if (<= l -2.5e+108)
t_0
(if (<= l -21500000.0)
t_1
(if (<= l 2.15e-16)
(+ U (* 2.0 (* J (* l (cos (* K 0.5))))))
(if (<= l 6e+83) t_1 t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + (cos((K / 2.0)) * (pow(l, 3.0) * (J * 0.3333333333333333)));
double t_1 = ((exp(l) - exp(-l)) * J) + 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 = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else if (l <= 6e+83) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = u + (cos((k / 2.0d0)) * ((l ** 3.0d0) * (j * 0.3333333333333333d0)))
t_1 = ((exp(l) - exp(-l)) * j) + u
if (l <= (-2.5d+108)) then
tmp = t_0
else if (l <= (-21500000.0d0)) then
tmp = t_1
else if (l <= 2.15d-16) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
else if (l <= 6d+83) then
tmp = t_1
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 = U + (Math.cos((K / 2.0)) * (Math.pow(l, 3.0) * (J * 0.3333333333333333)));
double t_1 = ((Math.exp(l) - Math.exp(-l)) * J) + 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 = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else if (l <= 6e+83) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (math.cos((K / 2.0)) * (math.pow(l, 3.0) * (J * 0.3333333333333333))) t_1 = ((math.exp(l) - math.exp(-l)) * J) + U tmp = 0 if l <= -2.5e+108: tmp = t_0 elif l <= -21500000.0: tmp = t_1 elif l <= 2.15e-16: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) elif l <= 6e+83: tmp = t_1 else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64((l ^ 3.0) * Float64(J * 0.3333333333333333)))) t_1 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + 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(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); elseif (l <= 6e+83) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + (cos((K / 2.0)) * ((l ^ 3.0) * (J * 0.3333333333333333))); t_1 = ((exp(l) - exp(-l)) * J) + 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 = U + (2.0 * (J * (l * cos((K * 0.5))))); elseif (l <= 6e+83) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $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[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6e+83], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\
t_1 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + 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}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\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%
associate-*r*100.0%
*-commutative100.0%
*-commutative100.0%
Simplified100.0%
if -2.49999999999999995e108 < l < -2.15e7 or 2.1499999999999999e-16 < l < 5.9999999999999999e83Initial program 100.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%
Final simplification94.5%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.02) (+ U (* 2.0 (* J (* l (cos (* K 0.5)))))) (+ U (* J (+ (* (pow l 3.0) 0.3333333333333333) (* l 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.02) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else {
tmp = U + (J * ((pow(l, 3.0) * 0.3333333333333333) + (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.02d0)) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
else
tmp = u + (j * (((l ** 3.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.02) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else {
tmp = U + (J * ((Math.pow(l, 3.0) * 0.3333333333333333) + (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.02: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) else: tmp = U + (J * ((math.pow(l, 3.0) * 0.3333333333333333) + (l * 2.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.02) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); else tmp = Float64(U + Float64(J * Float64(Float64((l ^ 3.0) * 0.3333333333333333) + Float64(l * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.02) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); else tmp = U + (J * (((l ^ 3.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.02], 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[(N[(N[Power[l, 3.0], $MachinePrecision] * 0.3333333333333333), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
\;\;\;\;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}^{3} \cdot 0.3333333333333333 + \ell \cdot 2\right)\\
\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%
Final simplification77.5%
(FPCore (J l K U) :precision binary64 (if (or (<= l -21500000.0) (not (<= l 2.15e-16))) (+ (* (- (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 <= -21500000.0) || !(l <= 2.15e-16)) {
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 <= (-21500000.0d0)) .or. (.not. (l <= 2.15d-16))) 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 <= -21500000.0) || !(l <= 2.15e-16)) {
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 <= -21500000.0) or not (l <= 2.15e-16): 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 <= -21500000.0) || !(l <= 2.15e-16)) 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 <= -21500000.0) || ~((l <= 2.15e-16))) 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, -21500000.0], N[Not[LessEqual[l, 2.15e-16]], $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 -21500000 \lor \neg \left(\ell \leq 2.15 \cdot 10^{-16}\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 < -2.15e7 or 2.1499999999999999e-16 < l Initial program 100.0%
Taylor expanded in K around 0 76.2%
if -2.15e7 < l < 2.1499999999999999e-16Initial program 74.2%
Taylor expanded in l around 0 98.3%
Final simplification87.4%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.02) (+ U (* (pow l 3.0) (* J -0.3333333333333333))) (+ U (* 0.3333333333333333 (* J (pow l 3.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.02) {
tmp = U + (pow(l, 3.0) * (J * -0.3333333333333333));
} else {
tmp = U + (0.3333333333333333 * (J * pow(l, 3.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.02d0)) then
tmp = u + ((l ** 3.0d0) * (j * (-0.3333333333333333d0)))
else
tmp = u + (0.3333333333333333d0 * (j * (l ** 3.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.02) {
tmp = U + (Math.pow(l, 3.0) * (J * -0.3333333333333333));
} else {
tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.02: tmp = U + (math.pow(l, 3.0) * (J * -0.3333333333333333)) else: tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.02) tmp = Float64(U + Float64((l ^ 3.0) * Float64(J * -0.3333333333333333))); else tmp = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.02) tmp = U + ((l ^ 3.0) * (J * -0.3333333333333333)); else tmp = U + (0.3333333333333333 * (J * (l ^ 3.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.02], N[(U + N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
\;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot -0.3333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.0200000000000000004Initial program 85.4%
Taylor expanded in l around 0 82.7%
Taylor expanded in K around 0 37.6%
add-sqr-sqrt28.6%
sqrt-unprod57.3%
*-commutative57.3%
*-commutative57.3%
swap-sqr57.3%
pow-prod-up57.3%
metadata-eval57.3%
metadata-eval57.3%
Applied egg-rr57.3%
Taylor expanded in l around -inf 68.4%
*-commutative68.4%
*-commutative68.4%
associate-*l*68.4%
Simplified68.4%
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%
Taylor expanded in l around inf 71.7%
Final simplification70.8%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ U (* 0.3333333333333333 (* J (pow l 3.0))))))
(if (<= l -1.7e+46)
t_0
(if (<= l -410.0)
(+ U (* 0.020833333333333332 (* J (pow K 4.0))))
(if (<= l 3.8e+16) (+ U (* 2.0 (* J (* l (cos (* K 0.5)))))) t_0)))))
double code(double J, double l, double K, double U) {
double t_0 = U + (0.3333333333333333 * (J * pow(l, 3.0)));
double tmp;
if (l <= -1.7e+46) {
tmp = t_0;
} else if (l <= -410.0) {
tmp = U + (0.020833333333333332 * (J * pow(K, 4.0)));
} else if (l <= 3.8e+16) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} 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 = u + (0.3333333333333333d0 * (j * (l ** 3.0d0)))
if (l <= (-1.7d+46)) then
tmp = t_0
else if (l <= (-410.0d0)) then
tmp = u + (0.020833333333333332d0 * (j * (k ** 4.0d0)))
else if (l <= 3.8d+16) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
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 = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
double tmp;
if (l <= -1.7e+46) {
tmp = t_0;
} else if (l <= -410.0) {
tmp = U + (0.020833333333333332 * (J * Math.pow(K, 4.0)));
} else if (l <= 3.8e+16) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) tmp = 0 if l <= -1.7e+46: tmp = t_0 elif l <= -410.0: tmp = U + (0.020833333333333332 * (J * math.pow(K, 4.0))) elif l <= 3.8e+16: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))) tmp = 0.0 if (l <= -1.7e+46) tmp = t_0; elseif (l <= -410.0) tmp = Float64(U + Float64(0.020833333333333332 * Float64(J * (K ^ 4.0)))); elseif (l <= 3.8e+16) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + (0.3333333333333333 * (J * (l ^ 3.0))); tmp = 0.0; if (l <= -1.7e+46) tmp = t_0; elseif (l <= -410.0) tmp = U + (0.020833333333333332 * (J * (K ^ 4.0))); elseif (l <= 3.8e+16) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); else tmp = t_0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.7e+46], t$95$0, If[LessEqual[l, -410.0], N[(U + N[(0.020833333333333332 * N[(J * N[Power[K, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3.8e+16], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{if}\;\ell \leq -1.7 \cdot 10^{+46}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -410:\\
\;\;\;\;U + 0.020833333333333332 \cdot \left(J \cdot {K}^{4}\right)\\
\mathbf{elif}\;\ell \leq 3.8 \cdot 10^{+16}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -1.6999999999999999e46 or 3.8e16 < l Initial program 100.0%
Taylor expanded in l around 0 80.6%
Taylor expanded in K around 0 62.1%
Taylor expanded in l around inf 62.1%
if -1.6999999999999999e46 < l < -410Initial program 100.0%
Applied egg-rr1.2%
Taylor expanded in K around 0 12.6%
Taylor expanded in K around inf 48.2%
if -410 < l < 3.8e16Initial program 75.3%
Taylor expanded in l around 0 95.6%
Final simplification79.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ U (* 0.3333333333333333 (* J (pow l 3.0))))))
(if (<= l -5.8e+47)
t_0
(if (<= l -470.0)
(+ U (* 0.020833333333333332 (* J (pow K 4.0))))
(if (<= l 2.15e-16) (+ U (* l (* J 2.0))) t_0)))))
double code(double J, double l, double K, double U) {
double t_0 = U + (0.3333333333333333 * (J * pow(l, 3.0)));
double tmp;
if (l <= -5.8e+47) {
tmp = t_0;
} else if (l <= -470.0) {
tmp = U + (0.020833333333333332 * (J * pow(K, 4.0)));
} else if (l <= 2.15e-16) {
tmp = U + (l * (J * 2.0));
} 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 = u + (0.3333333333333333d0 * (j * (l ** 3.0d0)))
if (l <= (-5.8d+47)) then
tmp = t_0
else if (l <= (-470.0d0)) then
tmp = u + (0.020833333333333332d0 * (j * (k ** 4.0d0)))
else if (l <= 2.15d-16) then
tmp = u + (l * (j * 2.0d0))
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 = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
double tmp;
if (l <= -5.8e+47) {
tmp = t_0;
} else if (l <= -470.0) {
tmp = U + (0.020833333333333332 * (J * Math.pow(K, 4.0)));
} else if (l <= 2.15e-16) {
tmp = U + (l * (J * 2.0));
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) tmp = 0 if l <= -5.8e+47: tmp = t_0 elif l <= -470.0: tmp = U + (0.020833333333333332 * (J * math.pow(K, 4.0))) elif l <= 2.15e-16: tmp = U + (l * (J * 2.0)) else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))) tmp = 0.0 if (l <= -5.8e+47) tmp = t_0; elseif (l <= -470.0) tmp = Float64(U + Float64(0.020833333333333332 * Float64(J * (K ^ 4.0)))); elseif (l <= 2.15e-16) tmp = Float64(U + Float64(l * Float64(J * 2.0))); else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + (0.3333333333333333 * (J * (l ^ 3.0))); tmp = 0.0; if (l <= -5.8e+47) tmp = t_0; elseif (l <= -470.0) tmp = U + (0.020833333333333332 * (J * (K ^ 4.0))); elseif (l <= 2.15e-16) tmp = U + (l * (J * 2.0)); else tmp = t_0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -5.8e+47], t$95$0, If[LessEqual[l, -470.0], N[(U + N[(0.020833333333333332 * N[(J * N[Power[K, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.15e-16], N[(U + N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{if}\;\ell \leq -5.8 \cdot 10^{+47}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -470:\\
\;\;\;\;U + 0.020833333333333332 \cdot \left(J \cdot {K}^{4}\right)\\
\mathbf{elif}\;\ell \leq 2.15 \cdot 10^{-16}:\\
\;\;\;\;U + \ell \cdot \left(J \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -5.79999999999999961e47 or 2.1499999999999999e-16 < l Initial program 100.0%
Taylor expanded in l around 0 77.7%
Taylor expanded in K around 0 59.6%
Taylor expanded in l around inf 59.6%
if -5.79999999999999961e47 < l < -470Initial program 100.0%
Applied egg-rr1.2%
Taylor expanded in K around 0 12.6%
Taylor expanded in K around inf 48.2%
if -470 < l < 2.1499999999999999e-16Initial program 73.8%
Taylor expanded in l around 0 99.7%
Taylor expanded in K around 0 86.9%
associate-*r*86.9%
Simplified86.9%
Final simplification72.5%
(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 86.9%
Taylor expanded in l around 0 65.4%
Taylor expanded in K around 0 54.9%
associate-*r*54.9%
Simplified54.9%
Final simplification54.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%
Final simplification38.7%
herbie shell --seed 2024034
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))