
(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 15 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 (- INFINITY)) (not (<= t_0 5e-8)))
(+ (* (* t_0 J) (cos (/ K 2.0))) U)
(+ U (* 2.0 (* J (* l (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 <= -((double) INFINITY)) || !(t_0 <= 5e-8)) {
tmp = ((t_0 * J) * cos((K / 2.0))) + U;
} else {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
}
return tmp;
}
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 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 5e-8)) {
tmp = ((t_0 * J) * Math.cos((K / 2.0))) + U;
} else {
tmp = U + (2.0 * (J * (l * 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 <= -math.inf) or not (t_0 <= 5e-8): tmp = ((t_0 * J) * math.cos((K / 2.0))) + U else: tmp = U + (2.0 * (J * (l * 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 <= Float64(-Inf)) || !(t_0 <= 5e-8)) tmp = Float64(Float64(Float64(t_0 * J) * cos(Float64(K / 2.0))) + U); else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * 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 <= -Inf) || ~((t_0 <= 5e-8))) tmp = ((t_0 * J) * cos((K / 2.0))) + U; else tmp = U + (2.0 * (J * (l * 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, (-Infinity)], N[Not[LessEqual[t$95$0, 5e-8]], $MachinePrecision]], N[(N[(N[(t$95$0 * J), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[(l * 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 -\infty \lor \neg \left(t_0 \leq 5 \cdot 10^{-8}\right):\\
\;\;\;\;\left(t_0 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 4.9999999999999998e-8 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 4.9999999999999998e-8Initial program 69.8%
Taylor expanded in l around 0 99.9%
Final simplification100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* (- (exp l) (exp (- l))) J)))
(if (<= t_0 (- INFINITY))
t_0
(if (<= t_0 1e+296)
(+ U (* 2.0 (* J (* l (cos (* K 0.5))))))
(+ U (* t_0 (+ 1.0 (* -0.125 (* K K)))))))))
double code(double J, double l, double K, double U) {
double t_0 = (exp(l) - exp(-l)) * J;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = t_0;
} else if (t_0 <= 1e+296) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else {
tmp = U + (t_0 * (1.0 + (-0.125 * (K * K))));
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = (Math.exp(l) - Math.exp(-l)) * J;
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = t_0;
} else if (t_0 <= 1e+296) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else {
tmp = U + (t_0 * (1.0 + (-0.125 * (K * K))));
}
return tmp;
}
def code(J, l, K, U): t_0 = (math.exp(l) - math.exp(-l)) * J tmp = 0 if t_0 <= -math.inf: tmp = t_0 elif t_0 <= 1e+296: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) else: tmp = U + (t_0 * (1.0 + (-0.125 * (K * K)))) return tmp
function code(J, l, K, U) t_0 = Float64(Float64(exp(l) - exp(Float64(-l))) * J) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = t_0; elseif (t_0 <= 1e+296) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); else tmp = Float64(U + Float64(t_0 * Float64(1.0 + Float64(-0.125 * Float64(K * K))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = (exp(l) - exp(-l)) * J; tmp = 0.0; if (t_0 <= -Inf) tmp = t_0; elseif (t_0 <= 1e+296) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); else tmp = U + (t_0 * (1.0 + (-0.125 * (K * K)))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$0, If[LessEqual[t$95$0, 1e+296], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(t$95$0 * N[(1.0 + N[(-0.125 * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 10^{+296}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + t_0 \cdot \left(1 + -0.125 \cdot \left(K \cdot K\right)\right)\\
\end{array}
\end{array}
if (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < -inf.0Initial program 100.0%
Taylor expanded in K around 0 83.3%
Taylor expanded in J around inf 83.3%
if -inf.0 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < 9.99999999999999981e295Initial program 69.8%
Taylor expanded in l around 0 99.9%
if 9.99999999999999981e295 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) Initial program 100.0%
Taylor expanded in K around 0 75.4%
unpow275.4%
Simplified75.4%
Final simplification88.6%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* (- (exp l) (exp (- l))) J)))
(if (<= t_0 (- INFINITY))
t_0
(if (<= t_0 1e+296)
(+ U (* 2.0 (* J (* l (cos (* K 0.5))))))
(+ t_0 U)))))
double code(double J, double l, double K, double U) {
double t_0 = (exp(l) - exp(-l)) * J;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = t_0;
} else if (t_0 <= 1e+296) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else {
tmp = t_0 + U;
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = (Math.exp(l) - Math.exp(-l)) * J;
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = t_0;
} else if (t_0 <= 1e+296) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else {
tmp = t_0 + U;
}
return tmp;
}
def code(J, l, K, U): t_0 = (math.exp(l) - math.exp(-l)) * J tmp = 0 if t_0 <= -math.inf: tmp = t_0 elif t_0 <= 1e+296: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) else: tmp = t_0 + U return tmp
function code(J, l, K, U) t_0 = Float64(Float64(exp(l) - exp(Float64(-l))) * J) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = t_0; elseif (t_0 <= 1e+296) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); else tmp = Float64(t_0 + U); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = (exp(l) - exp(-l)) * J; tmp = 0.0; if (t_0 <= -Inf) tmp = t_0; elseif (t_0 <= 1e+296) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); else tmp = t_0 + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$0, If[LessEqual[t$95$0, 1e+296], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + U), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 10^{+296}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + U\\
\end{array}
\end{array}
if (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < -inf.0Initial program 100.0%
Taylor expanded in K around 0 83.3%
Taylor expanded in J around inf 83.3%
if -inf.0 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < 9.99999999999999981e295Initial program 69.8%
Taylor expanded in l around 0 99.9%
if 9.99999999999999981e295 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) Initial program 100.0%
Taylor expanded in K around 0 73.9%
Final simplification88.2%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 5e-8)))
(* t_0 J)
(+ U (* 2.0 (* J (* l (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 <= -((double) INFINITY)) || !(t_0 <= 5e-8)) {
tmp = t_0 * J;
} else {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
}
return tmp;
}
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 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 5e-8)) {
tmp = t_0 * J;
} else {
tmp = U + (2.0 * (J * (l * 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 <= -math.inf) or not (t_0 <= 5e-8): tmp = t_0 * J else: tmp = U + (2.0 * (J * (l * 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 <= Float64(-Inf)) || !(t_0 <= 5e-8)) tmp = Float64(t_0 * J); else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * 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 <= -Inf) || ~((t_0 <= 5e-8))) tmp = t_0 * J; else tmp = U + (2.0 * (J * (l * 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, (-Infinity)], N[Not[LessEqual[t$95$0, 5e-8]], $MachinePrecision]], N[(t$95$0 * J), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[(l * 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 -\infty \lor \neg \left(t_0 \leq 5 \cdot 10^{-8}\right):\\
\;\;\;\;t_0 \cdot J\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 4.9999999999999998e-8 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
Taylor expanded in K around 0 78.7%
Taylor expanded in J around inf 78.7%
if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 4.9999999999999998e-8Initial program 69.8%
Taylor expanded in l around 0 99.9%
Final simplification88.2%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.475) (+ U (* 2.0 (* J (* l (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.475) {
tmp = U + (2.0 * (J * (l * 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.475d0) then
tmp = u + (2.0d0 * (j * (l * 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.475) {
tmp = U + (2.0 * (J * (l * 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.475: tmp = U + (2.0 * (J * (l * 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.475) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * 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.475) tmp = U + (2.0 * (J * (l * 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.475], N[(U + N[(2.0 * N[(J * N[(l * 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.475:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \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.47499999999999998Initial program 86.2%
Taylor expanded in l around 0 64.6%
if 0.47499999999999998 < (cos.f64 (/.f64 K 2)) Initial program 86.6%
Taylor expanded in K around 0 86.6%
Taylor expanded in l around 0 85.3%
Final simplification78.8%
(FPCore (J l K U) :precision binary64 (if (or (<= l -4.5e+14) (not (<= l 1.65e+55))) (+ U (* J (* 0.3333333333333333 (pow l 3.0)))) (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -4.5e+14) || !(l <= 1.65e+55)) {
tmp = U + (J * (0.3333333333333333 * pow(l, 3.0)));
} else {
tmp = U + (2.0 * (J * (l * 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 <= (-4.5d+14)) .or. (.not. (l <= 1.65d+55))) then
tmp = u + (j * (0.3333333333333333d0 * (l ** 3.0d0)))
else
tmp = u + (2.0d0 * (j * (l * 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 <= -4.5e+14) || !(l <= 1.65e+55)) {
tmp = U + (J * (0.3333333333333333 * Math.pow(l, 3.0)));
} else {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -4.5e+14) or not (l <= 1.65e+55): tmp = U + (J * (0.3333333333333333 * math.pow(l, 3.0))) else: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -4.5e+14) || !(l <= 1.65e+55)) tmp = Float64(U + Float64(J * Float64(0.3333333333333333 * (l ^ 3.0)))); else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -4.5e+14) || ~((l <= 1.65e+55))) tmp = U + (J * (0.3333333333333333 * (l ^ 3.0))); else tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -4.5e+14], N[Not[LessEqual[l, 1.65e+55]], $MachinePrecision]], N[(U + N[(J * N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4.5 \cdot 10^{+14} \lor \neg \left(\ell \leq 1.65 \cdot 10^{+55}\right):\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if l < -4.5e14 or 1.65e55 < l Initial program 100.0%
Taylor expanded in K around 0 81.0%
Taylor expanded in l around 0 68.7%
Taylor expanded in l around inf 68.7%
*-commutative68.7%
associate-*r*68.7%
*-commutative68.7%
Simplified68.7%
if -4.5e14 < l < 1.65e55Initial program 73.3%
Taylor expanded in l around 0 89.6%
Final simplification79.3%
(FPCore (J l K U) :precision binary64 (if (or (<= l -25000000000000.0) (not (<= l 2.7))) (+ U (* J (* 0.3333333333333333 (pow l 3.0)))) (fma l (* J 2.0) U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -25000000000000.0) || !(l <= 2.7)) {
tmp = U + (J * (0.3333333333333333 * pow(l, 3.0)));
} else {
tmp = fma(l, (J * 2.0), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if ((l <= -25000000000000.0) || !(l <= 2.7)) tmp = Float64(U + Float64(J * Float64(0.3333333333333333 * (l ^ 3.0)))); else tmp = fma(l, Float64(J * 2.0), U); end return tmp end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -25000000000000.0], N[Not[LessEqual[l, 2.7]], $MachinePrecision]], N[(U + N[(J * N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(l * N[(J * 2.0), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -25000000000000 \lor \neg \left(\ell \leq 2.7\right):\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\ell, J \cdot 2, U\right)\\
\end{array}
\end{array}
if l < -2.5e13 or 2.7000000000000002 < l Initial program 100.0%
Taylor expanded in K around 0 78.8%
Taylor expanded in l around 0 63.4%
Taylor expanded in l around inf 63.4%
*-commutative63.4%
associate-*r*63.4%
*-commutative63.4%
Simplified63.4%
if -2.5e13 < l < 2.7000000000000002Initial program 70.8%
Taylor expanded in K around 0 70.0%
Taylor expanded in l around 0 84.3%
+-commutative84.3%
associate-*r*84.3%
*-commutative84.3%
fma-def84.3%
*-commutative84.3%
Simplified84.3%
Final simplification73.1%
(FPCore (J l K U) :precision binary64 (if (<= U -1.15e+183) (- -19683.0 (* U U)) (fma l (* J 2.0) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (U <= -1.15e+183) {
tmp = -19683.0 - (U * U);
} else {
tmp = fma(l, (J * 2.0), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (U <= -1.15e+183) tmp = Float64(-19683.0 - Float64(U * U)); else tmp = fma(l, Float64(J * 2.0), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[U, -1.15e+183], N[(-19683.0 - N[(U * U), $MachinePrecision]), $MachinePrecision], N[(l * N[(J * 2.0), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;U \leq -1.15 \cdot 10^{+183}:\\
\;\;\;\;-19683 - U \cdot U\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\ell, J \cdot 2, U\right)\\
\end{array}
\end{array}
if U < -1.1499999999999999e183Initial program 97.0%
associate-*l*97.0%
fma-def97.0%
Simplified97.0%
Applied egg-rr2.9%
Applied egg-rr55.5%
cancel-sign-sub-inv55.5%
Simplified55.5%
if -1.1499999999999999e183 < U Initial program 84.9%
Taylor expanded in K around 0 74.1%
Taylor expanded in l around 0 53.9%
+-commutative53.9%
associate-*r*53.9%
*-commutative53.9%
fma-def53.9%
*-commutative53.9%
Simplified53.9%
Final simplification54.1%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* J (* l 2.0))))
(if (<= l -4e+75)
t_0
(if (<= l -1050.0) (- -19683.0 (* U U)) (if (<= l 1.05e-15) U t_0)))))
double code(double J, double l, double K, double U) {
double t_0 = J * (l * 2.0);
double tmp;
if (l <= -4e+75) {
tmp = t_0;
} else if (l <= -1050.0) {
tmp = -19683.0 - (U * U);
} else if (l <= 1.05e-15) {
tmp = U;
} 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) :: tmp
t_0 = j * (l * 2.0d0)
if (l <= (-4d+75)) then
tmp = t_0
else if (l <= (-1050.0d0)) then
tmp = (-19683.0d0) - (u * u)
else if (l <= 1.05d-15) then
tmp = u
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 = J * (l * 2.0);
double tmp;
if (l <= -4e+75) {
tmp = t_0;
} else if (l <= -1050.0) {
tmp = -19683.0 - (U * U);
} else if (l <= 1.05e-15) {
tmp = U;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = J * (l * 2.0) tmp = 0 if l <= -4e+75: tmp = t_0 elif l <= -1050.0: tmp = -19683.0 - (U * U) elif l <= 1.05e-15: tmp = U else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(J * Float64(l * 2.0)) tmp = 0.0 if (l <= -4e+75) tmp = t_0; elseif (l <= -1050.0) tmp = Float64(-19683.0 - Float64(U * U)); elseif (l <= 1.05e-15) tmp = U; else tmp = 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 <= -4e+75) tmp = t_0; elseif (l <= -1050.0) tmp = -19683.0 - (U * U); elseif (l <= 1.05e-15) tmp = U; else tmp = 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, -4e+75], t$95$0, If[LessEqual[l, -1050.0], N[(-19683.0 - N[(U * U), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.05e-15], U, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := J \cdot \left(\ell \cdot 2\right)\\
\mathbf{if}\;\ell \leq -4 \cdot 10^{+75}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -1050:\\
\;\;\;\;-19683 - U \cdot U\\
\mathbf{elif}\;\ell \leq 1.05 \cdot 10^{-15}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if l < -3.99999999999999971e75 or 1.0499999999999999e-15 < l Initial program 98.8%
Taylor expanded in l around 0 30.8%
Taylor expanded in J around inf 30.6%
associate-*r*30.6%
*-commutative30.6%
associate-*l*30.6%
*-commutative30.6%
Simplified30.6%
Taylor expanded in K around 0 24.5%
*-commutative24.5%
associate-*l*24.5%
Simplified24.5%
if -3.99999999999999971e75 < l < -1050Initial program 100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Applied egg-rr2.4%
Applied egg-rr36.3%
cancel-sign-sub-inv36.3%
Simplified36.3%
if -1050 < l < 1.0499999999999999e-15Initial program 70.4%
associate-*l*70.4%
fma-def70.4%
Simplified70.4%
Taylor expanded in J around 0 70.4%
Final simplification45.3%
(FPCore (J l K U) :precision binary64 (if (or (<= l -8e-43) (not (<= l 2.7e-15))) (* J (* l 2.0)) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -8e-43) || !(l <= 2.7e-15)) {
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 ((l <= (-8d-43)) .or. (.not. (l <= 2.7d-15))) 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 ((l <= -8e-43) || !(l <= 2.7e-15)) {
tmp = J * (l * 2.0);
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -8e-43) or not (l <= 2.7e-15): tmp = J * (l * 2.0) else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -8e-43) || !(l <= 2.7e-15)) 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 ((l <= -8e-43) || ~((l <= 2.7e-15))) tmp = J * (l * 2.0); else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -8e-43], N[Not[LessEqual[l, 2.7e-15]], $MachinePrecision]], N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -8 \cdot 10^{-43} \lor \neg \left(\ell \leq 2.7 \cdot 10^{-15}\right):\\
\;\;\;\;J \cdot \left(\ell \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -8.00000000000000062e-43 or 2.70000000000000009e-15 < l Initial program 96.9%
Taylor expanded in l around 0 30.9%
Taylor expanded in J around inf 28.9%
associate-*r*28.9%
*-commutative28.9%
associate-*l*28.9%
*-commutative28.9%
Simplified28.9%
Taylor expanded in K around 0 22.7%
*-commutative22.7%
associate-*l*22.7%
Simplified22.7%
if -8.00000000000000062e-43 < l < 2.70000000000000009e-15Initial program 71.8%
associate-*l*71.8%
fma-def71.8%
Simplified71.8%
Taylor expanded in J around 0 71.8%
Final simplification43.2%
(FPCore (J l K U) :precision binary64 (if (<= U -1.15e+183) (- -19683.0 (* U U)) (+ U (* l (* J 2.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if (U <= -1.15e+183) {
tmp = -19683.0 - (U * U);
} else {
tmp = U + (l * (J * 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 (u <= (-1.15d+183)) then
tmp = (-19683.0d0) - (u * u)
else
tmp = u + (l * (j * 2.0d0))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (U <= -1.15e+183) {
tmp = -19683.0 - (U * U);
} else {
tmp = U + (l * (J * 2.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if U <= -1.15e+183: tmp = -19683.0 - (U * U) else: tmp = U + (l * (J * 2.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if (U <= -1.15e+183) tmp = Float64(-19683.0 - Float64(U * U)); else tmp = Float64(U + Float64(l * Float64(J * 2.0))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (U <= -1.15e+183) tmp = -19683.0 - (U * U); else tmp = U + (l * (J * 2.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[U, -1.15e+183], N[(-19683.0 - N[(U * U), $MachinePrecision]), $MachinePrecision], N[(U + N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;U \leq -1.15 \cdot 10^{+183}:\\
\;\;\;\;-19683 - U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(J \cdot 2\right)\\
\end{array}
\end{array}
if U < -1.1499999999999999e183Initial program 97.0%
associate-*l*97.0%
fma-def97.0%
Simplified97.0%
Applied egg-rr2.9%
Applied egg-rr55.5%
cancel-sign-sub-inv55.5%
Simplified55.5%
if -1.1499999999999999e183 < U Initial program 84.9%
Taylor expanded in K around 0 74.1%
Taylor expanded in l around 0 53.9%
associate-*r*53.9%
*-commutative53.9%
Simplified53.9%
Final simplification54.1%
(FPCore (J l K U) :precision binary64 (if (<= l -1.7e+44) (* U U) (if (<= l 1.5e-8) U (* U U))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -1.7e+44) {
tmp = U * U;
} else if (l <= 1.5e-8) {
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 <= (-1.7d+44)) then
tmp = u * u
else if (l <= 1.5d-8) 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 <= -1.7e+44) {
tmp = U * U;
} else if (l <= 1.5e-8) {
tmp = U;
} else {
tmp = U * U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -1.7e+44: tmp = U * U elif l <= 1.5e-8: tmp = U else: tmp = U * U return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -1.7e+44) tmp = Float64(U * U); elseif (l <= 1.5e-8) tmp = U; else tmp = Float64(U * U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -1.7e+44) tmp = U * U; elseif (l <= 1.5e-8) tmp = U; else tmp = U * U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -1.7e+44], N[(U * U), $MachinePrecision], If[LessEqual[l, 1.5e-8], U, N[(U * U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.7 \cdot 10^{+44}:\\
\;\;\;\;U \cdot U\\
\mathbf{elif}\;\ell \leq 1.5 \cdot 10^{-8}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;U \cdot U\\
\end{array}
\end{array}
if l < -1.7e44 or 1.49999999999999987e-8 < l Initial program 99.7%
associate-*l*99.7%
fma-def99.7%
Simplified99.7%
Applied egg-rr13.5%
if -1.7e44 < l < 1.49999999999999987e-8Initial program 72.0%
associate-*l*72.0%
fma-def72.0%
Simplified72.0%
Taylor expanded in J around 0 64.6%
Final simplification38.0%
(FPCore (J l K U) :precision binary64 0.0)
double code(double J, double l, double K, double U) {
return 0.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 = 0.0d0
end function
public static double code(double J, double l, double K, double U) {
return 0.0;
}
def code(J, l, K, U): return 0.0
function code(J, l, K, U) return 0.0 end
function tmp = code(J, l, K, U) tmp = 0.0; end
code[J_, l_, K_, U_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 86.4%
Taylor expanded in K around 0 74.7%
Applied egg-rr2.3%
+-inverses2.3%
Simplified2.3%
Final simplification2.3%
(FPCore (J l K U) :precision binary64 1.0)
double code(double J, double l, double K, double U) {
return 1.0;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = 1.0d0
end function
public static double code(double J, double l, double K, double U) {
return 1.0;
}
def code(J, l, K, U): return 1.0
function code(J, l, K, U) return 1.0 end
function tmp = code(J, l, K, U) tmp = 1.0; end
code[J_, l_, K_, U_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 86.4%
Taylor expanded in K around 0 74.7%
Applied egg-rr2.7%
*-inverses2.7%
Simplified2.7%
Final simplification2.7%
(FPCore (J l K U) :precision binary64 U)
double code(double J, double l, double K, double U) {
return U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
public static double code(double J, double l, double K, double U) {
return U;
}
def code(J, l, K, U): return U
function code(J, l, K, U) return U end
function tmp = code(J, l, K, U) tmp = U; end
code[J_, l_, K_, U_] := U
\begin{array}{l}
\\
U
\end{array}
Initial program 86.4%
associate-*l*86.4%
fma-def86.4%
Simplified86.4%
Taylor expanded in J around 0 32.3%
Final simplification32.3%
herbie shell --seed 2023292
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))