
(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 14 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 2e-5)))
(+ (* (* t_0 J) (cos (/ K 2.0))) U)
(fma
J
(* (fma l 2.0 (* (pow l 3.0) 0.3333333333333333)) (cos (* K 0.5)))
U))))
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 <= 2e-5)) {
tmp = ((t_0 * J) * cos((K / 2.0))) + U;
} else {
tmp = fma(J, (fma(l, 2.0, (pow(l, 3.0) * 0.3333333333333333)) * cos((K * 0.5))), U);
}
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 <= 2e-5)) tmp = Float64(Float64(Float64(t_0 * J) * cos(Float64(K / 2.0))) + U); else tmp = fma(J, Float64(fma(l, 2.0, Float64((l ^ 3.0) * 0.3333333333333333)) * cos(Float64(K * 0.5))), U); end return 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, 2e-5]], $MachinePrecision]], N[(N[(N[(t$95$0 * J), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(J * N[(N[(l * 2.0 + N[(N[Power[l, 3.0], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $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 2 \cdot 10^{-5}\right):\\
\;\;\;\;\left(t_0 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J, \mathsf{fma}\left(\ell, 2, {\ell}^{3} \cdot 0.3333333333333333\right) \cdot \cos \left(K \cdot 0.5\right), U\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 2.00000000000000016e-5 < (-.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))) < 2.00000000000000016e-5Initial program 69.8%
Taylor expanded in l around 0 99.9%
+-commutative99.9%
associate-*r*99.9%
associate-*r*99.9%
associate-*r*99.9%
associate-*r*99.9%
distribute-rgt-out99.9%
associate-*r*99.9%
*-commutative99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in K around inf 99.9%
+-commutative99.9%
fma-def99.9%
*-commutative99.9%
*-commutative99.9%
*-commutative99.9%
associate-*r*99.9%
*-commutative99.9%
associate-*r*99.9%
distribute-lft-in99.9%
fma-udef99.8%
associate-*r*99.8%
*-commutative99.8%
*-commutative99.8%
*-commutative99.8%
associate-*r*99.9%
fma-def99.9%
Simplified99.9%
Final simplification100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 2e-5)))
(+ (* (* t_0 J) (cos (/ K 2.0))) U)
(+
U
(*
(cos (* K 0.5))
(+ (* l (* J 2.0)) (* 0.3333333333333333 (* J (pow l 3.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 <= 2e-5)) {
tmp = ((t_0 * J) * cos((K / 2.0))) + U;
} else {
tmp = U + (cos((K * 0.5)) * ((l * (J * 2.0)) + (0.3333333333333333 * (J * pow(l, 3.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 <= 2e-5)) {
tmp = ((t_0 * J) * Math.cos((K / 2.0))) + U;
} else {
tmp = U + (Math.cos((K * 0.5)) * ((l * (J * 2.0)) + (0.3333333333333333 * (J * Math.pow(l, 3.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 <= 2e-5): tmp = ((t_0 * J) * math.cos((K / 2.0))) + U else: tmp = U + (math.cos((K * 0.5)) * ((l * (J * 2.0)) + (0.3333333333333333 * (J * math.pow(l, 3.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 <= 2e-5)) tmp = Float64(Float64(Float64(t_0 * J) * cos(Float64(K / 2.0))) + U); else tmp = Float64(U + Float64(cos(Float64(K * 0.5)) * Float64(Float64(l * Float64(J * 2.0)) + Float64(0.3333333333333333 * Float64(J * (l ^ 3.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 <= 2e-5))) tmp = ((t_0 * J) * cos((K / 2.0))) + U; else tmp = U + (cos((K * 0.5)) * ((l * (J * 2.0)) + (0.3333333333333333 * (J * (l ^ 3.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, 2e-5]], $MachinePrecision]], N[(N[(N[(t$95$0 * J), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision] + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $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 2 \cdot 10^{-5}\right):\\
\;\;\;\;\left(t_0 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + \cos \left(K \cdot 0.5\right) \cdot \left(\ell \cdot \left(J \cdot 2\right) + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 2.00000000000000016e-5 < (-.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))) < 2.00000000000000016e-5Initial program 69.8%
Taylor expanded in l around 0 99.9%
+-commutative99.9%
associate-*r*99.9%
associate-*r*99.9%
associate-*r*99.9%
associate-*r*99.9%
distribute-rgt-out99.9%
associate-*r*99.9%
*-commutative99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ (* (- (exp l) (exp (- l))) J) U))
(t_1 (cos (* K 0.5)))
(t_2 (* 0.3333333333333333 (* J (* (pow l 3.0) t_1)))))
(if (<= l -2.4e+137)
t_2
(if (<= l -0.07)
t_0
(if (<= l 0.092)
(+
U
(* t_1 (+ (* l (* J 2.0)) (* 0.3333333333333333 (* J (pow l 3.0))))))
(if (<= l 2.35e+101) t_0 t_2))))))
double code(double J, double l, double K, double U) {
double t_0 = ((exp(l) - exp(-l)) * J) + U;
double t_1 = cos((K * 0.5));
double t_2 = 0.3333333333333333 * (J * (pow(l, 3.0) * t_1));
double tmp;
if (l <= -2.4e+137) {
tmp = t_2;
} else if (l <= -0.07) {
tmp = t_0;
} else if (l <= 0.092) {
tmp = U + (t_1 * ((l * (J * 2.0)) + (0.3333333333333333 * (J * pow(l, 3.0)))));
} else if (l <= 2.35e+101) {
tmp = t_0;
} 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 = ((exp(l) - exp(-l)) * j) + u
t_1 = cos((k * 0.5d0))
t_2 = 0.3333333333333333d0 * (j * ((l ** 3.0d0) * t_1))
if (l <= (-2.4d+137)) then
tmp = t_2
else if (l <= (-0.07d0)) then
tmp = t_0
else if (l <= 0.092d0) then
tmp = u + (t_1 * ((l * (j * 2.0d0)) + (0.3333333333333333d0 * (j * (l ** 3.0d0)))))
else if (l <= 2.35d+101) then
tmp = t_0
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.exp(l) - Math.exp(-l)) * J) + U;
double t_1 = Math.cos((K * 0.5));
double t_2 = 0.3333333333333333 * (J * (Math.pow(l, 3.0) * t_1));
double tmp;
if (l <= -2.4e+137) {
tmp = t_2;
} else if (l <= -0.07) {
tmp = t_0;
} else if (l <= 0.092) {
tmp = U + (t_1 * ((l * (J * 2.0)) + (0.3333333333333333 * (J * Math.pow(l, 3.0)))));
} else if (l <= 2.35e+101) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(J, l, K, U): t_0 = ((math.exp(l) - math.exp(-l)) * J) + U t_1 = math.cos((K * 0.5)) t_2 = 0.3333333333333333 * (J * (math.pow(l, 3.0) * t_1)) tmp = 0 if l <= -2.4e+137: tmp = t_2 elif l <= -0.07: tmp = t_0 elif l <= 0.092: tmp = U + (t_1 * ((l * (J * 2.0)) + (0.3333333333333333 * (J * math.pow(l, 3.0))))) elif l <= 2.35e+101: tmp = t_0 else: tmp = t_2 return tmp
function code(J, l, K, U) t_0 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) t_1 = cos(Float64(K * 0.5)) t_2 = Float64(0.3333333333333333 * Float64(J * Float64((l ^ 3.0) * t_1))) tmp = 0.0 if (l <= -2.4e+137) tmp = t_2; elseif (l <= -0.07) tmp = t_0; elseif (l <= 0.092) tmp = Float64(U + Float64(t_1 * Float64(Float64(l * Float64(J * 2.0)) + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))))); elseif (l <= 2.35e+101) tmp = t_0; else tmp = t_2; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = ((exp(l) - exp(-l)) * J) + U; t_1 = cos((K * 0.5)); t_2 = 0.3333333333333333 * (J * ((l ^ 3.0) * t_1)); tmp = 0.0; if (l <= -2.4e+137) tmp = t_2; elseif (l <= -0.07) tmp = t_0; elseif (l <= 0.092) tmp = U + (t_1 * ((l * (J * 2.0)) + (0.3333333333333333 * (J * (l ^ 3.0))))); elseif (l <= 2.35e+101) tmp = t_0; else tmp = t_2; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(0.3333333333333333 * N[(J * N[(N[Power[l, 3.0], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.4e+137], t$95$2, If[LessEqual[l, -0.07], t$95$0, If[LessEqual[l, 0.092], N[(U + N[(t$95$1 * N[(N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision] + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.35e+101], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
t_1 := \cos \left(K \cdot 0.5\right)\\
t_2 := 0.3333333333333333 \cdot \left(J \cdot \left({\ell}^{3} \cdot t_1\right)\right)\\
\mathbf{if}\;\ell \leq -2.4 \cdot 10^{+137}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\ell \leq -0.07:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq 0.092:\\
\;\;\;\;U + t_1 \cdot \left(\ell \cdot \left(J \cdot 2\right) + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\right)\\
\mathbf{elif}\;\ell \leq 2.35 \cdot 10^{+101}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if l < -2.39999999999999983e137 or 2.34999999999999985e101 < l Initial program 100.0%
Taylor expanded in l around 0 98.8%
+-commutative98.8%
associate-*r*98.8%
associate-*r*98.8%
associate-*r*98.8%
associate-*r*98.8%
distribute-rgt-out98.8%
associate-*r*98.8%
*-commutative98.8%
*-commutative98.8%
Simplified98.8%
Taylor expanded in K around inf 98.8%
+-commutative98.8%
fma-def98.8%
*-commutative98.8%
*-commutative98.8%
*-commutative98.8%
associate-*r*98.8%
*-commutative98.8%
associate-*r*98.8%
distribute-lft-in98.8%
fma-udef98.8%
associate-*r*98.8%
*-commutative98.8%
*-commutative98.8%
*-commutative98.8%
associate-*r*98.8%
fma-def98.8%
Simplified98.8%
Taylor expanded in l around inf 98.8%
if -2.39999999999999983e137 < l < -0.070000000000000007 or 0.091999999999999998 < l < 2.34999999999999985e101Initial program 100.0%
Taylor expanded in K around 0 74.5%
if -0.070000000000000007 < l < 0.091999999999999998Initial program 69.8%
Taylor expanded in l around 0 99.9%
+-commutative99.9%
associate-*r*99.9%
associate-*r*99.9%
associate-*r*99.9%
associate-*r*99.9%
distribute-rgt-out99.9%
associate-*r*99.9%
*-commutative99.9%
*-commutative99.9%
Simplified99.9%
Final simplification94.1%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ (* (- (exp l) (exp (- l))) J) U))
(t_1 (* 0.3333333333333333 (* J (* (pow l 3.0) (cos (* K 0.5)))))))
(if (<= l -2.4e+137)
t_1
(if (<= l -0.14)
t_0
(if (<= l 0.125)
(+
U
(*
(cos (/ K 2.0))
(* J (+ (* (pow l 3.0) 0.3333333333333333) (* l 2.0)))))
(if (<= l 2.1e+100) t_0 t_1))))))
double code(double J, double l, double K, double U) {
double t_0 = ((exp(l) - exp(-l)) * J) + U;
double t_1 = 0.3333333333333333 * (J * (pow(l, 3.0) * cos((K * 0.5))));
double tmp;
if (l <= -2.4e+137) {
tmp = t_1;
} else if (l <= -0.14) {
tmp = t_0;
} else if (l <= 0.125) {
tmp = U + (cos((K / 2.0)) * (J * ((pow(l, 3.0) * 0.3333333333333333) + (l * 2.0))));
} else if (l <= 2.1e+100) {
tmp = t_0;
} 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) :: tmp
t_0 = ((exp(l) - exp(-l)) * j) + u
t_1 = 0.3333333333333333d0 * (j * ((l ** 3.0d0) * cos((k * 0.5d0))))
if (l <= (-2.4d+137)) then
tmp = t_1
else if (l <= (-0.14d0)) then
tmp = t_0
else if (l <= 0.125d0) then
tmp = u + (cos((k / 2.0d0)) * (j * (((l ** 3.0d0) * 0.3333333333333333d0) + (l * 2.0d0))))
else if (l <= 2.1d+100) then
tmp = t_0
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.exp(l) - Math.exp(-l)) * J) + U;
double t_1 = 0.3333333333333333 * (J * (Math.pow(l, 3.0) * Math.cos((K * 0.5))));
double tmp;
if (l <= -2.4e+137) {
tmp = t_1;
} else if (l <= -0.14) {
tmp = t_0;
} else if (l <= 0.125) {
tmp = U + (Math.cos((K / 2.0)) * (J * ((Math.pow(l, 3.0) * 0.3333333333333333) + (l * 2.0))));
} else if (l <= 2.1e+100) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = ((math.exp(l) - math.exp(-l)) * J) + U t_1 = 0.3333333333333333 * (J * (math.pow(l, 3.0) * math.cos((K * 0.5)))) tmp = 0 if l <= -2.4e+137: tmp = t_1 elif l <= -0.14: tmp = t_0 elif l <= 0.125: tmp = U + (math.cos((K / 2.0)) * (J * ((math.pow(l, 3.0) * 0.3333333333333333) + (l * 2.0)))) elif l <= 2.1e+100: tmp = t_0 else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) t_1 = Float64(0.3333333333333333 * Float64(J * Float64((l ^ 3.0) * cos(Float64(K * 0.5))))) tmp = 0.0 if (l <= -2.4e+137) tmp = t_1; elseif (l <= -0.14) tmp = t_0; elseif (l <= 0.125) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(Float64((l ^ 3.0) * 0.3333333333333333) + Float64(l * 2.0))))); elseif (l <= 2.1e+100) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = ((exp(l) - exp(-l)) * J) + U; t_1 = 0.3333333333333333 * (J * ((l ^ 3.0) * cos((K * 0.5)))); tmp = 0.0; if (l <= -2.4e+137) tmp = t_1; elseif (l <= -0.14) tmp = t_0; elseif (l <= 0.125) tmp = U + (cos((K / 2.0)) * (J * (((l ^ 3.0) * 0.3333333333333333) + (l * 2.0)))); elseif (l <= 2.1e+100) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, Block[{t$95$1 = N[(0.3333333333333333 * N[(J * N[(N[Power[l, 3.0], $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.4e+137], t$95$1, If[LessEqual[l, -0.14], t$95$0, If[LessEqual[l, 0.125], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(N[(N[Power[l, 3.0], $MachinePrecision] * 0.3333333333333333), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.1e+100], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
t_1 := 0.3333333333333333 \cdot \left(J \cdot \left({\ell}^{3} \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{if}\;\ell \leq -2.4 \cdot 10^{+137}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq -0.14:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq 0.125:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left({\ell}^{3} \cdot 0.3333333333333333 + \ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 2.1 \cdot 10^{+100}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if l < -2.39999999999999983e137 or 2.0999999999999999e100 < l Initial program 100.0%
Taylor expanded in l around 0 98.8%
+-commutative98.8%
associate-*r*98.8%
associate-*r*98.8%
associate-*r*98.8%
associate-*r*98.8%
distribute-rgt-out98.8%
associate-*r*98.8%
*-commutative98.8%
*-commutative98.8%
Simplified98.8%
Taylor expanded in K around inf 98.8%
+-commutative98.8%
fma-def98.8%
*-commutative98.8%
*-commutative98.8%
*-commutative98.8%
associate-*r*98.8%
*-commutative98.8%
associate-*r*98.8%
distribute-lft-in98.8%
fma-udef98.8%
associate-*r*98.8%
*-commutative98.8%
*-commutative98.8%
*-commutative98.8%
associate-*r*98.8%
fma-def98.8%
Simplified98.8%
Taylor expanded in l around inf 98.8%
if -2.39999999999999983e137 < l < -0.14000000000000001 or 0.125 < l < 2.0999999999999999e100Initial program 100.0%
Taylor expanded in K around 0 74.5%
if -0.14000000000000001 < l < 0.125Initial program 69.8%
Taylor expanded in l around 0 99.8%
Final simplification94.1%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ (* (- (exp l) (exp (- l))) J) U))
(t_1 (cos (* K 0.5)))
(t_2 (* 0.3333333333333333 (* J (* (pow l 3.0) t_1)))))
(if (<= l -2.4e+137)
t_2
(if (<= l -0.00052)
t_0
(if (<= l 8e-6)
(+ U (* 2.0 (* J (* l t_1))))
(if (<= l 1.05e+101) t_0 t_2))))))
double code(double J, double l, double K, double U) {
double t_0 = ((exp(l) - exp(-l)) * J) + U;
double t_1 = cos((K * 0.5));
double t_2 = 0.3333333333333333 * (J * (pow(l, 3.0) * t_1));
double tmp;
if (l <= -2.4e+137) {
tmp = t_2;
} else if (l <= -0.00052) {
tmp = t_0;
} else if (l <= 8e-6) {
tmp = U + (2.0 * (J * (l * t_1)));
} else if (l <= 1.05e+101) {
tmp = t_0;
} 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 = ((exp(l) - exp(-l)) * j) + u
t_1 = cos((k * 0.5d0))
t_2 = 0.3333333333333333d0 * (j * ((l ** 3.0d0) * t_1))
if (l <= (-2.4d+137)) then
tmp = t_2
else if (l <= (-0.00052d0)) then
tmp = t_0
else if (l <= 8d-6) then
tmp = u + (2.0d0 * (j * (l * t_1)))
else if (l <= 1.05d+101) then
tmp = t_0
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.exp(l) - Math.exp(-l)) * J) + U;
double t_1 = Math.cos((K * 0.5));
double t_2 = 0.3333333333333333 * (J * (Math.pow(l, 3.0) * t_1));
double tmp;
if (l <= -2.4e+137) {
tmp = t_2;
} else if (l <= -0.00052) {
tmp = t_0;
} else if (l <= 8e-6) {
tmp = U + (2.0 * (J * (l * t_1)));
} else if (l <= 1.05e+101) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(J, l, K, U): t_0 = ((math.exp(l) - math.exp(-l)) * J) + U t_1 = math.cos((K * 0.5)) t_2 = 0.3333333333333333 * (J * (math.pow(l, 3.0) * t_1)) tmp = 0 if l <= -2.4e+137: tmp = t_2 elif l <= -0.00052: tmp = t_0 elif l <= 8e-6: tmp = U + (2.0 * (J * (l * t_1))) elif l <= 1.05e+101: tmp = t_0 else: tmp = t_2 return tmp
function code(J, l, K, U) t_0 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) t_1 = cos(Float64(K * 0.5)) t_2 = Float64(0.3333333333333333 * Float64(J * Float64((l ^ 3.0) * t_1))) tmp = 0.0 if (l <= -2.4e+137) tmp = t_2; elseif (l <= -0.00052) tmp = t_0; elseif (l <= 8e-6) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * t_1)))); elseif (l <= 1.05e+101) tmp = t_0; else tmp = t_2; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = ((exp(l) - exp(-l)) * J) + U; t_1 = cos((K * 0.5)); t_2 = 0.3333333333333333 * (J * ((l ^ 3.0) * t_1)); tmp = 0.0; if (l <= -2.4e+137) tmp = t_2; elseif (l <= -0.00052) tmp = t_0; elseif (l <= 8e-6) tmp = U + (2.0 * (J * (l * t_1))); elseif (l <= 1.05e+101) tmp = t_0; else tmp = t_2; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(0.3333333333333333 * N[(J * N[(N[Power[l, 3.0], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.4e+137], t$95$2, If[LessEqual[l, -0.00052], t$95$0, If[LessEqual[l, 8e-6], N[(U + N[(2.0 * N[(J * N[(l * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.05e+101], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
t_1 := \cos \left(K \cdot 0.5\right)\\
t_2 := 0.3333333333333333 \cdot \left(J \cdot \left({\ell}^{3} \cdot t_1\right)\right)\\
\mathbf{if}\;\ell \leq -2.4 \cdot 10^{+137}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\ell \leq -0.00052:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq 8 \cdot 10^{-6}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot t_1\right)\right)\\
\mathbf{elif}\;\ell \leq 1.05 \cdot 10^{+101}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if l < -2.39999999999999983e137 or 1.05e101 < l Initial program 100.0%
Taylor expanded in l around 0 98.8%
+-commutative98.8%
associate-*r*98.8%
associate-*r*98.8%
associate-*r*98.8%
associate-*r*98.8%
distribute-rgt-out98.8%
associate-*r*98.8%
*-commutative98.8%
*-commutative98.8%
Simplified98.8%
Taylor expanded in K around inf 98.8%
+-commutative98.8%
fma-def98.8%
*-commutative98.8%
*-commutative98.8%
*-commutative98.8%
associate-*r*98.8%
*-commutative98.8%
associate-*r*98.8%
distribute-lft-in98.8%
fma-udef98.8%
associate-*r*98.8%
*-commutative98.8%
*-commutative98.8%
*-commutative98.8%
associate-*r*98.8%
fma-def98.8%
Simplified98.8%
Taylor expanded in l around inf 98.8%
if -2.39999999999999983e137 < l < -5.19999999999999954e-4 or 7.99999999999999964e-6 < l < 1.05e101Initial program 99.6%
Taylor expanded in K around 0 74.6%
if -5.19999999999999954e-4 < l < 7.99999999999999964e-6Initial program 69.7%
Taylor expanded in l around 0 99.9%
Final simplification94.0%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.01) (+ U (* 2.0 (* J (* l (cos (* K 0.5)))))) (+ U (+ (* 0.3333333333333333 (* J (pow l 3.0))) (* 2.0 (* l J))))))
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 + ((0.3333333333333333 * (J * pow(l, 3.0))) + (2.0 * (l * J)));
}
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 + ((0.3333333333333333d0 * (j * (l ** 3.0d0))) + (2.0d0 * (l * j)))
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 + ((0.3333333333333333 * (J * Math.pow(l, 3.0))) + (2.0 * (l * J)));
}
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 + ((0.3333333333333333 * (J * math.pow(l, 3.0))) + (2.0 * (l * J))) 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(Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))) + Float64(2.0 * Float64(l * J)))); 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 + ((0.3333333333333333 * (J * (l ^ 3.0))) + (2.0 * (l * J))); 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[(N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(l * J), $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 + \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right) + 2 \cdot \left(\ell \cdot J\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.0100000000000000002Initial program 89.5%
Taylor expanded in l around 0 57.9%
if -0.0100000000000000002 < (cos.f64 (/.f64 K 2)) Initial program 84.1%
Taylor expanded in l around 0 86.6%
+-commutative86.6%
associate-*r*86.6%
associate-*r*86.6%
associate-*r*86.6%
associate-*r*86.6%
distribute-rgt-out86.6%
associate-*r*86.6%
*-commutative86.6%
*-commutative86.6%
Simplified86.6%
Taylor expanded in K around 0 83.0%
Final simplification76.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 (+ (* (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.01) {
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.01d0)) 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.01) {
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.01: 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.01) 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.01) 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.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[(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.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}^{3} \cdot 0.3333333333333333 + \ell \cdot 2\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.0100000000000000002Initial program 89.5%
Taylor expanded in l around 0 57.9%
if -0.0100000000000000002 < (cos.f64 (/.f64 K 2)) Initial program 84.1%
Taylor expanded in l around 0 86.6%
+-commutative86.6%
associate-*r*86.6%
associate-*r*86.6%
associate-*r*86.6%
associate-*r*86.6%
distribute-rgt-out86.6%
associate-*r*86.6%
*-commutative86.6%
*-commutative86.6%
Simplified86.6%
Taylor expanded in K around inf 86.6%
+-commutative86.6%
fma-def86.6%
*-commutative86.6%
*-commutative86.6%
*-commutative86.6%
associate-*r*86.6%
*-commutative86.6%
associate-*r*86.6%
distribute-lft-in86.6%
fma-udef86.5%
associate-*r*86.5%
*-commutative86.5%
*-commutative86.5%
*-commutative86.5%
associate-*r*86.6%
fma-def86.6%
Simplified86.6%
Taylor expanded in K around 0 83.0%
Final simplification76.1%
(FPCore (J l K U) :precision binary64 (if (or (<= l -0.0046) (not (<= l 8e-6))) (+ (* (- (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.0046) || !(l <= 8e-6)) {
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.0046d0)) .or. (.not. (l <= 8d-6))) 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.0046) || !(l <= 8e-6)) {
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.0046) or not (l <= 8e-6): 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.0046) || !(l <= 8e-6)) 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.0046) || ~((l <= 8e-6))) 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.0046], N[Not[LessEqual[l, 8e-6]], $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.0046 \lor \neg \left(\ell \leq 8 \cdot 10^{-6}\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 < -0.0045999999999999999 or 7.99999999999999964e-6 < l Initial program 99.8%
Taylor expanded in K around 0 68.0%
if -0.0045999999999999999 < l < 7.99999999999999964e-6Initial program 69.7%
Taylor expanded in l around 0 99.9%
Final simplification83.1%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.67) (- U (* J (pow K 2.0))) (fma J (* l 2.0) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.67) {
tmp = U - (J * pow(K, 2.0));
} else {
tmp = fma(J, (l * 2.0), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.67) tmp = Float64(U - Float64(J * (K ^ 2.0))); else tmp = fma(J, Float64(l * 2.0), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.67], N[(U - N[(J * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(J * N[(l * 2.0), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.67:\\
\;\;\;\;U - J \cdot {K}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J, \ell \cdot 2, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.67000000000000004Initial program 89.6%
Applied egg-rr17.4%
Taylor expanded in K around 0 42.7%
+-commutative42.7%
mul-1-neg42.7%
unsub-neg42.7%
*-commutative42.7%
Simplified42.7%
Taylor expanded in K around inf 42.7%
associate-*r*42.7%
neg-mul-142.7%
*-commutative42.7%
Simplified42.7%
if -0.67000000000000004 < (cos.f64 (/.f64 K 2)) Initial program 85.0%
Taylor expanded in l around 0 62.4%
associate-*r*62.4%
associate-*r*62.4%
Simplified62.4%
Taylor expanded in K around 0 55.3%
+-commutative55.3%
*-commutative55.3%
associate-*r*55.3%
*-commutative55.3%
fma-def55.3%
*-commutative55.3%
Simplified55.3%
Final simplification53.6%
(FPCore (J l K U) :precision binary64 (+ U (* 2.0 (* J (* l (cos (* K 0.5)))))))
double code(double J, double l, double K, double U) {
return U + (2.0 * (J * (l * cos((K * 0.5)))));
}
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 + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
end function
public static double code(double J, double l, double K, double U) {
return U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
def code(J, l, K, U): return U + (2.0 * (J * (l * math.cos((K * 0.5)))))
function code(J, l, K, U) return Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))) end
function tmp = code(J, l, K, U) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); end
code[J_, l_, K_, U_] := N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)
\end{array}
Initial program 85.6%
Taylor expanded in l around 0 60.8%
Final simplification60.8%
(FPCore (J l K U) :precision binary64 (fma J (* l 2.0) U))
double code(double J, double l, double K, double U) {
return fma(J, (l * 2.0), U);
}
function code(J, l, K, U) return fma(J, Float64(l * 2.0), U) end
code[J_, l_, K_, U_] := N[(J * N[(l * 2.0), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(J, \ell \cdot 2, U\right)
\end{array}
Initial program 85.6%
Taylor expanded in l around 0 60.8%
associate-*r*60.8%
associate-*r*60.8%
Simplified60.8%
Taylor expanded in K around 0 50.2%
+-commutative50.2%
*-commutative50.2%
associate-*r*50.2%
*-commutative50.2%
fma-def50.2%
*-commutative50.2%
Simplified50.2%
Final simplification50.2%
(FPCore (J l K U) :precision binary64 (if (or (<= l -5.2e+17) (not (<= l 2.5e+16))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -5.2e+17) || !(l <= 2.5e+16)) {
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 <= (-5.2d+17)) .or. (.not. (l <= 2.5d+16))) 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 <= -5.2e+17) || !(l <= 2.5e+16)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -5.2e+17) or not (l <= 2.5e+16): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -5.2e+17) || !(l <= 2.5e+16)) tmp = Float64(U * U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -5.2e+17) || ~((l <= 2.5e+16))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -5.2e+17], N[Not[LessEqual[l, 2.5e+16]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5.2 \cdot 10^{+17} \lor \neg \left(\ell \leq 2.5 \cdot 10^{+16}\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -5.2e17 or 2.5e16 < l Initial program 100.0%
Applied egg-rr17.1%
if -5.2e17 < l < 2.5e16Initial program 71.2%
Taylor expanded in J around 0 65.2%
Final simplification41.2%
(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 85.6%
Taylor expanded in l around 0 60.8%
associate-*r*60.8%
associate-*r*60.8%
Simplified60.8%
Taylor expanded in K around 0 50.2%
*-commutative50.2%
associate-*r*50.2%
Simplified50.2%
Final simplification50.2%
(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 85.6%
Taylor expanded in J around 0 33.8%
Final simplification33.8%
herbie shell --seed 2023332
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))