
(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 10 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 -5000.0) (not (<= t_1 0.0)))
(+ (* (* t_1 J) t_0) U)
(+ U (* J (* t_0 (* l 2.0)))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = exp(l) - exp(-l);
double tmp;
if ((t_1 <= -5000.0) || !(t_1 <= 0.0)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (J * (t_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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = exp(l) - exp(-l)
if ((t_1 <= (-5000.0d0)) .or. (.not. (t_1 <= 0.0d0))) then
tmp = ((t_1 * j) * t_0) + u
else
tmp = u + (j * (t_0 * (l * 2.0d0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_1 <= -5000.0) || !(t_1 <= 0.0)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (J * (t_0 * (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = math.exp(l) - math.exp(-l) tmp = 0 if (t_1 <= -5000.0) or not (t_1 <= 0.0): tmp = ((t_1 * J) * t_0) + U else: tmp = U + (J * (t_0 * (l * 2.0))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_1 <= -5000.0) || !(t_1 <= 0.0)) tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U); else tmp = Float64(U + Float64(J * Float64(t_0 * Float64(l * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = exp(l) - exp(-l); tmp = 0.0; if ((t_1 <= -5000.0) || ~((t_1 <= 0.0))) tmp = ((t_1 * J) * t_0) + U; else tmp = U + (J * (t_0 * (l * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -5000.0], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(J * N[(t$95$0 * N[(l * 2.0), $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 -5000 \lor \neg \left(t_1 \leq 0\right):\\
\;\;\;\;\left(t_1 \cdot J\right) \cdot t_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(t_0 \cdot \left(\ell \cdot 2\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -5e3 or 0.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -5e3 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0Initial program 69.2%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
associate-*l*99.9%
*-commutative99.9%
associate-*r*99.9%
*-commutative99.9%
associate-*l*99.9%
*-commutative99.9%
associate-*r*99.9%
distribute-rgt-out99.9%
+-commutative99.9%
fma-def99.9%
Simplified99.9%
expm1-log1p-u84.8%
expm1-udef74.8%
*-commutative74.8%
*-commutative74.8%
metadata-eval74.8%
div-inv74.8%
*-commutative74.8%
Applied egg-rr74.8%
expm1-def84.8%
expm1-log1p99.9%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
Simplified99.9%
Final simplification100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* J (* 2.0 (sinh l)))))
(if (<= l -0.017)
(+ U (* (+ (* -0.125 (* K K)) 1.0) t_0))
(if (<= l 14000000.0)
(+ U (* J (* (cos (/ K 2.0)) (* l 2.0))))
(if (<= l 5.5e+102)
(+ U t_0)
(+
U
(* (cos (* K 0.5)) (* 0.3333333333333333 (* J (pow l 3.0))))))))))
double code(double J, double l, double K, double U) {
double t_0 = J * (2.0 * sinh(l));
double tmp;
if (l <= -0.017) {
tmp = U + (((-0.125 * (K * K)) + 1.0) * t_0);
} else if (l <= 14000000.0) {
tmp = U + (J * (cos((K / 2.0)) * (l * 2.0)));
} else if (l <= 5.5e+102) {
tmp = U + t_0;
} else {
tmp = U + (cos((K * 0.5)) * (0.3333333333333333 * (J * pow(l, 3.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 = j * (2.0d0 * sinh(l))
if (l <= (-0.017d0)) then
tmp = u + ((((-0.125d0) * (k * k)) + 1.0d0) * t_0)
else if (l <= 14000000.0d0) then
tmp = u + (j * (cos((k / 2.0d0)) * (l * 2.0d0)))
else if (l <= 5.5d+102) then
tmp = u + t_0
else
tmp = u + (cos((k * 0.5d0)) * (0.3333333333333333d0 * (j * (l ** 3.0d0))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = J * (2.0 * Math.sinh(l));
double tmp;
if (l <= -0.017) {
tmp = U + (((-0.125 * (K * K)) + 1.0) * t_0);
} else if (l <= 14000000.0) {
tmp = U + (J * (Math.cos((K / 2.0)) * (l * 2.0)));
} else if (l <= 5.5e+102) {
tmp = U + t_0;
} else {
tmp = U + (Math.cos((K * 0.5)) * (0.3333333333333333 * (J * Math.pow(l, 3.0))));
}
return tmp;
}
def code(J, l, K, U): t_0 = J * (2.0 * math.sinh(l)) tmp = 0 if l <= -0.017: tmp = U + (((-0.125 * (K * K)) + 1.0) * t_0) elif l <= 14000000.0: tmp = U + (J * (math.cos((K / 2.0)) * (l * 2.0))) elif l <= 5.5e+102: tmp = U + t_0 else: tmp = U + (math.cos((K * 0.5)) * (0.3333333333333333 * (J * math.pow(l, 3.0)))) return tmp
function code(J, l, K, U) t_0 = Float64(J * Float64(2.0 * sinh(l))) tmp = 0.0 if (l <= -0.017) tmp = Float64(U + Float64(Float64(Float64(-0.125 * Float64(K * K)) + 1.0) * t_0)); elseif (l <= 14000000.0) tmp = Float64(U + Float64(J * Float64(cos(Float64(K / 2.0)) * Float64(l * 2.0)))); elseif (l <= 5.5e+102) tmp = Float64(U + t_0); else tmp = Float64(U + Float64(cos(Float64(K * 0.5)) * Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = J * (2.0 * sinh(l)); tmp = 0.0; if (l <= -0.017) tmp = U + (((-0.125 * (K * K)) + 1.0) * t_0); elseif (l <= 14000000.0) tmp = U + (J * (cos((K / 2.0)) * (l * 2.0))); elseif (l <= 5.5e+102) tmp = U + t_0; else tmp = U + (cos((K * 0.5)) * (0.3333333333333333 * (J * (l ^ 3.0)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(J * N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -0.017], N[(U + N[(N[(N[(-0.125 * N[(K * K), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 14000000.0], N[(U + N[(J * N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5.5e+102], N[(U + t$95$0), $MachinePrecision], N[(U + N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := J \cdot \left(2 \cdot \sinh \ell\right)\\
\mathbf{if}\;\ell \leq -0.017:\\
\;\;\;\;U + \left(-0.125 \cdot \left(K \cdot K\right) + 1\right) \cdot t_0\\
\mathbf{elif}\;\ell \leq 14000000:\\
\;\;\;\;U + J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 5.5 \cdot 10^{+102}:\\
\;\;\;\;U + t_0\\
\mathbf{else}:\\
\;\;\;\;U + \cos \left(K \cdot 0.5\right) \cdot \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\right)\\
\end{array}
\end{array}
if l < -0.017000000000000001Initial program 100.0%
Taylor expanded in K around 0 1.7%
associate-*r*1.7%
distribute-rgt1-in83.9%
unpow283.9%
Simplified83.9%
expm1-log1p-u26.0%
expm1-udef26.0%
*-commutative26.0%
sinh-undef26.0%
Applied egg-rr38.6%
expm1-def26.0%
expm1-log1p64.9%
Simplified83.9%
if -0.017000000000000001 < l < 1.4e7Initial program 69.7%
Taylor expanded in l around 0 99.1%
*-commutative99.1%
associate-*l*99.1%
*-commutative99.1%
associate-*r*99.1%
*-commutative99.1%
associate-*l*99.1%
*-commutative99.1%
associate-*r*99.1%
distribute-rgt-out99.1%
+-commutative99.1%
fma-def99.1%
Simplified99.1%
expm1-log1p-u84.2%
expm1-udef74.4%
*-commutative74.4%
*-commutative74.4%
metadata-eval74.4%
div-inv74.4%
*-commutative74.4%
Applied egg-rr74.4%
expm1-def84.2%
expm1-log1p99.1%
associate-*l*99.2%
Simplified99.2%
Taylor expanded in l around 0 99.2%
*-commutative99.2%
Simplified99.2%
if 1.4e7 < l < 5.49999999999999981e102Initial program 100.0%
Taylor expanded in K around 0 95.0%
expm1-log1p-u45.0%
expm1-udef45.0%
*-commutative45.0%
sinh-undef45.0%
Applied egg-rr45.0%
expm1-def45.0%
expm1-log1p95.0%
Simplified95.0%
if 5.49999999999999981e102 < l Initial program 100.0%
Taylor expanded in l around 0 100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in l around inf 100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
*-commutative100.0%
Simplified100.0%
Final simplification95.3%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 0.25)
(+ U (* J (* t_0 (* l 2.0))))
(+ U (* J (* 2.0 (sinh l)))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= 0.25) {
tmp = U + (J * (t_0 * (l * 2.0)));
} 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) :: t_0
real(8) :: tmp
t_0 = cos((k / 2.0d0))
if (t_0 <= 0.25d0) then
tmp = u + (j * (t_0 * (l * 2.0d0)))
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 t_0 = Math.cos((K / 2.0));
double tmp;
if (t_0 <= 0.25) {
tmp = U + (J * (t_0 * (l * 2.0)));
} else {
tmp = U + (J * (2.0 * Math.sinh(l)));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) tmp = 0 if t_0 <= 0.25: tmp = U + (J * (t_0 * (l * 2.0))) else: tmp = U + (J * (2.0 * math.sinh(l))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= 0.25) tmp = Float64(U + Float64(J * Float64(t_0 * Float64(l * 2.0)))); else tmp = Float64(U + Float64(J * Float64(2.0 * sinh(l)))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); tmp = 0.0; if (t_0 <= 0.25) tmp = U + (J * (t_0 * (l * 2.0))); else tmp = U + (J * (2.0 * sinh(l))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 0.25], N[(U + N[(J * N[(t$95$0 * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t_0 \leq 0.25:\\
\;\;\;\;U + J \cdot \left(t_0 \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(2 \cdot \sinh \ell\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < 0.25Initial program 87.4%
Taylor expanded in l around 0 90.5%
*-commutative90.5%
associate-*l*90.5%
*-commutative90.5%
associate-*r*90.5%
*-commutative90.5%
associate-*l*90.5%
*-commutative90.5%
associate-*r*90.5%
distribute-rgt-out90.5%
+-commutative90.5%
fma-def90.5%
Simplified90.5%
expm1-log1p-u64.5%
expm1-udef58.8%
*-commutative58.8%
*-commutative58.8%
metadata-eval58.8%
div-inv58.8%
*-commutative58.8%
Applied egg-rr58.8%
expm1-def64.5%
expm1-log1p90.5%
associate-*l*90.5%
Simplified90.5%
Taylor expanded in l around 0 67.7%
*-commutative67.7%
Simplified67.7%
if 0.25 < (cos.f64 (/.f64 K 2)) Initial program 83.9%
Taylor expanded in K around 0 83.5%
expm1-log1p-u55.3%
expm1-udef55.3%
*-commutative55.3%
sinh-undef55.7%
Applied egg-rr55.7%
expm1-def59.4%
expm1-log1p94.5%
Simplified94.5%
Final simplification87.1%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.55) (+ U (* (+ (* -0.125 (* K K)) 1.0) (* J (* l 2.0)))) (+ U (* J (* 2.0 (sinh l))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.55) {
tmp = U + (((-0.125 * (K * K)) + 1.0) * (J * (l * 2.0)));
} 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.55d0)) then
tmp = u + ((((-0.125d0) * (k * k)) + 1.0d0) * (j * (l * 2.0d0)))
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.55) {
tmp = U + (((-0.125 * (K * K)) + 1.0) * (J * (l * 2.0)));
} 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.55: tmp = U + (((-0.125 * (K * K)) + 1.0) * (J * (l * 2.0))) 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.55) tmp = Float64(U + Float64(Float64(Float64(-0.125 * Float64(K * K)) + 1.0) * Float64(J * Float64(l * 2.0)))); 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.55) tmp = U + (((-0.125 * (K * K)) + 1.0) * (J * (l * 2.0))); 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.55], N[(U + N[(N[(N[(-0.125 * N[(K * K), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(J * N[(l * 2.0), $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.55:\\
\;\;\;\;U + \left(-0.125 \cdot \left(K \cdot K\right) + 1\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(2 \cdot \sinh \ell\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.55000000000000004Initial program 86.9%
Taylor expanded in K around 0 20.1%
associate-*r*20.1%
distribute-rgt1-in81.6%
unpow281.6%
Simplified81.6%
Taylor expanded in l around 0 59.4%
if -0.55000000000000004 < (cos.f64 (/.f64 K 2)) Initial program 84.5%
Taylor expanded in K around 0 79.1%
expm1-log1p-u54.6%
expm1-udef54.6%
*-commutative54.6%
sinh-undef54.9%
Applied egg-rr54.9%
expm1-def58.1%
expm1-log1p88.6%
Simplified88.6%
Final simplification84.2%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* J (* 2.0 (sinh l)))))
(if (<= l -4.0)
(+ U (* (+ (* -0.125 (* K K)) 1.0) t_0))
(if (<= l 14000000.0)
(+ U (* J (* (cos (/ K 2.0)) (* l 2.0))))
(+ U t_0)))))
double code(double J, double l, double K, double U) {
double t_0 = J * (2.0 * sinh(l));
double tmp;
if (l <= -4.0) {
tmp = U + (((-0.125 * (K * K)) + 1.0) * t_0);
} else if (l <= 14000000.0) {
tmp = U + (J * (cos((K / 2.0)) * (l * 2.0)));
} else {
tmp = U + 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) :: tmp
t_0 = j * (2.0d0 * sinh(l))
if (l <= (-4.0d0)) then
tmp = u + ((((-0.125d0) * (k * k)) + 1.0d0) * t_0)
else if (l <= 14000000.0d0) then
tmp = u + (j * (cos((k / 2.0d0)) * (l * 2.0d0)))
else
tmp = u + t_0
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = J * (2.0 * Math.sinh(l));
double tmp;
if (l <= -4.0) {
tmp = U + (((-0.125 * (K * K)) + 1.0) * t_0);
} else if (l <= 14000000.0) {
tmp = U + (J * (Math.cos((K / 2.0)) * (l * 2.0)));
} else {
tmp = U + t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = J * (2.0 * math.sinh(l)) tmp = 0 if l <= -4.0: tmp = U + (((-0.125 * (K * K)) + 1.0) * t_0) elif l <= 14000000.0: tmp = U + (J * (math.cos((K / 2.0)) * (l * 2.0))) else: tmp = U + t_0 return tmp
function code(J, l, K, U) t_0 = Float64(J * Float64(2.0 * sinh(l))) tmp = 0.0 if (l <= -4.0) tmp = Float64(U + Float64(Float64(Float64(-0.125 * Float64(K * K)) + 1.0) * t_0)); elseif (l <= 14000000.0) tmp = Float64(U + Float64(J * Float64(cos(Float64(K / 2.0)) * Float64(l * 2.0)))); else tmp = Float64(U + t_0); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = J * (2.0 * sinh(l)); tmp = 0.0; if (l <= -4.0) tmp = U + (((-0.125 * (K * K)) + 1.0) * t_0); elseif (l <= 14000000.0) tmp = U + (J * (cos((K / 2.0)) * (l * 2.0))); else tmp = U + t_0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(J * N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -4.0], N[(U + N[(N[(N[(-0.125 * N[(K * K), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 14000000.0], N[(U + N[(J * N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := J \cdot \left(2 \cdot \sinh \ell\right)\\
\mathbf{if}\;\ell \leq -4:\\
\;\;\;\;U + \left(-0.125 \cdot \left(K \cdot K\right) + 1\right) \cdot t_0\\
\mathbf{elif}\;\ell \leq 14000000:\\
\;\;\;\;U + J \cdot \left(\cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + t_0\\
\end{array}
\end{array}
if l < -4Initial program 100.0%
Taylor expanded in K around 0 1.7%
associate-*r*1.7%
distribute-rgt1-in83.9%
unpow283.9%
Simplified83.9%
expm1-log1p-u26.0%
expm1-udef26.0%
*-commutative26.0%
sinh-undef26.0%
Applied egg-rr38.6%
expm1-def26.0%
expm1-log1p64.9%
Simplified83.9%
if -4 < l < 1.4e7Initial program 69.7%
Taylor expanded in l around 0 99.1%
*-commutative99.1%
associate-*l*99.1%
*-commutative99.1%
associate-*r*99.1%
*-commutative99.1%
associate-*l*99.1%
*-commutative99.1%
associate-*r*99.1%
distribute-rgt-out99.1%
+-commutative99.1%
fma-def99.1%
Simplified99.1%
expm1-log1p-u84.2%
expm1-udef74.4%
*-commutative74.4%
*-commutative74.4%
metadata-eval74.4%
div-inv74.4%
*-commutative74.4%
Applied egg-rr74.4%
expm1-def84.2%
expm1-log1p99.1%
associate-*l*99.2%
Simplified99.2%
Taylor expanded in l around 0 99.2%
*-commutative99.2%
Simplified99.2%
if 1.4e7 < l Initial program 100.0%
Taylor expanded in K around 0 80.3%
expm1-log1p-u36.4%
expm1-udef36.4%
*-commutative36.4%
sinh-undef36.4%
Applied egg-rr36.4%
expm1-def36.4%
expm1-log1p80.3%
Simplified80.3%
Final simplification90.6%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* J (* l 2.0))))
(if (<= l -1.9e-38)
(+ U (* (* l J) (+ 2.0 (* (* K K) -0.25))))
(if (<= l 5e-27) (+ U t_0) (+ U (* (+ (* -0.125 (* K K)) 1.0) t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = J * (l * 2.0);
double tmp;
if (l <= -1.9e-38) {
tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
} else if (l <= 5e-27) {
tmp = U + t_0;
} else {
tmp = U + (((-0.125 * (K * K)) + 1.0) * 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) :: tmp
t_0 = j * (l * 2.0d0)
if (l <= (-1.9d-38)) then
tmp = u + ((l * j) * (2.0d0 + ((k * k) * (-0.25d0))))
else if (l <= 5d-27) then
tmp = u + t_0
else
tmp = u + ((((-0.125d0) * (k * k)) + 1.0d0) * t_0)
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = J * (l * 2.0);
double tmp;
if (l <= -1.9e-38) {
tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
} else if (l <= 5e-27) {
tmp = U + t_0;
} else {
tmp = U + (((-0.125 * (K * K)) + 1.0) * t_0);
}
return tmp;
}
def code(J, l, K, U): t_0 = J * (l * 2.0) tmp = 0 if l <= -1.9e-38: tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25))) elif l <= 5e-27: tmp = U + t_0 else: tmp = U + (((-0.125 * (K * K)) + 1.0) * t_0) return tmp
function code(J, l, K, U) t_0 = Float64(J * Float64(l * 2.0)) tmp = 0.0 if (l <= -1.9e-38) tmp = Float64(U + Float64(Float64(l * J) * Float64(2.0 + Float64(Float64(K * K) * -0.25)))); elseif (l <= 5e-27) tmp = Float64(U + t_0); else tmp = Float64(U + Float64(Float64(Float64(-0.125 * Float64(K * K)) + 1.0) * t_0)); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = J * (l * 2.0); tmp = 0.0; if (l <= -1.9e-38) tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25))); elseif (l <= 5e-27) tmp = U + t_0; else tmp = U + (((-0.125 * (K * K)) + 1.0) * t_0); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.9e-38], N[(U + N[(N[(l * J), $MachinePrecision] * N[(2.0 + N[(N[(K * K), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5e-27], N[(U + t$95$0), $MachinePrecision], N[(U + N[(N[(N[(-0.125 * N[(K * K), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := J \cdot \left(\ell \cdot 2\right)\\
\mathbf{if}\;\ell \leq -1.9 \cdot 10^{-38}:\\
\;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\
\mathbf{elif}\;\ell \leq 5 \cdot 10^{-27}:\\
\;\;\;\;U + t_0\\
\mathbf{else}:\\
\;\;\;\;U + \left(-0.125 \cdot \left(K \cdot K\right) + 1\right) \cdot t_0\\
\end{array}
\end{array}
if l < -1.9e-38Initial program 98.4%
Taylor expanded in l around 0 73.9%
*-commutative73.9%
associate-*l*74.0%
*-commutative74.0%
associate-*r*74.0%
*-commutative74.0%
associate-*l*74.0%
*-commutative74.0%
associate-*r*74.0%
distribute-rgt-out74.0%
+-commutative74.0%
fma-def74.0%
Simplified74.0%
Taylor expanded in l around 0 31.2%
*-commutative31.2%
Simplified31.2%
Taylor expanded in K around 0 10.1%
+-commutative10.1%
unpow210.1%
associate-*r*10.1%
distribute-rgt-out33.9%
Simplified33.9%
if -1.9e-38 < l < 5.0000000000000002e-27Initial program 69.5%
Taylor expanded in K around 0 69.5%
Taylor expanded in l around 0 86.2%
if 5.0000000000000002e-27 < l Initial program 100.0%
Taylor expanded in K around 0 2.9%
associate-*r*2.9%
distribute-rgt1-in72.5%
unpow272.5%
Simplified72.5%
Taylor expanded in l around 0 32.3%
Final simplification58.8%
(FPCore (J l K U) :precision binary64 (if (or (<= l -1.9e-38) (not (<= l 5e-27))) (+ U (* (* l J) (+ 2.0 (* (* K K) -0.25)))) (+ U (* J (* l 2.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1.9e-38) || !(l <= 5e-27)) {
tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
} 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 <= (-1.9d-38)) .or. (.not. (l <= 5d-27))) then
tmp = u + ((l * j) * (2.0d0 + ((k * k) * (-0.25d0))))
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 <= -1.9e-38) || !(l <= 5e-27)) {
tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
} else {
tmp = U + (J * (l * 2.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -1.9e-38) or not (l <= 5e-27): tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25))) else: tmp = U + (J * (l * 2.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -1.9e-38) || !(l <= 5e-27)) tmp = Float64(U + Float64(Float64(l * J) * Float64(2.0 + Float64(Float64(K * K) * -0.25)))); 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 <= -1.9e-38) || ~((l <= 5e-27))) tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25))); else tmp = U + (J * (l * 2.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -1.9e-38], N[Not[LessEqual[l, 5e-27]], $MachinePrecision]], N[(U + N[(N[(l * J), $MachinePrecision] * N[(2.0 + N[(N[(K * K), $MachinePrecision] * -0.25), $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 -1.9 \cdot 10^{-38} \lor \neg \left(\ell \leq 5 \cdot 10^{-27}\right):\\
\;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\
\end{array}
\end{array}
if l < -1.9e-38 or 5.0000000000000002e-27 < l Initial program 99.3%
Taylor expanded in l around 0 75.1%
*-commutative75.1%
associate-*l*75.1%
*-commutative75.1%
associate-*r*75.1%
*-commutative75.1%
associate-*l*75.1%
*-commutative75.1%
associate-*r*75.1%
distribute-rgt-out75.1%
+-commutative75.1%
fma-def75.1%
Simplified75.1%
Taylor expanded in l around 0 30.0%
*-commutative30.0%
Simplified30.0%
Taylor expanded in K around 0 10.4%
+-commutative10.4%
unpow210.4%
associate-*r*10.4%
distribute-rgt-out32.4%
Simplified32.4%
if -1.9e-38 < l < 5.0000000000000002e-27Initial program 69.5%
Taylor expanded in K around 0 69.5%
Taylor expanded in l around 0 86.2%
Final simplification58.4%
(FPCore (J l K U) :precision binary64 (if (or (<= l -1.9e-38) (not (<= l 38000000.0))) (+ U (* J (* K K))) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1.9e-38) || !(l <= 38000000.0)) {
tmp = U + (J * (K * K));
} 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 <= (-1.9d-38)) .or. (.not. (l <= 38000000.0d0))) then
tmp = u + (j * (k * k))
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 <= -1.9e-38) || !(l <= 38000000.0)) {
tmp = U + (J * (K * K));
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -1.9e-38) or not (l <= 38000000.0): tmp = U + (J * (K * K)) else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -1.9e-38) || !(l <= 38000000.0)) tmp = Float64(U + Float64(J * Float64(K * K))); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -1.9e-38) || ~((l <= 38000000.0))) tmp = U + (J * (K * K)); else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -1.9e-38], N[Not[LessEqual[l, 38000000.0]], $MachinePrecision]], N[(U + N[(J * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.9 \cdot 10^{-38} \lor \neg \left(\ell \leq 38000000\right):\\
\;\;\;\;U + J \cdot \left(K \cdot K\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -1.9e-38 or 3.8e7 < l Initial program 99.2%
Applied egg-rr2.8%
Taylor expanded in K around 0 17.2%
distribute-rgt-out17.2%
unpow217.2%
Simplified17.2%
Taylor expanded in K around inf 17.0%
unpow217.0%
*-commutative17.0%
Simplified17.0%
if -1.9e-38 < l < 3.8e7Initial program 70.3%
Taylor expanded in l around 0 99.1%
*-commutative99.1%
associate-*l*99.1%
*-commutative99.1%
associate-*r*99.1%
*-commutative99.1%
associate-*l*99.1%
*-commutative99.1%
associate-*r*99.1%
distribute-rgt-out99.1%
+-commutative99.1%
fma-def99.1%
Simplified99.1%
Taylor expanded in J around 0 69.5%
Final simplification43.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 84.9%
Taylor expanded in K around 0 70.9%
Taylor expanded in l around 0 51.9%
Final simplification51.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 84.9%
Taylor expanded in l around 0 87.1%
*-commutative87.1%
associate-*l*87.1%
*-commutative87.1%
associate-*r*87.1%
*-commutative87.1%
associate-*l*87.1%
*-commutative87.1%
associate-*r*87.1%
distribute-rgt-out87.1%
+-commutative87.1%
fma-def87.1%
Simplified87.1%
Taylor expanded in J around 0 35.6%
Final simplification35.6%
herbie shell --seed 2023194
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))