
(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 (cos (/ K 2.0))) (t_1 (- (exp l) (exp (- l)))))
(if (or (<= t_1 -0.2) (not (<= t_1 5e-7)))
(+ (* (* t_1 J) t_0) U)
(+ U (* t_0 (* J (+ (* 0.3333333333333333 (pow l 3.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 <= -0.2) || !(t_1 <= 5e-7)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = exp(l) - exp(-l)
if ((t_1 <= (-0.2d0)) .or. (.not. (t_1 <= 5d-7))) then
tmp = ((t_1 * j) * t_0) + u
else
tmp = u + (t_0 * (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 t_0 = Math.cos((K / 2.0));
double t_1 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_1 <= -0.2) || !(t_1 <= 5e-7)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * ((0.3333333333333333 * Math.pow(l, 3.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 <= -0.2) or not (t_1 <= 5e-7): tmp = ((t_1 * J) * t_0) + U else: tmp = U + (t_0 * (J * ((0.3333333333333333 * math.pow(l, 3.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 <= -0.2) || !(t_1 <= 5e-7)) tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U); else tmp = Float64(U + Float64(t_0 * 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) t_0 = cos((K / 2.0)); t_1 = exp(l) - exp(-l); tmp = 0.0; if ((t_1 <= -0.2) || ~((t_1 <= 5e-7))) tmp = ((t_1 * J) * t_0) + U; else tmp = U + (t_0 * (J * ((0.3333333333333333 * (l ^ 3.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, -0.2], N[Not[LessEqual[t$95$1, 5e-7]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $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 -0.2 \lor \neg \left(t_1 \leq 5 \cdot 10^{-7}\right):\\
\;\;\;\;\left(t_1 \cdot J\right) \cdot t_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + t_0 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -0.20000000000000001 or 4.99999999999999977e-7 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -0.20000000000000001 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 4.99999999999999977e-7Initial program 71.4%
Taylor expanded in l around 0 99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(if (or (<= l -9e+84)
(and (not (<= l -0.33)) (or (<= l 0.027) (not (<= l 1.25e+100)))))
(+
U
(* (cos (/ K 2.0)) (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
(+ (* (- (exp l) (exp (- l))) J) U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -9e+84) || (!(l <= -0.33) && ((l <= 0.027) || !(l <= 1.25e+100)))) {
tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
} else {
tmp = ((exp(l) - exp(-l)) * J) + 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 <= (-9d+84)) .or. (.not. (l <= (-0.33d0))) .and. (l <= 0.027d0) .or. (.not. (l <= 1.25d+100))) then
tmp = u + (cos((k / 2.0d0)) * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
else
tmp = ((exp(l) - exp(-l)) * j) + u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -9e+84) || (!(l <= -0.33) && ((l <= 0.027) || !(l <= 1.25e+100)))) {
tmp = U + (Math.cos((K / 2.0)) * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
} else {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -9e+84) or (not (l <= -0.33) and ((l <= 0.027) or not (l <= 1.25e+100))): tmp = U + (math.cos((K / 2.0)) * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) else: tmp = ((math.exp(l) - math.exp(-l)) * J) + U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -9e+84) || (!(l <= -0.33) && ((l <= 0.027) || !(l <= 1.25e+100)))) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))); else tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -9e+84) || (~((l <= -0.33)) && ((l <= 0.027) || ~((l <= 1.25e+100))))) tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))); else tmp = ((exp(l) - exp(-l)) * J) + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -9e+84], And[N[Not[LessEqual[l, -0.33]], $MachinePrecision], Or[LessEqual[l, 0.027], N[Not[LessEqual[l, 1.25e+100]], $MachinePrecision]]]], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -9 \cdot 10^{+84} \lor \neg \left(\ell \leq -0.33\right) \land \left(\ell \leq 0.027 \lor \neg \left(\ell \leq 1.25 \cdot 10^{+100}\right)\right):\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\end{array}
\end{array}
if l < -8.9999999999999994e84 or -0.330000000000000016 < l < 0.0269999999999999997 or 1.25e100 < l Initial program 83.5%
Taylor expanded in l around 0 98.8%
if -8.9999999999999994e84 < l < -0.330000000000000016 or 0.0269999999999999997 < l < 1.25e100Initial program 100.0%
Taylor expanded in K around 0 85.7%
Final simplification97.0%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.84) (+ U (* l (* 2.0 (* 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.84) {
tmp = U + (l * (2.0 * (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.84d0) then
tmp = u + (l * (2.0d0 * (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.84) {
tmp = U + (l * (2.0 * (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.84: tmp = U + (l * (2.0 * (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.84) tmp = Float64(U + Float64(l * Float64(2.0 * 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.84) tmp = U + (l * (2.0 * (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.84], N[(U + N[(l * N[(2.0 * 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.84:\\
\;\;\;\;U + \ell \cdot \left(2 \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.839999999999999969Initial program 83.8%
Taylor expanded in l around 0 71.4%
associate-*r*71.4%
*-commutative71.4%
associate-*l*71.5%
*-commutative71.5%
associate-*l*71.5%
Simplified71.5%
if 0.839999999999999969 < (cos.f64 (/.f64 K 2)) Initial program 87.0%
Taylor expanded in l around 0 88.6%
Taylor expanded in K around 0 87.1%
Final simplification80.7%
(FPCore (J l K U) :precision binary64 (if (or (<= l -0.135) (not (<= l 0.009))) (+ (* (- (exp l) (exp (- l))) J) U) (+ U (* l (* 2.0 (* J (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -0.135) || !(l <= 0.009)) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} else {
tmp = U + (l * (2.0 * (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 <= (-0.135d0)) .or. (.not. (l <= 0.009d0))) then
tmp = ((exp(l) - exp(-l)) * j) + u
else
tmp = u + (l * (2.0d0 * (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 <= -0.135) || !(l <= 0.009)) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} else {
tmp = U + (l * (2.0 * (J * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -0.135) or not (l <= 0.009): tmp = ((math.exp(l) - math.exp(-l)) * J) + U else: tmp = U + (l * (2.0 * (J * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -0.135) || !(l <= 0.009)) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); else tmp = Float64(U + Float64(l * Float64(2.0 * Float64(J * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -0.135) || ~((l <= 0.009))) tmp = ((exp(l) - exp(-l)) * J) + U; else tmp = U + (l * (2.0 * (J * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -0.135], N[Not[LessEqual[l, 0.009]], $MachinePrecision]], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(l * N[(2.0 * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -0.135 \lor \neg \left(\ell \leq 0.009\right):\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if l < -0.13500000000000001 or 0.00899999999999999932 < l Initial program 100.0%
Taylor expanded in K around 0 76.4%
if -0.13500000000000001 < l < 0.00899999999999999932Initial program 71.6%
Taylor expanded in l around 0 99.2%
associate-*r*99.2%
*-commutative99.2%
associate-*l*99.3%
*-commutative99.3%
associate-*l*99.3%
Simplified99.3%
Final simplification87.9%
(FPCore (J l K U) :precision binary64 (if (or (<= l -300000.0) (not (<= l 80000.0))) (* (pow l 3.0) (* J 0.3333333333333333)) (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -300000.0) || !(l <= 80000.0)) {
tmp = pow(l, 3.0) * (J * 0.3333333333333333);
} 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 <= (-300000.0d0)) .or. (.not. (l <= 80000.0d0))) then
tmp = (l ** 3.0d0) * (j * 0.3333333333333333d0)
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 <= -300000.0) || !(l <= 80000.0)) {
tmp = Math.pow(l, 3.0) * (J * 0.3333333333333333);
} else {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -300000.0) or not (l <= 80000.0): tmp = math.pow(l, 3.0) * (J * 0.3333333333333333) 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 <= -300000.0) || !(l <= 80000.0)) tmp = Float64((l ^ 3.0) * Float64(J * 0.3333333333333333)); 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 <= -300000.0) || ~((l <= 80000.0))) tmp = (l ^ 3.0) * (J * 0.3333333333333333); 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, -300000.0], N[Not[LessEqual[l, 80000.0]], $MachinePrecision]], N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $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 -300000 \lor \neg \left(\ell \leq 80000\right):\\
\;\;\;\;{\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\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 < -3e5 or 8e4 < l Initial program 100.0%
Taylor expanded in l around 0 78.4%
Taylor expanded in K around 0 59.2%
Taylor expanded in l around inf 59.2%
associate-*r*59.2%
Simplified59.2%
if -3e5 < l < 8e4Initial program 72.1%
Taylor expanded in l around 0 97.8%
Final simplification79.0%
(FPCore (J l K U) :precision binary64 (if (or (<= l -1250.0) (not (<= l 4600000.0))) (* (pow l 3.0) (* J 0.3333333333333333)) (+ U (* l (* 2.0 (* J (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1250.0) || !(l <= 4600000.0)) {
tmp = pow(l, 3.0) * (J * 0.3333333333333333);
} else {
tmp = U + (l * (2.0 * (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 <= (-1250.0d0)) .or. (.not. (l <= 4600000.0d0))) then
tmp = (l ** 3.0d0) * (j * 0.3333333333333333d0)
else
tmp = u + (l * (2.0d0 * (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 <= -1250.0) || !(l <= 4600000.0)) {
tmp = Math.pow(l, 3.0) * (J * 0.3333333333333333);
} else {
tmp = U + (l * (2.0 * (J * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -1250.0) or not (l <= 4600000.0): tmp = math.pow(l, 3.0) * (J * 0.3333333333333333) else: tmp = U + (l * (2.0 * (J * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -1250.0) || !(l <= 4600000.0)) tmp = Float64((l ^ 3.0) * Float64(J * 0.3333333333333333)); else tmp = Float64(U + Float64(l * Float64(2.0 * Float64(J * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -1250.0) || ~((l <= 4600000.0))) tmp = (l ^ 3.0) * (J * 0.3333333333333333); else tmp = U + (l * (2.0 * (J * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -1250.0], N[Not[LessEqual[l, 4600000.0]], $MachinePrecision]], N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision], N[(U + N[(l * N[(2.0 * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1250 \lor \neg \left(\ell \leq 4600000\right):\\
\;\;\;\;{\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if l < -1250 or 4.6e6 < l Initial program 100.0%
Taylor expanded in l around 0 78.4%
Taylor expanded in K around 0 59.2%
Taylor expanded in l around inf 59.2%
associate-*r*59.2%
Simplified59.2%
if -1250 < l < 4.6e6Initial program 72.1%
Taylor expanded in l around 0 97.8%
associate-*r*97.8%
*-commutative97.8%
associate-*l*97.8%
*-commutative97.8%
associate-*l*97.8%
Simplified97.8%
Final simplification79.0%
(FPCore (J l K U) :precision binary64 (if (or (<= l -6e-7) (not (<= l 700000.0))) (* (pow l 3.0) (* J 0.3333333333333333)) (+ U (* 2.0 (* l J)))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -6e-7) || !(l <= 700000.0)) {
tmp = pow(l, 3.0) * (J * 0.3333333333333333);
} else {
tmp = U + (2.0 * (l * J));
}
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 <= (-6d-7)) .or. (.not. (l <= 700000.0d0))) then
tmp = (l ** 3.0d0) * (j * 0.3333333333333333d0)
else
tmp = u + (2.0d0 * (l * j))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -6e-7) || !(l <= 700000.0)) {
tmp = Math.pow(l, 3.0) * (J * 0.3333333333333333);
} else {
tmp = U + (2.0 * (l * J));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -6e-7) or not (l <= 700000.0): tmp = math.pow(l, 3.0) * (J * 0.3333333333333333) else: tmp = U + (2.0 * (l * J)) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -6e-7) || !(l <= 700000.0)) tmp = Float64((l ^ 3.0) * Float64(J * 0.3333333333333333)); else tmp = Float64(U + Float64(2.0 * Float64(l * J))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -6e-7) || ~((l <= 700000.0))) tmp = (l ^ 3.0) * (J * 0.3333333333333333); else tmp = U + (2.0 * (l * J)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -6e-7], N[Not[LessEqual[l, 700000.0]], $MachinePrecision]], N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6 \cdot 10^{-7} \lor \neg \left(\ell \leq 700000\right):\\
\;\;\;\;{\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\
\end{array}
\end{array}
if l < -5.9999999999999997e-7 or 7e5 < l Initial program 99.8%
Taylor expanded in l around 0 78.3%
Taylor expanded in K around 0 58.2%
Taylor expanded in l around inf 58.3%
associate-*r*58.3%
Simplified58.3%
if -5.9999999999999997e-7 < l < 7e5Initial program 71.8%
Taylor expanded in l around 0 98.4%
Taylor expanded in K around 0 83.7%
Final simplification71.1%
(FPCore (J l K U) :precision binary64 (if (or (<= l -6e-7) (not (<= l 1020.0))) (- -4.0 (* U U)) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -6e-7) || !(l <= 1020.0)) {
tmp = -4.0 - (U * U);
} else {
tmp = U;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-6d-7)) .or. (.not. (l <= 1020.0d0))) then
tmp = (-4.0d0) - (u * u)
else
tmp = u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -6e-7) || !(l <= 1020.0)) {
tmp = -4.0 - (U * U);
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -6e-7) or not (l <= 1020.0): tmp = -4.0 - (U * U) else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -6e-7) || !(l <= 1020.0)) tmp = Float64(-4.0 - Float64(U * U)); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -6e-7) || ~((l <= 1020.0))) tmp = -4.0 - (U * U); else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -6e-7], N[Not[LessEqual[l, 1020.0]], $MachinePrecision]], N[(-4.0 - N[(U * U), $MachinePrecision]), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6 \cdot 10^{-7} \lor \neg \left(\ell \leq 1020\right):\\
\;\;\;\;-4 - U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -5.9999999999999997e-7 or 1020 < l Initial program 99.8%
associate-*l*99.8%
fma-def99.8%
Simplified99.8%
Applied egg-rr18.2%
cancel-sign-sub-inv18.2%
Simplified18.2%
if -5.9999999999999997e-7 < l < 1020Initial program 71.6%
Taylor expanded in J around 0 69.7%
Final simplification43.9%
(FPCore (J l K U) :precision binary64 (if (or (<= l -1.8e+56) (not (<= l 38000000.0))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1.8e+56) || !(l <= 38000000.0)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-1.8d+56)) .or. (.not. (l <= 38000000.0d0))) then
tmp = u * u
else
tmp = u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1.8e+56) || !(l <= 38000000.0)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -1.8e+56) or not (l <= 38000000.0): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -1.8e+56) || !(l <= 38000000.0)) tmp = Float64(U * U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -1.8e+56) || ~((l <= 38000000.0))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -1.8e+56], N[Not[LessEqual[l, 38000000.0]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.8 \cdot 10^{+56} \lor \neg \left(\ell \leq 38000000\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -1.79999999999999999e56 or 3.8e7 < l Initial program 100.0%
Applied egg-rr12.9%
if -1.79999999999999999e56 < l < 3.8e7Initial program 74.1%
Taylor expanded in J around 0 63.4%
Final simplification40.7%
(FPCore (J l K U) :precision binary64 (+ U (* 2.0 (* l J))))
double code(double J, double l, double K, double U) {
return U + (2.0 * (l * J));
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u + (2.0d0 * (l * j))
end function
public static double code(double J, double l, double K, double U) {
return U + (2.0 * (l * J));
}
def code(J, l, K, U): return U + (2.0 * (l * J))
function code(J, l, K, U) return Float64(U + Float64(2.0 * Float64(l * J))) end
function tmp = code(J, l, K, U) tmp = U + (2.0 * (l * J)); end
code[J_, l_, K_, U_] := N[(U + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + 2 \cdot \left(\ell \cdot J\right)
\end{array}
Initial program 85.7%
Taylor expanded in l around 0 66.6%
Taylor expanded in K around 0 54.3%
Final simplification54.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 85.7%
Applied egg-rr2.6%
*-inverses2.6%
Simplified2.6%
Final simplification2.6%
(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 85.7%
Taylor expanded in J around 0 35.9%
Final simplification35.9%
herbie shell --seed 2024018
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))