
(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 15 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 (- INFINITY)) (not (<= t_1 0.005)))
(+ (* t_0 (* t_1 J)) U)
(+
U
(*
t_0
(*
J
(+
(* 0.3333333333333333 (pow l 3.0))
(+ (* 0.016666666666666666 (pow l 5.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.005)) {
tmp = (t_0 * (t_1 * J)) + U;
} else {
tmp = U + (t_0 * (J * ((0.3333333333333333 * pow(l, 3.0)) + ((0.016666666666666666 * pow(l, 5.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.005)) {
tmp = (t_0 * (t_1 * J)) + U;
} else {
tmp = U + (t_0 * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + ((0.016666666666666666 * Math.pow(l, 5.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.005): tmp = (t_0 * (t_1 * J)) + U else: tmp = U + (t_0 * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + ((0.016666666666666666 * math.pow(l, 5.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.005)) tmp = Float64(Float64(t_0 * Float64(t_1 * J)) + U); else tmp = Float64(U + Float64(t_0 * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(Float64(0.016666666666666666 * (l ^ 5.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.005))) tmp = (t_0 * (t_1 * J)) + U; else tmp = U + (t_0 * (J * ((0.3333333333333333 * (l ^ 3.0)) + ((0.016666666666666666 * (l ^ 5.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.005]], $MachinePrecision]], N[(N[(t$95$0 * N[(t$95$1 * J), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.016666666666666666 * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $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.005\right):\\
\;\;\;\;t_0 \cdot \left(t_1 \cdot J\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + t_0 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \left(0.016666666666666666 \cdot {\ell}^{5} + \ell \cdot 2\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 0.0050000000000000001 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0050000000000000001Initial program 69.5%
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 (- (exp l) (exp (- l)))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 1e-14)))
(+ (* t_0 (* t_1 J)) 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 <= 1e-14)) {
tmp = (t_0 * (t_1 * J)) + 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 <= 1e-14)) {
tmp = (t_0 * (t_1 * J)) + 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 <= 1e-14): tmp = (t_0 * (t_1 * J)) + 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 <= 1e-14)) tmp = Float64(Float64(t_0 * Float64(t_1 * J)) + 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 <= 1e-14))) tmp = (t_0 * (t_1 * J)) + 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, 1e-14]], $MachinePrecision]], N[(N[(t$95$0 * N[(t$95$1 * J), $MachinePrecision]), $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 10^{-14}\right):\\
\;\;\;\;t_0 \cdot \left(t_1 \cdot J\right) + 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 9.99999999999999999e-15 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 99.9%
if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 9.99999999999999999e-15Initial program 69.1%
Taylor expanded in l around 0 99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* (- (exp l) (exp (- l))) J))
(t_1 (cos (/ K 2.0)))
(t_2 (+ U (* t_1 (* (pow l 5.0) (* J 0.016666666666666666))))))
(if (<= l -1e+116)
t_2
(if (<= l -980000.0)
(+ U t_0)
(if (<= l 3000.0)
(+ U (* t_1 (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
(if (<= l 4.5e+61) (+ U (* t_0 (+ (* -0.125 (* K K)) 1.0))) t_2))))))
double code(double J, double l, double K, double U) {
double t_0 = (exp(l) - exp(-l)) * J;
double t_1 = cos((K / 2.0));
double t_2 = U + (t_1 * (pow(l, 5.0) * (J * 0.016666666666666666)));
double tmp;
if (l <= -1e+116) {
tmp = t_2;
} else if (l <= -980000.0) {
tmp = U + t_0;
} else if (l <= 3000.0) {
tmp = U + (t_1 * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 4.5e+61) {
tmp = U + (t_0 * ((-0.125 * (K * K)) + 1.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
t_1 = cos((k / 2.0d0))
t_2 = u + (t_1 * ((l ** 5.0d0) * (j * 0.016666666666666666d0)))
if (l <= (-1d+116)) then
tmp = t_2
else if (l <= (-980000.0d0)) then
tmp = u + t_0
else if (l <= 3000.0d0) then
tmp = u + (t_1 * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
else if (l <= 4.5d+61) then
tmp = u + (t_0 * (((-0.125d0) * (k * k)) + 1.0d0))
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;
double t_1 = Math.cos((K / 2.0));
double t_2 = U + (t_1 * (Math.pow(l, 5.0) * (J * 0.016666666666666666)));
double tmp;
if (l <= -1e+116) {
tmp = t_2;
} else if (l <= -980000.0) {
tmp = U + t_0;
} else if (l <= 3000.0) {
tmp = U + (t_1 * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 4.5e+61) {
tmp = U + (t_0 * ((-0.125 * (K * K)) + 1.0));
} else {
tmp = t_2;
}
return tmp;
}
def code(J, l, K, U): t_0 = (math.exp(l) - math.exp(-l)) * J t_1 = math.cos((K / 2.0)) t_2 = U + (t_1 * (math.pow(l, 5.0) * (J * 0.016666666666666666))) tmp = 0 if l <= -1e+116: tmp = t_2 elif l <= -980000.0: tmp = U + t_0 elif l <= 3000.0: tmp = U + (t_1 * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) elif l <= 4.5e+61: tmp = U + (t_0 * ((-0.125 * (K * K)) + 1.0)) else: tmp = t_2 return tmp
function code(J, l, K, U) t_0 = Float64(Float64(exp(l) - exp(Float64(-l))) * J) t_1 = cos(Float64(K / 2.0)) t_2 = Float64(U + Float64(t_1 * Float64((l ^ 5.0) * Float64(J * 0.016666666666666666)))) tmp = 0.0 if (l <= -1e+116) tmp = t_2; elseif (l <= -980000.0) tmp = Float64(U + t_0); elseif (l <= 3000.0) tmp = Float64(U + Float64(t_1 * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))); elseif (l <= 4.5e+61) tmp = Float64(U + Float64(t_0 * Float64(Float64(-0.125 * Float64(K * K)) + 1.0))); else tmp = t_2; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = (exp(l) - exp(-l)) * J; t_1 = cos((K / 2.0)); t_2 = U + (t_1 * ((l ^ 5.0) * (J * 0.016666666666666666))); tmp = 0.0; if (l <= -1e+116) tmp = t_2; elseif (l <= -980000.0) tmp = U + t_0; elseif (l <= 3000.0) tmp = U + (t_1 * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))); elseif (l <= 4.5e+61) tmp = U + (t_0 * ((-0.125 * (K * K)) + 1.0)); else tmp = t_2; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $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, 5.0], $MachinePrecision] * N[(J * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1e+116], t$95$2, If[LessEqual[l, -980000.0], N[(U + t$95$0), $MachinePrecision], If[LessEqual[l, 3000.0], 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, 4.5e+61], N[(U + N[(t$95$0 * N[(N[(-0.125 * N[(K * K), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
t_1 := \cos \left(\frac{K}{2}\right)\\
t_2 := U + t_1 \cdot \left({\ell}^{5} \cdot \left(J \cdot 0.016666666666666666\right)\right)\\
\mathbf{if}\;\ell \leq -1 \cdot 10^{+116}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\ell \leq -980000:\\
\;\;\;\;U + t_0\\
\mathbf{elif}\;\ell \leq 3000:\\
\;\;\;\;U + t_1 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 4.5 \cdot 10^{+61}:\\
\;\;\;\;U + t_0 \cdot \left(-0.125 \cdot \left(K \cdot K\right) + 1\right)\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if l < -1.00000000000000002e116 or 4.5e61 < l Initial program 100.0%
Taylor expanded in l around 0 100.0%
Taylor expanded in l around inf 100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
if -1.00000000000000002e116 < l < -9.8e5Initial program 100.0%
Taylor expanded in K around 0 100.0%
if -9.8e5 < l < 3e3Initial program 70.1%
Taylor expanded in l around 0 98.5%
if 3e3 < l < 4.5e61Initial program 100.0%
Taylor expanded in K around 0 0.0%
associate-*r*0.0%
distribute-rgt1-in81.8%
unpow281.8%
Simplified81.8%
Final simplification98.4%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1 (+ U (* t_0 (* (pow l 5.0) (* J 0.016666666666666666)))))
(t_2 (+ U (* (- (exp l) (exp (- l))) J))))
(if (<= l -1e+116)
t_1
(if (<= l -980000.0)
t_2
(if (<= l 0.051)
(+ U (* t_0 (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
(if (<= l 4.2e+49) 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, 5.0) * (J * 0.016666666666666666)));
double t_2 = U + ((exp(l) - exp(-l)) * J);
double tmp;
if (l <= -1e+116) {
tmp = t_1;
} else if (l <= -980000.0) {
tmp = t_2;
} else if (l <= 0.051) {
tmp = U + (t_0 * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 4.2e+49) {
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 ** 5.0d0) * (j * 0.016666666666666666d0)))
t_2 = u + ((exp(l) - exp(-l)) * j)
if (l <= (-1d+116)) then
tmp = t_1
else if (l <= (-980000.0d0)) then
tmp = t_2
else if (l <= 0.051d0) then
tmp = u + (t_0 * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
else if (l <= 4.2d+49) 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, 5.0) * (J * 0.016666666666666666)));
double t_2 = U + ((Math.exp(l) - Math.exp(-l)) * J);
double tmp;
if (l <= -1e+116) {
tmp = t_1;
} else if (l <= -980000.0) {
tmp = t_2;
} else if (l <= 0.051) {
tmp = U + (t_0 * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 4.2e+49) {
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, 5.0) * (J * 0.016666666666666666))) t_2 = U + ((math.exp(l) - math.exp(-l)) * J) tmp = 0 if l <= -1e+116: tmp = t_1 elif l <= -980000.0: tmp = t_2 elif l <= 0.051: tmp = U + (t_0 * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) elif l <= 4.2e+49: 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 ^ 5.0) * Float64(J * 0.016666666666666666)))) t_2 = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J)) tmp = 0.0 if (l <= -1e+116) tmp = t_1; elseif (l <= -980000.0) tmp = t_2; elseif (l <= 0.051) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))); elseif (l <= 4.2e+49) 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 ^ 5.0) * (J * 0.016666666666666666))); t_2 = U + ((exp(l) - exp(-l)) * J); tmp = 0.0; if (l <= -1e+116) tmp = t_1; elseif (l <= -980000.0) tmp = t_2; elseif (l <= 0.051) tmp = U + (t_0 * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))); elseif (l <= 4.2e+49) 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, 5.0], $MachinePrecision] * N[(J * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1e+116], t$95$1, If[LessEqual[l, -980000.0], t$95$2, If[LessEqual[l, 0.051], 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, 4.2e+49], 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}^{5} \cdot \left(J \cdot 0.016666666666666666\right)\right)\\
t_2 := U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;\ell \leq -1 \cdot 10^{+116}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq -980000:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\ell \leq 0.051:\\
\;\;\;\;U + t_0 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 4.2 \cdot 10^{+49}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if l < -1.00000000000000002e116 or 4.20000000000000022e49 < l Initial program 100.0%
Taylor expanded in l around 0 98.9%
Taylor expanded in l around inf 98.9%
associate-*r*98.9%
*-commutative98.9%
associate-*l*98.9%
Simplified98.9%
if -1.00000000000000002e116 < l < -9.8e5 or 0.0509999999999999967 < l < 4.20000000000000022e49Initial program 100.0%
Taylor expanded in K around 0 88.5%
if -9.8e5 < l < 0.0509999999999999967Initial program 69.7%
Taylor expanded in l around 0 99.1%
Final simplification98.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1 (+ U (* t_0 (* (pow l 5.0) (* J 0.016666666666666666)))))
(t_2 (+ U (* (- (exp l) (exp (- l))) J))))
(if (<= l -1e+116)
t_1
(if (<= l -980000.0)
t_2
(if (<= l 0.0054)
(fma (* l 2.0) (* J t_0) U)
(if (<= l 4.2e+49) 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, 5.0) * (J * 0.016666666666666666)));
double t_2 = U + ((exp(l) - exp(-l)) * J);
double tmp;
if (l <= -1e+116) {
tmp = t_1;
} else if (l <= -980000.0) {
tmp = t_2;
} else if (l <= 0.0054) {
tmp = fma((l * 2.0), (J * t_0), U);
} else if (l <= 4.2e+49) {
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 ^ 5.0) * Float64(J * 0.016666666666666666)))) t_2 = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J)) tmp = 0.0 if (l <= -1e+116) tmp = t_1; elseif (l <= -980000.0) tmp = t_2; elseif (l <= 0.0054) tmp = fma(Float64(l * 2.0), Float64(J * t_0), U); elseif (l <= 4.2e+49) tmp = t_2; else tmp = t_1; end return 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, 5.0], $MachinePrecision] * N[(J * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1e+116], t$95$1, If[LessEqual[l, -980000.0], t$95$2, If[LessEqual[l, 0.0054], N[(N[(l * 2.0), $MachinePrecision] * N[(J * t$95$0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 4.2e+49], 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}^{5} \cdot \left(J \cdot 0.016666666666666666\right)\right)\\
t_2 := U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;\ell \leq -1 \cdot 10^{+116}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq -980000:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\ell \leq 0.0054:\\
\;\;\;\;\mathsf{fma}\left(\ell \cdot 2, J \cdot t_0, U\right)\\
\mathbf{elif}\;\ell \leq 4.2 \cdot 10^{+49}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if l < -1.00000000000000002e116 or 4.20000000000000022e49 < l Initial program 100.0%
Taylor expanded in l around 0 98.9%
Taylor expanded in l around inf 98.9%
associate-*r*98.9%
*-commutative98.9%
associate-*l*98.9%
Simplified98.9%
if -1.00000000000000002e116 < l < -9.8e5 or 0.0054000000000000003 < l < 4.20000000000000022e49Initial program 100.0%
Taylor expanded in K around 0 88.5%
if -9.8e5 < l < 0.0054000000000000003Initial program 69.7%
*-commutative69.7%
associate-*l*69.7%
fma-def69.7%
Simplified69.7%
Taylor expanded in l around 0 98.7%
Final simplification97.7%
(FPCore (J l K U) :precision binary64 (if (or (<= l -980000.0) (not (<= l 0.0075))) (+ U (* (- (exp l) (exp (- l))) J)) (fma (* l 2.0) (* J (cos (/ K 2.0))) U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -980000.0) || !(l <= 0.0075)) {
tmp = U + ((exp(l) - exp(-l)) * J);
} else {
tmp = fma((l * 2.0), (J * cos((K / 2.0))), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if ((l <= -980000.0) || !(l <= 0.0075)) tmp = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J)); else tmp = fma(Float64(l * 2.0), Float64(J * cos(Float64(K / 2.0))), U); end return tmp end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -980000.0], N[Not[LessEqual[l, 0.0075]], $MachinePrecision]], N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision], N[(N[(l * 2.0), $MachinePrecision] * N[(J * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -980000 \lor \neg \left(\ell \leq 0.0075\right):\\
\;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\ell \cdot 2, J \cdot \cos \left(\frac{K}{2}\right), U\right)\\
\end{array}
\end{array}
if l < -9.8e5 or 0.0074999999999999997 < l Initial program 100.0%
Taylor expanded in K around 0 83.0%
if -9.8e5 < l < 0.0074999999999999997Initial program 69.7%
*-commutative69.7%
associate-*l*69.7%
fma-def69.7%
Simplified69.7%
Taylor expanded in l around 0 98.7%
Final simplification91.8%
(FPCore (J l K U) :precision binary64 (if (or (<= l -980000.0) (not (<= l 0.0023))) (+ U (* (- (exp l) (exp (- l))) J)) (+ U (* 2.0 (* l (* J (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -980000.0) || !(l <= 0.0023)) {
tmp = U + ((exp(l) - exp(-l)) * J);
} else {
tmp = U + (2.0 * (l * (J * 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 <= (-980000.0d0)) .or. (.not. (l <= 0.0023d0))) then
tmp = u + ((exp(l) - exp(-l)) * j)
else
tmp = u + (2.0d0 * (l * (j * 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 <= -980000.0) || !(l <= 0.0023)) {
tmp = U + ((Math.exp(l) - Math.exp(-l)) * J);
} else {
tmp = U + (2.0 * (l * (J * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -980000.0) or not (l <= 0.0023): tmp = U + ((math.exp(l) - math.exp(-l)) * J) else: tmp = U + (2.0 * (l * (J * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -980000.0) || !(l <= 0.0023)) tmp = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J)); else tmp = Float64(U + Float64(2.0 * Float64(l * Float64(J * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -980000.0) || ~((l <= 0.0023))) tmp = U + ((exp(l) - exp(-l)) * J); else tmp = U + (2.0 * (l * (J * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -980000.0], N[Not[LessEqual[l, 0.0023]], $MachinePrecision]], N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(l * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -980000 \lor \neg \left(\ell \leq 0.0023\right):\\
\;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if l < -9.8e5 or 0.0023 < l Initial program 100.0%
Taylor expanded in K around 0 83.0%
if -9.8e5 < l < 0.0023Initial program 69.7%
Taylor expanded in l around 0 98.6%
*-commutative98.6%
associate-*l*98.7%
*-commutative98.7%
Simplified98.7%
Final simplification91.8%
(FPCore (J l K U)
:precision binary64
(if (or (<= l -620.0) (not (<= l 3000.0)))
(+
U
(*
(* J (pow l 5.0))
(+ 0.016666666666666666 (* (* K K) -0.0020833333333333333))))
(+ U (* 2.0 (* l (* J (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -620.0) || !(l <= 3000.0)) {
tmp = U + ((J * pow(l, 5.0)) * (0.016666666666666666 + ((K * K) * -0.0020833333333333333)));
} else {
tmp = U + (2.0 * (l * (J * 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 <= (-620.0d0)) .or. (.not. (l <= 3000.0d0))) then
tmp = u + ((j * (l ** 5.0d0)) * (0.016666666666666666d0 + ((k * k) * (-0.0020833333333333333d0))))
else
tmp = u + (2.0d0 * (l * (j * 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 <= -620.0) || !(l <= 3000.0)) {
tmp = U + ((J * Math.pow(l, 5.0)) * (0.016666666666666666 + ((K * K) * -0.0020833333333333333)));
} else {
tmp = U + (2.0 * (l * (J * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -620.0) or not (l <= 3000.0): tmp = U + ((J * math.pow(l, 5.0)) * (0.016666666666666666 + ((K * K) * -0.0020833333333333333))) else: tmp = U + (2.0 * (l * (J * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -620.0) || !(l <= 3000.0)) tmp = Float64(U + Float64(Float64(J * (l ^ 5.0)) * Float64(0.016666666666666666 + Float64(Float64(K * K) * -0.0020833333333333333)))); else tmp = Float64(U + Float64(2.0 * Float64(l * Float64(J * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -620.0) || ~((l <= 3000.0))) tmp = U + ((J * (l ^ 5.0)) * (0.016666666666666666 + ((K * K) * -0.0020833333333333333))); else tmp = U + (2.0 * (l * (J * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -620.0], N[Not[LessEqual[l, 3000.0]], $MachinePrecision]], N[(U + N[(N[(J * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision] * N[(0.016666666666666666 + N[(N[(K * K), $MachinePrecision] * -0.0020833333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(l * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -620 \lor \neg \left(\ell \leq 3000\right):\\
\;\;\;\;U + \left(J \cdot {\ell}^{5}\right) \cdot \left(0.016666666666666666 + \left(K \cdot K\right) \cdot -0.0020833333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if l < -620 or 3e3 < l Initial program 100.0%
Taylor expanded in l around 0 87.0%
Taylor expanded in l around inf 87.0%
associate-*r*87.0%
*-commutative87.0%
associate-*l*87.0%
Simplified87.0%
Taylor expanded in K around 0 1.2%
associate-*r*1.2%
distribute-rgt-out68.8%
*-commutative68.8%
*-commutative68.8%
unpow268.8%
Simplified68.8%
if -620 < l < 3e3Initial program 69.9%
Taylor expanded in l around 0 98.6%
*-commutative98.6%
associate-*l*98.7%
*-commutative98.7%
Simplified98.7%
Final simplification85.7%
(FPCore (J l K U) :precision binary64 (+ U (* 2.0 (* l (* J (cos (* K 0.5)))))))
double code(double J, double l, double K, double U) {
return U + (2.0 * (l * (J * 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 * (l * (j * cos((k * 0.5d0)))))
end function
public static double code(double J, double l, double K, double U) {
return U + (2.0 * (l * (J * Math.cos((K * 0.5)))));
}
def code(J, l, K, U): return U + (2.0 * (l * (J * math.cos((K * 0.5)))))
function code(J, l, K, U) return Float64(U + Float64(2.0 * Float64(l * Float64(J * cos(Float64(K * 0.5)))))) end
function tmp = code(J, l, K, U) tmp = U + (2.0 * (l * (J * cos((K * 0.5))))); end
code[J_, l_, K_, U_] := N[(U + N[(2.0 * N[(l * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)
\end{array}
Initial program 82.9%
Taylor expanded in l around 0 70.0%
*-commutative70.0%
associate-*l*70.1%
*-commutative70.1%
Simplified70.1%
Final simplification70.1%
(FPCore (J l K U) :precision binary64 (fma l (* J 2.0) U))
double code(double J, double l, double K, double U) {
return fma(l, (J * 2.0), U);
}
function code(J, l, K, U) return fma(l, Float64(J * 2.0), U) end
code[J_, l_, K_, U_] := N[(l * N[(J * 2.0), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\ell, J \cdot 2, U\right)
\end{array}
Initial program 82.9%
Taylor expanded in l around 0 70.0%
*-commutative70.0%
associate-*l*70.1%
*-commutative70.1%
Simplified70.1%
Taylor expanded in K around 0 59.5%
associate-*r*59.5%
*-commutative59.5%
associate-*l*59.5%
fma-def59.5%
Simplified59.5%
Final simplification59.5%
(FPCore (J l K U) :precision binary64 (if (or (<= l -3e-44) (not (<= l 1.25e+22))) (* J (* l 2.0)) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -3e-44) || !(l <= 1.25e+22)) {
tmp = J * (l * 2.0);
} 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 <= (-3d-44)) .or. (.not. (l <= 1.25d+22))) then
tmp = j * (l * 2.0d0)
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 <= -3e-44) || !(l <= 1.25e+22)) {
tmp = J * (l * 2.0);
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -3e-44) or not (l <= 1.25e+22): tmp = J * (l * 2.0) else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -3e-44) || !(l <= 1.25e+22)) tmp = Float64(J * Float64(l * 2.0)); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -3e-44) || ~((l <= 1.25e+22))) tmp = J * (l * 2.0); else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -3e-44], N[Not[LessEqual[l, 1.25e+22]], $MachinePrecision]], N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3 \cdot 10^{-44} \lor \neg \left(\ell \leq 1.25 \cdot 10^{+22}\right):\\
\;\;\;\;J \cdot \left(\ell \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -3.0000000000000002e-44 or 1.2499999999999999e22 < l Initial program 95.9%
Taylor expanded in l around 0 38.5%
*-commutative38.5%
associate-*l*38.5%
*-commutative38.5%
Simplified38.5%
Taylor expanded in K around 0 34.2%
Taylor expanded in l around inf 31.5%
associate-*r*31.5%
*-commutative31.5%
Simplified31.5%
if -3.0000000000000002e-44 < l < 1.2499999999999999e22Initial program 72.2%
Taylor expanded in J around 0 67.9%
Final simplification51.4%
(FPCore (J l K U) :precision binary64 (if (<= l -1.22e+97) (* U U) (if (<= l 8800000.0) U (* U U))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -1.22e+97) {
tmp = U * U;
} else if (l <= 8800000.0) {
tmp = U;
} else {
tmp = U * U;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (l <= (-1.22d+97)) then
tmp = u * u
else if (l <= 8800000.0d0) then
tmp = u
else
tmp = u * u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -1.22e+97) {
tmp = U * U;
} else if (l <= 8800000.0) {
tmp = U;
} else {
tmp = U * U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -1.22e+97: tmp = U * U elif l <= 8800000.0: tmp = U else: tmp = U * U return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -1.22e+97) tmp = Float64(U * U); elseif (l <= 8800000.0) tmp = U; else tmp = Float64(U * U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -1.22e+97) tmp = U * U; elseif (l <= 8800000.0) tmp = U; else tmp = U * U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -1.22e+97], N[(U * U), $MachinePrecision], If[LessEqual[l, 8800000.0], U, N[(U * U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.22 \cdot 10^{+97}:\\
\;\;\;\;U \cdot U\\
\mathbf{elif}\;\ell \leq 8800000:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;U \cdot U\\
\end{array}
\end{array}
if l < -1.21999999999999997e97 or 8.8e6 < l Initial program 100.0%
Applied egg-rr12.4%
if -1.21999999999999997e97 < l < 8.8e6Initial program 72.2%
Taylor expanded in J around 0 62.7%
Final simplification43.3%
(FPCore (J l K U) :precision binary64 (+ U (* 2.0 (* l J))))
double code(double J, double l, double K, double U) {
return U + (2.0 * (l * J));
}
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 * (l * j))
end function
public static double code(double J, double l, double K, double U) {
return U + (2.0 * (l * J));
}
def code(J, l, K, U): return U + (2.0 * (l * J))
function code(J, l, K, U) return Float64(U + Float64(2.0 * Float64(l * J))) end
function tmp = code(J, l, K, U) tmp = U + (2.0 * (l * J)); end
code[J_, l_, K_, U_] := N[(U + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + 2 \cdot \left(\ell \cdot J\right)
\end{array}
Initial program 82.9%
Taylor expanded in l around 0 70.0%
*-commutative70.0%
associate-*l*70.1%
*-commutative70.1%
Simplified70.1%
Taylor expanded in K around 0 59.5%
Final simplification59.5%
(FPCore (J l K U) :precision binary64 1.0)
double code(double J, double l, double K, double U) {
return 1.0;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = 1.0d0
end function
public static double code(double J, double l, double K, double U) {
return 1.0;
}
def code(J, l, K, U): return 1.0
function code(J, l, K, U) return 1.0 end
function tmp = code(J, l, K, U) tmp = 1.0; end
code[J_, l_, K_, U_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 82.9%
Applied egg-rr2.5%
*-inverses2.5%
Simplified2.5%
Final simplification2.5%
(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.9%
Taylor expanded in J around 0 39.4%
Final simplification39.4%
herbie shell --seed 2023244
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))