
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* J (- (exp l) (exp (- l))))) (t_1 (cos (/ K 2.0))))
(if (<= t_0 5e+182)
(+
(*
(*
J
(*
l
(+
2.0
(*
(* l l)
(+
0.3333333333333333
(*
(* l l)
(+ 0.016666666666666666 (* (* l l) 0.0003968253968253968))))))))
t_1)
U)
(+ U (* t_0 t_1)))))
double code(double J, double l, double K, double U) {
double t_0 = J * (exp(l) - exp(-l));
double t_1 = cos((K / 2.0));
double tmp;
if (t_0 <= 5e+182) {
tmp = ((J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))) * t_1) + U;
} else {
tmp = U + (t_0 * 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 = j * (exp(l) - exp(-l))
t_1 = cos((k / 2.0d0))
if (t_0 <= 5d+182) then
tmp = ((j * (l * (2.0d0 + ((l * l) * (0.3333333333333333d0 + ((l * l) * (0.016666666666666666d0 + ((l * l) * 0.0003968253968253968d0)))))))) * t_1) + u
else
tmp = u + (t_0 * t_1)
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = J * (Math.exp(l) - Math.exp(-l));
double t_1 = Math.cos((K / 2.0));
double tmp;
if (t_0 <= 5e+182) {
tmp = ((J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))) * t_1) + U;
} else {
tmp = U + (t_0 * t_1);
}
return tmp;
}
def code(J, l, K, U): t_0 = J * (math.exp(l) - math.exp(-l)) t_1 = math.cos((K / 2.0)) tmp = 0 if t_0 <= 5e+182: tmp = ((J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))) * t_1) + U else: tmp = U + (t_0 * t_1) return tmp
function code(J, l, K, U) t_0 = Float64(J * Float64(exp(l) - exp(Float64(-l)))) t_1 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= 5e+182) tmp = Float64(Float64(Float64(J * Float64(l * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(Float64(l * l) * Float64(0.016666666666666666 + Float64(Float64(l * l) * 0.0003968253968253968)))))))) * t_1) + U); else tmp = Float64(U + Float64(t_0 * t_1)); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = J * (exp(l) - exp(-l)); t_1 = cos((K / 2.0)); tmp = 0.0; if (t_0 <= 5e+182) tmp = ((J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))) * t_1) + U; else tmp = U + (t_0 * t_1); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 5e+182], N[(N[(N[(J * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * N[(0.3333333333333333 + N[(N[(l * l), $MachinePrecision] * N[(0.016666666666666666 + N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
t_1 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{+182}:\\
\;\;\;\;\left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right)\right)\right)\right) \cdot t\_1 + U\\
\mathbf{else}:\\
\;\;\;\;U + t\_0 \cdot t\_1\\
\end{array}
\end{array}
if (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < 4.99999999999999973e182Initial program 83.6%
Taylor expanded in l around 0 99.0%
*-commutative99.0%
Simplified99.0%
unpow299.0%
Applied egg-rr99.0%
unpow299.0%
Applied egg-rr99.0%
unpow299.0%
Applied egg-rr99.0%
if 4.99999999999999973e182 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) Initial program 100.0%
Final simplification99.2%
(FPCore (J l K U)
:precision binary64
(+
(*
(*
J
(*
l
(+
2.0
(*
(* l l)
(+
0.3333333333333333
(*
(* l l)
(+ 0.016666666666666666 (* (* l l) 0.0003968253968253968))))))))
(cos (/ K 2.0)))
U))
double code(double J, double l, double K, double U) {
return ((J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))) * 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 * (l * (2.0d0 + ((l * l) * (0.3333333333333333d0 + ((l * l) * (0.016666666666666666d0 + ((l * l) * 0.0003968253968253968d0)))))))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(l * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(Float64(l * l) * Float64(0.016666666666666666 + Float64(Float64(l * l) * 0.0003968253968253968)))))))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * N[(0.3333333333333333 + N[(N[(l * l), $MachinePrecision] * N[(0.016666666666666666 + N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
Initial program 87.1%
Taylor expanded in l around 0 97.3%
*-commutative97.3%
Simplified97.3%
unpow297.3%
Applied egg-rr97.3%
unpow297.3%
Applied egg-rr97.3%
unpow297.3%
Applied egg-rr97.3%
(FPCore (J l K U) :precision binary64 (if (<= l 2.12e-16) (+ U (* (cos (/ K 2.0)) (* J (* l 2.0)))) (* U (+ 1.0 (* 2.0 (* J (/ l U)))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= 2.12e-16) {
tmp = U + (cos((K / 2.0)) * (J * (l * 2.0)));
} else {
tmp = U * (1.0 + (2.0 * (J * (l / 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.12d-16) then
tmp = u + (cos((k / 2.0d0)) * (j * (l * 2.0d0)))
else
tmp = u * (1.0d0 + (2.0d0 * (j * (l / u))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= 2.12e-16) {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
} else {
tmp = U * (1.0 + (2.0 * (J * (l / U))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= 2.12e-16: tmp = U + (math.cos((K / 2.0)) * (J * (l * 2.0))) else: tmp = U * (1.0 + (2.0 * (J * (l / U)))) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= 2.12e-16) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0)))); else tmp = Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(l / U))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= 2.12e-16) tmp = U + (cos((K / 2.0)) * (J * (l * 2.0))); else tmp = U * (1.0 + (2.0 * (J * (l / U)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, 2.12e-16], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U * N[(1.0 + N[(2.0 * N[(J * N[(l / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 2.12 \cdot 10^{-16}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell}{U}\right)\right)\\
\end{array}
\end{array}
if l < 2.1199999999999999e-16Initial program 83.6%
Taylor expanded in l around 0 79.0%
*-commutative79.0%
associate-*l*79.0%
Simplified79.0%
if 2.1199999999999999e-16 < l Initial program 100.0%
Taylor expanded in l around 0 30.0%
*-commutative30.0%
*-commutative30.0%
associate-*l*30.0%
*-commutative30.0%
associate-*r*30.0%
*-commutative30.0%
associate-*l*30.0%
Simplified30.0%
Taylor expanded in U around inf 40.2%
associate-/l*45.5%
Simplified45.5%
Taylor expanded in K around 0 35.9%
associate-/l*39.4%
Simplified39.4%
Final simplification70.5%
(FPCore (J l K U) :precision binary64 (if (<= l 2.12e-16) (+ U (* l (* (cos (* K 0.5)) (* J 2.0)))) (* U (+ 1.0 (* 2.0 (* J (/ l U)))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= 2.12e-16) {
tmp = U + (l * (cos((K * 0.5)) * (J * 2.0)));
} else {
tmp = U * (1.0 + (2.0 * (J * (l / 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.12d-16) then
tmp = u + (l * (cos((k * 0.5d0)) * (j * 2.0d0)))
else
tmp = u * (1.0d0 + (2.0d0 * (j * (l / u))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= 2.12e-16) {
tmp = U + (l * (Math.cos((K * 0.5)) * (J * 2.0)));
} else {
tmp = U * (1.0 + (2.0 * (J * (l / U))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= 2.12e-16: tmp = U + (l * (math.cos((K * 0.5)) * (J * 2.0))) else: tmp = U * (1.0 + (2.0 * (J * (l / U)))) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= 2.12e-16) tmp = Float64(U + Float64(l * Float64(cos(Float64(K * 0.5)) * Float64(J * 2.0)))); else tmp = Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(l / U))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= 2.12e-16) tmp = U + (l * (cos((K * 0.5)) * (J * 2.0))); else tmp = U * (1.0 + (2.0 * (J * (l / U)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, 2.12e-16], N[(U + N[(l * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U * N[(1.0 + N[(2.0 * N[(J * N[(l / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 2.12 \cdot 10^{-16}:\\
\;\;\;\;U + \ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell}{U}\right)\right)\\
\end{array}
\end{array}
if l < 2.1199999999999999e-16Initial program 83.6%
Taylor expanded in l around 0 79.0%
*-commutative79.0%
*-commutative79.0%
associate-*l*79.0%
*-commutative79.0%
associate-*r*79.0%
*-commutative79.0%
associate-*l*79.0%
Simplified79.0%
if 2.1199999999999999e-16 < l Initial program 100.0%
Taylor expanded in l around 0 30.0%
*-commutative30.0%
*-commutative30.0%
associate-*l*30.0%
*-commutative30.0%
associate-*r*30.0%
*-commutative30.0%
associate-*l*30.0%
Simplified30.0%
Taylor expanded in U around inf 40.2%
associate-/l*45.5%
Simplified45.5%
Taylor expanded in K around 0 35.9%
associate-/l*39.4%
Simplified39.4%
Final simplification70.5%
(FPCore (J l K U) :precision binary64 (* U (+ 1.0 (* 2.0 (* J (* (cos (* K 0.5)) (/ l U)))))))
double code(double J, double l, double K, double U) {
return U * (1.0 + (2.0 * (J * (cos((K * 0.5)) * (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 * (cos((k * 0.5d0)) * (l / u)))))
end function
public static double code(double J, double l, double K, double U) {
return U * (1.0 + (2.0 * (J * (Math.cos((K * 0.5)) * (l / U)))));
}
def code(J, l, K, U): return U * (1.0 + (2.0 * (J * (math.cos((K * 0.5)) * (l / U)))))
function code(J, l, K, U) return Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(cos(Float64(K * 0.5)) * Float64(l / U)))))) end
function tmp = code(J, l, K, U) tmp = U * (1.0 + (2.0 * (J * (cos((K * 0.5)) * (l / U))))); end
code[J_, l_, K_, U_] := N[(U * N[(1.0 + N[(2.0 * N[(J * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(l / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U \cdot \left(1 + 2 \cdot \left(J \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \frac{\ell}{U}\right)\right)\right)
\end{array}
Initial program 87.1%
Taylor expanded in l around 0 68.5%
*-commutative68.5%
*-commutative68.5%
associate-*l*68.4%
*-commutative68.4%
associate-*r*68.4%
*-commutative68.4%
associate-*l*68.4%
Simplified68.4%
Taylor expanded in U around inf 71.0%
associate-/l*73.6%
Simplified73.6%
*-commutative73.6%
*-un-lft-identity73.6%
times-frac73.6%
Applied egg-rr73.6%
Final simplification73.6%
(FPCore (J l K U) :precision binary64 (* U (+ 1.0 (* 2.0 (* J (/ (* l (cos (* K 0.5))) U))))))
double code(double J, double l, double K, double U) {
return U * (1.0 + (2.0 * (J * ((l * cos((K * 0.5))) / 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 * cos((k * 0.5d0))) / u))))
end function
public static double code(double J, double l, double K, double U) {
return U * (1.0 + (2.0 * (J * ((l * Math.cos((K * 0.5))) / U))));
}
def code(J, l, K, U): return U * (1.0 + (2.0 * (J * ((l * math.cos((K * 0.5))) / U))))
function code(J, l, K, U) return Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(Float64(l * cos(Float64(K * 0.5))) / U))))) end
function tmp = code(J, l, K, U) tmp = U * (1.0 + (2.0 * (J * ((l * cos((K * 0.5))) / U)))); end
code[J_, l_, K_, U_] := N[(U * N[(1.0 + N[(2.0 * N[(J * N[(N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell \cdot \cos \left(K \cdot 0.5\right)}{U}\right)\right)
\end{array}
Initial program 87.1%
Taylor expanded in l around 0 68.5%
*-commutative68.5%
*-commutative68.5%
associate-*l*68.4%
*-commutative68.4%
associate-*r*68.4%
*-commutative68.4%
associate-*l*68.4%
Simplified68.4%
Taylor expanded in U around inf 71.0%
associate-/l*73.6%
Simplified73.6%
Final simplification73.6%
(FPCore (J l K U) :precision binary64 (if (<= J -4.8e+160) (* 2.0 (* J (* l (cos (* K 0.5))))) (* U (+ 1.0 (* 2.0 (* J (/ l U)))))))
double code(double J, double l, double K, double U) {
double tmp;
if (J <= -4.8e+160) {
tmp = 2.0 * (J * (l * cos((K * 0.5))));
} else {
tmp = U * (1.0 + (2.0 * (J * (l / U))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (j <= (-4.8d+160)) then
tmp = 2.0d0 * (j * (l * cos((k * 0.5d0))))
else
tmp = u * (1.0d0 + (2.0d0 * (j * (l / u))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (J <= -4.8e+160) {
tmp = 2.0 * (J * (l * Math.cos((K * 0.5))));
} else {
tmp = U * (1.0 + (2.0 * (J * (l / U))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if J <= -4.8e+160: tmp = 2.0 * (J * (l * math.cos((K * 0.5)))) else: tmp = U * (1.0 + (2.0 * (J * (l / U)))) return tmp
function code(J, l, K, U) tmp = 0.0 if (J <= -4.8e+160) tmp = Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5))))); else tmp = Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(l / U))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (J <= -4.8e+160) tmp = 2.0 * (J * (l * cos((K * 0.5)))); else tmp = U * (1.0 + (2.0 * (J * (l / U)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[J, -4.8e+160], N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U * N[(1.0 + N[(2.0 * N[(J * N[(l / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;J \leq -4.8 \cdot 10^{+160}:\\
\;\;\;\;2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell}{U}\right)\right)\\
\end{array}
\end{array}
if J < -4.8000000000000003e160Initial program 67.8%
Taylor expanded in l around 0 93.7%
*-commutative93.7%
*-commutative93.7%
associate-*l*93.6%
*-commutative93.6%
associate-*r*93.6%
*-commutative93.6%
associate-*l*93.6%
Simplified93.6%
Taylor expanded in U around inf 84.2%
associate-/l*84.1%
Simplified84.1%
Taylor expanded in U around 0 85.6%
if -4.8000000000000003e160 < J Initial program 89.7%
Taylor expanded in l around 0 65.1%
*-commutative65.1%
*-commutative65.1%
associate-*l*65.1%
*-commutative65.1%
associate-*r*65.1%
*-commutative65.1%
associate-*l*65.1%
Simplified65.1%
Taylor expanded in U around inf 69.2%
associate-/l*72.2%
Simplified72.2%
Taylor expanded in K around 0 59.9%
associate-/l*61.1%
Simplified61.1%
Final simplification64.0%
(FPCore (J l K U) :precision binary64 (if (or (<= l -760.0) (not (<= l 1000.0))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -760.0) || !(l <= 1000.0)) {
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 <= (-760.0d0)) .or. (.not. (l <= 1000.0d0))) 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 <= -760.0) || !(l <= 1000.0)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -760.0) or not (l <= 1000.0): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -760.0) || !(l <= 1000.0)) tmp = Float64(U * U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -760.0) || ~((l <= 1000.0))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -760.0], N[Not[LessEqual[l, 1000.0]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -760 \lor \neg \left(\ell \leq 1000\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -760 or 1e3 < l Initial program 100.0%
Applied egg-rr17.8%
if -760 < l < 1e3Initial program 76.3%
Taylor expanded in J around 0 75.4%
Final simplification49.0%
(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.1%
Taylor expanded in l around 0 68.5%
*-commutative68.5%
*-commutative68.5%
associate-*l*68.4%
*-commutative68.4%
associate-*r*68.4%
*-commutative68.4%
associate-*l*68.4%
Simplified68.4%
Taylor expanded in U around inf 71.0%
associate-/l*73.6%
Simplified73.6%
Taylor expanded in K around 0 61.1%
associate-/l*62.2%
Simplified62.2%
(FPCore (J l K U) :precision binary64 (+ U (* l (* J 2.0))))
double code(double J, double l, double K, double U) {
return U + (l * (J * 2.0));
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u + (l * (j * 2.0d0))
end function
public static double code(double J, double l, double K, double U) {
return U + (l * (J * 2.0));
}
def code(J, l, K, U): return U + (l * (J * 2.0))
function code(J, l, K, U) return Float64(U + Float64(l * Float64(J * 2.0))) end
function tmp = code(J, l, K, U) tmp = U + (l * (J * 2.0)); end
code[J_, l_, K_, U_] := N[(U + N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \ell \cdot \left(J \cdot 2\right)
\end{array}
Initial program 87.1%
Taylor expanded in l around 0 68.5%
*-commutative68.5%
*-commutative68.5%
associate-*l*68.4%
*-commutative68.4%
associate-*r*68.4%
*-commutative68.4%
associate-*l*68.4%
Simplified68.4%
Taylor expanded in K around 0 58.9%
associate-*r*58.9%
*-commutative58.9%
Simplified58.9%
Final simplification58.9%
(FPCore (J l K U) :precision binary64 U)
double code(double J, double l, double K, double U) {
return U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
public static double code(double J, double l, double K, double U) {
return U;
}
def code(J, l, K, U): return U
function code(J, l, K, U) return U end
function tmp = code(J, l, K, U) tmp = U; end
code[J_, l_, K_, U_] := U
\begin{array}{l}
\\
U
\end{array}
Initial program 87.1%
Taylor expanded in J around 0 41.8%
(FPCore (J l K U) :precision binary64 0.25)
double code(double J, double l, double K, double U) {
return 0.25;
}
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 = 0.25d0
end function
public static double code(double J, double l, double K, double U) {
return 0.25;
}
def code(J, l, K, U): return 0.25
function code(J, l, K, U) return 0.25 end
function tmp = code(J, l, K, U) tmp = 0.25; end
code[J_, l_, K_, U_] := 0.25
\begin{array}{l}
\\
0.25
\end{array}
Initial program 87.1%
Applied egg-rr26.2%
Taylor expanded in U around 0 2.7%
(FPCore (J l K U) :precision binary64 -4.0)
double code(double J, double l, double K, double U) {
return -4.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 = -4.0d0
end function
public static double code(double J, double l, double K, double U) {
return -4.0;
}
def code(J, l, K, U): return -4.0
function code(J, l, K, U) return -4.0 end
function tmp = code(J, l, K, U) tmp = -4.0; end
code[J_, l_, K_, U_] := -4.0
\begin{array}{l}
\\
-4
\end{array}
Initial program 87.1%
Applied egg-rr2.5%
fma-undefine2.5%
*-commutative2.5%
fma-define2.5%
Simplified2.5%
Taylor expanded in U around 0 2.7%
herbie shell --seed 2024151
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))