
(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 12 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 (* (* J (cos (* K 0.5))) (* l 2.0))))))
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 + ((J * cos((K * 0.5))) * (l * 2.0));
}
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 + ((J * Math.cos((K * 0.5))) * (l * 2.0));
}
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 + ((J * math.cos((K * 0.5))) * (l * 2.0)) 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(Float64(J * cos(Float64(K * 0.5))) * Float64(l * 2.0))); 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 + ((J * cos((K * 0.5))) * (l * 2.0)); 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[(N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(l * 2.0), $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 + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(\ell \cdot 2\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 75.3%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
*-commutative99.9%
associate-*r*99.9%
associate-*r*99.9%
*-commutative99.9%
*-commutative99.9%
distribute-lft-out99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
*-commutative99.9%
associate-*l*99.9%
associate-*l*99.9%
*-commutative99.9%
Simplified99.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) (* t_0 (* J 0.3333333333333333)))))
(t_2 (+ (* (- (exp l) (exp (- l))) J) U)))
(if (<= l -2.1e+102)
t_1
(if (<= l -8000.0)
t_2
(if (<= l 1.3e-22)
(+ U (* (* J t_0) (* l 2.0)))
(if (<= l 5.6e+102) 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) * (t_0 * (J * 0.3333333333333333)));
double t_2 = ((exp(l) - exp(-l)) * J) + U;
double tmp;
if (l <= -2.1e+102) {
tmp = t_1;
} else if (l <= -8000.0) {
tmp = t_2;
} else if (l <= 1.3e-22) {
tmp = U + ((J * t_0) * (l * 2.0));
} else if (l <= 5.6e+102) {
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) * (t_0 * (j * 0.3333333333333333d0)))
t_2 = ((exp(l) - exp(-l)) * j) + u
if (l <= (-2.1d+102)) then
tmp = t_1
else if (l <= (-8000.0d0)) then
tmp = t_2
else if (l <= 1.3d-22) then
tmp = u + ((j * t_0) * (l * 2.0d0))
else if (l <= 5.6d+102) 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) * (t_0 * (J * 0.3333333333333333)));
double t_2 = ((Math.exp(l) - Math.exp(-l)) * J) + U;
double tmp;
if (l <= -2.1e+102) {
tmp = t_1;
} else if (l <= -8000.0) {
tmp = t_2;
} else if (l <= 1.3e-22) {
tmp = U + ((J * t_0) * (l * 2.0));
} else if (l <= 5.6e+102) {
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) * (t_0 * (J * 0.3333333333333333))) t_2 = ((math.exp(l) - math.exp(-l)) * J) + U tmp = 0 if l <= -2.1e+102: tmp = t_1 elif l <= -8000.0: tmp = t_2 elif l <= 1.3e-22: tmp = U + ((J * t_0) * (l * 2.0)) elif l <= 5.6e+102: 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(t_0 * Float64(J * 0.3333333333333333)))) t_2 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) tmp = 0.0 if (l <= -2.1e+102) tmp = t_1; elseif (l <= -8000.0) tmp = t_2; elseif (l <= 1.3e-22) tmp = Float64(U + Float64(Float64(J * t_0) * Float64(l * 2.0))); elseif (l <= 5.6e+102) 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) * (t_0 * (J * 0.3333333333333333))); t_2 = ((exp(l) - exp(-l)) * J) + U; tmp = 0.0; if (l <= -2.1e+102) tmp = t_1; elseif (l <= -8000.0) tmp = t_2; elseif (l <= 1.3e-22) tmp = U + ((J * t_0) * (l * 2.0)); elseif (l <= 5.6e+102) 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[(t$95$0 * N[(J * 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.1e+102], t$95$1, If[LessEqual[l, -8000.0], t$95$2, If[LessEqual[l, 1.3e-22], N[(U + N[(N[(J * t$95$0), $MachinePrecision] * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5.6e+102], 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(t\_0 \cdot \left(J \cdot 0.3333333333333333\right)\right)\\
t_2 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{if}\;\ell \leq -2.1 \cdot 10^{+102}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq -8000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\ell \leq 1.3 \cdot 10^{-22}:\\
\;\;\;\;U + \left(J \cdot t\_0\right) \cdot \left(\ell \cdot 2\right)\\
\mathbf{elif}\;\ell \leq 5.6 \cdot 10^{+102}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if l < -2.10000000000000001e102 or 5.60000000000000037e102 < l Initial program 100.0%
Taylor expanded in l around 0 100.0%
Taylor expanded in l around inf 100.0%
*-commutative100.0%
associate-*r*100.0%
associate-*l*100.0%
*-commutative100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
if -2.10000000000000001e102 < l < -8e3 or 1.3e-22 < l < 5.60000000000000037e102Initial program 100.0%
Taylor expanded in K around 0 77.8%
if -8e3 < l < 1.3e-22Initial program 75.3%
Taylor expanded in l around 0 99.2%
*-commutative99.2%
*-commutative99.2%
associate-*r*99.2%
associate-*r*99.2%
*-commutative99.2%
*-commutative99.2%
distribute-lft-out99.2%
fma-define99.2%
Simplified99.2%
Taylor expanded in l around 0 99.2%
*-commutative99.2%
*-commutative99.2%
associate-*l*99.2%
associate-*l*99.2%
*-commutative99.2%
Simplified99.2%
Final simplification95.7%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.5) (+ U (* (* J (cos (* K 0.5))) (* l 2.0))) (* U (+ 1.0 (/ (* 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.5) {
tmp = U + ((J * cos((K * 0.5))) * (l * 2.0));
} else {
tmp = U * (1.0 + ((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.5d0) then
tmp = u + ((j * cos((k * 0.5d0))) * (l * 2.0d0))
else
tmp = u * (1.0d0 + ((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.5) {
tmp = U + ((J * Math.cos((K * 0.5))) * (l * 2.0));
} else {
tmp = U * (1.0 + ((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.5: tmp = U + ((J * math.cos((K * 0.5))) * (l * 2.0)) else: tmp = U * (1.0 + ((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.5) tmp = Float64(U + Float64(Float64(J * cos(Float64(K * 0.5))) * Float64(l * 2.0))); else tmp = Float64(U * Float64(1.0 + 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.5) tmp = U + ((J * cos((K * 0.5))) * (l * 2.0)); else tmp = U * (1.0 + ((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.5], N[(U + N[(N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U * N[(1.0 + N[(N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.5:\\
\;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(\ell \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;U \cdot \left(1 + \frac{J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)}{U}\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.5Initial program 90.6%
Taylor expanded in l around 0 81.6%
*-commutative81.6%
*-commutative81.6%
associate-*r*81.6%
associate-*r*81.6%
*-commutative81.6%
*-commutative81.6%
distribute-lft-out81.6%
fma-define81.6%
Simplified81.6%
Taylor expanded in l around 0 58.3%
*-commutative58.3%
*-commutative58.3%
associate-*l*58.3%
associate-*l*58.3%
*-commutative58.3%
Simplified58.3%
if 0.5 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 87.0%
Taylor expanded in l around 0 88.1%
Taylor expanded in K around 0 85.6%
Taylor expanded in U around inf 88.7%
Final simplification79.4%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.5) (+ U (* (* J (cos (* K 0.5))) (* l 2.0))) (+ 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.5) {
tmp = U + ((J * cos((K * 0.5))) * (l * 2.0));
} 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.5d0) then
tmp = u + ((j * cos((k * 0.5d0))) * (l * 2.0d0))
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.5) {
tmp = U + ((J * Math.cos((K * 0.5))) * (l * 2.0));
} 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.5: tmp = U + ((J * math.cos((K * 0.5))) * (l * 2.0)) 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.5) tmp = Float64(U + Float64(Float64(J * cos(Float64(K * 0.5))) * Float64(l * 2.0))); 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.5) tmp = U + ((J * cos((K * 0.5))) * (l * 2.0)); 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.5], N[(U + N[(N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(l * 2.0), $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.5:\\
\;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(\ell \cdot 2\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.5Initial program 90.6%
Taylor expanded in l around 0 81.6%
*-commutative81.6%
*-commutative81.6%
associate-*r*81.6%
associate-*r*81.6%
*-commutative81.6%
*-commutative81.6%
distribute-lft-out81.6%
fma-define81.6%
Simplified81.6%
Taylor expanded in l around 0 58.3%
*-commutative58.3%
*-commutative58.3%
associate-*l*58.3%
associate-*l*58.3%
*-commutative58.3%
Simplified58.3%
if 0.5 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 87.0%
Taylor expanded in l around 0 88.1%
Taylor expanded in K around 0 85.6%
Final simplification77.3%
(FPCore (J l K U) :precision binary64 (if (or (<= l -8000.0) (not (<= l 1.3e-22))) (+ (* (- (exp l) (exp (- l))) J) U) (+ U (* (* J (cos (* K 0.5))) (* l 2.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -8000.0) || !(l <= 1.3e-22)) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} else {
tmp = U + ((J * cos((K * 0.5))) * (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 ((l <= (-8000.0d0)) .or. (.not. (l <= 1.3d-22))) then
tmp = ((exp(l) - exp(-l)) * j) + u
else
tmp = u + ((j * cos((k * 0.5d0))) * (l * 2.0d0))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -8000.0) || !(l <= 1.3e-22)) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} else {
tmp = U + ((J * Math.cos((K * 0.5))) * (l * 2.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -8000.0) or not (l <= 1.3e-22): tmp = ((math.exp(l) - math.exp(-l)) * J) + U else: tmp = U + ((J * math.cos((K * 0.5))) * (l * 2.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -8000.0) || !(l <= 1.3e-22)) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); else tmp = Float64(U + Float64(Float64(J * cos(Float64(K * 0.5))) * Float64(l * 2.0))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -8000.0) || ~((l <= 1.3e-22))) tmp = ((exp(l) - exp(-l)) * J) + U; else tmp = U + ((J * cos((K * 0.5))) * (l * 2.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -8000.0], N[Not[LessEqual[l, 1.3e-22]], $MachinePrecision]], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -8000 \lor \neg \left(\ell \leq 1.3 \cdot 10^{-22}\right):\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{else}:\\
\;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(\ell \cdot 2\right)\\
\end{array}
\end{array}
if l < -8e3 or 1.3e-22 < l Initial program 100.0%
Taylor expanded in K around 0 69.9%
if -8e3 < l < 1.3e-22Initial program 75.3%
Taylor expanded in l around 0 99.2%
*-commutative99.2%
*-commutative99.2%
associate-*r*99.2%
associate-*r*99.2%
*-commutative99.2%
*-commutative99.2%
distribute-lft-out99.2%
fma-define99.2%
Simplified99.2%
Taylor expanded in l around 0 99.2%
*-commutative99.2%
*-commutative99.2%
associate-*l*99.2%
associate-*l*99.2%
*-commutative99.2%
Simplified99.2%
Final simplification84.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ U (* 0.3333333333333333 (* J (pow l 3.0))))))
(if (<= l -2.5e+39)
t_0
(if (<= l 1050.0)
(+ U (* J (* l 2.0)))
(if (<= l 2.8e+92) (pow U -3.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 <= -2.5e+39) {
tmp = t_0;
} else if (l <= 1050.0) {
tmp = U + (J * (l * 2.0));
} else if (l <= 2.8e+92) {
tmp = pow(U, -3.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 <= (-2.5d+39)) then
tmp = t_0
else if (l <= 1050.0d0) then
tmp = u + (j * (l * 2.0d0))
else if (l <= 2.8d+92) then
tmp = u ** (-3.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 <= -2.5e+39) {
tmp = t_0;
} else if (l <= 1050.0) {
tmp = U + (J * (l * 2.0));
} else if (l <= 2.8e+92) {
tmp = Math.pow(U, -3.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 <= -2.5e+39: tmp = t_0 elif l <= 1050.0: tmp = U + (J * (l * 2.0)) elif l <= 2.8e+92: tmp = math.pow(U, -3.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 <= -2.5e+39) tmp = t_0; elseif (l <= 1050.0) tmp = Float64(U + Float64(J * Float64(l * 2.0))); elseif (l <= 2.8e+92) tmp = U ^ -3.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 <= -2.5e+39) tmp = t_0; elseif (l <= 1050.0) tmp = U + (J * (l * 2.0)); elseif (l <= 2.8e+92) tmp = U ^ -3.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, -2.5e+39], t$95$0, If[LessEqual[l, 1050.0], N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.8e+92], N[Power[U, -3.0], $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 -2.5 \cdot 10^{+39}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq 1050:\\
\;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\
\mathbf{elif}\;\ell \leq 2.8 \cdot 10^{+92}:\\
\;\;\;\;{U}^{-3}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -2.50000000000000008e39 or 2.80000000000000001e92 < l Initial program 100.0%
Taylor expanded in l around 0 89.9%
Taylor expanded in l around inf 89.9%
*-commutative89.9%
associate-*r*89.9%
associate-*l*89.9%
*-commutative89.9%
associate-*r*89.9%
*-commutative89.9%
Simplified89.9%
Taylor expanded in K around 0 59.8%
if -2.50000000000000008e39 < l < 1050Initial program 77.0%
Taylor expanded in l around 0 94.8%
Taylor expanded in K around 0 86.2%
Taylor expanded in l around 0 86.2%
*-commutative86.2%
associate-*r*86.2%
*-commutative86.2%
Simplified86.2%
if 1050 < l < 2.80000000000000001e92Initial program 100.0%
Applied egg-rr43.6%
Final simplification72.1%
(FPCore (J l K U) :precision binary64 (if (or (<= J -3.5e+123) (not (<= J 1.05e+61))) (+ U (* 2.0 (* J (* l (cos (* K 0.5)))))) (+ U (* 0.3333333333333333 (* J (pow l 3.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((J <= -3.5e+123) || !(J <= 1.05e+61)) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} 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 ((j <= (-3.5d+123)) .or. (.not. (j <= 1.05d+61))) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
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 ((J <= -3.5e+123) || !(J <= 1.05e+61)) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else {
tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (J <= -3.5e+123) or not (J <= 1.05e+61): tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) else: tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((J <= -3.5e+123) || !(J <= 1.05e+61)) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); 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 ((J <= -3.5e+123) || ~((J <= 1.05e+61))) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); else tmp = U + (0.3333333333333333 * (J * (l ^ 3.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[J, -3.5e+123], N[Not[LessEqual[J, 1.05e+61]], $MachinePrecision]], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $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}\;J \leq -3.5 \cdot 10^{+123} \lor \neg \left(J \leq 1.05 \cdot 10^{+61}\right):\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\end{array}
\end{array}
if J < -3.5e123 or 1.0500000000000001e61 < J Initial program 71.9%
Taylor expanded in l around 0 88.2%
if -3.5e123 < J < 1.0500000000000001e61Initial program 96.6%
Taylor expanded in l around 0 83.3%
Taylor expanded in l around inf 80.0%
*-commutative80.0%
associate-*r*80.0%
associate-*l*80.0%
*-commutative80.0%
associate-*r*80.0%
*-commutative80.0%
Simplified80.0%
Taylor expanded in K around 0 68.7%
Final simplification75.4%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* K 0.5))))
(if (<= J -3.4e+123)
(+ U (* 2.0 (* J (* l t_0))))
(if (<= J 4.2e+59)
(+ U (* 0.3333333333333333 (* J (pow l 3.0))))
(+ U (* (* J t_0) (* l 2.0)))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K * 0.5));
double tmp;
if (J <= -3.4e+123) {
tmp = U + (2.0 * (J * (l * t_0)));
} else if (J <= 4.2e+59) {
tmp = U + (0.3333333333333333 * (J * pow(l, 3.0)));
} else {
tmp = U + ((J * t_0) * (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) :: t_0
real(8) :: tmp
t_0 = cos((k * 0.5d0))
if (j <= (-3.4d+123)) then
tmp = u + (2.0d0 * (j * (l * t_0)))
else if (j <= 4.2d+59) then
tmp = u + (0.3333333333333333d0 * (j * (l ** 3.0d0)))
else
tmp = u + ((j * t_0) * (l * 2.0d0))
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 tmp;
if (J <= -3.4e+123) {
tmp = U + (2.0 * (J * (l * t_0)));
} else if (J <= 4.2e+59) {
tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
} else {
tmp = U + ((J * t_0) * (l * 2.0));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K * 0.5)) tmp = 0 if J <= -3.4e+123: tmp = U + (2.0 * (J * (l * t_0))) elif J <= 4.2e+59: tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) else: tmp = U + ((J * t_0) * (l * 2.0)) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K * 0.5)) tmp = 0.0 if (J <= -3.4e+123) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * t_0)))); elseif (J <= 4.2e+59) tmp = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))); else tmp = Float64(U + Float64(Float64(J * t_0) * Float64(l * 2.0))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K * 0.5)); tmp = 0.0; if (J <= -3.4e+123) tmp = U + (2.0 * (J * (l * t_0))); elseif (J <= 4.2e+59) tmp = U + (0.3333333333333333 * (J * (l ^ 3.0))); else tmp = U + ((J * t_0) * (l * 2.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[J, -3.4e+123], N[(U + N[(2.0 * N[(J * N[(l * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 4.2e+59], N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(J * t$95$0), $MachinePrecision] * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
\mathbf{if}\;J \leq -3.4 \cdot 10^{+123}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot t\_0\right)\right)\\
\mathbf{elif}\;J \leq 4.2 \cdot 10^{+59}:\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(J \cdot t\_0\right) \cdot \left(\ell \cdot 2\right)\\
\end{array}
\end{array}
if J < -3.40000000000000001e123Initial program 68.1%
Taylor expanded in l around 0 93.4%
if -3.40000000000000001e123 < J < 4.19999999999999968e59Initial program 96.6%
Taylor expanded in l around 0 83.3%
Taylor expanded in l around inf 80.0%
*-commutative80.0%
associate-*r*80.0%
associate-*l*80.0%
*-commutative80.0%
associate-*r*80.0%
*-commutative80.0%
Simplified80.0%
Taylor expanded in K around 0 68.7%
if 4.19999999999999968e59 < J Initial program 75.2%
Taylor expanded in l around 0 94.0%
*-commutative94.0%
*-commutative94.0%
associate-*r*94.0%
associate-*r*94.0%
*-commutative94.0%
*-commutative94.0%
distribute-lft-out94.0%
fma-define94.0%
Simplified94.0%
Taylor expanded in l around 0 83.8%
*-commutative83.8%
*-commutative83.8%
associate-*l*83.8%
associate-*l*83.8%
*-commutative83.8%
Simplified83.8%
Final simplification75.4%
(FPCore (J l K U) :precision binary64 (if (or (<= l -1.35e+41) (not (<= l 12000000000.0))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1.35e+41) || !(l <= 12000000000.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 <= (-1.35d+41)) .or. (.not. (l <= 12000000000.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 <= -1.35e+41) || !(l <= 12000000000.0)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -1.35e+41) or not (l <= 12000000000.0): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -1.35e+41) || !(l <= 12000000000.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 <= -1.35e+41) || ~((l <= 12000000000.0))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -1.35e+41], N[Not[LessEqual[l, 12000000000.0]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.35 \cdot 10^{+41} \lor \neg \left(\ell \leq 12000000000\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -1.35e41 or 1.2e10 < l Initial program 100.0%
Applied egg-rr17.9%
if -1.35e41 < l < 1.2e10Initial program 77.5%
Taylor expanded in J around 0 70.3%
Final simplification45.5%
(FPCore (J l K U) :precision binary64 (+ U (* J (* l 2.0))))
double code(double J, double l, double K, double U) {
return U + (J * (l * 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 + (j * (l * 2.0d0))
end function
public static double code(double J, double l, double K, double U) {
return U + (J * (l * 2.0));
}
def code(J, l, K, U): return U + (J * (l * 2.0))
function code(J, l, K, U) return Float64(U + Float64(J * Float64(l * 2.0))) end
function tmp = code(J, l, K, U) tmp = U + (J * (l * 2.0)); end
code[J_, l_, K_, U_] := N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + J \cdot \left(\ell \cdot 2\right)
\end{array}
Initial program 88.1%
Taylor expanded in l around 0 88.0%
Taylor expanded in K around 0 69.8%
Taylor expanded in l around 0 54.9%
*-commutative54.9%
associate-*r*54.9%
*-commutative54.9%
Simplified54.9%
Final simplification54.9%
(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 88.1%
Applied egg-rr2.7%
*-inverses2.7%
Simplified2.7%
Final simplification2.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 88.1%
Taylor expanded in J around 0 38.1%
Final simplification38.1%
herbie shell --seed 2024073
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))