
(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 -0.02) (not (<= t_1 0.0)))
(+ U (* (* t_1 J) t_0))
(+
U
(* t_0 (+ (* 0.3333333333333333 (* J (pow l 3.0))) (* 2.0 (* l J))))))))
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 <= -0.02) || !(t_1 <= 0.0)) {
tmp = U + ((t_1 * J) * t_0);
} else {
tmp = U + (t_0 * ((0.3333333333333333 * (J * pow(l, 3.0))) + (2.0 * (l * J))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = exp(l) - exp(-l)
if ((t_1 <= (-0.02d0)) .or. (.not. (t_1 <= 0.0d0))) then
tmp = u + ((t_1 * j) * t_0)
else
tmp = u + (t_0 * ((0.3333333333333333d0 * (j * (l ** 3.0d0))) + (2.0d0 * (l * j))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_1 <= -0.02) || !(t_1 <= 0.0)) {
tmp = U + ((t_1 * J) * t_0);
} else {
tmp = U + (t_0 * ((0.3333333333333333 * (J * Math.pow(l, 3.0))) + (2.0 * (l * J))));
}
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 <= -0.02) or not (t_1 <= 0.0): tmp = U + ((t_1 * J) * t_0) else: tmp = U + (t_0 * ((0.3333333333333333 * (J * math.pow(l, 3.0))) + (2.0 * (l * J)))) 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 <= -0.02) || !(t_1 <= 0.0)) tmp = Float64(U + Float64(Float64(t_1 * J) * t_0)); else tmp = Float64(U + Float64(t_0 * Float64(Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))) + Float64(2.0 * Float64(l * J))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = exp(l) - exp(-l); tmp = 0.0; if ((t_1 <= -0.02) || ~((t_1 <= 0.0))) tmp = U + ((t_1 * J) * t_0); else tmp = U + (t_0 * ((0.3333333333333333 * (J * (l ^ 3.0))) + (2.0 * (l * J)))); 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, -0.02], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], N[(U + N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(U + N[(t$95$0 * N[(N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(l * J), $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 -0.02 \lor \neg \left(t_1 \leq 0\right):\\
\;\;\;\;U + \left(t_1 \cdot J\right) \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;U + t_0 \cdot \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right) + 2 \cdot \left(\ell \cdot J\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -0.0200000000000000004 or 0.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 99.9%
if -0.0200000000000000004 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0Initial program 70.8%
Taylor expanded in l around 0 100.0%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* 0.5 K))) (t_1 (- (exp l) (exp (- l)))))
(if (<= t_1 0.01)
(+
(fma
0.0003968253968253968
(* (* (pow l 7.0) J) t_0)
(fma
0.016666666666666666
(* t_0 (* J (pow l 5.0)))
(+
(* 0.3333333333333333 (* J (* t_0 (pow l 3.0))))
(* 2.0 (* t_0 (* l J))))))
U)
(+ U (* (* t_1 J) (cos (/ K 2.0)))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((0.5 * K));
double t_1 = exp(l) - exp(-l);
double tmp;
if (t_1 <= 0.01) {
tmp = fma(0.0003968253968253968, ((pow(l, 7.0) * J) * t_0), fma(0.016666666666666666, (t_0 * (J * pow(l, 5.0))), ((0.3333333333333333 * (J * (t_0 * pow(l, 3.0)))) + (2.0 * (t_0 * (l * J)))))) + U;
} else {
tmp = U + ((t_1 * J) * cos((K / 2.0)));
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(0.5 * K)) t_1 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if (t_1 <= 0.01) tmp = Float64(fma(0.0003968253968253968, Float64(Float64((l ^ 7.0) * J) * t_0), fma(0.016666666666666666, Float64(t_0 * Float64(J * (l ^ 5.0))), Float64(Float64(0.3333333333333333 * Float64(J * Float64(t_0 * (l ^ 3.0)))) + Float64(2.0 * Float64(t_0 * Float64(l * J)))))) + U); else tmp = Float64(U + Float64(Float64(t_1 * J) * cos(Float64(K / 2.0)))); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.01], N[(N[(0.0003968253968253968 * N[(N[(N[Power[l, 7.0], $MachinePrecision] * J), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(0.016666666666666666 * N[(t$95$0 * N[(J * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(0.3333333333333333 * N[(J * N[(t$95$0 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(t$95$0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[(t$95$1 * J), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(0.5 \cdot K\right)\\
t_1 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_1 \leq 0.01:\\
\;\;\;\;\mathsf{fma}\left(0.0003968253968253968, \left({\ell}^{7} \cdot J\right) \cdot t_0, \mathsf{fma}\left(0.016666666666666666, t_0 \cdot \left(J \cdot {\ell}^{5}\right), 0.3333333333333333 \cdot \left(J \cdot \left(t_0 \cdot {\ell}^{3}\right)\right) + 2 \cdot \left(t_0 \cdot \left(\ell \cdot J\right)\right)\right)\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + \left(t_1 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0100000000000000002Initial program 81.5%
Taylor expanded in l around 0 97.9%
fma-def97.9%
associate-*r*97.9%
*-commutative97.9%
fma-def97.9%
associate-*r*97.9%
*-commutative97.9%
fma-def97.9%
associate-*r*97.9%
*-commutative97.9%
Simplified97.9%
fma-udef97.9%
*-commutative97.9%
*-commutative97.9%
Applied egg-rr97.9%
if 0.0100000000000000002 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
Final simplification98.5%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))) (t_1 (cos (/ K 2.0))))
(if (<= t_0 0.01)
(+
U
(*
t_1
(*
J
(+
(* 0.0003968253968253968 (pow l 7.0))
(+
(* 0.016666666666666666 (pow l 5.0))
(+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))))
(+ U (* (* t_0 J) t_1)))))
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 tmp;
if (t_0 <= 0.01) {
tmp = U + (t_1 * (J * ((0.0003968253968253968 * pow(l, 7.0)) + ((0.016666666666666666 * pow(l, 5.0)) + ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))))));
} else {
tmp = U + ((t_0 * J) * t_1);
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = exp(l) - exp(-l)
t_1 = cos((k / 2.0d0))
if (t_0 <= 0.01d0) then
tmp = u + (t_1 * (j * ((0.0003968253968253968d0 * (l ** 7.0d0)) + ((0.016666666666666666d0 * (l ** 5.0d0)) + ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))))
else
tmp = u + ((t_0 * j) * t_1)
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.exp(l) - Math.exp(-l);
double t_1 = Math.cos((K / 2.0));
double tmp;
if (t_0 <= 0.01) {
tmp = U + (t_1 * (J * ((0.0003968253968253968 * Math.pow(l, 7.0)) + ((0.016666666666666666 * Math.pow(l, 5.0)) + ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))))));
} else {
tmp = U + ((t_0 * J) * t_1);
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) t_1 = math.cos((K / 2.0)) tmp = 0 if t_0 <= 0.01: tmp = U + (t_1 * (J * ((0.0003968253968253968 * math.pow(l, 7.0)) + ((0.016666666666666666 * math.pow(l, 5.0)) + ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))))) else: tmp = U + ((t_0 * J) * t_1) return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) t_1 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= 0.01) tmp = Float64(U + Float64(t_1 * Float64(J * Float64(Float64(0.0003968253968253968 * (l ^ 7.0)) + Float64(Float64(0.016666666666666666 * (l ^ 5.0)) + Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))))); else tmp = Float64(U + Float64(Float64(t_0 * J) * t_1)); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); t_1 = cos((K / 2.0)); tmp = 0.0; if (t_0 <= 0.01) tmp = U + (t_1 * (J * ((0.0003968253968253968 * (l ^ 7.0)) + ((0.016666666666666666 * (l ^ 5.0)) + ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))))); else tmp = U + ((t_0 * J) * t_1); 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]}, If[LessEqual[t$95$0, 0.01], N[(U + N[(t$95$1 * N[(J * N[(N[(0.0003968253968253968 * N[Power[l, 7.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.016666666666666666 * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(t$95$0 * J), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
t_1 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t_0 \leq 0.01:\\
\;\;\;\;U + t_1 \cdot \left(J \cdot \left(0.0003968253968253968 \cdot {\ell}^{7} + \left(0.016666666666666666 \cdot {\ell}^{5} + \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(t_0 \cdot J\right) \cdot t_1\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0100000000000000002Initial program 81.5%
Taylor expanded in l around 0 97.9%
if 0.0100000000000000002 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
Final simplification98.5%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))) (t_1 (cos (/ K 2.0))))
(if (<= t_0 0.01)
(+
U
(*
t_1
(+
(* 0.016666666666666666 (* J (pow l 5.0)))
(+ (* 0.3333333333333333 (* J (pow l 3.0))) (* 2.0 (* l J))))))
(+ U (* (* t_0 J) t_1)))))
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 tmp;
if (t_0 <= 0.01) {
tmp = U + (t_1 * ((0.016666666666666666 * (J * pow(l, 5.0))) + ((0.3333333333333333 * (J * pow(l, 3.0))) + (2.0 * (l * J)))));
} else {
tmp = U + ((t_0 * J) * t_1);
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = exp(l) - exp(-l)
t_1 = cos((k / 2.0d0))
if (t_0 <= 0.01d0) then
tmp = u + (t_1 * ((0.016666666666666666d0 * (j * (l ** 5.0d0))) + ((0.3333333333333333d0 * (j * (l ** 3.0d0))) + (2.0d0 * (l * j)))))
else
tmp = u + ((t_0 * j) * t_1)
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.exp(l) - Math.exp(-l);
double t_1 = Math.cos((K / 2.0));
double tmp;
if (t_0 <= 0.01) {
tmp = U + (t_1 * ((0.016666666666666666 * (J * Math.pow(l, 5.0))) + ((0.3333333333333333 * (J * Math.pow(l, 3.0))) + (2.0 * (l * J)))));
} else {
tmp = U + ((t_0 * J) * t_1);
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) t_1 = math.cos((K / 2.0)) tmp = 0 if t_0 <= 0.01: tmp = U + (t_1 * ((0.016666666666666666 * (J * math.pow(l, 5.0))) + ((0.3333333333333333 * (J * math.pow(l, 3.0))) + (2.0 * (l * J))))) else: tmp = U + ((t_0 * J) * t_1) return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) t_1 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= 0.01) tmp = Float64(U + Float64(t_1 * Float64(Float64(0.016666666666666666 * Float64(J * (l ^ 5.0))) + Float64(Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))) + Float64(2.0 * Float64(l * J)))))); else tmp = Float64(U + Float64(Float64(t_0 * J) * t_1)); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); t_1 = cos((K / 2.0)); tmp = 0.0; if (t_0 <= 0.01) tmp = U + (t_1 * ((0.016666666666666666 * (J * (l ^ 5.0))) + ((0.3333333333333333 * (J * (l ^ 3.0))) + (2.0 * (l * J))))); else tmp = U + ((t_0 * J) * t_1); 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]}, If[LessEqual[t$95$0, 0.01], N[(U + N[(t$95$1 * N[(N[(0.016666666666666666 * N[(J * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(t$95$0 * J), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
t_1 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t_0 \leq 0.01:\\
\;\;\;\;U + t_1 \cdot \left(0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\right) + \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right) + 2 \cdot \left(\ell \cdot J\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(t_0 \cdot J\right) \cdot t_1\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0100000000000000002Initial program 81.5%
Taylor expanded in l around 0 97.9%
if 0.0100000000000000002 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
Final simplification98.5%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))) (t_1 (cos (/ K 2.0))))
(if (<= t_0 0.01)
(+
U
(*
t_1
(*
J
(+
(* 0.016666666666666666 (pow l 5.0))
(+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0))))))
(+ U (* (* t_0 J) t_1)))))
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 tmp;
if (t_0 <= 0.01) {
tmp = U + (t_1 * (J * ((0.016666666666666666 * pow(l, 5.0)) + ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0)))));
} else {
tmp = U + ((t_0 * J) * t_1);
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = exp(l) - exp(-l)
t_1 = cos((k / 2.0d0))
if (t_0 <= 0.01d0) then
tmp = u + (t_1 * (j * ((0.016666666666666666d0 * (l ** 5.0d0)) + ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0)))))
else
tmp = u + ((t_0 * j) * t_1)
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.exp(l) - Math.exp(-l);
double t_1 = Math.cos((K / 2.0));
double tmp;
if (t_0 <= 0.01) {
tmp = U + (t_1 * (J * ((0.016666666666666666 * Math.pow(l, 5.0)) + ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)))));
} else {
tmp = U + ((t_0 * J) * t_1);
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) t_1 = math.cos((K / 2.0)) tmp = 0 if t_0 <= 0.01: tmp = U + (t_1 * (J * ((0.016666666666666666 * math.pow(l, 5.0)) + ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))))) else: tmp = U + ((t_0 * J) * t_1) return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) t_1 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= 0.01) tmp = Float64(U + Float64(t_1 * Float64(J * Float64(Float64(0.016666666666666666 * (l ^ 5.0)) + Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)))))); else tmp = Float64(U + Float64(Float64(t_0 * J) * t_1)); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); t_1 = cos((K / 2.0)); tmp = 0.0; if (t_0 <= 0.01) tmp = U + (t_1 * (J * ((0.016666666666666666 * (l ^ 5.0)) + ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0))))); else tmp = U + ((t_0 * J) * t_1); 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]}, If[LessEqual[t$95$0, 0.01], N[(U + N[(t$95$1 * N[(J * N[(N[(0.016666666666666666 * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(t$95$0 * J), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
t_1 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t_0 \leq 0.01:\\
\;\;\;\;U + t_1 \cdot \left(J \cdot \left(0.016666666666666666 \cdot {\ell}^{5} + \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(t_0 \cdot J\right) \cdot t_1\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0100000000000000002Initial program 81.5%
Taylor expanded in l around 0 97.9%
if 0.0100000000000000002 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
Final simplification98.5%
(FPCore (J l K U)
:precision binary64
(if (<= (/ K 2.0) 0.0002)
(+ U (* J (* 2.0 (sinh l))))
(+
U
(*
(cos (/ K 2.0))
(+ (* 0.3333333333333333 (* J (pow l 3.0))) (* 2.0 (* l J)))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 0.0002) {
tmp = U + (J * (2.0 * sinh(l)));
} else {
tmp = U + (cos((K / 2.0)) * ((0.3333333333333333 * (J * pow(l, 3.0))) + (2.0 * (l * J))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((k / 2.0d0) <= 0.0002d0) then
tmp = u + (j * (2.0d0 * sinh(l)))
else
tmp = u + (cos((k / 2.0d0)) * ((0.3333333333333333d0 * (j * (l ** 3.0d0))) + (2.0d0 * (l * j))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 0.0002) {
tmp = U + (J * (2.0 * Math.sinh(l)));
} else {
tmp = U + (Math.cos((K / 2.0)) * ((0.3333333333333333 * (J * Math.pow(l, 3.0))) + (2.0 * (l * J))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (K / 2.0) <= 0.0002: tmp = U + (J * (2.0 * math.sinh(l))) else: tmp = U + (math.cos((K / 2.0)) * ((0.3333333333333333 * (J * math.pow(l, 3.0))) + (2.0 * (l * J)))) return tmp
function code(J, l, K, U) tmp = 0.0 if (Float64(K / 2.0) <= 0.0002) tmp = Float64(U + Float64(J * Float64(2.0 * sinh(l)))); else tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))) + Float64(2.0 * Float64(l * J))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((K / 2.0) <= 0.0002) tmp = U + (J * (2.0 * sinh(l))); else tmp = U + (cos((K / 2.0)) * ((0.3333333333333333 * (J * (l ^ 3.0))) + (2.0 * (l * J)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 0.0002], N[(U + N[(J * N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 0.0002:\\
\;\;\;\;U + J \cdot \left(2 \cdot \sinh \ell\right)\\
\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right) + 2 \cdot \left(\ell \cdot J\right)\right)\\
\end{array}
\end{array}
if (/.f64 K 2) < 2.0000000000000001e-4Initial program 85.3%
Taylor expanded in K around 0 76.6%
*-commutative76.6%
fma-def76.6%
sinh-undef86.7%
Applied egg-rr86.7%
fma-udef86.7%
*-commutative86.7%
Applied egg-rr86.7%
if 2.0000000000000001e-4 < (/.f64 K 2) Initial program 89.5%
Taylor expanded in l around 0 88.0%
Final simplification87.0%
(FPCore (J l K U)
:precision binary64
(if (<= (/ K 2.0) 0.0002)
(+ U (* J (* 2.0 (sinh l))))
(+
U
(*
(cos (/ K 2.0))
(* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 0.0002) {
tmp = U + (J * (2.0 * sinh(l)));
} else {
tmp = U + (cos((K / 2.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) :: tmp
if ((k / 2.0d0) <= 0.0002d0) then
tmp = u + (j * (2.0d0 * sinh(l)))
else
tmp = u + (cos((k / 2.0d0)) * (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 ((K / 2.0) <= 0.0002) {
tmp = U + (J * (2.0 * Math.sinh(l)));
} else {
tmp = U + (Math.cos((K / 2.0)) * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (K / 2.0) <= 0.0002: tmp = U + (J * (2.0 * math.sinh(l))) else: tmp = U + (math.cos((K / 2.0)) * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) return tmp
function code(J, l, K, U) tmp = 0.0 if (Float64(K / 2.0) <= 0.0002) tmp = Float64(U + Float64(J * Float64(2.0 * sinh(l)))); else tmp = Float64(U + Float64(cos(Float64(K / 2.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) tmp = 0.0; if ((K / 2.0) <= 0.0002) tmp = U + (J * (2.0 * sinh(l))); else tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 0.0002], N[(U + N[(J * N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 0.0002:\\
\;\;\;\;U + J \cdot \left(2 \cdot \sinh \ell\right)\\
\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\
\end{array}
\end{array}
if (/.f64 K 2) < 2.0000000000000001e-4Initial program 85.3%
Taylor expanded in K around 0 76.6%
*-commutative76.6%
fma-def76.6%
sinh-undef86.7%
Applied egg-rr86.7%
fma-udef86.7%
*-commutative86.7%
Applied egg-rr86.7%
if 2.0000000000000001e-4 < (/.f64 K 2) Initial program 89.5%
Taylor expanded in l around 0 88.0%
Final simplification87.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1 (+ U (* t_0 (* (pow l 7.0) (* 0.0003968253968253968 J))))))
(if (<= l -4.2)
t_1
(if (<= l 1.45e-28)
(+ U (* t_0 (* J (* l 2.0))))
(if (<= l 1.1e+44) (+ U (* J (* 2.0 (sinh l)))) 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, 7.0) * (0.0003968253968253968 * J)));
double tmp;
if (l <= -4.2) {
tmp = t_1;
} else if (l <= 1.45e-28) {
tmp = U + (t_0 * (J * (l * 2.0)));
} else if (l <= 1.1e+44) {
tmp = U + (J * (2.0 * sinh(l)));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = u + (t_0 * ((l ** 7.0d0) * (0.0003968253968253968d0 * j)))
if (l <= (-4.2d0)) then
tmp = t_1
else if (l <= 1.45d-28) then
tmp = u + (t_0 * (j * (l * 2.0d0)))
else if (l <= 1.1d+44) then
tmp = u + (j * (2.0d0 * sinh(l)))
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, 7.0) * (0.0003968253968253968 * J)));
double tmp;
if (l <= -4.2) {
tmp = t_1;
} else if (l <= 1.45e-28) {
tmp = U + (t_0 * (J * (l * 2.0)));
} else if (l <= 1.1e+44) {
tmp = U + (J * (2.0 * Math.sinh(l)));
} 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, 7.0) * (0.0003968253968253968 * J))) tmp = 0 if l <= -4.2: tmp = t_1 elif l <= 1.45e-28: tmp = U + (t_0 * (J * (l * 2.0))) elif l <= 1.1e+44: tmp = U + (J * (2.0 * math.sinh(l))) 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 ^ 7.0) * Float64(0.0003968253968253968 * J)))) tmp = 0.0 if (l <= -4.2) tmp = t_1; elseif (l <= 1.45e-28) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * 2.0)))); elseif (l <= 1.1e+44) tmp = Float64(U + Float64(J * Float64(2.0 * sinh(l)))); 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 ^ 7.0) * (0.0003968253968253968 * J))); tmp = 0.0; if (l <= -4.2) tmp = t_1; elseif (l <= 1.45e-28) tmp = U + (t_0 * (J * (l * 2.0))); elseif (l <= 1.1e+44) tmp = U + (J * (2.0 * sinh(l))); 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, 7.0], $MachinePrecision] * N[(0.0003968253968253968 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -4.2], t$95$1, If[LessEqual[l, 1.45e-28], N[(U + N[(t$95$0 * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.1e+44], N[(U + N[(J * N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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}^{7} \cdot \left(0.0003968253968253968 \cdot J\right)\right)\\
\mathbf{if}\;\ell \leq -4.2:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq 1.45 \cdot 10^{-28}:\\
\;\;\;\;U + t_0 \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;U + J \cdot \left(2 \cdot \sinh \ell\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if l < -4.20000000000000018 or 1.09999999999999998e44 < l Initial program 100.0%
Taylor expanded in l around 0 96.9%
Taylor expanded in l around inf 96.9%
*-commutative96.9%
*-commutative96.9%
associate-*l*96.9%
Simplified96.9%
if -4.20000000000000018 < l < 1.45000000000000006e-28Initial program 71.6%
Taylor expanded in l around 0 99.5%
if 1.45000000000000006e-28 < l < 1.09999999999999998e44Initial program 92.4%
Taylor expanded in K around 0 84.7%
*-commutative84.7%
fma-def84.7%
sinh-undef92.3%
Applied egg-rr92.3%
fma-udef92.3%
*-commutative92.3%
Applied egg-rr92.3%
Final simplification97.8%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.22) (+ U (* 2.0 (* J (+ l (* -0.125 (* l (* K K))))))) (+ U (* J (* 2.0 (sinh l))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.22) {
tmp = U + (2.0 * (J * (l + (-0.125 * (l * (K * K))))));
} else {
tmp = U + (J * (2.0 * sinh(l)));
}
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.22d0)) then
tmp = u + (2.0d0 * (j * (l + ((-0.125d0) * (l * (k * k))))))
else
tmp = u + (j * (2.0d0 * sinh(l)))
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.22) {
tmp = U + (2.0 * (J * (l + (-0.125 * (l * (K * K))))));
} else {
tmp = U + (J * (2.0 * Math.sinh(l)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.22: tmp = U + (2.0 * (J * (l + (-0.125 * (l * (K * K)))))) else: tmp = U + (J * (2.0 * math.sinh(l))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.22) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l + Float64(-0.125 * Float64(l * Float64(K * K))))))); else tmp = Float64(U + Float64(J * Float64(2.0 * sinh(l)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.22) tmp = U + (2.0 * (J * (l + (-0.125 * (l * (K * K)))))); else tmp = U + (J * (2.0 * sinh(l))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.22], N[(U + N[(2.0 * N[(J * N[(l + N[(-0.125 * N[(l * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.22:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell + -0.125 \cdot \left(\ell \cdot \left(K \cdot K\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(2 \cdot \sinh \ell\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.220000000000000001Initial program 89.9%
Taylor expanded in l around 0 61.7%
Taylor expanded in K around 0 64.9%
*-commutative64.9%
unpow264.9%
Simplified64.9%
if -0.220000000000000001 < (cos.f64 (/.f64 K 2)) Initial program 85.4%
Taylor expanded in K around 0 83.4%
*-commutative83.4%
fma-def83.4%
sinh-undef93.6%
Applied egg-rr93.6%
fma-udef93.6%
*-commutative93.6%
Applied egg-rr93.6%
Final simplification87.5%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ U (* 2.0 (* J (+ l (* -0.125 (* l (* K K)))))))))
(if (<= l -2.55e+82)
t_0
(if (<= l -880.0)
(pow U -8.0)
(if (<= l 0.00335)
(+ U (* J (* l 2.0)))
(if (or (<= l 4e+98) (not (<= l 1.26e+194))) t_0 (pow U -8.0)))))))
double code(double J, double l, double K, double U) {
double t_0 = U + (2.0 * (J * (l + (-0.125 * (l * (K * K))))));
double tmp;
if (l <= -2.55e+82) {
tmp = t_0;
} else if (l <= -880.0) {
tmp = pow(U, -8.0);
} else if (l <= 0.00335) {
tmp = U + (J * (l * 2.0));
} else if ((l <= 4e+98) || !(l <= 1.26e+194)) {
tmp = t_0;
} else {
tmp = pow(U, -8.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 + (2.0d0 * (j * (l + ((-0.125d0) * (l * (k * k))))))
if (l <= (-2.55d+82)) then
tmp = t_0
else if (l <= (-880.0d0)) then
tmp = u ** (-8.0d0)
else if (l <= 0.00335d0) then
tmp = u + (j * (l * 2.0d0))
else if ((l <= 4d+98) .or. (.not. (l <= 1.26d+194))) then
tmp = t_0
else
tmp = u ** (-8.0d0)
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = U + (2.0 * (J * (l + (-0.125 * (l * (K * K))))));
double tmp;
if (l <= -2.55e+82) {
tmp = t_0;
} else if (l <= -880.0) {
tmp = Math.pow(U, -8.0);
} else if (l <= 0.00335) {
tmp = U + (J * (l * 2.0));
} else if ((l <= 4e+98) || !(l <= 1.26e+194)) {
tmp = t_0;
} else {
tmp = Math.pow(U, -8.0);
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (2.0 * (J * (l + (-0.125 * (l * (K * K)))))) tmp = 0 if l <= -2.55e+82: tmp = t_0 elif l <= -880.0: tmp = math.pow(U, -8.0) elif l <= 0.00335: tmp = U + (J * (l * 2.0)) elif (l <= 4e+98) or not (l <= 1.26e+194): tmp = t_0 else: tmp = math.pow(U, -8.0) return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(2.0 * Float64(J * Float64(l + Float64(-0.125 * Float64(l * Float64(K * K))))))) tmp = 0.0 if (l <= -2.55e+82) tmp = t_0; elseif (l <= -880.0) tmp = U ^ -8.0; elseif (l <= 0.00335) tmp = Float64(U + Float64(J * Float64(l * 2.0))); elseif ((l <= 4e+98) || !(l <= 1.26e+194)) tmp = t_0; else tmp = U ^ -8.0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + (2.0 * (J * (l + (-0.125 * (l * (K * K)))))); tmp = 0.0; if (l <= -2.55e+82) tmp = t_0; elseif (l <= -880.0) tmp = U ^ -8.0; elseif (l <= 0.00335) tmp = U + (J * (l * 2.0)); elseif ((l <= 4e+98) || ~((l <= 1.26e+194))) tmp = t_0; else tmp = U ^ -8.0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(2.0 * N[(J * N[(l + N[(-0.125 * N[(l * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.55e+82], t$95$0, If[LessEqual[l, -880.0], N[Power[U, -8.0], $MachinePrecision], If[LessEqual[l, 0.00335], N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[l, 4e+98], N[Not[LessEqual[l, 1.26e+194]], $MachinePrecision]], t$95$0, N[Power[U, -8.0], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + 2 \cdot \left(J \cdot \left(\ell + -0.125 \cdot \left(\ell \cdot \left(K \cdot K\right)\right)\right)\right)\\
\mathbf{if}\;\ell \leq -2.55 \cdot 10^{+82}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -880:\\
\;\;\;\;{U}^{-8}\\
\mathbf{elif}\;\ell \leq 0.00335:\\
\;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\
\mathbf{elif}\;\ell \leq 4 \cdot 10^{+98} \lor \neg \left(\ell \leq 1.26 \cdot 10^{+194}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;{U}^{-8}\\
\end{array}
\end{array}
if l < -2.5500000000000001e82 or 0.00335000000000000011 < l < 3.99999999999999999e98 or 1.26e194 < l Initial program 99.9%
Taylor expanded in l around 0 32.6%
Taylor expanded in K around 0 42.6%
*-commutative42.6%
unpow242.6%
Simplified42.6%
if -2.5500000000000001e82 < l < -880 or 3.99999999999999999e98 < l < 1.26e194Initial program 100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Applied egg-rr48.9%
if -880 < l < 0.00335000000000000011Initial program 71.3%
Taylor expanded in K around 0 70.5%
Taylor expanded in l around 0 87.2%
Final simplification64.5%
(FPCore (J l K U) :precision binary64 (if (or (<= l -7e+76) (not (<= l 0.00335))) (+ U (* 2.0 (* J (+ l (* -0.125 (* l (* K K))))))) (+ U (* J (* l 2.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -7e+76) || !(l <= 0.00335)) {
tmp = U + (2.0 * (J * (l + (-0.125 * (l * (K * K))))));
} 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 <= (-7d+76)) .or. (.not. (l <= 0.00335d0))) then
tmp = u + (2.0d0 * (j * (l + ((-0.125d0) * (l * (k * k))))))
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 <= -7e+76) || !(l <= 0.00335)) {
tmp = U + (2.0 * (J * (l + (-0.125 * (l * (K * K))))));
} else {
tmp = U + (J * (l * 2.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -7e+76) or not (l <= 0.00335): tmp = U + (2.0 * (J * (l + (-0.125 * (l * (K * K)))))) else: tmp = U + (J * (l * 2.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -7e+76) || !(l <= 0.00335)) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l + Float64(-0.125 * Float64(l * Float64(K * K))))))); 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 <= -7e+76) || ~((l <= 0.00335))) tmp = U + (2.0 * (J * (l + (-0.125 * (l * (K * K)))))); else tmp = U + (J * (l * 2.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -7e+76], N[Not[LessEqual[l, 0.00335]], $MachinePrecision]], N[(U + N[(2.0 * N[(J * N[(l + N[(-0.125 * N[(l * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 \cdot 10^{+76} \lor \neg \left(\ell \leq 0.00335\right):\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell + -0.125 \cdot \left(\ell \cdot \left(K \cdot K\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\
\end{array}
\end{array}
if l < -7.00000000000000001e76 or 0.00335000000000000011 < l Initial program 99.9%
Taylor expanded in l around 0 31.2%
Taylor expanded in K around 0 38.4%
*-commutative38.4%
unpow238.4%
Simplified38.4%
if -7.00000000000000001e76 < l < 0.00335000000000000011Initial program 73.1%
Taylor expanded in K around 0 71.5%
Taylor expanded in l around 0 82.1%
Final simplification60.4%
(FPCore (J l K U) :precision binary64 (if (or (<= l -3.3e-29) (not (<= l 1.15e-62))) (* l (* J 2.0)) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -3.3e-29) || !(l <= 1.15e-62)) {
tmp = l * (J * 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 <= (-3.3d-29)) .or. (.not. (l <= 1.15d-62))) then
tmp = l * (j * 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 <= -3.3e-29) || !(l <= 1.15e-62)) {
tmp = l * (J * 2.0);
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -3.3e-29) or not (l <= 1.15e-62): tmp = l * (J * 2.0) else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -3.3e-29) || !(l <= 1.15e-62)) tmp = Float64(l * Float64(J * 2.0)); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -3.3e-29) || ~((l <= 1.15e-62))) tmp = l * (J * 2.0); else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -3.3e-29], N[Not[LessEqual[l, 1.15e-62]], $MachinePrecision]], N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3.3 \cdot 10^{-29} \lor \neg \left(\ell \leq 1.15 \cdot 10^{-62}\right):\\
\;\;\;\;\ell \cdot \left(J \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -3.30000000000000028e-29 or 1.15e-62 < l Initial program 94.3%
Taylor expanded in K around 0 69.3%
Taylor expanded in l around 0 25.7%
Taylor expanded in J around inf 23.6%
*-commutative23.6%
*-commutative23.6%
associate-*r*23.6%
Simplified23.6%
if -3.30000000000000028e-29 < l < 1.15e-62Initial program 75.5%
associate-*l*75.5%
fma-def75.5%
Simplified75.5%
Taylor expanded in J around 0 75.5%
Final simplification45.5%
(FPCore (J l K U) :precision binary64 (if (<= l -0.0115) (* U U) (if (<= l 860.0) U (* U U))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -0.0115) {
tmp = U * U;
} else if (l <= 860.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 <= (-0.0115d0)) then
tmp = u * u
else if (l <= 860.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 <= -0.0115) {
tmp = U * U;
} else if (l <= 860.0) {
tmp = U;
} else {
tmp = U * U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -0.0115: tmp = U * U elif l <= 860.0: tmp = U else: tmp = U * U return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -0.0115) tmp = Float64(U * U); elseif (l <= 860.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 <= -0.0115) tmp = U * U; elseif (l <= 860.0) tmp = U; else tmp = U * U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -0.0115], N[(U * U), $MachinePrecision], If[LessEqual[l, 860.0], U, N[(U * U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -0.0115:\\
\;\;\;\;U \cdot U\\
\mathbf{elif}\;\ell \leq 860:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;U \cdot U\\
\end{array}
\end{array}
if l < -0.0115 or 860 < l Initial program 100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Applied egg-rr15.0%
if -0.0115 < l < 860Initial program 71.5%
associate-*l*71.5%
fma-def71.5%
Simplified71.5%
Taylor expanded in J around 0 69.7%
Final simplification41.0%
(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 86.4%
Taylor expanded in K around 0 71.9%
Taylor expanded in l around 0 52.3%
Final simplification52.3%
(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 86.4%
associate-*l*86.4%
fma-def86.4%
Simplified86.4%
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 86.4%
associate-*l*86.4%
fma-def86.4%
Simplified86.4%
Taylor expanded in J around 0 34.4%
Final simplification34.4%
herbie shell --seed 2023271
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))