
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 5e+228)))
(+ t_0 U)
(+
U
(*
(* J (cos (* K 0.5)))
(+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))))
double code(double J, double l, double K, double U) {
double t_0 = (J * (exp(l) - exp(-l))) * cos((K / 2.0));
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 5e+228)) {
tmp = t_0 + U;
} else {
tmp = U + ((J * cos((K * 0.5))) * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0)));
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = (J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0));
double tmp;
if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 5e+228)) {
tmp = t_0 + U;
} else {
tmp = U + ((J * Math.cos((K * 0.5))) * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): t_0 = (J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0)) tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= 5e+228): tmp = t_0 + U else: tmp = U + ((J * math.cos((K * 0.5))) * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))) return tmp
function code(J, l, K, U) t_0 = Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 5e+228)) tmp = Float64(t_0 + U); else tmp = Float64(U + Float64(Float64(J * cos(Float64(K * 0.5))) * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = (J * (exp(l) - exp(-l))) * cos((K / 2.0)); tmp = 0.0; if ((t_0 <= -Inf) || ~((t_0 <= 5e+228))) tmp = t_0 + U; else tmp = U + ((J * cos((K * 0.5))) * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 5e+228]], $MachinePrecision]], N[(t$95$0 + U), $MachinePrecision], N[(U + N[(N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 5 \cdot 10^{+228}\right):\\
\;\;\;\;t_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K 2))) < -inf.0 or 5e228 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K 2))) Initial program 100.0%
if -inf.0 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K 2))) < 5e228Initial program 79.1%
Taylor expanded in l around 0 99.9%
pow199.9%
*-commutative99.9%
associate-*r*99.9%
div-inv99.9%
metadata-eval99.9%
fma-def99.9%
*-commutative99.9%
Applied egg-rr99.9%
fma-udef99.9%
*-commutative99.9%
+-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
Final simplification100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))))
(t_1 (cos (* K 0.5))))
(if (<= t_0 5e+228)
(+
(+
(* 0.016666666666666666 (* J (* (pow l 5.0) t_1)))
(+
(* 0.3333333333333333 (* J (* t_1 (pow l 3.0))))
(* 2.0 (* J (* l t_1)))))
U)
(+ t_0 U))))
double code(double J, double l, double K, double U) {
double t_0 = (J * (exp(l) - exp(-l))) * cos((K / 2.0));
double t_1 = cos((K * 0.5));
double tmp;
if (t_0 <= 5e+228) {
tmp = ((0.016666666666666666 * (J * (pow(l, 5.0) * t_1))) + ((0.3333333333333333 * (J * (t_1 * pow(l, 3.0)))) + (2.0 * (J * (l * t_1))))) + U;
} else {
tmp = t_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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (j * (exp(l) - exp(-l))) * cos((k / 2.0d0))
t_1 = cos((k * 0.5d0))
if (t_0 <= 5d+228) then
tmp = ((0.016666666666666666d0 * (j * ((l ** 5.0d0) * t_1))) + ((0.3333333333333333d0 * (j * (t_1 * (l ** 3.0d0)))) + (2.0d0 * (j * (l * t_1))))) + u
else
tmp = t_0 + u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = (J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0));
double t_1 = Math.cos((K * 0.5));
double tmp;
if (t_0 <= 5e+228) {
tmp = ((0.016666666666666666 * (J * (Math.pow(l, 5.0) * t_1))) + ((0.3333333333333333 * (J * (t_1 * Math.pow(l, 3.0)))) + (2.0 * (J * (l * t_1))))) + U;
} else {
tmp = t_0 + U;
}
return tmp;
}
def code(J, l, K, U): t_0 = (J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0)) t_1 = math.cos((K * 0.5)) tmp = 0 if t_0 <= 5e+228: tmp = ((0.016666666666666666 * (J * (math.pow(l, 5.0) * t_1))) + ((0.3333333333333333 * (J * (t_1 * math.pow(l, 3.0)))) + (2.0 * (J * (l * t_1))))) + U else: tmp = t_0 + U return tmp
function code(J, l, K, U) t_0 = Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) t_1 = cos(Float64(K * 0.5)) tmp = 0.0 if (t_0 <= 5e+228) tmp = Float64(Float64(Float64(0.016666666666666666 * Float64(J * Float64((l ^ 5.0) * t_1))) + Float64(Float64(0.3333333333333333 * Float64(J * Float64(t_1 * (l ^ 3.0)))) + Float64(2.0 * Float64(J * Float64(l * t_1))))) + U); else tmp = Float64(t_0 + U); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = (J * (exp(l) - exp(-l))) * cos((K / 2.0)); t_1 = cos((K * 0.5)); tmp = 0.0; if (t_0 <= 5e+228) tmp = ((0.016666666666666666 * (J * ((l ^ 5.0) * t_1))) + ((0.3333333333333333 * (J * (t_1 * (l ^ 3.0)))) + (2.0 * (J * (l * t_1))))) + U; else tmp = t_0 + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 5e+228], N[(N[(N[(0.016666666666666666 * N[(J * N[(N[Power[l, 5.0], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(0.3333333333333333 * N[(J * N[(t$95$1 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(J * N[(l * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(t$95$0 + U), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right)\\
t_1 := \cos \left(K \cdot 0.5\right)\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{+228}:\\
\;\;\;\;\left(0.016666666666666666 \cdot \left(J \cdot \left({\ell}^{5} \cdot t_1\right)\right) + \left(0.3333333333333333 \cdot \left(J \cdot \left(t_1 \cdot {\ell}^{3}\right)\right) + 2 \cdot \left(J \cdot \left(\ell \cdot t_1\right)\right)\right)\right) + U\\
\mathbf{else}:\\
\;\;\;\;t_0 + U\\
\end{array}
\end{array}
if (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K 2))) < 5e228Initial program 85.0%
Taylor expanded in l around 0 98.0%
if 5e228 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K 2))) Initial program 100.0%
Final simplification98.5%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (- (exp l) (exp (- l)))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 0.001)))
(+ (* (* J t_1) t_0) U)
(+ U (* t_0 (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = exp(l) - exp(-l);
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 0.001)) {
tmp = ((J * t_1) * t_0) + U;
} else {
tmp = U + (t_0 * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 0.001)) {
tmp = ((J * t_1) * t_0) + U;
} else {
tmp = U + (t_0 * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = math.exp(l) - math.exp(-l) tmp = 0 if (t_1 <= -math.inf) or not (t_1 <= 0.001): tmp = ((J * t_1) * t_0) + U else: tmp = U + (t_0 * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 0.001)) tmp = Float64(Float64(Float64(J * t_1) * t_0) + U); else tmp = Float64(U + Float64(t_0 * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = exp(l) - exp(-l); tmp = 0.0; if ((t_1 <= -Inf) || ~((t_1 <= 0.001))) tmp = ((J * t_1) * t_0) + U; else tmp = U + (t_0 * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 0.001]], $MachinePrecision]], N[(N[(N[(J * t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 0.001\right):\\
\;\;\;\;\left(J \cdot t_1\right) \cdot t_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + t_0 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 1e-3 < (-.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))) < 1e-3Initial program 79.1%
Taylor expanded in l around 0 99.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 0.001)))
(+ (* J t_0) U)
(+ (* 2.0 (* J (* l (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 <= 0.001)) {
tmp = (J * t_0) + U;
} else {
tmp = (2.0 * (J * (l * cos((K * 0.5))))) + U;
}
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.001)) {
tmp = (J * t_0) + U;
} else {
tmp = (2.0 * (J * (l * Math.cos((K * 0.5))))) + U;
}
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.001): tmp = (J * t_0) + U else: tmp = (2.0 * (J * (l * math.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 <= 0.001)) tmp = Float64(Float64(J * t_0) + U); else tmp = Float64(Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5))))) + U); 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.001))) tmp = (J * t_0) + U; else tmp = (2.0 * (J * (l * cos((K * 0.5))))) + U; 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.001]], $MachinePrecision]], N[(N[(J * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $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 0.001\right):\\
\;\;\;\;J \cdot t_0 + U\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right) + U\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 1e-3 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
Taylor expanded in K around 0 75.8%
if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 1e-3Initial program 79.1%
Taylor expanded in l around 0 99.7%
Final simplification88.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* K 0.5)))
(t_1 (+ U (* (* t_0 (pow l 3.0)) (* J 0.3333333333333333))))
(t_2 (+ (* J (- (exp l) (exp (- l)))) U)))
(if (<= l -7.5e+72)
t_1
(if (<= l -0.00115)
t_2
(if (<= l 0.031)
(+ (* 2.0 (* J (* l t_0))) U)
(if (<= l 7.5e+97) 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 + ((t_0 * pow(l, 3.0)) * (J * 0.3333333333333333));
double t_2 = (J * (exp(l) - exp(-l))) + U;
double tmp;
if (l <= -7.5e+72) {
tmp = t_1;
} else if (l <= -0.00115) {
tmp = t_2;
} else if (l <= 0.031) {
tmp = (2.0 * (J * (l * t_0))) + U;
} else if (l <= 7.5e+97) {
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 + ((t_0 * (l ** 3.0d0)) * (j * 0.3333333333333333d0))
t_2 = (j * (exp(l) - exp(-l))) + u
if (l <= (-7.5d+72)) then
tmp = t_1
else if (l <= (-0.00115d0)) then
tmp = t_2
else if (l <= 0.031d0) then
tmp = (2.0d0 * (j * (l * t_0))) + u
else if (l <= 7.5d+97) 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 + ((t_0 * Math.pow(l, 3.0)) * (J * 0.3333333333333333));
double t_2 = (J * (Math.exp(l) - Math.exp(-l))) + U;
double tmp;
if (l <= -7.5e+72) {
tmp = t_1;
} else if (l <= -0.00115) {
tmp = t_2;
} else if (l <= 0.031) {
tmp = (2.0 * (J * (l * t_0))) + U;
} else if (l <= 7.5e+97) {
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 + ((t_0 * math.pow(l, 3.0)) * (J * 0.3333333333333333)) t_2 = (J * (math.exp(l) - math.exp(-l))) + U tmp = 0 if l <= -7.5e+72: tmp = t_1 elif l <= -0.00115: tmp = t_2 elif l <= 0.031: tmp = (2.0 * (J * (l * t_0))) + U elif l <= 7.5e+97: 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(Float64(t_0 * (l ^ 3.0)) * Float64(J * 0.3333333333333333))) t_2 = Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) + U) tmp = 0.0 if (l <= -7.5e+72) tmp = t_1; elseif (l <= -0.00115) tmp = t_2; elseif (l <= 0.031) tmp = Float64(Float64(2.0 * Float64(J * Float64(l * t_0))) + U); elseif (l <= 7.5e+97) 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 + ((t_0 * (l ^ 3.0)) * (J * 0.3333333333333333)); t_2 = (J * (exp(l) - exp(-l))) + U; tmp = 0.0; if (l <= -7.5e+72) tmp = t_1; elseif (l <= -0.00115) tmp = t_2; elseif (l <= 0.031) tmp = (2.0 * (J * (l * t_0))) + U; elseif (l <= 7.5e+97) 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[(t$95$0 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -7.5e+72], t$95$1, If[LessEqual[l, -0.00115], t$95$2, If[LessEqual[l, 0.031], N[(N[(2.0 * N[(J * N[(l * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 7.5e+97], t$95$2, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
t_1 := U + \left(t_0 \cdot {\ell}^{3}\right) \cdot \left(J \cdot 0.3333333333333333\right)\\
t_2 := J \cdot \left(e^{\ell} - e^{-\ell}\right) + U\\
\mathbf{if}\;\ell \leq -7.5 \cdot 10^{+72}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq -0.00115:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\ell \leq 0.031:\\
\;\;\;\;2 \cdot \left(J \cdot \left(\ell \cdot t_0\right)\right) + U\\
\mathbf{elif}\;\ell \leq 7.5 \cdot 10^{+97}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if l < -7.50000000000000027e72 or 7.5000000000000004e97 < l Initial program 100.0%
Taylor expanded in l around 0 97.8%
Taylor expanded in l around inf 97.8%
associate-*r*97.8%
*-commutative97.8%
*-commutative97.8%
Simplified97.8%
if -7.50000000000000027e72 < l < -0.00115 or 0.031 < l < 7.5000000000000004e97Initial program 99.9%
Taylor expanded in K around 0 86.6%
if -0.00115 < l < 0.031Initial program 79.1%
Taylor expanded in l around 0 99.7%
Final simplification97.5%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ U (* (* (cos (* K 0.5)) (pow l 3.0)) (* J 0.3333333333333333))))
(t_1 (+ (* J (- (exp l) (exp (- l)))) U)))
(if (<= l -4.4e+73)
t_0
(if (<= l -0.068)
t_1
(if (<= l 0.057)
(+
U
(*
(cos (/ K 2.0))
(* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
(if (<= l 7e+92) t_1 t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + ((cos((K * 0.5)) * pow(l, 3.0)) * (J * 0.3333333333333333));
double t_1 = (J * (exp(l) - exp(-l))) + U;
double tmp;
if (l <= -4.4e+73) {
tmp = t_0;
} else if (l <= -0.068) {
tmp = t_1;
} else if (l <= 0.057) {
tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 7e+92) {
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 * 0.5d0)) * (l ** 3.0d0)) * (j * 0.3333333333333333d0))
t_1 = (j * (exp(l) - exp(-l))) + u
if (l <= (-4.4d+73)) then
tmp = t_0
else if (l <= (-0.068d0)) then
tmp = t_1
else if (l <= 0.057d0) then
tmp = u + (cos((k / 2.0d0)) * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
else if (l <= 7d+92) 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 * 0.5)) * Math.pow(l, 3.0)) * (J * 0.3333333333333333));
double t_1 = (J * (Math.exp(l) - Math.exp(-l))) + U;
double tmp;
if (l <= -4.4e+73) {
tmp = t_0;
} else if (l <= -0.068) {
tmp = t_1;
} else if (l <= 0.057) {
tmp = U + (Math.cos((K / 2.0)) * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 7e+92) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + ((math.cos((K * 0.5)) * math.pow(l, 3.0)) * (J * 0.3333333333333333)) t_1 = (J * (math.exp(l) - math.exp(-l))) + U tmp = 0 if l <= -4.4e+73: tmp = t_0 elif l <= -0.068: tmp = t_1 elif l <= 0.057: tmp = U + (math.cos((K / 2.0)) * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) elif l <= 7e+92: tmp = t_1 else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(Float64(cos(Float64(K * 0.5)) * (l ^ 3.0)) * Float64(J * 0.3333333333333333))) t_1 = Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) + U) tmp = 0.0 if (l <= -4.4e+73) tmp = t_0; elseif (l <= -0.068) tmp = t_1; elseif (l <= 0.057) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))); elseif (l <= 7e+92) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + ((cos((K * 0.5)) * (l ^ 3.0)) * (J * 0.3333333333333333)); t_1 = (J * (exp(l) - exp(-l))) + U; tmp = 0.0; if (l <= -4.4e+73) tmp = t_0; elseif (l <= -0.068) tmp = t_1; elseif (l <= 0.057) tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))); elseif (l <= 7e+92) 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[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -4.4e+73], t$95$0, If[LessEqual[l, -0.068], t$95$1, If[LessEqual[l, 0.057], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 7e+92], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + \left(\cos \left(K \cdot 0.5\right) \cdot {\ell}^{3}\right) \cdot \left(J \cdot 0.3333333333333333\right)\\
t_1 := J \cdot \left(e^{\ell} - e^{-\ell}\right) + U\\
\mathbf{if}\;\ell \leq -4.4 \cdot 10^{+73}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -0.068:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq 0.057:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 7 \cdot 10^{+92}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if l < -4.4e73 or 6.99999999999999972e92 < l Initial program 100.0%
Taylor expanded in l around 0 97.8%
Taylor expanded in l around inf 97.8%
associate-*r*97.8%
*-commutative97.8%
*-commutative97.8%
Simplified97.8%
if -4.4e73 < l < -0.068000000000000005 or 0.0570000000000000021 < l < 6.99999999999999972e92Initial program 99.9%
Taylor expanded in K around 0 86.6%
if -0.068000000000000005 < l < 0.0570000000000000021Initial program 79.1%
Taylor expanded in l around 0 99.9%
Final simplification97.7%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.6) (+ (* 2.0 (* J (* l (cos (* K 0.5))))) U) (+ U (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.6) {
tmp = (2.0 * (J * (l * cos((K * 0.5))))) + U;
} else {
tmp = U + (J * ((0.3333333333333333 * pow(l, 3.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) :: tmp
if (cos((k / 2.0d0)) <= 0.6d0) then
tmp = (2.0d0 * (j * (l * cos((k * 0.5d0))))) + u
else
tmp = u + (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (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.6) {
tmp = (2.0 * (J * (l * Math.cos((K * 0.5))))) + U;
} else {
tmp = U + (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.6: tmp = (2.0 * (J * (l * math.cos((K * 0.5))))) + U else: tmp = U + (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.6) tmp = Float64(Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5))))) + U); else tmp = Float64(U + Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + 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.6) tmp = (2.0 * (J * (l * cos((K * 0.5))))) + U; else tmp = U + (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.6], N[(N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $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.6:\\
\;\;\;\;2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < 0.599999999999999978Initial program 85.7%
Taylor expanded in l around 0 77.6%
if 0.599999999999999978 < (cos.f64 (/.f64 K 2)) Initial program 90.2%
Taylor expanded in l around 0 89.2%
Taylor expanded in K around 0 88.3%
Final simplification84.3%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.05) (+ U (* -0.25 (* J (* l (pow K 2.0))))) (+ U (* J (* 0.3333333333333333 (pow l 3.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.05) {
tmp = U + (-0.25 * (J * (l * pow(K, 2.0))));
} else {
tmp = U + (J * (0.3333333333333333 * 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.05d0)) then
tmp = u + ((-0.25d0) * (j * (l * (k ** 2.0d0))))
else
tmp = u + (j * (0.3333333333333333d0 * (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.05) {
tmp = U + (-0.25 * (J * (l * Math.pow(K, 2.0))));
} else {
tmp = U + (J * (0.3333333333333333 * Math.pow(l, 3.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.05: tmp = U + (-0.25 * (J * (l * math.pow(K, 2.0)))) else: tmp = U + (J * (0.3333333333333333 * math.pow(l, 3.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.05) tmp = Float64(U + Float64(-0.25 * Float64(J * Float64(l * (K ^ 2.0))))); else tmp = Float64(U + Float64(J * Float64(0.3333333333333333 * (l ^ 3.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.05) tmp = U + (-0.25 * (J * (l * (K ^ 2.0)))); else tmp = U + (J * (0.3333333333333333 * (l ^ 3.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.05], N[(U + N[(-0.25 * N[(J * N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(0.3333333333333333 * 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.05:\\
\;\;\;\;U + -0.25 \cdot \left(J \cdot \left(\ell \cdot {K}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.050000000000000003Initial program 88.4%
Taylor expanded in l around 0 76.7%
associate-*r*76.7%
*-commutative76.7%
associate-*l*76.7%
associate-*r*76.7%
Simplified76.7%
Taylor expanded in K around 0 57.3%
Taylor expanded in K around inf 58.7%
if -0.050000000000000003 < (cos.f64 (/.f64 K 2)) Initial program 88.6%
Taylor expanded in l around 0 90.0%
Taylor expanded in K around 0 85.7%
Taylor expanded in l around inf 77.9%
*-commutative77.9%
associate-*l*77.9%
*-commutative77.9%
Simplified77.9%
Final simplification73.2%
(FPCore (J l K U) :precision binary64 (if (or (<= J -0.222) (not (<= J 4.4e-36))) (+ (* 2.0 (* J (* l (cos (* K 0.5))))) U) (+ U (* J (* 0.3333333333333333 (pow l 3.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((J <= -0.222) || !(J <= 4.4e-36)) {
tmp = (2.0 * (J * (l * cos((K * 0.5))))) + U;
} else {
tmp = U + (J * (0.3333333333333333 * 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 <= (-0.222d0)) .or. (.not. (j <= 4.4d-36))) then
tmp = (2.0d0 * (j * (l * cos((k * 0.5d0))))) + u
else
tmp = u + (j * (0.3333333333333333d0 * (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 <= -0.222) || !(J <= 4.4e-36)) {
tmp = (2.0 * (J * (l * Math.cos((K * 0.5))))) + U;
} else {
tmp = U + (J * (0.3333333333333333 * Math.pow(l, 3.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (J <= -0.222) or not (J <= 4.4e-36): tmp = (2.0 * (J * (l * math.cos((K * 0.5))))) + U else: tmp = U + (J * (0.3333333333333333 * math.pow(l, 3.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((J <= -0.222) || !(J <= 4.4e-36)) tmp = Float64(Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5))))) + U); else tmp = Float64(U + Float64(J * Float64(0.3333333333333333 * (l ^ 3.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((J <= -0.222) || ~((J <= 4.4e-36))) tmp = (2.0 * (J * (l * cos((K * 0.5))))) + U; else tmp = U + (J * (0.3333333333333333 * (l ^ 3.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[J, -0.222], N[Not[LessEqual[J, 4.4e-36]], $MachinePrecision]], N[(N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(J * N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;J \leq -0.222 \lor \neg \left(J \leq 4.4 \cdot 10^{-36}\right):\\
\;\;\;\;2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\
\end{array}
\end{array}
if J < -0.222000000000000003 or 4.3999999999999999e-36 < J Initial program 79.7%
Taylor expanded in l around 0 80.1%
if -0.222000000000000003 < J < 4.3999999999999999e-36Initial program 99.9%
Taylor expanded in l around 0 90.5%
Taylor expanded in K around 0 84.8%
Taylor expanded in l around inf 84.8%
*-commutative84.8%
associate-*l*84.8%
*-commutative84.8%
Simplified84.8%
Final simplification82.1%
(FPCore (J l K U)
:precision binary64
(if (<= J -0.35)
(+ U (* (cos (/ K 2.0)) (* J (* l 2.0))))
(if (<= J 8.8e-36)
(+ U (* J (* 0.3333333333333333 (pow l 3.0))))
(+ (* 2.0 (* J (* l (cos (* K 0.5))))) U))))
double code(double J, double l, double K, double U) {
double tmp;
if (J <= -0.35) {
tmp = U + (cos((K / 2.0)) * (J * (l * 2.0)));
} else if (J <= 8.8e-36) {
tmp = U + (J * (0.3333333333333333 * pow(l, 3.0)));
} else {
tmp = (2.0 * (J * (l * cos((K * 0.5))))) + 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 (j <= (-0.35d0)) then
tmp = u + (cos((k / 2.0d0)) * (j * (l * 2.0d0)))
else if (j <= 8.8d-36) then
tmp = u + (j * (0.3333333333333333d0 * (l ** 3.0d0)))
else
tmp = (2.0d0 * (j * (l * cos((k * 0.5d0))))) + u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (J <= -0.35) {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
} else if (J <= 8.8e-36) {
tmp = U + (J * (0.3333333333333333 * Math.pow(l, 3.0)));
} else {
tmp = (2.0 * (J * (l * Math.cos((K * 0.5))))) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if J <= -0.35: tmp = U + (math.cos((K / 2.0)) * (J * (l * 2.0))) elif J <= 8.8e-36: tmp = U + (J * (0.3333333333333333 * math.pow(l, 3.0))) else: tmp = (2.0 * (J * (l * math.cos((K * 0.5))))) + U return tmp
function code(J, l, K, U) tmp = 0.0 if (J <= -0.35) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0)))); elseif (J <= 8.8e-36) tmp = Float64(U + Float64(J * Float64(0.3333333333333333 * (l ^ 3.0)))); else tmp = Float64(Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5))))) + U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (J <= -0.35) tmp = U + (cos((K / 2.0)) * (J * (l * 2.0))); elseif (J <= 8.8e-36) tmp = U + (J * (0.3333333333333333 * (l ^ 3.0))); else tmp = (2.0 * (J * (l * cos((K * 0.5))))) + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[J, -0.35], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 8.8e-36], N[(U + N[(J * N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;J \leq -0.35:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{elif}\;J \leq 8.8 \cdot 10^{-36}:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right) + U\\
\end{array}
\end{array}
if J < -0.34999999999999998Initial program 72.5%
Taylor expanded in l around 0 80.4%
if -0.34999999999999998 < J < 8.7999999999999997e-36Initial program 99.9%
Taylor expanded in l around 0 90.5%
Taylor expanded in K around 0 84.8%
Taylor expanded in l around inf 84.8%
*-commutative84.8%
associate-*l*84.8%
*-commutative84.8%
Simplified84.8%
if 8.7999999999999997e-36 < J Initial program 85.4%
Taylor expanded in l around 0 79.9%
Final simplification82.1%
(FPCore (J l K U) :precision binary64 (if (or (<= l -2.5e+20) (not (<= l 1.7e-9))) (* 0.3333333333333333 (* J (pow l 3.0))) (+ U (* J (* l 2.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.5e+20) || !(l <= 1.7e-9)) {
tmp = 0.3333333333333333 * (J * pow(l, 3.0));
} else {
tmp = U + (J * (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 <= (-2.5d+20)) .or. (.not. (l <= 1.7d-9))) then
tmp = 0.3333333333333333d0 * (j * (l ** 3.0d0))
else
tmp = u + (j * (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 <= -2.5e+20) || !(l <= 1.7e-9)) {
tmp = 0.3333333333333333 * (J * Math.pow(l, 3.0));
} else {
tmp = U + (J * (l * 2.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -2.5e+20) or not (l <= 1.7e-9): tmp = 0.3333333333333333 * (J * math.pow(l, 3.0)) else: tmp = U + (J * (l * 2.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -2.5e+20) || !(l <= 1.7e-9)) tmp = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))); else tmp = Float64(U + Float64(J * Float64(l * 2.0))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -2.5e+20) || ~((l <= 1.7e-9))) tmp = 0.3333333333333333 * (J * (l ^ 3.0)); else tmp = U + (J * (l * 2.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -2.5e+20], N[Not[LessEqual[l, 1.7e-9]], $MachinePrecision]], N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.5 \cdot 10^{+20} \lor \neg \left(\ell \leq 1.7 \cdot 10^{-9}\right):\\
\;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\
\end{array}
\end{array}
if l < -2.5e20 or 1.6999999999999999e-9 < l Initial program 99.5%
Taylor expanded in l around 0 82.5%
Taylor expanded in K around 0 59.8%
Taylor expanded in l around inf 59.9%
if -2.5e20 < l < 1.6999999999999999e-9Initial program 79.6%
Taylor expanded in l around 0 97.9%
associate-*r*97.9%
*-commutative97.9%
associate-*l*97.9%
associate-*r*97.9%
Simplified97.9%
Taylor expanded in K around 0 87.6%
Final simplification75.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 88.5%
Taylor expanded in l around 0 69.6%
associate-*r*69.5%
*-commutative69.5%
associate-*l*69.5%
associate-*r*69.5%
Simplified69.5%
Taylor expanded in K around 0 58.3%
Final simplification58.3%
(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.5%
Applied egg-rr30.7%
Taylor expanded in J around 0 43.3%
Final simplification43.3%
herbie shell --seed 2024017
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))