Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.6% → 99.6%
Time: 13.3s
Alternatives: 11
Speedup: 1.0×

Specification

?
\[\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
 (+ (* (* 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:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 11 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 86.6% accurate, 1.0× speedup?

\[\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
 (+ (* (* 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}

Alternative 1: 99.6% accurate, 0.4× speedup?

\[\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 -2 \cdot 10^{+14} \lor \neg \left(t_1 \leq 5 \cdot 10^{-16}\right):\\ \;\;\;\;\left(t_1 \cdot J\right) \cdot t_0 + U\\ \mathbf{else}:\\ \;\;\;\;U + t_0 \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\ \end{array} \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 -2e+14) (not (<= t_1 5e-16)))
     (+ (* (* t_1 J) t_0) U)
     (+ U (* t_0 (* J (* 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 <= -2e+14) || !(t_1 <= 5e-16)) {
		tmp = ((t_1 * J) * t_0) + U;
	} else {
		tmp = U + (t_0 * (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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = cos((k / 2.0d0))
    t_1 = exp(l) - exp(-l)
    if ((t_1 <= (-2d+14)) .or. (.not. (t_1 <= 5d-16))) then
        tmp = ((t_1 * j) * t_0) + u
    else
        tmp = u + (t_0 * (j * (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 <= -2e+14) || !(t_1 <= 5e-16)) {
		tmp = ((t_1 * J) * t_0) + U;
	} else {
		tmp = U + (t_0 * (J * (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 <= -2e+14) or not (t_1 <= 5e-16):
		tmp = ((t_1 * J) * t_0) + U
	else:
		tmp = U + (t_0 * (J * (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 <= -2e+14) || !(t_1 <= 5e-16))
		tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U);
	else
		tmp = Float64(U + Float64(t_0 * Float64(J * 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 <= -2e+14) || ~((t_1 <= 5e-16)))
		tmp = ((t_1 * J) * t_0) + U;
	else
		tmp = U + (t_0 * (J * (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, -2e+14], N[Not[LessEqual[t$95$1, 5e-16]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(J * 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 -2 \cdot 10^{+14} \lor \neg \left(t_1 \leq 5 \cdot 10^{-16}\right):\\
\;\;\;\;\left(t_1 \cdot J\right) \cdot t_0 + U\\

\mathbf{else}:\\
\;\;\;\;U + t_0 \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -2e14 or 5.0000000000000004e-16 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

    1. Initial program 100.0%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]

    if -2e14 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.0000000000000004e-16

    1. Initial program 73.2%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Taylor expanded in l around 0 100.0%

      \[\leadsto \left(J \cdot \color{blue}{\left(2 \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  3. Recombined 2 regimes into one program.
  4. Final simplification100.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{\ell} - e^{-\ell} \leq -2 \cdot 10^{+14} \lor \neg \left(e^{\ell} - e^{-\ell} \leq 5 \cdot 10^{-16}\right):\\ \;\;\;\;\left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\ \end{array} \]

Alternative 2: 88.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ t_1 := U + \left(J \cdot {\ell}^{3}\right) \cdot \left(0.3333333333333333 + -0.041666666666666664 \cdot \left(K \cdot K\right)\right)\\ \mathbf{if}\;t_0 \leq -0.915:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq -0.49:\\ \;\;\;\;U + \ell \cdot \left(J \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;t_0 \leq -0.01:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;U + \sinh \ell \cdot \left(J \cdot 2\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0)))
        (t_1
         (+
          U
          (*
           (* J (pow l 3.0))
           (+ 0.3333333333333333 (* -0.041666666666666664 (* K K)))))))
   (if (<= t_0 -0.915)
     t_1
     (if (<= t_0 -0.49)
       (+ U (* l (* J (* 2.0 (cos (* K 0.5))))))
       (if (<= t_0 -0.01) t_1 (+ U (* (sinh l) (* J 2.0))))))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K / 2.0));
	double t_1 = U + ((J * pow(l, 3.0)) * (0.3333333333333333 + (-0.041666666666666664 * (K * K))));
	double tmp;
	if (t_0 <= -0.915) {
		tmp = t_1;
	} else if (t_0 <= -0.49) {
		tmp = U + (l * (J * (2.0 * cos((K * 0.5)))));
	} else if (t_0 <= -0.01) {
		tmp = t_1;
	} else {
		tmp = U + (sinh(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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = cos((k / 2.0d0))
    t_1 = u + ((j * (l ** 3.0d0)) * (0.3333333333333333d0 + ((-0.041666666666666664d0) * (k * k))))
    if (t_0 <= (-0.915d0)) then
        tmp = t_1
    else if (t_0 <= (-0.49d0)) then
        tmp = u + (l * (j * (2.0d0 * cos((k * 0.5d0)))))
    else if (t_0 <= (-0.01d0)) then
        tmp = t_1
    else
        tmp = u + (sinh(l) * (j * 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 = U + ((J * Math.pow(l, 3.0)) * (0.3333333333333333 + (-0.041666666666666664 * (K * K))));
	double tmp;
	if (t_0 <= -0.915) {
		tmp = t_1;
	} else if (t_0 <= -0.49) {
		tmp = U + (l * (J * (2.0 * Math.cos((K * 0.5)))));
	} else if (t_0 <= -0.01) {
		tmp = t_1;
	} else {
		tmp = U + (Math.sinh(l) * (J * 2.0));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K / 2.0))
	t_1 = U + ((J * math.pow(l, 3.0)) * (0.3333333333333333 + (-0.041666666666666664 * (K * K))))
	tmp = 0
	if t_0 <= -0.915:
		tmp = t_1
	elif t_0 <= -0.49:
		tmp = U + (l * (J * (2.0 * math.cos((K * 0.5)))))
	elif t_0 <= -0.01:
		tmp = t_1
	else:
		tmp = U + (math.sinh(l) * (J * 2.0))
	return tmp
function code(J, l, K, U)
	t_0 = cos(Float64(K / 2.0))
	t_1 = Float64(U + Float64(Float64(J * (l ^ 3.0)) * Float64(0.3333333333333333 + Float64(-0.041666666666666664 * Float64(K * K)))))
	tmp = 0.0
	if (t_0 <= -0.915)
		tmp = t_1;
	elseif (t_0 <= -0.49)
		tmp = Float64(U + Float64(l * Float64(J * Float64(2.0 * cos(Float64(K * 0.5))))));
	elseif (t_0 <= -0.01)
		tmp = t_1;
	else
		tmp = Float64(U + Float64(sinh(l) * Float64(J * 2.0)));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = cos((K / 2.0));
	t_1 = U + ((J * (l ^ 3.0)) * (0.3333333333333333 + (-0.041666666666666664 * (K * K))));
	tmp = 0.0;
	if (t_0 <= -0.915)
		tmp = t_1;
	elseif (t_0 <= -0.49)
		tmp = U + (l * (J * (2.0 * cos((K * 0.5)))));
	elseif (t_0 <= -0.01)
		tmp = t_1;
	else
		tmp = U + (sinh(l) * (J * 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[(U + N[(N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] * N[(0.3333333333333333 + N[(-0.041666666666666664 * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.915], t$95$1, If[LessEqual[t$95$0, -0.49], N[(U + N[(l * N[(J * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.01], t$95$1, N[(U + N[(N[Sinh[l], $MachinePrecision] * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := U + \left(J \cdot {\ell}^{3}\right) \cdot \left(0.3333333333333333 + -0.041666666666666664 \cdot \left(K \cdot K\right)\right)\\
\mathbf{if}\;t_0 \leq -0.915:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_0 \leq -0.49:\\
\;\;\;\;U + \ell \cdot \left(J \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\

\mathbf{elif}\;t_0 \leq -0.01:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;U + \sinh \ell \cdot \left(J \cdot 2\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (cos.f64 (/.f64 K 2)) < -0.91500000000000004 or -0.48999999999999999 < (cos.f64 (/.f64 K 2)) < -0.0100000000000000002

    1. Initial program 92.1%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Taylor expanded in l around 0 91.7%

      \[\leadsto \left(J \cdot \color{blue}{\left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in l around inf 83.3%

      \[\leadsto \color{blue}{\left(0.3333333333333333 \cdot \left({\ell}^{3} \cdot J\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. associate-*r*83.3%

        \[\leadsto \color{blue}{\left(\left(0.3333333333333333 \cdot {\ell}^{3}\right) \cdot J\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
      2. *-commutative83.3%

        \[\leadsto \left(\color{blue}{\left({\ell}^{3} \cdot 0.3333333333333333\right)} \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      3. associate-*l*83.3%

        \[\leadsto \color{blue}{\left({\ell}^{3} \cdot \left(0.3333333333333333 \cdot J\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
    5. Simplified83.3%

      \[\leadsto \color{blue}{\left({\ell}^{3} \cdot \left(0.3333333333333333 \cdot J\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
    6. Taylor expanded in K around 0 12.4%

      \[\leadsto \color{blue}{\left(-0.041666666666666664 \cdot \left({K}^{2} \cdot \left({\ell}^{3} \cdot J\right)\right) + 0.3333333333333333 \cdot \left({\ell}^{3} \cdot J\right)\right)} + U \]
    7. Step-by-step derivation
      1. +-commutative12.4%

        \[\leadsto \color{blue}{\left(0.3333333333333333 \cdot \left({\ell}^{3} \cdot J\right) + -0.041666666666666664 \cdot \left({K}^{2} \cdot \left({\ell}^{3} \cdot J\right)\right)\right)} + U \]
      2. unpow212.4%

        \[\leadsto \left(0.3333333333333333 \cdot \left({\ell}^{3} \cdot J\right) + -0.041666666666666664 \cdot \left(\color{blue}{\left(K \cdot K\right)} \cdot \left({\ell}^{3} \cdot J\right)\right)\right) + U \]
      3. associate-*r*12.4%

        \[\leadsto \left(0.3333333333333333 \cdot \left({\ell}^{3} \cdot J\right) + \color{blue}{\left(-0.041666666666666664 \cdot \left(K \cdot K\right)\right) \cdot \left({\ell}^{3} \cdot J\right)}\right) + U \]
      4. distribute-rgt-out83.0%

        \[\leadsto \color{blue}{\left({\ell}^{3} \cdot J\right) \cdot \left(0.3333333333333333 + -0.041666666666666664 \cdot \left(K \cdot K\right)\right)} + U \]
    8. Simplified83.0%

      \[\leadsto \color{blue}{\left({\ell}^{3} \cdot J\right) \cdot \left(0.3333333333333333 + -0.041666666666666664 \cdot \left(K \cdot K\right)\right)} + U \]

    if -0.91500000000000004 < (cos.f64 (/.f64 K 2)) < -0.48999999999999999

    1. Initial program 86.9%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Taylor expanded in l around 0 95.6%

      \[\leadsto \left(J \cdot \color{blue}{\left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in l around 0 82.2%

      \[\leadsto \color{blue}{2 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot J\right)\right)} + U \]
    4. Step-by-step derivation
      1. associate-*r*82.2%

        \[\leadsto \color{blue}{\left(2 \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \left(\ell \cdot J\right)} + U \]
      2. *-commutative82.2%

        \[\leadsto \left(2 \cdot \cos \color{blue}{\left(K \cdot 0.5\right)}\right) \cdot \left(\ell \cdot J\right) + U \]
      3. *-commutative82.2%

        \[\leadsto \color{blue}{\left(\ell \cdot J\right) \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)} + U \]
      4. associate-*l*82.2%

        \[\leadsto \color{blue}{\ell \cdot \left(J \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)} + U \]
      5. *-commutative82.2%

        \[\leadsto \ell \cdot \left(J \cdot \left(2 \cdot \cos \color{blue}{\left(0.5 \cdot K\right)}\right)\right) + U \]
    5. Simplified82.2%

      \[\leadsto \color{blue}{\ell \cdot \left(J \cdot \left(2 \cdot \cos \left(0.5 \cdot K\right)\right)\right)} + U \]

    if -0.0100000000000000002 < (cos.f64 (/.f64 K 2))

    1. Initial program 86.5%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Taylor expanded in K around 0 86.5%

      \[\leadsto \color{blue}{\left(e^{\ell} - e^{-\ell}\right) \cdot J} + U \]
    3. Step-by-step derivation
      1. expm1-log1p-u64.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right)\right)} + U \]
      2. expm1-udef63.9%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right)} - 1\right)} + U \]
      3. sinh-undef66.5%

        \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{\left(2 \cdot \sinh \ell\right)} \cdot J\right)} - 1\right) + U \]
    4. Applied egg-rr66.5%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\left(2 \cdot \sinh \ell\right) \cdot J\right)} - 1\right)} + U \]
    5. Step-by-step derivation
      1. expm1-def69.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(2 \cdot \sinh \ell\right) \cdot J\right)\right)} + U \]
      2. expm1-log1p96.8%

        \[\leadsto \color{blue}{\left(2 \cdot \sinh \ell\right) \cdot J} + U \]
      3. *-commutative96.8%

        \[\leadsto \color{blue}{\left(\sinh \ell \cdot 2\right)} \cdot J + U \]
      4. associate-*l*96.8%

        \[\leadsto \color{blue}{\sinh \ell \cdot \left(2 \cdot J\right)} + U \]
    6. Simplified96.8%

      \[\leadsto \color{blue}{\sinh \ell \cdot \left(2 \cdot J\right)} + U \]
  3. Recombined 3 regimes into one program.
  4. Final simplification93.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.915:\\ \;\;\;\;U + \left(J \cdot {\ell}^{3}\right) \cdot \left(0.3333333333333333 + -0.041666666666666664 \cdot \left(K \cdot K\right)\right)\\ \mathbf{elif}\;\cos \left(\frac{K}{2}\right) \leq -0.49:\\ \;\;\;\;U + \ell \cdot \left(J \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\ \;\;\;\;U + \left(J \cdot {\ell}^{3}\right) \cdot \left(0.3333333333333333 + -0.041666666666666664 \cdot \left(K \cdot K\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + \sinh \ell \cdot \left(J \cdot 2\right)\\ \end{array} \]

Alternative 3: 86.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ t_1 := U + J \cdot \left(-0.25 \cdot \left(K \cdot \left(\ell \cdot K\right)\right)\right)\\ \mathbf{if}\;t_0 \leq -0.915:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq -0.65:\\ \;\;\;\;U + \ell \cdot \left(J \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;t_0 \leq -0.01:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;U + \sinh \ell \cdot \left(J \cdot 2\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))) (t_1 (+ U (* J (* -0.25 (* K (* l K)))))))
   (if (<= t_0 -0.915)
     t_1
     (if (<= t_0 -0.65)
       (+ U (* l (* J (* 2.0 (cos (* K 0.5))))))
       (if (<= t_0 -0.01) t_1 (+ U (* (sinh l) (* J 2.0))))))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K / 2.0));
	double t_1 = U + (J * (-0.25 * (K * (l * K))));
	double tmp;
	if (t_0 <= -0.915) {
		tmp = t_1;
	} else if (t_0 <= -0.65) {
		tmp = U + (l * (J * (2.0 * cos((K * 0.5)))));
	} else if (t_0 <= -0.01) {
		tmp = t_1;
	} else {
		tmp = U + (sinh(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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = cos((k / 2.0d0))
    t_1 = u + (j * ((-0.25d0) * (k * (l * k))))
    if (t_0 <= (-0.915d0)) then
        tmp = t_1
    else if (t_0 <= (-0.65d0)) then
        tmp = u + (l * (j * (2.0d0 * cos((k * 0.5d0)))))
    else if (t_0 <= (-0.01d0)) then
        tmp = t_1
    else
        tmp = u + (sinh(l) * (j * 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 = U + (J * (-0.25 * (K * (l * K))));
	double tmp;
	if (t_0 <= -0.915) {
		tmp = t_1;
	} else if (t_0 <= -0.65) {
		tmp = U + (l * (J * (2.0 * Math.cos((K * 0.5)))));
	} else if (t_0 <= -0.01) {
		tmp = t_1;
	} else {
		tmp = U + (Math.sinh(l) * (J * 2.0));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K / 2.0))
	t_1 = U + (J * (-0.25 * (K * (l * K))))
	tmp = 0
	if t_0 <= -0.915:
		tmp = t_1
	elif t_0 <= -0.65:
		tmp = U + (l * (J * (2.0 * math.cos((K * 0.5)))))
	elif t_0 <= -0.01:
		tmp = t_1
	else:
		tmp = U + (math.sinh(l) * (J * 2.0))
	return tmp
function code(J, l, K, U)
	t_0 = cos(Float64(K / 2.0))
	t_1 = Float64(U + Float64(J * Float64(-0.25 * Float64(K * Float64(l * K)))))
	tmp = 0.0
	if (t_0 <= -0.915)
		tmp = t_1;
	elseif (t_0 <= -0.65)
		tmp = Float64(U + Float64(l * Float64(J * Float64(2.0 * cos(Float64(K * 0.5))))));
	elseif (t_0 <= -0.01)
		tmp = t_1;
	else
		tmp = Float64(U + Float64(sinh(l) * Float64(J * 2.0)));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = cos((K / 2.0));
	t_1 = U + (J * (-0.25 * (K * (l * K))));
	tmp = 0.0;
	if (t_0 <= -0.915)
		tmp = t_1;
	elseif (t_0 <= -0.65)
		tmp = U + (l * (J * (2.0 * cos((K * 0.5)))));
	elseif (t_0 <= -0.01)
		tmp = t_1;
	else
		tmp = U + (sinh(l) * (J * 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[(U + N[(J * N[(-0.25 * N[(K * N[(l * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.915], t$95$1, If[LessEqual[t$95$0, -0.65], N[(U + N[(l * N[(J * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.01], t$95$1, N[(U + N[(N[Sinh[l], $MachinePrecision] * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := U + J \cdot \left(-0.25 \cdot \left(K \cdot \left(\ell \cdot K\right)\right)\right)\\
\mathbf{if}\;t_0 \leq -0.915:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_0 \leq -0.65:\\
\;\;\;\;U + \ell \cdot \left(J \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\

\mathbf{elif}\;t_0 \leq -0.01:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;U + \sinh \ell \cdot \left(J \cdot 2\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (cos.f64 (/.f64 K 2)) < -0.91500000000000004 or -0.650000000000000022 < (cos.f64 (/.f64 K 2)) < -0.0100000000000000002

    1. Initial program 92.9%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Taylor expanded in l around 0 39.9%

      \[\leadsto \left(J \cdot \color{blue}{\left(2 \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in K around 0 54.0%

      \[\leadsto \color{blue}{\left(2 \cdot \left(\ell \cdot J\right) + -0.25 \cdot \left({K}^{2} \cdot \left(\ell \cdot J\right)\right)\right)} + U \]
    4. Step-by-step derivation
      1. fma-def54.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \left({K}^{2} \cdot \left(\ell \cdot J\right)\right)\right)} + U \]
      2. associate-*r*59.0%

        \[\leadsto \mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \color{blue}{\left(\left({K}^{2} \cdot \ell\right) \cdot J\right)}\right) + U \]
      3. unpow259.0%

        \[\leadsto \mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \left(\left(\color{blue}{\left(K \cdot K\right)} \cdot \ell\right) \cdot J\right)\right) + U \]
    5. Simplified59.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right)\right)} + U \]
    6. Taylor expanded in K around inf 64.5%

      \[\leadsto \color{blue}{-0.25 \cdot \left({K}^{2} \cdot \left(\ell \cdot J\right)\right)} + U \]
    7. Step-by-step derivation
      1. unpow264.5%

        \[\leadsto -0.25 \cdot \left(\color{blue}{\left(K \cdot K\right)} \cdot \left(\ell \cdot J\right)\right) + U \]
      2. associate-*r*64.5%

        \[\leadsto \color{blue}{\left(-0.25 \cdot \left(K \cdot K\right)\right) \cdot \left(\ell \cdot J\right)} + U \]
      3. associate-*r*69.5%

        \[\leadsto \color{blue}{\left(\left(-0.25 \cdot \left(K \cdot K\right)\right) \cdot \ell\right) \cdot J} + U \]
      4. associate-*r*69.5%

        \[\leadsto \color{blue}{\left(-0.25 \cdot \left(\left(K \cdot K\right) \cdot \ell\right)\right)} \cdot J + U \]
      5. unpow269.5%

        \[\leadsto \left(-0.25 \cdot \left(\color{blue}{{K}^{2}} \cdot \ell\right)\right) \cdot J + U \]
      6. *-commutative69.5%

        \[\leadsto \color{blue}{J \cdot \left(-0.25 \cdot \left({K}^{2} \cdot \ell\right)\right)} + U \]
      7. unpow269.5%

        \[\leadsto J \cdot \left(-0.25 \cdot \left(\color{blue}{\left(K \cdot K\right)} \cdot \ell\right)\right) + U \]
      8. *-commutative69.5%

        \[\leadsto J \cdot \left(-0.25 \cdot \color{blue}{\left(\ell \cdot \left(K \cdot K\right)\right)}\right) + U \]
      9. associate-*r*74.6%

        \[\leadsto J \cdot \left(-0.25 \cdot \color{blue}{\left(\left(\ell \cdot K\right) \cdot K\right)}\right) + U \]
    8. Simplified74.6%

      \[\leadsto \color{blue}{J \cdot \left(-0.25 \cdot \left(\left(\ell \cdot K\right) \cdot K\right)\right)} + U \]

    if -0.91500000000000004 < (cos.f64 (/.f64 K 2)) < -0.650000000000000022

    1. Initial program 84.0%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Taylor expanded in l around 0 94.6%

      \[\leadsto \left(J \cdot \color{blue}{\left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in l around 0 89.0%

      \[\leadsto \color{blue}{2 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot J\right)\right)} + U \]
    4. Step-by-step derivation
      1. associate-*r*89.0%

        \[\leadsto \color{blue}{\left(2 \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \left(\ell \cdot J\right)} + U \]
      2. *-commutative89.0%

        \[\leadsto \left(2 \cdot \cos \color{blue}{\left(K \cdot 0.5\right)}\right) \cdot \left(\ell \cdot J\right) + U \]
      3. *-commutative89.0%

        \[\leadsto \color{blue}{\left(\ell \cdot J\right) \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)} + U \]
      4. associate-*l*89.0%

        \[\leadsto \color{blue}{\ell \cdot \left(J \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)} + U \]
      5. *-commutative89.0%

        \[\leadsto \ell \cdot \left(J \cdot \left(2 \cdot \cos \color{blue}{\left(0.5 \cdot K\right)}\right)\right) + U \]
    5. Simplified89.0%

      \[\leadsto \color{blue}{\ell \cdot \left(J \cdot \left(2 \cdot \cos \left(0.5 \cdot K\right)\right)\right)} + U \]

    if -0.0100000000000000002 < (cos.f64 (/.f64 K 2))

    1. Initial program 86.5%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Taylor expanded in K around 0 86.5%

      \[\leadsto \color{blue}{\left(e^{\ell} - e^{-\ell}\right) \cdot J} + U \]
    3. Step-by-step derivation
      1. expm1-log1p-u64.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right)\right)} + U \]
      2. expm1-udef63.9%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right)} - 1\right)} + U \]
      3. sinh-undef66.5%

        \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{\left(2 \cdot \sinh \ell\right)} \cdot J\right)} - 1\right) + U \]
    4. Applied egg-rr66.5%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\left(2 \cdot \sinh \ell\right) \cdot J\right)} - 1\right)} + U \]
    5. Step-by-step derivation
      1. expm1-def69.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(2 \cdot \sinh \ell\right) \cdot J\right)\right)} + U \]
      2. expm1-log1p96.8%

        \[\leadsto \color{blue}{\left(2 \cdot \sinh \ell\right) \cdot J} + U \]
      3. *-commutative96.8%

        \[\leadsto \color{blue}{\left(\sinh \ell \cdot 2\right)} \cdot J + U \]
      4. associate-*l*96.8%

        \[\leadsto \color{blue}{\sinh \ell \cdot \left(2 \cdot J\right)} + U \]
    6. Simplified96.8%

      \[\leadsto \color{blue}{\sinh \ell \cdot \left(2 \cdot J\right)} + U \]
  3. Recombined 3 regimes into one program.
  4. Final simplification93.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.915:\\ \;\;\;\;U + J \cdot \left(-0.25 \cdot \left(K \cdot \left(\ell \cdot K\right)\right)\right)\\ \mathbf{elif}\;\cos \left(\frac{K}{2}\right) \leq -0.65:\\ \;\;\;\;U + \ell \cdot \left(J \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\ \;\;\;\;U + J \cdot \left(-0.25 \cdot \left(K \cdot \left(\ell \cdot K\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + \sinh \ell \cdot \left(J \cdot 2\right)\\ \end{array} \]

Alternative 4: 94.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t_0 \leq 0.68:\\ \;\;\;\;U + t_0 \cdot \left(J \cdot \left(\ell \cdot 2 + 0.3333333333333333 \cdot {\ell}^{3}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + \sinh \ell \cdot \left(J \cdot 2\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))))
   (if (<= t_0 0.68)
     (+ U (* t_0 (* J (+ (* l 2.0) (* 0.3333333333333333 (pow l 3.0))))))
     (+ U (* (sinh l) (* J 2.0))))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K / 2.0));
	double tmp;
	if (t_0 <= 0.68) {
		tmp = U + (t_0 * (J * ((l * 2.0) + (0.3333333333333333 * pow(l, 3.0)))));
	} else {
		tmp = U + (sinh(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) :: t_0
    real(8) :: tmp
    t_0 = cos((k / 2.0d0))
    if (t_0 <= 0.68d0) then
        tmp = u + (t_0 * (j * ((l * 2.0d0) + (0.3333333333333333d0 * (l ** 3.0d0)))))
    else
        tmp = u + (sinh(l) * (j * 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 tmp;
	if (t_0 <= 0.68) {
		tmp = U + (t_0 * (J * ((l * 2.0) + (0.3333333333333333 * Math.pow(l, 3.0)))));
	} else {
		tmp = U + (Math.sinh(l) * (J * 2.0));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K / 2.0))
	tmp = 0
	if t_0 <= 0.68:
		tmp = U + (t_0 * (J * ((l * 2.0) + (0.3333333333333333 * math.pow(l, 3.0)))))
	else:
		tmp = U + (math.sinh(l) * (J * 2.0))
	return tmp
function code(J, l, K, U)
	t_0 = cos(Float64(K / 2.0))
	tmp = 0.0
	if (t_0 <= 0.68)
		tmp = Float64(U + Float64(t_0 * Float64(J * Float64(Float64(l * 2.0) + Float64(0.3333333333333333 * (l ^ 3.0))))));
	else
		tmp = Float64(U + Float64(sinh(l) * Float64(J * 2.0)));
	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.68)
		tmp = U + (t_0 * (J * ((l * 2.0) + (0.3333333333333333 * (l ^ 3.0)))));
	else
		tmp = U + (sinh(l) * (J * 2.0));
	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.68], N[(U + N[(t$95$0 * N[(J * N[(N[(l * 2.0), $MachinePrecision] + N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[Sinh[l], $MachinePrecision] * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t_0 \leq 0.68:\\
\;\;\;\;U + t_0 \cdot \left(J \cdot \left(\ell \cdot 2 + 0.3333333333333333 \cdot {\ell}^{3}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;U + \sinh \ell \cdot \left(J \cdot 2\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 (/.f64 K 2)) < 0.680000000000000049

    1. Initial program 87.7%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Taylor expanded in l around 0 94.9%

      \[\leadsto \left(J \cdot \color{blue}{\left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]

    if 0.680000000000000049 < (cos.f64 (/.f64 K 2))

    1. Initial program 87.1%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Taylor expanded in K around 0 87.1%

      \[\leadsto \color{blue}{\left(e^{\ell} - e^{-\ell}\right) \cdot J} + U \]
    3. Step-by-step derivation
      1. expm1-log1p-u63.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right)\right)} + U \]
      2. expm1-udef63.1%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right)} - 1\right)} + U \]
      3. sinh-undef66.7%

        \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{\left(2 \cdot \sinh \ell\right)} \cdot J\right)} - 1\right) + U \]
    4. Applied egg-rr66.7%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\left(2 \cdot \sinh \ell\right) \cdot J\right)} - 1\right)} + U \]
    5. Step-by-step derivation
      1. expm1-def70.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(2 \cdot \sinh \ell\right) \cdot J\right)\right)} + U \]
      2. expm1-log1p99.3%

        \[\leadsto \color{blue}{\left(2 \cdot \sinh \ell\right) \cdot J} + U \]
      3. *-commutative99.3%

        \[\leadsto \color{blue}{\left(\sinh \ell \cdot 2\right)} \cdot J + U \]
      4. associate-*l*99.3%

        \[\leadsto \color{blue}{\sinh \ell \cdot \left(2 \cdot J\right)} + U \]
    6. Simplified99.3%

      \[\leadsto \color{blue}{\sinh \ell \cdot \left(2 \cdot J\right)} + U \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.68:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2 + 0.3333333333333333 \cdot {\ell}^{3}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + \sinh \ell \cdot \left(J \cdot 2\right)\\ \end{array} \]

Alternative 5: 90.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t_0 \leq 0.03:\\ \;\;\;\;U + t_0 \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + \sinh \ell \cdot \left(J \cdot 2\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))))
   (if (<= t_0 0.03)
     (+ U (* t_0 (* (pow l 3.0) (* J 0.3333333333333333))))
     (+ U (* (sinh l) (* J 2.0))))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K / 2.0));
	double tmp;
	if (t_0 <= 0.03) {
		tmp = U + (t_0 * (pow(l, 3.0) * (J * 0.3333333333333333)));
	} else {
		tmp = U + (sinh(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) :: t_0
    real(8) :: tmp
    t_0 = cos((k / 2.0d0))
    if (t_0 <= 0.03d0) then
        tmp = u + (t_0 * ((l ** 3.0d0) * (j * 0.3333333333333333d0)))
    else
        tmp = u + (sinh(l) * (j * 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 tmp;
	if (t_0 <= 0.03) {
		tmp = U + (t_0 * (Math.pow(l, 3.0) * (J * 0.3333333333333333)));
	} else {
		tmp = U + (Math.sinh(l) * (J * 2.0));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K / 2.0))
	tmp = 0
	if t_0 <= 0.03:
		tmp = U + (t_0 * (math.pow(l, 3.0) * (J * 0.3333333333333333)))
	else:
		tmp = U + (math.sinh(l) * (J * 2.0))
	return tmp
function code(J, l, K, U)
	t_0 = cos(Float64(K / 2.0))
	tmp = 0.0
	if (t_0 <= 0.03)
		tmp = Float64(U + Float64(t_0 * Float64((l ^ 3.0) * Float64(J * 0.3333333333333333))));
	else
		tmp = Float64(U + Float64(sinh(l) * Float64(J * 2.0)));
	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.03)
		tmp = U + (t_0 * ((l ^ 3.0) * (J * 0.3333333333333333)));
	else
		tmp = U + (sinh(l) * (J * 2.0));
	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.03], N[(U + N[(t$95$0 * N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[Sinh[l], $MachinePrecision] * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t_0 \leq 0.03:\\
\;\;\;\;U + t_0 \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\

\mathbf{else}:\\
\;\;\;\;U + \sinh \ell \cdot \left(J \cdot 2\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 (/.f64 K 2)) < 0.029999999999999999

    1. Initial program 90.2%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Taylor expanded in l around 0 93.4%

      \[\leadsto \left(J \cdot \color{blue}{\left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in l around inf 83.4%

      \[\leadsto \color{blue}{\left(0.3333333333333333 \cdot \left({\ell}^{3} \cdot J\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. associate-*r*83.4%

        \[\leadsto \color{blue}{\left(\left(0.3333333333333333 \cdot {\ell}^{3}\right) \cdot J\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
      2. *-commutative83.4%

        \[\leadsto \left(\color{blue}{\left({\ell}^{3} \cdot 0.3333333333333333\right)} \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      3. associate-*l*83.4%

        \[\leadsto \color{blue}{\left({\ell}^{3} \cdot \left(0.3333333333333333 \cdot J\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
    5. Simplified83.4%

      \[\leadsto \color{blue}{\left({\ell}^{3} \cdot \left(0.3333333333333333 \cdot J\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]

    if 0.029999999999999999 < (cos.f64 (/.f64 K 2))

    1. Initial program 86.5%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Taylor expanded in K around 0 86.5%

      \[\leadsto \color{blue}{\left(e^{\ell} - e^{-\ell}\right) \cdot J} + U \]
    3. Step-by-step derivation
      1. expm1-log1p-u64.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right)\right)} + U \]
      2. expm1-udef63.6%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right)} - 1\right)} + U \]
      3. sinh-undef66.2%

        \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{\left(2 \cdot \sinh \ell\right)} \cdot J\right)} - 1\right) + U \]
    4. Applied egg-rr66.2%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\left(2 \cdot \sinh \ell\right) \cdot J\right)} - 1\right)} + U \]
    5. Step-by-step derivation
      1. expm1-def69.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(2 \cdot \sinh \ell\right) \cdot J\right)\right)} + U \]
      2. expm1-log1p96.9%

        \[\leadsto \color{blue}{\left(2 \cdot \sinh \ell\right) \cdot J} + U \]
      3. *-commutative96.9%

        \[\leadsto \color{blue}{\left(\sinh \ell \cdot 2\right)} \cdot J + U \]
      4. associate-*l*96.9%

        \[\leadsto \color{blue}{\sinh \ell \cdot \left(2 \cdot J\right)} + U \]
    6. Simplified96.9%

      \[\leadsto \color{blue}{\sinh \ell \cdot \left(2 \cdot J\right)} + U \]
  3. Recombined 2 regimes into one program.
  4. Final simplification93.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.03:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + \sinh \ell \cdot \left(J \cdot 2\right)\\ \end{array} \]

Alternative 6: 86.4% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\ \;\;\;\;U + J \cdot \left(-0.25 \cdot \left(K \cdot \left(\ell \cdot K\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + \sinh \ell \cdot \left(J \cdot 2\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= (cos (/ K 2.0)) -0.01)
   (+ U (* J (* -0.25 (* K (* l K)))))
   (+ U (* (sinh l) (* J 2.0)))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (cos((K / 2.0)) <= -0.01) {
		tmp = U + (J * (-0.25 * (K * (l * K))));
	} else {
		tmp = U + (sinh(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 (cos((k / 2.0d0)) <= (-0.01d0)) then
        tmp = u + (j * ((-0.25d0) * (k * (l * k))))
    else
        tmp = u + (sinh(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 (Math.cos((K / 2.0)) <= -0.01) {
		tmp = U + (J * (-0.25 * (K * (l * K))));
	} else {
		tmp = U + (Math.sinh(l) * (J * 2.0));
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if math.cos((K / 2.0)) <= -0.01:
		tmp = U + (J * (-0.25 * (K * (l * K))))
	else:
		tmp = U + (math.sinh(l) * (J * 2.0))
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (cos(Float64(K / 2.0)) <= -0.01)
		tmp = Float64(U + Float64(J * Float64(-0.25 * Float64(K * Float64(l * K)))));
	else
		tmp = Float64(U + Float64(sinh(l) * Float64(J * 2.0)));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (cos((K / 2.0)) <= -0.01)
		tmp = U + (J * (-0.25 * (K * (l * K))));
	else
		tmp = U + (sinh(l) * (J * 2.0));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(U + N[(J * N[(-0.25 * N[(K * N[(l * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[Sinh[l], $MachinePrecision] * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;U + J \cdot \left(-0.25 \cdot \left(K \cdot \left(\ell \cdot K\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;U + \sinh \ell \cdot \left(J \cdot 2\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 (/.f64 K 2)) < -0.0100000000000000002

    1. Initial program 90.1%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Taylor expanded in l around 0 55.7%

      \[\leadsto \left(J \cdot \color{blue}{\left(2 \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in K around 0 47.4%

      \[\leadsto \color{blue}{\left(2 \cdot \left(\ell \cdot J\right) + -0.25 \cdot \left({K}^{2} \cdot \left(\ell \cdot J\right)\right)\right)} + U \]
    4. Step-by-step derivation
      1. fma-def47.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \left({K}^{2} \cdot \left(\ell \cdot J\right)\right)\right)} + U \]
      2. associate-*r*50.9%

        \[\leadsto \mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \color{blue}{\left(\left({K}^{2} \cdot \ell\right) \cdot J\right)}\right) + U \]
      3. unpow250.9%

        \[\leadsto \mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \left(\left(\color{blue}{\left(K \cdot K\right)} \cdot \ell\right) \cdot J\right)\right) + U \]
    5. Simplified50.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right)\right)} + U \]
    6. Taylor expanded in K around inf 58.2%

      \[\leadsto \color{blue}{-0.25 \cdot \left({K}^{2} \cdot \left(\ell \cdot J\right)\right)} + U \]
    7. Step-by-step derivation
      1. unpow258.2%

        \[\leadsto -0.25 \cdot \left(\color{blue}{\left(K \cdot K\right)} \cdot \left(\ell \cdot J\right)\right) + U \]
      2. associate-*r*58.2%

        \[\leadsto \color{blue}{\left(-0.25 \cdot \left(K \cdot K\right)\right) \cdot \left(\ell \cdot J\right)} + U \]
      3. associate-*r*61.6%

        \[\leadsto \color{blue}{\left(\left(-0.25 \cdot \left(K \cdot K\right)\right) \cdot \ell\right) \cdot J} + U \]
      4. associate-*r*61.6%

        \[\leadsto \color{blue}{\left(-0.25 \cdot \left(\left(K \cdot K\right) \cdot \ell\right)\right)} \cdot J + U \]
      5. unpow261.6%

        \[\leadsto \left(-0.25 \cdot \left(\color{blue}{{K}^{2}} \cdot \ell\right)\right) \cdot J + U \]
      6. *-commutative61.6%

        \[\leadsto \color{blue}{J \cdot \left(-0.25 \cdot \left({K}^{2} \cdot \ell\right)\right)} + U \]
      7. unpow261.6%

        \[\leadsto J \cdot \left(-0.25 \cdot \left(\color{blue}{\left(K \cdot K\right)} \cdot \ell\right)\right) + U \]
      8. *-commutative61.6%

        \[\leadsto J \cdot \left(-0.25 \cdot \color{blue}{\left(\ell \cdot \left(K \cdot K\right)\right)}\right) + U \]
      9. associate-*r*67.0%

        \[\leadsto J \cdot \left(-0.25 \cdot \color{blue}{\left(\left(\ell \cdot K\right) \cdot K\right)}\right) + U \]
    8. Simplified67.0%

      \[\leadsto \color{blue}{J \cdot \left(-0.25 \cdot \left(\left(\ell \cdot K\right) \cdot K\right)\right)} + U \]

    if -0.0100000000000000002 < (cos.f64 (/.f64 K 2))

    1. Initial program 86.5%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Taylor expanded in K around 0 86.5%

      \[\leadsto \color{blue}{\left(e^{\ell} - e^{-\ell}\right) \cdot J} + U \]
    3. Step-by-step derivation
      1. expm1-log1p-u64.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right)\right)} + U \]
      2. expm1-udef63.9%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right)} - 1\right)} + U \]
      3. sinh-undef66.5%

        \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{\left(2 \cdot \sinh \ell\right)} \cdot J\right)} - 1\right) + U \]
    4. Applied egg-rr66.5%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\left(2 \cdot \sinh \ell\right) \cdot J\right)} - 1\right)} + U \]
    5. Step-by-step derivation
      1. expm1-def69.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(2 \cdot \sinh \ell\right) \cdot J\right)\right)} + U \]
      2. expm1-log1p96.8%

        \[\leadsto \color{blue}{\left(2 \cdot \sinh \ell\right) \cdot J} + U \]
      3. *-commutative96.8%

        \[\leadsto \color{blue}{\left(\sinh \ell \cdot 2\right)} \cdot J + U \]
      4. associate-*l*96.8%

        \[\leadsto \color{blue}{\sinh \ell \cdot \left(2 \cdot J\right)} + U \]
    6. Simplified96.8%

      \[\leadsto \color{blue}{\sinh \ell \cdot \left(2 \cdot J\right)} + U \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\ \;\;\;\;U + J \cdot \left(-0.25 \cdot \left(K \cdot \left(\ell \cdot K\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + \sinh \ell \cdot \left(J \cdot 2\right)\\ \end{array} \]

Alternative 7: 60.0% accurate, 18.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -5.9 \cdot 10^{+31} \lor \neg \left(\ell \leq 1.08 \cdot 10^{+51}\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} \]
(FPCore (J l K U)
 :precision binary64
 (if (or (<= l -5.9e+31) (not (<= l 1.08e+51)))
   (+ 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 <= -5.9e+31) || !(l <= 1.08e+51)) {
		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 <= (-5.9d+31)) .or. (.not. (l <= 1.08d+51))) 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 <= -5.9e+31) || !(l <= 1.08e+51)) {
		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 <= -5.9e+31) or not (l <= 1.08e+51):
		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 <= -5.9e+31) || !(l <= 1.08e+51))
		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 <= -5.9e+31) || ~((l <= 1.08e+51)))
		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, -5.9e+31], N[Not[LessEqual[l, 1.08e+51]], $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 -5.9 \cdot 10^{+31} \lor \neg \left(\ell \leq 1.08 \cdot 10^{+51}\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}
Derivation
  1. Split input into 2 regimes
  2. if l < -5.9000000000000004e31 or 1.08e51 < l

    1. Initial program 100.0%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Taylor expanded in l around 0 27.5%

      \[\leadsto \left(J \cdot \color{blue}{\left(2 \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in K around 0 19.4%

      \[\leadsto \color{blue}{\left(2 \cdot \left(\ell \cdot J\right) + -0.25 \cdot \left({K}^{2} \cdot \left(\ell \cdot J\right)\right)\right)} + U \]
    4. Step-by-step derivation
      1. +-commutative19.4%

        \[\leadsto \color{blue}{\left(-0.25 \cdot \left({K}^{2} \cdot \left(\ell \cdot J\right)\right) + 2 \cdot \left(\ell \cdot J\right)\right)} + U \]
      2. associate-*r*19.4%

        \[\leadsto \left(\color{blue}{\left(-0.25 \cdot {K}^{2}\right) \cdot \left(\ell \cdot J\right)} + 2 \cdot \left(\ell \cdot J\right)\right) + U \]
      3. distribute-rgt-out36.6%

        \[\leadsto \color{blue}{\left(\ell \cdot J\right) \cdot \left(-0.25 \cdot {K}^{2} + 2\right)} + U \]
      4. *-commutative36.6%

        \[\leadsto \left(\ell \cdot J\right) \cdot \left(\color{blue}{{K}^{2} \cdot -0.25} + 2\right) + U \]
      5. unpow236.6%

        \[\leadsto \left(\ell \cdot J\right) \cdot \left(\color{blue}{\left(K \cdot K\right)} \cdot -0.25 + 2\right) + U \]
    5. Simplified36.6%

      \[\leadsto \color{blue}{\left(\ell \cdot J\right) \cdot \left(\left(K \cdot K\right) \cdot -0.25 + 2\right)} + U \]

    if -5.9000000000000004e31 < l < 1.08e51

    1. Initial program 76.8%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Taylor expanded in l around 0 90.7%

      \[\leadsto \left(J \cdot \color{blue}{\left(2 \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in K around 0 60.3%

      \[\leadsto \color{blue}{\left(2 \cdot \left(\ell \cdot J\right) + -0.25 \cdot \left({K}^{2} \cdot \left(\ell \cdot J\right)\right)\right)} + U \]
    4. Step-by-step derivation
      1. fma-def60.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \left({K}^{2} \cdot \left(\ell \cdot J\right)\right)\right)} + U \]
      2. associate-*r*60.5%

        \[\leadsto \mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \color{blue}{\left(\left({K}^{2} \cdot \ell\right) \cdot J\right)}\right) + U \]
      3. unpow260.5%

        \[\leadsto \mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \left(\left(\color{blue}{\left(K \cdot K\right)} \cdot \ell\right) \cdot J\right)\right) + U \]
    5. Simplified60.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right)\right)} + U \]
    6. Taylor expanded in K around 0 81.9%

      \[\leadsto \color{blue}{2 \cdot \left(\ell \cdot J\right)} + U \]
    7. Step-by-step derivation
      1. associate-*r*81.9%

        \[\leadsto \color{blue}{\left(2 \cdot \ell\right) \cdot J} + U \]
      2. *-commutative81.9%

        \[\leadsto \color{blue}{\left(\ell \cdot 2\right)} \cdot J + U \]
    8. Simplified81.9%

      \[\leadsto \color{blue}{\left(\ell \cdot 2\right) \cdot J} + U \]
  3. Recombined 2 regimes into one program.
  4. Final simplification61.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5.9 \cdot 10^{+31} \lor \neg \left(\ell \leq 1.08 \cdot 10^{+51}\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} \]

Alternative 8: 53.1% accurate, 20.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;J \leq 1.7 \cdot 10^{-176} \lor \neg \left(J \leq 2 \cdot 10^{+58}\right):\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(-0.25 \cdot \left(K \cdot \left(\ell \cdot K\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (or (<= J 1.7e-176) (not (<= J 2e+58)))
   (+ U (* J (* l 2.0)))
   (+ U (* J (* -0.25 (* K (* l K)))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if ((J <= 1.7e-176) || !(J <= 2e+58)) {
		tmp = U + (J * (l * 2.0));
	} else {
		tmp = U + (J * (-0.25 * (K * (l * K))));
	}
	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 <= 1.7d-176) .or. (.not. (j <= 2d+58))) then
        tmp = u + (j * (l * 2.0d0))
    else
        tmp = u + (j * ((-0.25d0) * (k * (l * k))))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if ((J <= 1.7e-176) || !(J <= 2e+58)) {
		tmp = U + (J * (l * 2.0));
	} else {
		tmp = U + (J * (-0.25 * (K * (l * K))));
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if (J <= 1.7e-176) or not (J <= 2e+58):
		tmp = U + (J * (l * 2.0))
	else:
		tmp = U + (J * (-0.25 * (K * (l * K))))
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if ((J <= 1.7e-176) || !(J <= 2e+58))
		tmp = Float64(U + Float64(J * Float64(l * 2.0)));
	else
		tmp = Float64(U + Float64(J * Float64(-0.25 * Float64(K * Float64(l * K)))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if ((J <= 1.7e-176) || ~((J <= 2e+58)))
		tmp = U + (J * (l * 2.0));
	else
		tmp = U + (J * (-0.25 * (K * (l * K))));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[Or[LessEqual[J, 1.7e-176], N[Not[LessEqual[J, 2e+58]], $MachinePrecision]], N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(-0.25 * N[(K * N[(l * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;J \leq 1.7 \cdot 10^{-176} \lor \neg \left(J \leq 2 \cdot 10^{+58}\right):\\
\;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\

\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(-0.25 \cdot \left(K \cdot \left(\ell \cdot K\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if J < 1.6999999999999999e-176 or 1.99999999999999989e58 < J

    1. Initial program 85.8%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Taylor expanded in l around 0 67.6%

      \[\leadsto \left(J \cdot \color{blue}{\left(2 \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in K around 0 39.4%

      \[\leadsto \color{blue}{\left(2 \cdot \left(\ell \cdot J\right) + -0.25 \cdot \left({K}^{2} \cdot \left(\ell \cdot J\right)\right)\right)} + U \]
    4. Step-by-step derivation
      1. fma-def39.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \left({K}^{2} \cdot \left(\ell \cdot J\right)\right)\right)} + U \]
      2. associate-*r*46.2%

        \[\leadsto \mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \color{blue}{\left(\left({K}^{2} \cdot \ell\right) \cdot J\right)}\right) + U \]
      3. unpow246.2%

        \[\leadsto \mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \left(\left(\color{blue}{\left(K \cdot K\right)} \cdot \ell\right) \cdot J\right)\right) + U \]
    5. Simplified46.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right)\right)} + U \]
    6. Taylor expanded in K around 0 58.9%

      \[\leadsto \color{blue}{2 \cdot \left(\ell \cdot J\right)} + U \]
    7. Step-by-step derivation
      1. associate-*r*58.9%

        \[\leadsto \color{blue}{\left(2 \cdot \ell\right) \cdot J} + U \]
      2. *-commutative58.9%

        \[\leadsto \color{blue}{\left(\ell \cdot 2\right)} \cdot J + U \]
    8. Simplified58.9%

      \[\leadsto \color{blue}{\left(\ell \cdot 2\right) \cdot J} + U \]

    if 1.6999999999999999e-176 < J < 1.99999999999999989e58

    1. Initial program 94.0%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Taylor expanded in l around 0 38.3%

      \[\leadsto \left(J \cdot \color{blue}{\left(2 \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in K around 0 52.1%

      \[\leadsto \color{blue}{\left(2 \cdot \left(\ell \cdot J\right) + -0.25 \cdot \left({K}^{2} \cdot \left(\ell \cdot J\right)\right)\right)} + U \]
    4. Step-by-step derivation
      1. fma-def52.1%

        \[\leadsto \color{blue}{\mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \left({K}^{2} \cdot \left(\ell \cdot J\right)\right)\right)} + U \]
      2. associate-*r*54.0%

        \[\leadsto \mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \color{blue}{\left(\left({K}^{2} \cdot \ell\right) \cdot J\right)}\right) + U \]
      3. unpow254.0%

        \[\leadsto \mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \left(\left(\color{blue}{\left(K \cdot K\right)} \cdot \ell\right) \cdot J\right)\right) + U \]
    5. Simplified54.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right)\right)} + U \]
    6. Taylor expanded in K around inf 49.0%

      \[\leadsto \color{blue}{-0.25 \cdot \left({K}^{2} \cdot \left(\ell \cdot J\right)\right)} + U \]
    7. Step-by-step derivation
      1. unpow249.0%

        \[\leadsto -0.25 \cdot \left(\color{blue}{\left(K \cdot K\right)} \cdot \left(\ell \cdot J\right)\right) + U \]
      2. associate-*r*49.0%

        \[\leadsto \color{blue}{\left(-0.25 \cdot \left(K \cdot K\right)\right) \cdot \left(\ell \cdot J\right)} + U \]
      3. associate-*r*50.8%

        \[\leadsto \color{blue}{\left(\left(-0.25 \cdot \left(K \cdot K\right)\right) \cdot \ell\right) \cdot J} + U \]
      4. associate-*r*50.8%

        \[\leadsto \color{blue}{\left(-0.25 \cdot \left(\left(K \cdot K\right) \cdot \ell\right)\right)} \cdot J + U \]
      5. unpow250.8%

        \[\leadsto \left(-0.25 \cdot \left(\color{blue}{{K}^{2}} \cdot \ell\right)\right) \cdot J + U \]
      6. *-commutative50.8%

        \[\leadsto \color{blue}{J \cdot \left(-0.25 \cdot \left({K}^{2} \cdot \ell\right)\right)} + U \]
      7. unpow250.8%

        \[\leadsto J \cdot \left(-0.25 \cdot \left(\color{blue}{\left(K \cdot K\right)} \cdot \ell\right)\right) + U \]
      8. *-commutative50.8%

        \[\leadsto J \cdot \left(-0.25 \cdot \color{blue}{\left(\ell \cdot \left(K \cdot K\right)\right)}\right) + U \]
      9. associate-*r*50.8%

        \[\leadsto J \cdot \left(-0.25 \cdot \color{blue}{\left(\left(\ell \cdot K\right) \cdot K\right)}\right) + U \]
    8. Simplified50.8%

      \[\leadsto \color{blue}{J \cdot \left(-0.25 \cdot \left(\left(\ell \cdot K\right) \cdot K\right)\right)} + U \]
  3. Recombined 2 regimes into one program.
  4. Final simplification57.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;J \leq 1.7 \cdot 10^{-176} \lor \neg \left(J \leq 2 \cdot 10^{+58}\right):\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(-0.25 \cdot \left(K \cdot \left(\ell \cdot K\right)\right)\right)\\ \end{array} \]

Alternative 9: 45.1% accurate, 28.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -32 \lor \neg \left(\ell \leq 1.2 \cdot 10^{-16}\right):\\ \;\;\;\;U + J \cdot \left(K \cdot K\right)\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (or (<= l -32.0) (not (<= l 1.2e-16))) (+ U (* J (* K K))) U))
double code(double J, double l, double K, double U) {
	double tmp;
	if ((l <= -32.0) || !(l <= 1.2e-16)) {
		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 <= (-32.0d0)) .or. (.not. (l <= 1.2d-16))) 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 <= -32.0) || !(l <= 1.2e-16)) {
		tmp = U + (J * (K * K));
	} else {
		tmp = U;
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if (l <= -32.0) or not (l <= 1.2e-16):
		tmp = U + (J * (K * K))
	else:
		tmp = U
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if ((l <= -32.0) || !(l <= 1.2e-16))
		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 <= -32.0) || ~((l <= 1.2e-16)))
		tmp = U + (J * (K * K));
	else
		tmp = U;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -32.0], N[Not[LessEqual[l, 1.2e-16]], $MachinePrecision]], N[(U + N[(J * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], U]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -32 \lor \neg \left(\ell \leq 1.2 \cdot 10^{-16}\right):\\
\;\;\;\;U + J \cdot \left(K \cdot K\right)\\

\mathbf{else}:\\
\;\;\;\;U\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -32 or 1.20000000000000002e-16 < l

    1. Initial program 99.4%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Applied egg-rr5.0%

      \[\leadsto \left(J \cdot \color{blue}{-8}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in K around 0 16.1%

      \[\leadsto \color{blue}{\left({K}^{2} \cdot J + -8 \cdot J\right)} + U \]
    4. Step-by-step derivation
      1. distribute-rgt-out16.1%

        \[\leadsto \color{blue}{J \cdot \left({K}^{2} + -8\right)} + U \]
      2. unpow216.1%

        \[\leadsto J \cdot \left(\color{blue}{K \cdot K} + -8\right) + U \]
    5. Simplified16.1%

      \[\leadsto \color{blue}{J \cdot \left(K \cdot K + -8\right)} + U \]
    6. Taylor expanded in K around inf 16.1%

      \[\leadsto \color{blue}{{K}^{2} \cdot J} + U \]
    7. Step-by-step derivation
      1. *-commutative16.1%

        \[\leadsto \color{blue}{J \cdot {K}^{2}} + U \]
      2. unpow216.1%

        \[\leadsto J \cdot \color{blue}{\left(K \cdot K\right)} + U \]
    8. Simplified16.1%

      \[\leadsto \color{blue}{J \cdot \left(K \cdot K\right)} + U \]

    if -32 < l < 1.20000000000000002e-16

    1. Initial program 73.6%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Applied egg-rr53.3%

      \[\leadsto \left(J \cdot \color{blue}{0.125}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in J around 0 73.4%

      \[\leadsto \color{blue}{U} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification43.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -32 \lor \neg \left(\ell \leq 1.2 \cdot 10^{-16}\right):\\ \;\;\;\;U + J \cdot \left(K \cdot K\right)\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \]

Alternative 10: 54.9% accurate, 44.6× speedup?

\[\begin{array}{l} \\ U + J \cdot \left(\ell \cdot 2\right) \end{array} \]
(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}
Derivation
  1. Initial program 87.3%

    \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  2. Taylor expanded in l around 0 62.1%

    \[\leadsto \left(J \cdot \color{blue}{\left(2 \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  3. Taylor expanded in K around 0 41.8%

    \[\leadsto \color{blue}{\left(2 \cdot \left(\ell \cdot J\right) + -0.25 \cdot \left({K}^{2} \cdot \left(\ell \cdot J\right)\right)\right)} + U \]
  4. Step-by-step derivation
    1. fma-def41.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \left({K}^{2} \cdot \left(\ell \cdot J\right)\right)\right)} + U \]
    2. associate-*r*47.6%

      \[\leadsto \mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \color{blue}{\left(\left({K}^{2} \cdot \ell\right) \cdot J\right)}\right) + U \]
    3. unpow247.6%

      \[\leadsto \mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \left(\left(\color{blue}{\left(K \cdot K\right)} \cdot \ell\right) \cdot J\right)\right) + U \]
  5. Simplified47.6%

    \[\leadsto \color{blue}{\mathsf{fma}\left(2, \ell \cdot J, -0.25 \cdot \left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right)\right)} + U \]
  6. Taylor expanded in K around 0 54.2%

    \[\leadsto \color{blue}{2 \cdot \left(\ell \cdot J\right)} + U \]
  7. Step-by-step derivation
    1. associate-*r*54.2%

      \[\leadsto \color{blue}{\left(2 \cdot \ell\right) \cdot J} + U \]
    2. *-commutative54.2%

      \[\leadsto \color{blue}{\left(\ell \cdot 2\right)} \cdot J + U \]
  8. Simplified54.2%

    \[\leadsto \color{blue}{\left(\ell \cdot 2\right) \cdot J} + U \]
  9. Final simplification54.2%

    \[\leadsto U + J \cdot \left(\ell \cdot 2\right) \]

Alternative 11: 37.7% accurate, 312.0× speedup?

\[\begin{array}{l} \\ U \end{array} \]
(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}
Derivation
  1. Initial program 87.3%

    \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  2. Applied egg-rr27.8%

    \[\leadsto \left(J \cdot \color{blue}{0.125}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  3. Taylor expanded in J around 0 37.0%

    \[\leadsto \color{blue}{U} \]
  4. Final simplification37.0%

    \[\leadsto U \]

Reproduce

?
herbie shell --seed 2023187 
(FPCore (J l K U)
  :name "Maksimov and Kolovsky, Equation (4)"
  :precision binary64
  (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))