
(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 16 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.0001)))
(+ (* (* t_1 J) t_0) U)
(+ U (* t_0 (* J (* l (+ 2.0 (* 0.3333333333333333 (pow 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.0001)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * pow(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.0001)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * Math.pow(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.0001): tmp = ((t_1 * J) * t_0) + U else: tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * math.pow(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.0001)) tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U); else tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = exp(l) - exp(-l); tmp = 0.0; if ((t_1 <= -Inf) || ~((t_1 <= 0.0001))) tmp = ((t_1 * J) * t_0) + U; else tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * (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.0001]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $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.0001\right):\\
\;\;\;\;\left(t\_1 \cdot J\right) \cdot t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 1.00000000000000005e-4 < (-.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))) < 1.00000000000000005e-4Initial program 75.3%
Taylor expanded in l around 0 99.9%
Final simplification100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1 (+ U (* t_0 (* J (* 0.3333333333333333 (pow l 3.0))))))
(t_2 (+ (* (- (exp l) (exp (- l))) J) U)))
(if (<= l -2.05e+68)
t_1
(if (<= l -50000000.0)
t_2
(if (<= l 0.0026)
(+ U (* t_0 (* l (* J 2.0))))
(if (<= l 1.1e+91) 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 * (J * (0.3333333333333333 * pow(l, 3.0))));
double t_2 = ((exp(l) - exp(-l)) * J) + U;
double tmp;
if (l <= -2.05e+68) {
tmp = t_1;
} else if (l <= -50000000.0) {
tmp = t_2;
} else if (l <= 0.0026) {
tmp = U + (t_0 * (l * (J * 2.0)));
} else if (l <= 1.1e+91) {
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 * (j * (0.3333333333333333d0 * (l ** 3.0d0))))
t_2 = ((exp(l) - exp(-l)) * j) + u
if (l <= (-2.05d+68)) then
tmp = t_1
else if (l <= (-50000000.0d0)) then
tmp = t_2
else if (l <= 0.0026d0) then
tmp = u + (t_0 * (l * (j * 2.0d0)))
else if (l <= 1.1d+91) 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 * (J * (0.3333333333333333 * Math.pow(l, 3.0))));
double t_2 = ((Math.exp(l) - Math.exp(-l)) * J) + U;
double tmp;
if (l <= -2.05e+68) {
tmp = t_1;
} else if (l <= -50000000.0) {
tmp = t_2;
} else if (l <= 0.0026) {
tmp = U + (t_0 * (l * (J * 2.0)));
} else if (l <= 1.1e+91) {
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 * (J * (0.3333333333333333 * math.pow(l, 3.0)))) t_2 = ((math.exp(l) - math.exp(-l)) * J) + U tmp = 0 if l <= -2.05e+68: tmp = t_1 elif l <= -50000000.0: tmp = t_2 elif l <= 0.0026: tmp = U + (t_0 * (l * (J * 2.0))) elif l <= 1.1e+91: 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(J * Float64(0.3333333333333333 * (l ^ 3.0))))) t_2 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) tmp = 0.0 if (l <= -2.05e+68) tmp = t_1; elseif (l <= -50000000.0) tmp = t_2; elseif (l <= 0.0026) tmp = Float64(U + Float64(t_0 * Float64(l * Float64(J * 2.0)))); elseif (l <= 1.1e+91) 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 * (J * (0.3333333333333333 * (l ^ 3.0)))); t_2 = ((exp(l) - exp(-l)) * J) + U; tmp = 0.0; if (l <= -2.05e+68) tmp = t_1; elseif (l <= -50000000.0) tmp = t_2; elseif (l <= 0.0026) tmp = U + (t_0 * (l * (J * 2.0))); elseif (l <= 1.1e+91) 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[(J * N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -2.05e+68], t$95$1, If[LessEqual[l, -50000000.0], t$95$2, If[LessEqual[l, 0.0026], N[(U + N[(t$95$0 * N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.1e+91], 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(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\right)\\
t_2 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{if}\;\ell \leq -2.05 \cdot 10^{+68}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq -50000000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\ell \leq 0.0026:\\
\;\;\;\;U + t\_0 \cdot \left(\ell \cdot \left(J \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+91}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if l < -2.05e68 or 1.1e91 < l Initial program 100.0%
Taylor expanded in l around 0 99.1%
Taylor expanded in l around inf 99.1%
associate-*r*99.1%
*-commutative99.1%
associate-*r*99.1%
Simplified99.1%
if -2.05e68 < l < -5e7 or 0.0025999999999999999 < l < 1.1e91Initial program 100.0%
Taylor expanded in K around 0 88.9%
if -5e7 < l < 0.0025999999999999999Initial program 75.5%
Taylor expanded in l around 0 99.0%
associate-*r*99.0%
Simplified99.0%
Final simplification97.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1 (+ U (* t_0 (* J (* 0.3333333333333333 (pow l 3.0))))))
(t_2 (+ (* (- (exp l) (exp (- l))) J) U)))
(if (<= l -2.05e+68)
t_1
(if (<= l -50000000.0)
t_2
(if (<= l 0.004)
(+ U (* t_0 (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0)))))))
(if (<= l 1.95e+92) 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 * (J * (0.3333333333333333 * pow(l, 3.0))));
double t_2 = ((exp(l) - exp(-l)) * J) + U;
double tmp;
if (l <= -2.05e+68) {
tmp = t_1;
} else if (l <= -50000000.0) {
tmp = t_2;
} else if (l <= 0.004) {
tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))))));
} else if (l <= 1.95e+92) {
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 * (j * (0.3333333333333333d0 * (l ** 3.0d0))))
t_2 = ((exp(l) - exp(-l)) * j) + u
if (l <= (-2.05d+68)) then
tmp = t_1
else if (l <= (-50000000.0d0)) then
tmp = t_2
else if (l <= 0.004d0) then
tmp = u + (t_0 * (j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0))))))
else if (l <= 1.95d+92) 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 * (J * (0.3333333333333333 * Math.pow(l, 3.0))));
double t_2 = ((Math.exp(l) - Math.exp(-l)) * J) + U;
double tmp;
if (l <= -2.05e+68) {
tmp = t_1;
} else if (l <= -50000000.0) {
tmp = t_2;
} else if (l <= 0.004) {
tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))))));
} else if (l <= 1.95e+92) {
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 * (J * (0.3333333333333333 * math.pow(l, 3.0)))) t_2 = ((math.exp(l) - math.exp(-l)) * J) + U tmp = 0 if l <= -2.05e+68: tmp = t_1 elif l <= -50000000.0: tmp = t_2 elif l <= 0.004: tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0)))))) elif l <= 1.95e+92: 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(J * Float64(0.3333333333333333 * (l ^ 3.0))))) t_2 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) tmp = 0.0 if (l <= -2.05e+68) tmp = t_1; elseif (l <= -50000000.0) tmp = t_2; elseif (l <= 0.004) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))))); elseif (l <= 1.95e+92) 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 * (J * (0.3333333333333333 * (l ^ 3.0)))); t_2 = ((exp(l) - exp(-l)) * J) + U; tmp = 0.0; if (l <= -2.05e+68) tmp = t_1; elseif (l <= -50000000.0) tmp = t_2; elseif (l <= 0.004) tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0)))))); elseif (l <= 1.95e+92) 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[(J * N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -2.05e+68], t$95$1, If[LessEqual[l, -50000000.0], t$95$2, If[LessEqual[l, 0.004], N[(U + N[(t$95$0 * N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.95e+92], 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(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\right)\\
t_2 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{if}\;\ell \leq -2.05 \cdot 10^{+68}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq -50000000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\ell \leq 0.004:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\right)\\
\mathbf{elif}\;\ell \leq 1.95 \cdot 10^{+92}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if l < -2.05e68 or 1.95000000000000006e92 < l Initial program 100.0%
Taylor expanded in l around 0 99.1%
Taylor expanded in l around inf 99.1%
associate-*r*99.1%
*-commutative99.1%
associate-*r*99.1%
Simplified99.1%
if -2.05e68 < l < -5e7 or 0.0040000000000000001 < l < 1.95000000000000006e92Initial program 100.0%
Taylor expanded in K around 0 88.9%
if -5e7 < l < 0.0040000000000000001Initial program 75.5%
Taylor expanded in l around 0 99.2%
Final simplification98.1%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 0.092)
(+ U (* t_0 (* l (* J 2.0))))
(+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0)))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= 0.092) {
tmp = U + (t_0 * (l * (J * 2.0)));
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0)))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = cos((k / 2.0d0))
if (t_0 <= 0.092d0) then
tmp = u + (t_0 * (l * (j * 2.0d0)))
else
tmp = u + (j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0)))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double tmp;
if (t_0 <= 0.092) {
tmp = U + (t_0 * (l * (J * 2.0)));
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0)))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) tmp = 0 if t_0 <= 0.092: tmp = U + (t_0 * (l * (J * 2.0))) else: tmp = U + (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0))))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= 0.092) tmp = Float64(U + Float64(t_0 * Float64(l * Float64(J * 2.0)))); else tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0)))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); tmp = 0.0; if (t_0 <= 0.092) tmp = U + (t_0 * (l * (J * 2.0))); else tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (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]}, If[LessEqual[t$95$0, 0.092], N[(U + N[(t$95$0 * N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq 0.092:\\
\;\;\;\;U + t\_0 \cdot \left(\ell \cdot \left(J \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.091999999999999998Initial program 85.0%
Taylor expanded in l around 0 68.4%
associate-*r*68.4%
Simplified68.4%
if 0.091999999999999998 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 87.8%
Taylor expanded in l around 0 90.3%
Taylor expanded in K around 0 87.9%
Final simplification82.2%
(FPCore (J l K U) :precision binary64 (if (or (<= l -50000000.0) (not (<= l 0.00041))) (+ (* (- (exp l) (exp (- l))) J) U) (+ U (* (cos (/ K 2.0)) (* l (* J 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -50000000.0) || !(l <= 0.00041)) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} else {
tmp = U + (cos((K / 2.0)) * (l * (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 <= (-50000000.0d0)) .or. (.not. (l <= 0.00041d0))) then
tmp = ((exp(l) - exp(-l)) * j) + u
else
tmp = u + (cos((k / 2.0d0)) * (l * (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 <= -50000000.0) || !(l <= 0.00041)) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} else {
tmp = U + (Math.cos((K / 2.0)) * (l * (J * 2.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -50000000.0) or not (l <= 0.00041): tmp = ((math.exp(l) - math.exp(-l)) * J) + U else: tmp = U + (math.cos((K / 2.0)) * (l * (J * 2.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -50000000.0) || !(l <= 0.00041)) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); else tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(l * Float64(J * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -50000000.0) || ~((l <= 0.00041))) tmp = ((exp(l) - exp(-l)) * J) + U; else tmp = U + (cos((K / 2.0)) * (l * (J * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -50000000.0], N[Not[LessEqual[l, 0.00041]], $MachinePrecision]], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -50000000 \lor \neg \left(\ell \leq 0.00041\right):\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(J \cdot 2\right)\right)\\
\end{array}
\end{array}
if l < -5e7 or 4.0999999999999999e-4 < l Initial program 100.0%
Taylor expanded in K around 0 73.3%
if -5e7 < l < 4.0999999999999999e-4Initial program 75.5%
Taylor expanded in l around 0 99.0%
associate-*r*99.0%
Simplified99.0%
Final simplification87.0%
(FPCore (J l K U)
:precision binary64
(if (<= l -4.7e+70)
(* 0.3333333333333333 (* J (pow l 3.0)))
(if (<= l 0.004)
(+ U (* (cos (/ K 2.0)) (* l (* J 2.0))))
(* U (+ 1.0 (/ (* (pow l 3.0) (* J 0.3333333333333333)) U))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -4.7e+70) {
tmp = 0.3333333333333333 * (J * pow(l, 3.0));
} else if (l <= 0.004) {
tmp = U + (cos((K / 2.0)) * (l * (J * 2.0)));
} else {
tmp = U * (1.0 + ((pow(l, 3.0) * (J * 0.3333333333333333)) / 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 <= (-4.7d+70)) then
tmp = 0.3333333333333333d0 * (j * (l ** 3.0d0))
else if (l <= 0.004d0) then
tmp = u + (cos((k / 2.0d0)) * (l * (j * 2.0d0)))
else
tmp = u * (1.0d0 + (((l ** 3.0d0) * (j * 0.3333333333333333d0)) / u))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -4.7e+70) {
tmp = 0.3333333333333333 * (J * Math.pow(l, 3.0));
} else if (l <= 0.004) {
tmp = U + (Math.cos((K / 2.0)) * (l * (J * 2.0)));
} else {
tmp = U * (1.0 + ((Math.pow(l, 3.0) * (J * 0.3333333333333333)) / U));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -4.7e+70: tmp = 0.3333333333333333 * (J * math.pow(l, 3.0)) elif l <= 0.004: tmp = U + (math.cos((K / 2.0)) * (l * (J * 2.0))) else: tmp = U * (1.0 + ((math.pow(l, 3.0) * (J * 0.3333333333333333)) / U)) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -4.7e+70) tmp = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))); elseif (l <= 0.004) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(l * Float64(J * 2.0)))); else tmp = Float64(U * Float64(1.0 + Float64(Float64((l ^ 3.0) * Float64(J * 0.3333333333333333)) / U))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -4.7e+70) tmp = 0.3333333333333333 * (J * (l ^ 3.0)); elseif (l <= 0.004) tmp = U + (cos((K / 2.0)) * (l * (J * 2.0))); else tmp = U * (1.0 + (((l ^ 3.0) * (J * 0.3333333333333333)) / U)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -4.7e+70], N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 0.004], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U * N[(1.0 + N[(N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4.7 \cdot 10^{+70}:\\
\;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{elif}\;\ell \leq 0.004:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(J \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U \cdot \left(1 + \frac{{\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)}{U}\right)\\
\end{array}
\end{array}
if l < -4.6999999999999998e70Initial program 100.0%
Taylor expanded in l around 0 100.0%
Taylor expanded in K around 0 78.0%
Taylor expanded in l around inf 78.0%
if -4.6999999999999998e70 < l < 0.0040000000000000001Initial program 77.2%
Taylor expanded in l around 0 93.2%
associate-*r*93.2%
Simplified93.2%
if 0.0040000000000000001 < l Initial program 100.0%
Taylor expanded in l around 0 75.3%
Taylor expanded in K around 0 50.3%
Taylor expanded in U around inf 53.4%
Taylor expanded in l around inf 53.4%
associate-*r/53.4%
associate-*r*53.4%
*-commutative53.4%
Simplified53.4%
Final simplification80.9%
(FPCore (J l K U)
:precision binary64
(if (<= l -2.8e+77)
(* 0.3333333333333333 (* J (pow l 3.0)))
(if (<= l 650.0)
(+ U (* 2.0 (* J (* l (cos (* K 0.5))))))
(* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -2.8e+77) {
tmp = 0.3333333333333333 * (J * pow(l, 3.0));
} else if (l <= 650.0) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else {
tmp = J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (l <= (-2.8d+77)) then
tmp = 0.3333333333333333d0 * (j * (l ** 3.0d0))
else if (l <= 650.0d0) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
else
tmp = j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -2.8e+77) {
tmp = 0.3333333333333333 * (J * Math.pow(l, 3.0));
} else if (l <= 650.0) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else {
tmp = J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -2.8e+77: tmp = 0.3333333333333333 * (J * math.pow(l, 3.0)) elif l <= 650.0: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) else: tmp = J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0)))) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -2.8e+77) tmp = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))); elseif (l <= 650.0) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); else tmp = Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -2.8e+77) tmp = 0.3333333333333333 * (J * (l ^ 3.0)); elseif (l <= 650.0) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); else tmp = J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -2.8e+77], N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 650.0], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.8 \cdot 10^{+77}:\\
\;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{elif}\;\ell \leq 650:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\
\end{array}
\end{array}
if l < -2.8e77Initial program 100.0%
Taylor expanded in l around 0 100.0%
Taylor expanded in K around 0 78.0%
Taylor expanded in l around inf 78.0%
if -2.8e77 < l < 650Initial program 77.5%
Taylor expanded in l around 0 92.8%
if 650 < l Initial program 100.0%
Taylor expanded in l around 0 75.6%
Taylor expanded in K around 0 49.7%
Taylor expanded in J around inf 49.6%
Final simplification80.1%
(FPCore (J l K U)
:precision binary64
(if (<= l -7.5e+70)
(* 0.3333333333333333 (* J (pow l 3.0)))
(if (<= l 650.0)
(+ U (* (cos (/ K 2.0)) (* l (* J 2.0))))
(* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -7.5e+70) {
tmp = 0.3333333333333333 * (J * pow(l, 3.0));
} else if (l <= 650.0) {
tmp = U + (cos((K / 2.0)) * (l * (J * 2.0)));
} else {
tmp = J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (l <= (-7.5d+70)) then
tmp = 0.3333333333333333d0 * (j * (l ** 3.0d0))
else if (l <= 650.0d0) then
tmp = u + (cos((k / 2.0d0)) * (l * (j * 2.0d0)))
else
tmp = j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -7.5e+70) {
tmp = 0.3333333333333333 * (J * Math.pow(l, 3.0));
} else if (l <= 650.0) {
tmp = U + (Math.cos((K / 2.0)) * (l * (J * 2.0)));
} else {
tmp = J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -7.5e+70: tmp = 0.3333333333333333 * (J * math.pow(l, 3.0)) elif l <= 650.0: tmp = U + (math.cos((K / 2.0)) * (l * (J * 2.0))) else: tmp = J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0)))) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -7.5e+70) tmp = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))); elseif (l <= 650.0) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(l * Float64(J * 2.0)))); else tmp = Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -7.5e+70) tmp = 0.3333333333333333 * (J * (l ^ 3.0)); elseif (l <= 650.0) tmp = U + (cos((K / 2.0)) * (l * (J * 2.0))); else tmp = J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -7.5e+70], N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 650.0], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -7.5 \cdot 10^{+70}:\\
\;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{elif}\;\ell \leq 650:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(J \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\
\end{array}
\end{array}
if l < -7.50000000000000031e70Initial program 100.0%
Taylor expanded in l around 0 100.0%
Taylor expanded in K around 0 78.0%
Taylor expanded in l around inf 78.0%
if -7.50000000000000031e70 < l < 650Initial program 77.5%
Taylor expanded in l around 0 92.8%
associate-*r*92.8%
Simplified92.8%
if 650 < l Initial program 100.0%
Taylor expanded in l around 0 75.6%
Taylor expanded in K around 0 49.7%
Taylor expanded in J around inf 49.6%
Final simplification80.1%
(FPCore (J l K U)
:precision binary64
(if (<= l -2.1e+51)
(* 0.3333333333333333 (* J (pow l 3.0)))
(if (<= l 650.0)
(+ U (* J (* l 2.0)))
(* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -2.1e+51) {
tmp = 0.3333333333333333 * (J * pow(l, 3.0));
} else if (l <= 650.0) {
tmp = U + (J * (l * 2.0));
} else {
tmp = J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (l <= (-2.1d+51)) then
tmp = 0.3333333333333333d0 * (j * (l ** 3.0d0))
else if (l <= 650.0d0) then
tmp = u + (j * (l * 2.0d0))
else
tmp = j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -2.1e+51) {
tmp = 0.3333333333333333 * (J * Math.pow(l, 3.0));
} else if (l <= 650.0) {
tmp = U + (J * (l * 2.0));
} else {
tmp = J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -2.1e+51: tmp = 0.3333333333333333 * (J * math.pow(l, 3.0)) elif l <= 650.0: tmp = U + (J * (l * 2.0)) else: tmp = J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0)))) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -2.1e+51) tmp = Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))); elseif (l <= 650.0) tmp = Float64(U + Float64(J * Float64(l * 2.0))); else tmp = Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -2.1e+51) tmp = 0.3333333333333333 * (J * (l ^ 3.0)); elseif (l <= 650.0) tmp = U + (J * (l * 2.0)); else tmp = J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -2.1e+51], N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 650.0], N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.1 \cdot 10^{+51}:\\
\;\;\;\;0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{elif}\;\ell \leq 650:\\
\;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\
\end{array}
\end{array}
if l < -2.1000000000000001e51Initial program 100.0%
Taylor expanded in l around 0 93.3%
Taylor expanded in K around 0 70.3%
Taylor expanded in l around inf 70.3%
if -2.1000000000000001e51 < l < 650Initial program 76.4%
Taylor expanded in l around 0 96.8%
Taylor expanded in K around 0 85.5%
Taylor expanded in l around 0 85.5%
*-commutative85.5%
associate-*r*85.5%
*-commutative85.5%
Simplified85.5%
if 650 < l Initial program 100.0%
Taylor expanded in l around 0 75.6%
Taylor expanded in K around 0 49.7%
Taylor expanded in J around inf 49.6%
Final simplification74.0%
(FPCore (J l K U) :precision binary64 (if (or (<= l -7.5e+50) (not (<= l 650.0))) (* 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 <= -7.5e+50) || !(l <= 650.0)) {
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 <= (-7.5d+50)) .or. (.not. (l <= 650.0d0))) 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 <= -7.5e+50) || !(l <= 650.0)) {
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 <= -7.5e+50) or not (l <= 650.0): 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 <= -7.5e+50) || !(l <= 650.0)) 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 <= -7.5e+50) || ~((l <= 650.0))) 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, -7.5e+50], N[Not[LessEqual[l, 650.0]], $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 -7.5 \cdot 10^{+50} \lor \neg \left(\ell \leq 650\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 < -7.4999999999999999e50 or 650 < l Initial program 100.0%
Taylor expanded in l around 0 84.4%
Taylor expanded in K around 0 59.9%
Taylor expanded in l around inf 59.8%
if -7.4999999999999999e50 < l < 650Initial program 76.4%
Taylor expanded in l around 0 96.8%
Taylor expanded in K around 0 85.5%
Taylor expanded in l around 0 85.5%
*-commutative85.5%
associate-*r*85.5%
*-commutative85.5%
Simplified85.5%
Final simplification74.0%
(FPCore (J l K U) :precision binary64 (if (or (<= l -2.7e+83) (not (<= l 2.1e+41))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.7e+83) || !(l <= 2.1e+41)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-2.7d+83)) .or. (.not. (l <= 2.1d+41))) then
tmp = u * u
else
tmp = u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.7e+83) || !(l <= 2.1e+41)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -2.7e+83) or not (l <= 2.1e+41): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -2.7e+83) || !(l <= 2.1e+41)) tmp = Float64(U * U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -2.7e+83) || ~((l <= 2.1e+41))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -2.7e+83], N[Not[LessEqual[l, 2.1e+41]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.7 \cdot 10^{+83} \lor \neg \left(\ell \leq 2.1 \cdot 10^{+41}\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -2.70000000000000007e83 or 2.1e41 < l Initial program 100.0%
Applied egg-rr19.2%
if -2.70000000000000007e83 < l < 2.1e41Initial program 78.5%
Taylor expanded in J around 0 66.0%
Final simplification47.6%
(FPCore (J l K U) :precision binary64 (if (<= l -2.7e+83) (* U (- U -4.0)) (if (<= l 2.4e+40) U (* U U))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -2.7e+83) {
tmp = U * (U - -4.0);
} else if (l <= 2.4e+40) {
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 <= (-2.7d+83)) then
tmp = u * (u - (-4.0d0))
else if (l <= 2.4d+40) 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 <= -2.7e+83) {
tmp = U * (U - -4.0);
} else if (l <= 2.4e+40) {
tmp = U;
} else {
tmp = U * U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -2.7e+83: tmp = U * (U - -4.0) elif l <= 2.4e+40: tmp = U else: tmp = U * U return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -2.7e+83) tmp = Float64(U * Float64(U - -4.0)); elseif (l <= 2.4e+40) tmp = U; else tmp = Float64(U * U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -2.7e+83) tmp = U * (U - -4.0); elseif (l <= 2.4e+40) tmp = U; else tmp = U * U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -2.7e+83], N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.4e+40], U, N[(U * U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.7 \cdot 10^{+83}:\\
\;\;\;\;U \cdot \left(U - -4\right)\\
\mathbf{elif}\;\ell \leq 2.4 \cdot 10^{+40}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;U \cdot U\\
\end{array}
\end{array}
if l < -2.70000000000000007e83Initial program 100.0%
Applied egg-rr21.3%
if -2.70000000000000007e83 < l < 2.4e40Initial program 78.5%
Taylor expanded in J around 0 66.0%
if 2.4e40 < l Initial program 100.0%
Applied egg-rr17.1%
Final simplification47.6%
(FPCore (J l K U) :precision binary64 (* U (+ 1.0 (* 2.0 (* J (/ l U))))))
double code(double J, double l, double K, double U) {
return U * (1.0 + (2.0 * (J * (l / 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 * (1.0d0 + (2.0d0 * (j * (l / u))))
end function
public static double code(double J, double l, double K, double U) {
return U * (1.0 + (2.0 * (J * (l / U))));
}
def code(J, l, K, U): return U * (1.0 + (2.0 * (J * (l / U))))
function code(J, l, K, U) return Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(l / U))))) end
function tmp = code(J, l, K, U) tmp = U * (1.0 + (2.0 * (J * (l / U)))); end
code[J_, l_, K_, U_] := N[(U * N[(1.0 + N[(2.0 * N[(J * N[(l / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell}{U}\right)\right)
\end{array}
Initial program 87.0%
Taylor expanded in l around 0 91.2%
Taylor expanded in K around 0 74.0%
Taylor expanded in U around inf 74.0%
Taylor expanded in l around 0 57.2%
associate-/l*60.2%
Simplified60.2%
Final simplification60.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 87.0%
Taylor expanded in l around 0 91.2%
Taylor expanded in K around 0 74.0%
Taylor expanded in l around 0 55.4%
*-commutative55.4%
associate-*r*55.4%
*-commutative55.4%
Simplified55.4%
Final simplification55.4%
(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 87.0%
Applied egg-rr2.7%
*-inverses2.7%
Simplified2.7%
Final simplification2.7%
(FPCore (J l K U) :precision binary64 U)
double code(double J, double l, double K, double U) {
return U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
public static double code(double J, double l, double K, double U) {
return U;
}
def code(J, l, K, U): return U
function code(J, l, K, U) return U end
function tmp = code(J, l, K, U) tmp = U; end
code[J_, l_, K_, U_] := U
\begin{array}{l}
\\
U
\end{array}
Initial program 87.0%
Taylor expanded in J around 0 40.9%
Final simplification40.9%
herbie shell --seed 2024078
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))