
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (- (exp l) (exp (- l)))))
(if (or (<= t_1 -5e+142) (not (<= t_1 1e-6)))
(+ (* (* t_1 J) 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 <= -5e+142) || !(t_1 <= 1e-6)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = exp(l) - exp(-l)
if ((t_1 <= (-5d+142)) .or. (.not. (t_1 <= 1d-6))) then
tmp = ((t_1 * j) * t_0) + u
else
tmp = u + (t_0 * (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 t_0 = Math.cos((K / 2.0));
double t_1 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_1 <= -5e+142) || !(t_1 <= 1e-6)) {
tmp = ((t_1 * J) * 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 <= -5e+142) or not (t_1 <= 1e-6): tmp = ((t_1 * J) * 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 <= -5e+142) || !(t_1 <= 1e-6)) tmp = Float64(Float64(Float64(t_1 * J) * 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 <= -5e+142) || ~((t_1 <= 1e-6))) tmp = ((t_1 * J) * 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, -5e+142], N[Not[LessEqual[t$95$1, 1e-6]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $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 -5 \cdot 10^{+142} \lor \neg \left(t_1 \leq 10^{-6}\right):\\
\;\;\;\;\left(t_1 \cdot J\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))) < -5.0000000000000001e142 or 9.99999999999999955e-7 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -5.0000000000000001e142 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 9.99999999999999955e-7Initial program 65.7%
Taylor expanded in l around 0 99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1 (+ U (* t_0 (* (pow l 3.0) (* J 0.3333333333333333)))))
(t_2 (+ (* (- (exp l) (exp (- l))) J) U)))
(if (<= l -7.6e+92)
t_1
(if (<= l -330.0)
t_2
(if (<= l 8.8e+18)
(+ U (* t_0 (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
(if (<= l 5e+101) t_2 t_1))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = U + (t_0 * (pow(l, 3.0) * (J * 0.3333333333333333)));
double t_2 = ((exp(l) - exp(-l)) * J) + U;
double tmp;
if (l <= -7.6e+92) {
tmp = t_1;
} else if (l <= -330.0) {
tmp = t_2;
} else if (l <= 8.8e+18) {
tmp = U + (t_0 * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 5e+101) {
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 / 2.0d0))
t_1 = u + (t_0 * ((l ** 3.0d0) * (j * 0.3333333333333333d0)))
t_2 = ((exp(l) - exp(-l)) * j) + u
if (l <= (-7.6d+92)) then
tmp = t_1
else if (l <= (-330.0d0)) then
tmp = t_2
else if (l <= 8.8d+18) then
tmp = u + (t_0 * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
else if (l <= 5d+101) 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 / 2.0));
double t_1 = U + (t_0 * (Math.pow(l, 3.0) * (J * 0.3333333333333333)));
double t_2 = ((Math.exp(l) - Math.exp(-l)) * J) + U;
double tmp;
if (l <= -7.6e+92) {
tmp = t_1;
} else if (l <= -330.0) {
tmp = t_2;
} else if (l <= 8.8e+18) {
tmp = U + (t_0 * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 5e+101) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = U + (t_0 * (math.pow(l, 3.0) * (J * 0.3333333333333333))) t_2 = ((math.exp(l) - math.exp(-l)) * J) + U tmp = 0 if l <= -7.6e+92: tmp = t_1 elif l <= -330.0: tmp = t_2 elif l <= 8.8e+18: tmp = U + (t_0 * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) elif l <= 5e+101: tmp = t_2 else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(U + Float64(t_0 * Float64((l ^ 3.0) * Float64(J * 0.3333333333333333)))) t_2 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) tmp = 0.0 if (l <= -7.6e+92) tmp = t_1; elseif (l <= -330.0) tmp = t_2; elseif (l <= 8.8e+18) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))); elseif (l <= 5e+101) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = U + (t_0 * ((l ^ 3.0) * (J * 0.3333333333333333))); t_2 = ((exp(l) - exp(-l)) * J) + U; tmp = 0.0; if (l <= -7.6e+92) tmp = t_1; elseif (l <= -330.0) tmp = t_2; elseif (l <= 8.8e+18) tmp = U + (t_0 * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))); elseif (l <= 5e+101) 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 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(t$95$0 * N[(N[Power[l, 3.0], $MachinePrecision] * 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, -7.6e+92], t$95$1, If[LessEqual[l, -330.0], t$95$2, If[LessEqual[l, 8.8e+18], 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], If[LessEqual[l, 5e+101], t$95$2, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := U + t_0 \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\
t_2 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{if}\;\ell \leq -7.6 \cdot 10^{+92}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq -330:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\ell \leq 8.8 \cdot 10^{+18}:\\
\;\;\;\;U + t_0 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 5 \cdot 10^{+101}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if l < -7.6000000000000001e92 or 4.99999999999999989e101 < l Initial program 100.0%
Taylor expanded in l around 0 98.8%
Taylor expanded in l around inf 98.8%
*-commutative98.8%
*-commutative98.8%
associate-*l*98.8%
Simplified98.8%
if -7.6000000000000001e92 < l < -330 or 8.8e18 < l < 4.99999999999999989e101Initial program 100.0%
Taylor expanded in K around 0 70.3%
if -330 < l < 8.8e18Initial program 67.2%
Taylor expanded in l around 0 97.9%
Final simplification94.2%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l))))
(t_1 (cos (/ K 2.0)))
(t_2 (+ U (* t_1 (* (pow l 3.0) (* J 0.3333333333333333))))))
(if (<= l -1.45e+102)
t_2
(if (<= l -2.8)
(+ U (* t_0 (+ J (* J (* -0.125 (* K K))))))
(if (<= l 8.8e+18)
(+ U (* t_1 (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
(if (<= l 5.6e+102) (+ (* t_0 J) U) t_2))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double t_1 = cos((K / 2.0));
double t_2 = U + (t_1 * (pow(l, 3.0) * (J * 0.3333333333333333)));
double tmp;
if (l <= -1.45e+102) {
tmp = t_2;
} else if (l <= -2.8) {
tmp = U + (t_0 * (J + (J * (-0.125 * (K * K)))));
} else if (l <= 8.8e+18) {
tmp = U + (t_1 * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 5.6e+102) {
tmp = (t_0 * J) + U;
} 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)
t_1 = cos((k / 2.0d0))
t_2 = u + (t_1 * ((l ** 3.0d0) * (j * 0.3333333333333333d0)))
if (l <= (-1.45d+102)) then
tmp = t_2
else if (l <= (-2.8d0)) then
tmp = u + (t_0 * (j + (j * ((-0.125d0) * (k * k)))))
else if (l <= 8.8d+18) then
tmp = u + (t_1 * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
else if (l <= 5.6d+102) then
tmp = (t_0 * j) + u
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);
double t_1 = Math.cos((K / 2.0));
double t_2 = U + (t_1 * (Math.pow(l, 3.0) * (J * 0.3333333333333333)));
double tmp;
if (l <= -1.45e+102) {
tmp = t_2;
} else if (l <= -2.8) {
tmp = U + (t_0 * (J + (J * (-0.125 * (K * K)))));
} else if (l <= 8.8e+18) {
tmp = U + (t_1 * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 5.6e+102) {
tmp = (t_0 * J) + U;
} else {
tmp = t_2;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) t_1 = math.cos((K / 2.0)) t_2 = U + (t_1 * (math.pow(l, 3.0) * (J * 0.3333333333333333))) tmp = 0 if l <= -1.45e+102: tmp = t_2 elif l <= -2.8: tmp = U + (t_0 * (J + (J * (-0.125 * (K * K))))) elif l <= 8.8e+18: tmp = U + (t_1 * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) elif l <= 5.6e+102: tmp = (t_0 * J) + U else: tmp = t_2 return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) t_1 = cos(Float64(K / 2.0)) t_2 = Float64(U + Float64(t_1 * Float64((l ^ 3.0) * Float64(J * 0.3333333333333333)))) tmp = 0.0 if (l <= -1.45e+102) tmp = t_2; elseif (l <= -2.8) tmp = Float64(U + Float64(t_0 * Float64(J + Float64(J * Float64(-0.125 * Float64(K * K)))))); elseif (l <= 8.8e+18) tmp = Float64(U + Float64(t_1 * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))); elseif (l <= 5.6e+102) tmp = Float64(Float64(t_0 * J) + U); else tmp = t_2; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); t_1 = cos((K / 2.0)); t_2 = U + (t_1 * ((l ^ 3.0) * (J * 0.3333333333333333))); tmp = 0.0; if (l <= -1.45e+102) tmp = t_2; elseif (l <= -2.8) tmp = U + (t_0 * (J + (J * (-0.125 * (K * K))))); elseif (l <= 8.8e+18) tmp = U + (t_1 * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))); elseif (l <= 5.6e+102) tmp = (t_0 * J) + U; else tmp = t_2; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(U + N[(t$95$1 * N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.45e+102], t$95$2, If[LessEqual[l, -2.8], N[(U + N[(t$95$0 * N[(J + N[(J * N[(-0.125 * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 8.8e+18], N[(U + N[(t$95$1 * 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, 5.6e+102], N[(N[(t$95$0 * J), $MachinePrecision] + U), $MachinePrecision], t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
t_1 := \cos \left(\frac{K}{2}\right)\\
t_2 := U + t_1 \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\
\mathbf{if}\;\ell \leq -1.45 \cdot 10^{+102}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\ell \leq -2.8:\\
\;\;\;\;U + t_0 \cdot \left(J + J \cdot \left(-0.125 \cdot \left(K \cdot K\right)\right)\right)\\
\mathbf{elif}\;\ell \leq 8.8 \cdot 10^{+18}:\\
\;\;\;\;U + t_1 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 5.6 \cdot 10^{+102}:\\
\;\;\;\;t_0 \cdot J + U\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if l < -1.4500000000000001e102 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%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
if -1.4500000000000001e102 < l < -2.7999999999999998Initial program 100.0%
Taylor expanded in K around 0 0.3%
+-commutative0.3%
associate-*r*0.3%
associate-*r*0.3%
distribute-rgt-out81.3%
associate-*r*81.3%
*-commutative81.3%
associate-*l*81.3%
unpow281.3%
Simplified81.3%
if -2.7999999999999998 < l < 8.8e18Initial program 67.0%
Taylor expanded in l around 0 98.6%
if 8.8e18 < l < 5.60000000000000037e102Initial program 100.0%
Taylor expanded in K around 0 77.8%
Final simplification96.1%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ U (* (cos (/ K 2.0)) (* (pow l 3.0) (* J 0.3333333333333333)))))
(t_1 (+ (* (- (exp l) (exp (- l))) J) U)))
(if (<= l -7.6e+92)
t_0
(if (<= l -330.0)
t_1
(if (<= l 8.8e+18)
(+ U (* l (* (cos (* K 0.5)) (* J 2.0))))
(if (<= l 2.95e+101) t_1 t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + (cos((K / 2.0)) * (pow(l, 3.0) * (J * 0.3333333333333333)));
double t_1 = ((exp(l) - exp(-l)) * J) + U;
double tmp;
if (l <= -7.6e+92) {
tmp = t_0;
} else if (l <= -330.0) {
tmp = t_1;
} else if (l <= 8.8e+18) {
tmp = U + (l * (cos((K * 0.5)) * (J * 2.0)));
} else if (l <= 2.95e+101) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = u + (cos((k / 2.0d0)) * ((l ** 3.0d0) * (j * 0.3333333333333333d0)))
t_1 = ((exp(l) - exp(-l)) * j) + u
if (l <= (-7.6d+92)) then
tmp = t_0
else if (l <= (-330.0d0)) then
tmp = t_1
else if (l <= 8.8d+18) then
tmp = u + (l * (cos((k * 0.5d0)) * (j * 2.0d0)))
else if (l <= 2.95d+101) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = U + (Math.cos((K / 2.0)) * (Math.pow(l, 3.0) * (J * 0.3333333333333333)));
double t_1 = ((Math.exp(l) - Math.exp(-l)) * J) + U;
double tmp;
if (l <= -7.6e+92) {
tmp = t_0;
} else if (l <= -330.0) {
tmp = t_1;
} else if (l <= 8.8e+18) {
tmp = U + (l * (Math.cos((K * 0.5)) * (J * 2.0)));
} else if (l <= 2.95e+101) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (math.cos((K / 2.0)) * (math.pow(l, 3.0) * (J * 0.3333333333333333))) t_1 = ((math.exp(l) - math.exp(-l)) * J) + U tmp = 0 if l <= -7.6e+92: tmp = t_0 elif l <= -330.0: tmp = t_1 elif l <= 8.8e+18: tmp = U + (l * (math.cos((K * 0.5)) * (J * 2.0))) elif l <= 2.95e+101: tmp = t_1 else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64((l ^ 3.0) * Float64(J * 0.3333333333333333)))) t_1 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) tmp = 0.0 if (l <= -7.6e+92) tmp = t_0; elseif (l <= -330.0) tmp = t_1; elseif (l <= 8.8e+18) tmp = Float64(U + Float64(l * Float64(cos(Float64(K * 0.5)) * Float64(J * 2.0)))); elseif (l <= 2.95e+101) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + (cos((K / 2.0)) * ((l ^ 3.0) * (J * 0.3333333333333333))); t_1 = ((exp(l) - exp(-l)) * J) + U; tmp = 0.0; if (l <= -7.6e+92) tmp = t_0; elseif (l <= -330.0) tmp = t_1; elseif (l <= 8.8e+18) tmp = U + (l * (cos((K * 0.5)) * (J * 2.0))); elseif (l <= 2.95e+101) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -7.6e+92], t$95$0, If[LessEqual[l, -330.0], t$95$1, If[LessEqual[l, 8.8e+18], N[(U + N[(l * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.95e+101], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\
t_1 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{if}\;\ell \leq -7.6 \cdot 10^{+92}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -330:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq 8.8 \cdot 10^{+18}:\\
\;\;\;\;U + \ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 2.95 \cdot 10^{+101}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if l < -7.6000000000000001e92 or 2.9499999999999999e101 < l Initial program 100.0%
Taylor expanded in l around 0 98.8%
Taylor expanded in l around inf 98.8%
*-commutative98.8%
*-commutative98.8%
associate-*l*98.8%
Simplified98.8%
if -7.6000000000000001e92 < l < -330 or 8.8e18 < l < 2.9499999999999999e101Initial program 100.0%
Taylor expanded in K around 0 70.3%
if -330 < l < 8.8e18Initial program 67.2%
Taylor expanded in l around 0 97.5%
associate-*r*97.5%
*-commutative97.5%
associate-*l*97.6%
Simplified97.6%
Final simplification94.0%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.02) (+ U (* 2.0 (* J (* l (cos (* K 0.5)))))) (+ U (* J (+ (* 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.02) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} 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.02d0)) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
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.02) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} 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.02: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) 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.02) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); 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.02) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); 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.02], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(N[(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.02:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.0200000000000000004Initial program 79.0%
Taylor expanded in l around 0 69.8%
if -0.0200000000000000004 < (cos.f64 (/.f64 K 2)) Initial program 83.6%
Taylor expanded in l around 0 88.6%
Taylor expanded in K around 0 82.8%
Final simplification79.3%
(FPCore (J l K U) :precision binary64 (if (or (<= l -330.0) (not (<= l 8.8e+18))) (+ (* (- (exp l) (exp (- l))) J) U) (+ U (* l (* (cos (* K 0.5)) (* J 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -330.0) || !(l <= 8.8e+18)) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} else {
tmp = U + (l * (cos((K * 0.5)) * (J * 2.0)));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-330.0d0)) .or. (.not. (l <= 8.8d+18))) then
tmp = ((exp(l) - exp(-l)) * j) + u
else
tmp = u + (l * (cos((k * 0.5d0)) * (j * 2.0d0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -330.0) || !(l <= 8.8e+18)) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} else {
tmp = U + (l * (Math.cos((K * 0.5)) * (J * 2.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -330.0) or not (l <= 8.8e+18): tmp = ((math.exp(l) - math.exp(-l)) * J) + U else: tmp = U + (l * (math.cos((K * 0.5)) * (J * 2.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -330.0) || !(l <= 8.8e+18)) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); else tmp = Float64(U + Float64(l * Float64(cos(Float64(K * 0.5)) * Float64(J * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -330.0) || ~((l <= 8.8e+18))) tmp = ((exp(l) - exp(-l)) * J) + U; else tmp = U + (l * (cos((K * 0.5)) * (J * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -330.0], N[Not[LessEqual[l, 8.8e+18]], $MachinePrecision]], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(l * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -330 \lor \neg \left(\ell \leq 8.8 \cdot 10^{+18}\right):\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right)\right)\\
\end{array}
\end{array}
if l < -330 or 8.8e18 < l Initial program 100.0%
Taylor expanded in K around 0 74.6%
if -330 < l < 8.8e18Initial program 67.2%
Taylor expanded in l around 0 97.5%
associate-*r*97.5%
*-commutative97.5%
associate-*l*97.6%
Simplified97.6%
Final simplification87.0%
(FPCore (J l K U) :precision binary64 (if (or (<= l -8.5e+51) (not (<= l 2.7e+62))) (+ U (* 0.3333333333333333 (* J (pow l 3.0)))) (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -8.5e+51) || !(l <= 2.7e+62)) {
tmp = U + (0.3333333333333333 * (J * pow(l, 3.0)));
} 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 <= (-8.5d+51)) .or. (.not. (l <= 2.7d+62))) then
tmp = u + (0.3333333333333333d0 * (j * (l ** 3.0d0)))
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 <= -8.5e+51) || !(l <= 2.7e+62)) {
tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
} else {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -8.5e+51) or not (l <= 2.7e+62): tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) 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 <= -8.5e+51) || !(l <= 2.7e+62)) tmp = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))); 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 <= -8.5e+51) || ~((l <= 2.7e+62))) tmp = U + (0.3333333333333333 * (J * (l ^ 3.0))); 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, -8.5e+51], N[Not[LessEqual[l, 2.7e+62]], $MachinePrecision]], N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -8.5 \cdot 10^{+51} \lor \neg \left(\ell \leq 2.7 \cdot 10^{+62}\right):\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if l < -8.4999999999999999e51 or 2.7e62 < l Initial program 100.0%
Taylor expanded in l around 0 89.8%
Taylor expanded in K around 0 70.6%
Taylor expanded in l around inf 70.6%
if -8.4999999999999999e51 < l < 2.7e62Initial program 72.1%
Taylor expanded in l around 0 85.4%
Final simplification79.9%
(FPCore (J l K U) :precision binary64 (if (or (<= l -1.25e+52) (not (<= l 3.05e+62))) (+ U (* 0.3333333333333333 (* J (pow l 3.0)))) (+ U (* l (* (cos (* K 0.5)) (* J 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1.25e+52) || !(l <= 3.05e+62)) {
tmp = U + (0.3333333333333333 * (J * pow(l, 3.0)));
} else {
tmp = U + (l * (cos((K * 0.5)) * (J * 2.0)));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-1.25d+52)) .or. (.not. (l <= 3.05d+62))) then
tmp = u + (0.3333333333333333d0 * (j * (l ** 3.0d0)))
else
tmp = u + (l * (cos((k * 0.5d0)) * (j * 2.0d0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1.25e+52) || !(l <= 3.05e+62)) {
tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
} else {
tmp = U + (l * (Math.cos((K * 0.5)) * (J * 2.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -1.25e+52) or not (l <= 3.05e+62): tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) else: tmp = U + (l * (math.cos((K * 0.5)) * (J * 2.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -1.25e+52) || !(l <= 3.05e+62)) tmp = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))); else tmp = Float64(U + Float64(l * Float64(cos(Float64(K * 0.5)) * Float64(J * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -1.25e+52) || ~((l <= 3.05e+62))) tmp = U + (0.3333333333333333 * (J * (l ^ 3.0))); else tmp = U + (l * (cos((K * 0.5)) * (J * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -1.25e+52], N[Not[LessEqual[l, 3.05e+62]], $MachinePrecision]], N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(l * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.25 \cdot 10^{+52} \lor \neg \left(\ell \leq 3.05 \cdot 10^{+62}\right):\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right)\right)\\
\end{array}
\end{array}
if l < -1.25e52 or 3.0499999999999998e62 < l Initial program 100.0%
Taylor expanded in l around 0 89.8%
Taylor expanded in K around 0 70.6%
Taylor expanded in l around inf 70.6%
if -1.25e52 < l < 3.0499999999999998e62Initial program 72.1%
Taylor expanded in l around 0 85.4%
associate-*r*85.4%
*-commutative85.4%
associate-*l*85.4%
Simplified85.4%
Final simplification80.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ U (* 0.3333333333333333 (* J (pow l 3.0))))))
(if (<= l -1.6e+93)
t_0
(if (<= l -200.0)
(+ U (* J (+ (* K K) -8.0)))
(if (<= l 12.2) (+ U (* l (* J 2.0))) t_0)))))
double code(double J, double l, double K, double U) {
double t_0 = U + (0.3333333333333333 * (J * pow(l, 3.0)));
double tmp;
if (l <= -1.6e+93) {
tmp = t_0;
} else if (l <= -200.0) {
tmp = U + (J * ((K * K) + -8.0));
} else if (l <= 12.2) {
tmp = U + (l * (J * 2.0));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = u + (0.3333333333333333d0 * (j * (l ** 3.0d0)))
if (l <= (-1.6d+93)) then
tmp = t_0
else if (l <= (-200.0d0)) then
tmp = u + (j * ((k * k) + (-8.0d0)))
else if (l <= 12.2d0) then
tmp = u + (l * (j * 2.0d0))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
double tmp;
if (l <= -1.6e+93) {
tmp = t_0;
} else if (l <= -200.0) {
tmp = U + (J * ((K * K) + -8.0));
} else if (l <= 12.2) {
tmp = U + (l * (J * 2.0));
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) tmp = 0 if l <= -1.6e+93: tmp = t_0 elif l <= -200.0: tmp = U + (J * ((K * K) + -8.0)) elif l <= 12.2: tmp = U + (l * (J * 2.0)) else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))) tmp = 0.0 if (l <= -1.6e+93) tmp = t_0; elseif (l <= -200.0) tmp = Float64(U + Float64(J * Float64(Float64(K * K) + -8.0))); elseif (l <= 12.2) tmp = Float64(U + Float64(l * Float64(J * 2.0))); else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + (0.3333333333333333 * (J * (l ^ 3.0))); tmp = 0.0; if (l <= -1.6e+93) tmp = t_0; elseif (l <= -200.0) tmp = U + (J * ((K * K) + -8.0)); elseif (l <= 12.2) tmp = U + (l * (J * 2.0)); else tmp = t_0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.6e+93], t$95$0, If[LessEqual[l, -200.0], N[(U + N[(J * N[(N[(K * K), $MachinePrecision] + -8.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 12.2], N[(U + N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{if}\;\ell \leq -1.6 \cdot 10^{+93}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -200:\\
\;\;\;\;U + J \cdot \left(K \cdot K + -8\right)\\
\mathbf{elif}\;\ell \leq 12.2:\\
\;\;\;\;U + \ell \cdot \left(J \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if l < -1.6000000000000001e93 or 12.199999999999999 < l Initial program 100.0%
Taylor expanded in l around 0 85.0%
Taylor expanded in K around 0 64.9%
Taylor expanded in l around inf 64.9%
if -1.6000000000000001e93 < l < -200Initial program 100.0%
Applied egg-rr3.7%
Taylor expanded in K around 0 40.0%
*-commutative40.0%
distribute-lft-out40.0%
unpow240.0%
Simplified40.0%
if -200 < l < 12.199999999999999Initial program 66.2%
Taylor expanded in l around 0 98.9%
associate-*r*98.9%
*-commutative98.9%
associate-*l*98.9%
Simplified98.9%
Taylor expanded in K around 0 79.6%
Final simplification70.6%
(FPCore (J l K U) :precision binary64 (+ U (* l (* J 2.0))))
double code(double J, double l, double K, double U) {
return U + (l * (J * 2.0));
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u + (l * (j * 2.0d0))
end function
public static double code(double J, double l, double K, double U) {
return U + (l * (J * 2.0));
}
def code(J, l, K, U): return U + (l * (J * 2.0))
function code(J, l, K, U) return Float64(U + Float64(l * Float64(J * 2.0))) end
function tmp = code(J, l, K, U) tmp = U + (l * (J * 2.0)); end
code[J_, l_, K_, U_] := N[(U + N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \ell \cdot \left(J \cdot 2\right)
\end{array}
Initial program 82.3%
Taylor expanded in l around 0 66.5%
associate-*r*66.5%
*-commutative66.5%
associate-*l*66.5%
Simplified66.5%
Taylor expanded in K around 0 51.9%
Final simplification51.9%
(FPCore (J l K U) :precision binary64 U)
double code(double J, double l, double K, double U) {
return U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
public static double code(double J, double l, double K, double U) {
return U;
}
def code(J, l, K, U): return U
function code(J, l, K, U) return U end
function tmp = code(J, l, K, U) tmp = U; end
code[J_, l_, K_, U_] := U
\begin{array}{l}
\\
U
\end{array}
Initial program 82.3%
Applied egg-rr25.9%
Taylor expanded in J around 0 34.2%
Final simplification34.2%
herbie shell --seed 2023283
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))