
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
(FPCore (J l K U) :precision binary64 (+ (* 2.0 (* J (log1p (expm1 (* l (cos (* K 0.5))))))) U))
double code(double J, double l, double K, double U) {
return (2.0 * (J * log1p(expm1((l * cos((K * 0.5))))))) + U;
}
public static double code(double J, double l, double K, double U) {
return (2.0 * (J * Math.log1p(Math.expm1((l * Math.cos((K * 0.5))))))) + U;
}
def code(J, l, K, U): return (2.0 * (J * math.log1p(math.expm1((l * math.cos((K * 0.5))))))) + U
function code(J, l, K, U) return Float64(Float64(2.0 * Float64(J * log1p(expm1(Float64(l * cos(Float64(K * 0.5))))))) + U) end
code[J_, l_, K_, U_] := N[(N[(2.0 * N[(J * N[Log[1 + N[(Exp[N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\right) + U
\end{array}
Initial program 82.4%
Taylor expanded in l around 0 64.6%
log1p-expm1-u99.1%
*-commutative99.1%
Applied egg-rr99.1%
Final simplification99.1%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ U (* (* (pow l 5.0) (* J 0.016666666666666666)) (cos (/ K 2.0)))))
(t_1 (+ U (* J (- (exp l) (exp (- l)))))))
(if (<= l -4.2e+90)
t_0
(if (<= l -0.00068)
t_1
(if (<= l 0.00055)
(+ U (* (* J l) (* 2.0 (cos (* K 0.5)))))
(if (<= l 4.5e+61) t_1 t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + ((pow(l, 5.0) * (J * 0.016666666666666666)) * cos((K / 2.0)));
double t_1 = U + (J * (exp(l) - exp(-l)));
double tmp;
if (l <= -4.2e+90) {
tmp = t_0;
} else if (l <= -0.00068) {
tmp = t_1;
} else if (l <= 0.00055) {
tmp = U + ((J * l) * (2.0 * cos((K * 0.5))));
} else if (l <= 4.5e+61) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = u + (((l ** 5.0d0) * (j * 0.016666666666666666d0)) * cos((k / 2.0d0)))
t_1 = u + (j * (exp(l) - exp(-l)))
if (l <= (-4.2d+90)) then
tmp = t_0
else if (l <= (-0.00068d0)) then
tmp = t_1
else if (l <= 0.00055d0) then
tmp = u + ((j * l) * (2.0d0 * cos((k * 0.5d0))))
else if (l <= 4.5d+61) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = U + ((Math.pow(l, 5.0) * (J * 0.016666666666666666)) * Math.cos((K / 2.0)));
double t_1 = U + (J * (Math.exp(l) - Math.exp(-l)));
double tmp;
if (l <= -4.2e+90) {
tmp = t_0;
} else if (l <= -0.00068) {
tmp = t_1;
} else if (l <= 0.00055) {
tmp = U + ((J * l) * (2.0 * Math.cos((K * 0.5))));
} else if (l <= 4.5e+61) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + ((math.pow(l, 5.0) * (J * 0.016666666666666666)) * math.cos((K / 2.0))) t_1 = U + (J * (math.exp(l) - math.exp(-l))) tmp = 0 if l <= -4.2e+90: tmp = t_0 elif l <= -0.00068: tmp = t_1 elif l <= 0.00055: tmp = U + ((J * l) * (2.0 * math.cos((K * 0.5)))) elif l <= 4.5e+61: tmp = t_1 else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(Float64((l ^ 5.0) * Float64(J * 0.016666666666666666)) * cos(Float64(K / 2.0)))) t_1 = Float64(U + Float64(J * Float64(exp(l) - exp(Float64(-l))))) tmp = 0.0 if (l <= -4.2e+90) tmp = t_0; elseif (l <= -0.00068) tmp = t_1; elseif (l <= 0.00055) tmp = Float64(U + Float64(Float64(J * l) * Float64(2.0 * cos(Float64(K * 0.5))))); elseif (l <= 4.5e+61) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + (((l ^ 5.0) * (J * 0.016666666666666666)) * cos((K / 2.0))); t_1 = U + (J * (exp(l) - exp(-l))); tmp = 0.0; if (l <= -4.2e+90) tmp = t_0; elseif (l <= -0.00068) tmp = t_1; elseif (l <= 0.00055) tmp = U + ((J * l) * (2.0 * cos((K * 0.5)))); elseif (l <= 4.5e+61) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(N[(N[Power[l, 5.0], $MachinePrecision] * N[(J * 0.016666666666666666), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -4.2e+90], t$95$0, If[LessEqual[l, -0.00068], t$95$1, If[LessEqual[l, 0.00055], N[(U + N[(N[(J * l), $MachinePrecision] * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 4.5e+61], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + \left({\ell}^{5} \cdot \left(J \cdot 0.016666666666666666\right)\right) \cdot \cos \left(\frac{K}{2}\right)\\
t_1 := U + J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\mathbf{if}\;\ell \leq -4.2 \cdot 10^{+90}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -0.00068:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq 0.00055:\\
\;\;\;\;U + \left(J \cdot \ell\right) \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{elif}\;\ell \leq 4.5 \cdot 10^{+61}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if l < -4.19999999999999961e90 or 4.5e61 < l Initial program 100.0%
Taylor expanded in l around 0 100.0%
Taylor expanded in l around inf 100.0%
*-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
if -4.19999999999999961e90 < l < -6.8e-4 or 5.50000000000000033e-4 < l < 4.5e61Initial program 99.7%
Taylor expanded in K around 0 87.2%
if -6.8e-4 < l < 5.50000000000000033e-4Initial program 65.7%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
associate-*r*99.9%
associate-*l*99.9%
*-commutative99.9%
Simplified99.9%
Final simplification98.5%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.08) (+ U (* (* J l) (* 2.0 (cos (* K 0.5))))) (+ U (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* 2.0 l))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.08) {
tmp = U + ((J * l) * (2.0 * cos((K * 0.5))));
} else {
tmp = U + (J * ((0.3333333333333333 * pow(l, 3.0)) + (2.0 * 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.08d0) then
tmp = u + ((j * l) * (2.0d0 * cos((k * 0.5d0))))
else
tmp = u + (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (2.0d0 * 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.08) {
tmp = U + ((J * l) * (2.0 * Math.cos((K * 0.5))));
} else {
tmp = U + (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (2.0 * l)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.08: tmp = U + ((J * l) * (2.0 * math.cos((K * 0.5)))) else: tmp = U + (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (2.0 * l))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.08) tmp = Float64(U + Float64(Float64(J * l) * Float64(2.0 * cos(Float64(K * 0.5))))); else tmp = Float64(U + Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(2.0 * l)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= 0.08) tmp = U + ((J * l) * (2.0 * cos((K * 0.5)))); else tmp = U + (J * ((0.3333333333333333 * (l ^ 3.0)) + (2.0 * l))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.08], N[(U + N[(N[(J * l), $MachinePrecision] * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.08:\\
\;\;\;\;U + \left(J \cdot \ell\right) \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < 0.0800000000000000017Initial program 79.0%
Taylor expanded in l around 0 74.5%
*-commutative74.5%
associate-*r*74.6%
associate-*l*74.6%
*-commutative74.6%
Simplified74.6%
if 0.0800000000000000017 < (cos.f64 (/.f64 K 2)) Initial program 83.4%
Taylor expanded in l around 0 88.2%
Taylor expanded in K around 0 84.9%
Final simplification82.6%
(FPCore (J l K U) :precision binary64 (if (or (<= l -0.00015) (not (<= l 2.8e-5))) (+ U (* J (- (exp l) (exp (- l))))) (+ U (* (* J l) (* 2.0 (cos (* K 0.5)))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -0.00015) || !(l <= 2.8e-5)) {
tmp = U + (J * (exp(l) - exp(-l)));
} else {
tmp = U + ((J * l) * (2.0 * cos((K * 0.5))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-0.00015d0)) .or. (.not. (l <= 2.8d-5))) then
tmp = u + (j * (exp(l) - exp(-l)))
else
tmp = u + ((j * l) * (2.0d0 * cos((k * 0.5d0))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -0.00015) || !(l <= 2.8e-5)) {
tmp = U + (J * (Math.exp(l) - Math.exp(-l)));
} else {
tmp = U + ((J * l) * (2.0 * Math.cos((K * 0.5))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -0.00015) or not (l <= 2.8e-5): tmp = U + (J * (math.exp(l) - math.exp(-l))) else: tmp = U + ((J * l) * (2.0 * math.cos((K * 0.5)))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -0.00015) || !(l <= 2.8e-5)) tmp = Float64(U + Float64(J * Float64(exp(l) - exp(Float64(-l))))); else tmp = Float64(U + Float64(Float64(J * l) * Float64(2.0 * cos(Float64(K * 0.5))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -0.00015) || ~((l <= 2.8e-5))) tmp = U + (J * (exp(l) - exp(-l))); else tmp = U + ((J * l) * (2.0 * cos((K * 0.5)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -0.00015], N[Not[LessEqual[l, 2.8e-5]], $MachinePrecision]], N[(U + N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(J * l), $MachinePrecision] * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -0.00015 \lor \neg \left(\ell \leq 2.8 \cdot 10^{-5}\right):\\
\;\;\;\;U + J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(J \cdot \ell\right) \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if l < -1.49999999999999987e-4 or 2.79999999999999996e-5 < l Initial program 99.9%
Taylor expanded in K around 0 80.9%
if -1.49999999999999987e-4 < l < 2.79999999999999996e-5Initial program 65.7%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
associate-*r*99.9%
associate-*l*99.9%
*-commutative99.9%
Simplified99.9%
Final simplification90.6%
(FPCore (J l K U) :precision binary64 (+ U (* 2.0 (* J (* l (cos (* K 0.5)))))))
double code(double J, double l, double K, double U) {
return U + (2.0 * (J * (l * cos((K * 0.5)))));
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
end function
public static double code(double J, double l, double K, double U) {
return U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
def code(J, l, K, U): return U + (2.0 * (J * (l * math.cos((K * 0.5)))))
function code(J, l, K, U) return Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))) end
function tmp = code(J, l, K, U) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); end
code[J_, l_, K_, U_] := N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)
\end{array}
Initial program 82.4%
Taylor expanded in l around 0 64.6%
Final simplification64.6%
(FPCore (J l K U) :precision binary64 (+ U (* (* J l) (* 2.0 (cos (* K 0.5))))))
double code(double J, double l, double K, double U) {
return U + ((J * l) * (2.0 * cos((K * 0.5))));
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u + ((j * l) * (2.0d0 * cos((k * 0.5d0))))
end function
public static double code(double J, double l, double K, double U) {
return U + ((J * l) * (2.0 * Math.cos((K * 0.5))));
}
def code(J, l, K, U): return U + ((J * l) * (2.0 * math.cos((K * 0.5))))
function code(J, l, K, U) return Float64(U + Float64(Float64(J * l) * Float64(2.0 * cos(Float64(K * 0.5))))) end
function tmp = code(J, l, K, U) tmp = U + ((J * l) * (2.0 * cos((K * 0.5)))); end
code[J_, l_, K_, U_] := N[(U + N[(N[(J * l), $MachinePrecision] * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \left(J \cdot \ell\right) \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)
\end{array}
Initial program 82.4%
Taylor expanded in l around 0 64.6%
*-commutative64.6%
associate-*r*64.6%
associate-*l*64.6%
*-commutative64.6%
Simplified64.6%
Final simplification64.6%
(FPCore (J l K U) :precision binary64 (if (<= l -750.0) (* U U) (if (<= l 1.45) U (* U (- U -4.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -750.0) {
tmp = U * U;
} else if (l <= 1.45) {
tmp = U;
} else {
tmp = U * (U - -4.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 <= (-750.0d0)) then
tmp = u * u
else if (l <= 1.45d0) then
tmp = u
else
tmp = u * (u - (-4.0d0))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -750.0) {
tmp = U * U;
} else if (l <= 1.45) {
tmp = U;
} else {
tmp = U * (U - -4.0);
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -750.0: tmp = U * U elif l <= 1.45: tmp = U else: tmp = U * (U - -4.0) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -750.0) tmp = Float64(U * U); elseif (l <= 1.45) tmp = U; else tmp = Float64(U * Float64(U - -4.0)); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -750.0) tmp = U * U; elseif (l <= 1.45) tmp = U; else tmp = U * (U - -4.0); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -750.0], N[(U * U), $MachinePrecision], If[LessEqual[l, 1.45], U, N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -750:\\
\;\;\;\;U \cdot U\\
\mathbf{elif}\;\ell \leq 1.45:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;U \cdot \left(U - -4\right)\\
\end{array}
\end{array}
if l < -750Initial program 100.0%
Applied egg-rr23.9%
if -750 < l < 1.44999999999999996Initial program 66.7%
Taylor expanded in J around 0 64.7%
if 1.44999999999999996 < l Initial program 100.0%
Applied egg-rr10.4%
Final simplification42.3%
(FPCore (J l K U) :precision binary64 (if (<= l -660.0) (* U U) (if (<= l 1.76e+52) U (- -4.0 (* U U)))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -660.0) {
tmp = U * U;
} else if (l <= 1.76e+52) {
tmp = U;
} else {
tmp = -4.0 - (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 <= (-660.0d0)) then
tmp = u * u
else if (l <= 1.76d+52) then
tmp = u
else
tmp = (-4.0d0) - (u * u)
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -660.0) {
tmp = U * U;
} else if (l <= 1.76e+52) {
tmp = U;
} else {
tmp = -4.0 - (U * U);
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -660.0: tmp = U * U elif l <= 1.76e+52: tmp = U else: tmp = -4.0 - (U * U) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -660.0) tmp = Float64(U * U); elseif (l <= 1.76e+52) tmp = U; else tmp = Float64(-4.0 - Float64(U * U)); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -660.0) tmp = U * U; elseif (l <= 1.76e+52) tmp = U; else tmp = -4.0 - (U * U); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -660.0], N[(U * U), $MachinePrecision], If[LessEqual[l, 1.76e+52], U, N[(-4.0 - N[(U * U), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -660:\\
\;\;\;\;U \cdot U\\
\mathbf{elif}\;\ell \leq 1.76 \cdot 10^{+52}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-4 - U \cdot U\\
\end{array}
\end{array}
if l < -660Initial program 100.0%
Applied egg-rr23.9%
if -660 < l < 1.75999999999999993e52Initial program 68.5%
Taylor expanded in J around 0 61.2%
if 1.75999999999999993e52 < l Initial program 100.0%
*-commutative100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Applied egg-rr15.4%
cancel-sign-sub-inv15.4%
Simplified15.4%
Final simplification43.1%
(FPCore (J l K U) :precision binary64 (if (or (<= l -22000.0) (not (<= l 6.2e+63))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -22000.0) || !(l <= 6.2e+63)) {
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 <= (-22000.0d0)) .or. (.not. (l <= 6.2d+63))) 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 <= -22000.0) || !(l <= 6.2e+63)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -22000.0) or not (l <= 6.2e+63): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -22000.0) || !(l <= 6.2e+63)) tmp = Float64(U * U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -22000.0) || ~((l <= 6.2e+63))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -22000.0], N[Not[LessEqual[l, 6.2e+63]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -22000 \lor \neg \left(\ell \leq 6.2 \cdot 10^{+63}\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -22000 or 6.2000000000000001e63 < l Initial program 100.0%
Applied egg-rr18.6%
if -22000 < l < 6.2000000000000001e63Initial program 68.9%
Taylor expanded in J around 0 60.4%
Final simplification42.3%
(FPCore (J l K U) :precision binary64 (+ U (* l (* 2.0 J))))
double code(double J, double l, double K, double U) {
return U + (l * (2.0 * J));
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u + (l * (2.0d0 * j))
end function
public static double code(double J, double l, double K, double U) {
return U + (l * (2.0 * J));
}
def code(J, l, K, U): return U + (l * (2.0 * J))
function code(J, l, K, U) return Float64(U + Float64(l * Float64(2.0 * J))) end
function tmp = code(J, l, K, U) tmp = U + (l * (2.0 * J)); end
code[J_, l_, K_, U_] := N[(U + N[(l * N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \ell \cdot \left(2 \cdot J\right)
\end{array}
Initial program 82.4%
Taylor expanded in l around 0 64.6%
Taylor expanded in K around 0 53.9%
+-commutative53.9%
associate-*r*53.9%
*-commutative53.9%
Simplified53.9%
Final simplification53.9%
(FPCore (J l K U) :precision binary64 U)
double code(double J, double l, double K, double U) {
return U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
public static double code(double J, double l, double K, double U) {
return U;
}
def code(J, l, K, U): return U
function code(J, l, K, U) return U end
function tmp = code(J, l, K, U) tmp = U; end
code[J_, l_, K_, U_] := U
\begin{array}{l}
\\
U
\end{array}
Initial program 82.4%
Taylor expanded in J around 0 35.2%
Final simplification35.2%
herbie shell --seed 2023299
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))