
(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 12 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 (- (exp l) (exp (- l)))))
(if (or (<= t_0 -10.0) (not (<= t_0 0.0)))
(+ (* (cos (/ K 2.0)) (* t_0 J)) U)
(+ U (* 2.0 (* l (* J (cos (* K 0.5)))))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double tmp;
if ((t_0 <= -10.0) || !(t_0 <= 0.0)) {
tmp = (cos((K / 2.0)) * (t_0 * J)) + U;
} else {
tmp = U + (2.0 * (l * (J * 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) :: t_0
real(8) :: tmp
t_0 = exp(l) - exp(-l)
if ((t_0 <= (-10.0d0)) .or. (.not. (t_0 <= 0.0d0))) then
tmp = (cos((k / 2.0d0)) * (t_0 * j)) + u
else
tmp = u + (2.0d0 * (l * (j * cos((k * 0.5d0)))))
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 tmp;
if ((t_0 <= -10.0) || !(t_0 <= 0.0)) {
tmp = (Math.cos((K / 2.0)) * (t_0 * J)) + U;
} else {
tmp = U + (2.0 * (l * (J * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) tmp = 0 if (t_0 <= -10.0) or not (t_0 <= 0.0): tmp = (math.cos((K / 2.0)) * (t_0 * J)) + U else: tmp = U + (2.0 * (l * (J * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_0 <= -10.0) || !(t_0 <= 0.0)) tmp = Float64(Float64(cos(Float64(K / 2.0)) * Float64(t_0 * J)) + U); else tmp = Float64(U + Float64(2.0 * Float64(l * Float64(J * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); tmp = 0.0; if ((t_0 <= -10.0) || ~((t_0 <= 0.0))) tmp = (cos((K / 2.0)) * (t_0 * J)) + U; else tmp = U + (2.0 * (l * (J * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -10.0], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], N[(N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(t$95$0 * J), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(2.0 * N[(l * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_0 \leq -10 \lor \neg \left(t_0 \leq 0\right):\\
\;\;\;\;\cos \left(\frac{K}{2}\right) \cdot \left(t_0 \cdot J\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -10 or 0.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -10 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0Initial program 69.9%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
associate-*l*99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))) (t_1 (* t_0 J)))
(if (<= t_0 -10.0)
t_1
(if (<= t_0 0.0) (+ U (* 2.0 (* l (* J (cos (* K 0.5)))))) (+ U t_1)))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double t_1 = t_0 * J;
double tmp;
if (t_0 <= -10.0) {
tmp = t_1;
} else if (t_0 <= 0.0) {
tmp = U + (2.0 * (l * (J * cos((K * 0.5)))));
} else {
tmp = U + 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 = t_0 * j
if (t_0 <= (-10.0d0)) then
tmp = t_1
else if (t_0 <= 0.0d0) then
tmp = u + (2.0d0 * (l * (j * cos((k * 0.5d0)))))
else
tmp = u + 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 = t_0 * J;
double tmp;
if (t_0 <= -10.0) {
tmp = t_1;
} else if (t_0 <= 0.0) {
tmp = U + (2.0 * (l * (J * Math.cos((K * 0.5)))));
} else {
tmp = U + t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) t_1 = t_0 * J tmp = 0 if t_0 <= -10.0: tmp = t_1 elif t_0 <= 0.0: tmp = U + (2.0 * (l * (J * math.cos((K * 0.5))))) else: tmp = U + t_1 return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) t_1 = Float64(t_0 * J) tmp = 0.0 if (t_0 <= -10.0) tmp = t_1; elseif (t_0 <= 0.0) tmp = Float64(U + Float64(2.0 * Float64(l * Float64(J * cos(Float64(K * 0.5)))))); else tmp = Float64(U + t_1); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); t_1 = t_0 * J; tmp = 0.0; if (t_0 <= -10.0) tmp = t_1; elseif (t_0 <= 0.0) tmp = U + (2.0 * (l * (J * cos((K * 0.5))))); else tmp = U + 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[(t$95$0 * J), $MachinePrecision]}, If[LessEqual[t$95$0, -10.0], t$95$1, If[LessEqual[t$95$0, 0.0], N[(U + N[(2.0 * N[(l * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
t_1 := t_0 \cdot J\\
\mathbf{if}\;t_0 \leq -10:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + t_1\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -10Initial program 100.0%
Taylor expanded in K around 0 84.6%
Taylor expanded in J around inf 84.6%
if -10 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0Initial program 69.9%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
associate-*l*99.9%
*-commutative99.9%
Simplified99.9%
if 0.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
Taylor expanded in K around 0 76.7%
Final simplification90.2%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))))
(if (or (<= t_0 -10.0) (not (<= t_0 2e-6)))
(* t_0 J)
(+ U (* 2.0 (* l (* J (cos (* K 0.5)))))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double tmp;
if ((t_0 <= -10.0) || !(t_0 <= 2e-6)) {
tmp = t_0 * J;
} else {
tmp = U + (2.0 * (l * (J * 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) :: t_0
real(8) :: tmp
t_0 = exp(l) - exp(-l)
if ((t_0 <= (-10.0d0)) .or. (.not. (t_0 <= 2d-6))) then
tmp = t_0 * j
else
tmp = u + (2.0d0 * (l * (j * cos((k * 0.5d0)))))
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 tmp;
if ((t_0 <= -10.0) || !(t_0 <= 2e-6)) {
tmp = t_0 * J;
} else {
tmp = U + (2.0 * (l * (J * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) tmp = 0 if (t_0 <= -10.0) or not (t_0 <= 2e-6): tmp = t_0 * J else: tmp = U + (2.0 * (l * (J * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_0 <= -10.0) || !(t_0 <= 2e-6)) tmp = Float64(t_0 * J); else tmp = Float64(U + Float64(2.0 * Float64(l * Float64(J * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); tmp = 0.0; if ((t_0 <= -10.0) || ~((t_0 <= 2e-6))) tmp = t_0 * J; else tmp = U + (2.0 * (l * (J * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -10.0], N[Not[LessEqual[t$95$0, 2e-6]], $MachinePrecision]], N[(t$95$0 * J), $MachinePrecision], N[(U + N[(2.0 * N[(l * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_0 \leq -10 \lor \neg \left(t_0 \leq 2 \cdot 10^{-6}\right):\\
\;\;\;\;t_0 \cdot J\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -10 or 1.99999999999999991e-6 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
Taylor expanded in K around 0 79.5%
Taylor expanded in J around inf 79.5%
if -10 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 1.99999999999999991e-6Initial program 70.6%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
associate-*l*99.9%
*-commutative99.9%
Simplified99.9%
Final simplification90.2%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.15) (+ U (* 2.0 (* l (* J (cos (* K 0.5)))))) (+ U (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.15) {
tmp = U + (2.0 * (l * (J * cos((K * 0.5)))));
} else {
tmp = U + (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 (cos((k / 2.0d0)) <= 0.15d0) then
tmp = u + (2.0d0 * (l * (j * cos((k * 0.5d0)))))
else
tmp = u + (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 (Math.cos((K / 2.0)) <= 0.15) {
tmp = U + (2.0 * (l * (J * Math.cos((K * 0.5)))));
} else {
tmp = U + (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.15: tmp = U + (2.0 * (l * (J * math.cos((K * 0.5))))) else: tmp = U + (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.15) tmp = Float64(U + Float64(2.0 * Float64(l * Float64(J * cos(Float64(K * 0.5)))))); else tmp = Float64(U + 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 (cos((K / 2.0)) <= 0.15) tmp = U + (2.0 * (l * (J * cos((K * 0.5))))); else tmp = U + (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.15], N[(U + N[(2.0 * N[(l * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.15:\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < 0.149999999999999994Initial program 85.1%
Taylor expanded in l around 0 65.9%
*-commutative65.9%
associate-*l*65.9%
*-commutative65.9%
Simplified65.9%
if 0.149999999999999994 < (cos.f64 (/.f64 K 2)) Initial program 84.5%
Taylor expanded in K around 0 84.5%
Taylor expanded in l around 0 88.4%
Final simplification83.2%
(FPCore (J l K U) :precision binary64 (if (or (<= l -2.6) (not (<= l 9e+41))) (* J (+ (* l 2.0) (* 0.3333333333333333 (* l (* l l))))) (+ U (* 2.0 (* l (* J (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.6) || !(l <= 9e+41)) {
tmp = J * ((l * 2.0) + (0.3333333333333333 * (l * (l * l))));
} else {
tmp = U + (2.0 * (l * (J * 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 <= (-2.6d0)) .or. (.not. (l <= 9d+41))) then
tmp = j * ((l * 2.0d0) + (0.3333333333333333d0 * (l * (l * l))))
else
tmp = u + (2.0d0 * (l * (j * 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 <= -2.6) || !(l <= 9e+41)) {
tmp = J * ((l * 2.0) + (0.3333333333333333 * (l * (l * l))));
} else {
tmp = U + (2.0 * (l * (J * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -2.6) or not (l <= 9e+41): tmp = J * ((l * 2.0) + (0.3333333333333333 * (l * (l * l)))) else: tmp = U + (2.0 * (l * (J * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -2.6) || !(l <= 9e+41)) tmp = Float64(J * Float64(Float64(l * 2.0) + Float64(0.3333333333333333 * Float64(l * Float64(l * l))))); else tmp = Float64(U + Float64(2.0 * Float64(l * Float64(J * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -2.6) || ~((l <= 9e+41))) tmp = J * ((l * 2.0) + (0.3333333333333333 * (l * (l * l)))); else tmp = U + (2.0 * (l * (J * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -2.6], N[Not[LessEqual[l, 9e+41]], $MachinePrecision]], N[(J * N[(N[(l * 2.0), $MachinePrecision] + N[(0.3333333333333333 * N[(l * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(l * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.6 \lor \neg \left(\ell \leq 9 \cdot 10^{+41}\right):\\
\;\;\;\;J \cdot \left(\ell \cdot 2 + 0.3333333333333333 \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if l < -2.60000000000000009 or 9.0000000000000002e41 < l Initial program 100.0%
Taylor expanded in K around 0 81.1%
Taylor expanded in l around 0 72.5%
associate-+r+72.5%
associate-*r*72.5%
associate-*r*72.5%
distribute-rgt-out72.5%
fma-def72.5%
+-commutative72.5%
fma-def72.5%
Simplified72.5%
Taylor expanded in J around inf 72.6%
unpow372.6%
Applied egg-rr72.6%
if -2.60000000000000009 < l < 9.0000000000000002e41Initial program 72.8%
Taylor expanded in l around 0 92.7%
*-commutative92.7%
associate-*l*92.7%
*-commutative92.7%
Simplified92.7%
Final simplification84.0%
(FPCore (J l K U) :precision binary64 (if (or (<= l -2.6) (not (<= l 60000000000.0))) (* J (+ (* l 2.0) (* 0.3333333333333333 (* l (* l l))))) (fma (* l 2.0) J U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.6) || !(l <= 60000000000.0)) {
tmp = J * ((l * 2.0) + (0.3333333333333333 * (l * (l * l))));
} else {
tmp = fma((l * 2.0), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if ((l <= -2.6) || !(l <= 60000000000.0)) tmp = Float64(J * Float64(Float64(l * 2.0) + Float64(0.3333333333333333 * Float64(l * Float64(l * l))))); else tmp = fma(Float64(l * 2.0), J, U); end return tmp end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -2.6], N[Not[LessEqual[l, 60000000000.0]], $MachinePrecision]], N[(J * N[(N[(l * 2.0), $MachinePrecision] + N[(0.3333333333333333 * N[(l * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(l * 2.0), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.6 \lor \neg \left(\ell \leq 60000000000\right):\\
\;\;\;\;J \cdot \left(\ell \cdot 2 + 0.3333333333333333 \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\ell \cdot 2, J, U\right)\\
\end{array}
\end{array}
if l < -2.60000000000000009 or 6e10 < l Initial program 100.0%
Taylor expanded in K around 0 80.3%
Taylor expanded in l around 0 68.9%
associate-+r+68.9%
associate-*r*68.9%
associate-*r*68.9%
distribute-rgt-out68.9%
fma-def68.9%
+-commutative68.9%
fma-def68.9%
Simplified68.9%
Taylor expanded in J around inf 69.0%
unpow369.0%
Applied egg-rr69.0%
if -2.60000000000000009 < l < 6e10Initial program 71.6%
Taylor expanded in K around 0 70.2%
Taylor expanded in l around 0 84.6%
associate-+r+84.6%
associate-*r*84.6%
associate-*r*84.6%
distribute-rgt-out84.6%
fma-def84.7%
+-commutative84.7%
fma-def84.7%
Simplified84.7%
Taylor expanded in l around 0 84.6%
associate-*r*84.6%
*-commutative84.6%
fma-def84.6%
Simplified84.6%
Final simplification77.5%
(FPCore (J l K U) :precision binary64 (if (or (<= l -2.6) (not (<= l 1e+15))) (* J (+ (* l 2.0) (* 0.3333333333333333 (* l (* l l))))) (+ U (* J (* l 2.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.6) || !(l <= 1e+15)) {
tmp = J * ((l * 2.0) + (0.3333333333333333 * (l * (l * l))));
} 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 <= (-2.6d0)) .or. (.not. (l <= 1d+15))) then
tmp = j * ((l * 2.0d0) + (0.3333333333333333d0 * (l * (l * l))))
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 <= -2.6) || !(l <= 1e+15)) {
tmp = J * ((l * 2.0) + (0.3333333333333333 * (l * (l * l))));
} else {
tmp = U + (J * (l * 2.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -2.6) or not (l <= 1e+15): tmp = J * ((l * 2.0) + (0.3333333333333333 * (l * (l * l)))) else: tmp = U + (J * (l * 2.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -2.6) || !(l <= 1e+15)) tmp = Float64(J * Float64(Float64(l * 2.0) + Float64(0.3333333333333333 * Float64(l * Float64(l * l))))); 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 <= -2.6) || ~((l <= 1e+15))) tmp = J * ((l * 2.0) + (0.3333333333333333 * (l * (l * l)))); else tmp = U + (J * (l * 2.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -2.6], N[Not[LessEqual[l, 1e+15]], $MachinePrecision]], N[(J * N[(N[(l * 2.0), $MachinePrecision] + N[(0.3333333333333333 * N[(l * N[(l * l), $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 -2.6 \lor \neg \left(\ell \leq 10^{+15}\right):\\
\;\;\;\;J \cdot \left(\ell \cdot 2 + 0.3333333333333333 \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\
\end{array}
\end{array}
if l < -2.60000000000000009 or 1e15 < l Initial program 100.0%
Taylor expanded in K around 0 80.3%
Taylor expanded in l around 0 68.9%
associate-+r+68.9%
associate-*r*68.9%
associate-*r*68.9%
distribute-rgt-out68.9%
fma-def68.9%
+-commutative68.9%
fma-def68.9%
Simplified68.9%
Taylor expanded in J around inf 69.0%
unpow369.0%
Applied egg-rr69.0%
if -2.60000000000000009 < l < 1e15Initial program 71.6%
Taylor expanded in K around 0 70.2%
Taylor expanded in l around 0 84.6%
Final simplification77.5%
(FPCore (J l K U) :precision binary64 (if (or (<= J -9.2e+191) (not (<= J 5.5e+120))) (* J (* l 2.0)) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((J <= -9.2e+191) || !(J <= 5.5e+120)) {
tmp = J * (l * 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 ((j <= (-9.2d+191)) .or. (.not. (j <= 5.5d+120))) then
tmp = j * (l * 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 ((J <= -9.2e+191) || !(J <= 5.5e+120)) {
tmp = J * (l * 2.0);
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (J <= -9.2e+191) or not (J <= 5.5e+120): tmp = J * (l * 2.0) else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((J <= -9.2e+191) || !(J <= 5.5e+120)) tmp = Float64(J * Float64(l * 2.0)); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((J <= -9.2e+191) || ~((J <= 5.5e+120))) tmp = J * (l * 2.0); else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[J, -9.2e+191], N[Not[LessEqual[J, 5.5e+120]], $MachinePrecision]], N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;J \leq -9.2 \cdot 10^{+191} \lor \neg \left(J \leq 5.5 \cdot 10^{+120}\right):\\
\;\;\;\;J \cdot \left(\ell \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if J < -9.1999999999999997e191 or 5.50000000000000003e120 < J Initial program 66.2%
Taylor expanded in K around 0 60.4%
Taylor expanded in l around 0 82.5%
associate-+r+82.5%
associate-*r*82.5%
associate-*r*82.5%
distribute-rgt-out82.5%
fma-def82.5%
+-commutative82.5%
fma-def82.5%
Simplified82.5%
Taylor expanded in J around inf 68.9%
Taylor expanded in l around 0 56.9%
associate-*r*56.9%
*-commutative56.9%
*-commutative56.9%
Simplified56.9%
if -9.1999999999999997e191 < J < 5.50000000000000003e120Initial program 91.4%
Taylor expanded in J around 0 46.5%
Final simplification49.3%
(FPCore (J l K U) :precision binary64 (if (<= l -2.6) (* U U) (if (<= l 6.4e+40) U (* U U))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -2.6) {
tmp = U * U;
} else if (l <= 6.4e+40) {
tmp = U;
} else {
tmp = U * U;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (l <= (-2.6d0)) then
tmp = u * u
else if (l <= 6.4d+40) then
tmp = u
else
tmp = u * u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -2.6) {
tmp = U * U;
} else if (l <= 6.4e+40) {
tmp = U;
} else {
tmp = U * U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -2.6: tmp = U * U elif l <= 6.4e+40: tmp = U else: tmp = U * U return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -2.6) tmp = Float64(U * U); elseif (l <= 6.4e+40) tmp = U; else tmp = Float64(U * U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -2.6) tmp = U * U; elseif (l <= 6.4e+40) tmp = U; else tmp = U * U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -2.6], N[(U * U), $MachinePrecision], If[LessEqual[l, 6.4e+40], U, N[(U * U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.6:\\
\;\;\;\;U \cdot U\\
\mathbf{elif}\;\ell \leq 6.4 \cdot 10^{+40}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;U \cdot U\\
\end{array}
\end{array}
if l < -2.60000000000000009 or 6.39999999999999961e40 < l Initial program 100.0%
Applied egg-rr12.4%
if -2.60000000000000009 < l < 6.39999999999999961e40Initial program 72.4%
Taylor expanded in J around 0 66.4%
Final simplification42.5%
(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.6%
Taylor expanded in K around 0 74.8%
Taylor expanded in l around 0 59.0%
Final simplification59.0%
(FPCore (J l K U) :precision binary64 -0.14285714285714285)
double code(double J, double l, double K, double U) {
return -0.14285714285714285;
}
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.14285714285714285d0
end function
public static double code(double J, double l, double K, double U) {
return -0.14285714285714285;
}
def code(J, l, K, U): return -0.14285714285714285
function code(J, l, K, U) return -0.14285714285714285 end
function tmp = code(J, l, K, U) tmp = -0.14285714285714285; end
code[J_, l_, K_, U_] := -0.14285714285714285
\begin{array}{l}
\\
-0.14285714285714285
\end{array}
Initial program 84.6%
Applied egg-rr2.6%
associate-+r+2.6%
distribute-rgt1-in2.6%
*-commutative2.6%
distribute-rgt-out2.6%
associate-/r*2.6%
*-inverses2.6%
+-commutative2.6%
*-commutative2.6%
metadata-eval2.6%
Simplified2.6%
Taylor expanded in U around 0 2.9%
Final simplification2.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.6%
Taylor expanded in J around 0 38.1%
Final simplification38.1%
herbie shell --seed 2023203
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))