Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.4% → 99.9%
Time: 14.4s
Alternatives: 19
Speedup: 1.4×

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 19 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.4% 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.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\ell} - e^{-\ell}\\ \mathbf{if}\;t_0 \leq -0.1 \lor \neg \left(t_0 \leq 4 \cdot 10^{-8}\right):\\ \;\;\;\;J \cdot \left(t_0 \cdot \cos \left(0.5 \cdot K\right)\right) + U\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.016666666666666666 \cdot {\ell}^{5} + \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (- (exp l) (exp (- l)))))
   (if (or (<= t_0 -0.1) (not (<= t_0 4e-8)))
     (+ (* J (* t_0 (cos (* 0.5 K)))) U)
     (+
      U
      (*
       (cos (/ K 2.0))
       (*
        J
        (+
         (* 0.016666666666666666 (pow l 5.0))
         (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))))))
double code(double J, double l, double K, double U) {
	double t_0 = exp(l) - exp(-l);
	double tmp;
	if ((t_0 <= -0.1) || !(t_0 <= 4e-8)) {
		tmp = (J * (t_0 * cos((0.5 * K)))) + U;
	} else {
		tmp = U + (cos((K / 2.0)) * (J * ((0.016666666666666666 * pow(l, 5.0)) + ((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) :: tmp
    t_0 = exp(l) - exp(-l)
    if ((t_0 <= (-0.1d0)) .or. (.not. (t_0 <= 4d-8))) then
        tmp = (j * (t_0 * cos((0.5d0 * k)))) + u
    else
        tmp = u + (cos((k / 2.0d0)) * (j * ((0.016666666666666666d0 * (l ** 5.0d0)) + ((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.exp(l) - Math.exp(-l);
	double tmp;
	if ((t_0 <= -0.1) || !(t_0 <= 4e-8)) {
		tmp = (J * (t_0 * Math.cos((0.5 * K)))) + U;
	} else {
		tmp = U + (Math.cos((K / 2.0)) * (J * ((0.016666666666666666 * Math.pow(l, 5.0)) + ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)))));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.exp(l) - math.exp(-l)
	tmp = 0
	if (t_0 <= -0.1) or not (t_0 <= 4e-8):
		tmp = (J * (t_0 * math.cos((0.5 * K)))) + U
	else:
		tmp = U + (math.cos((K / 2.0)) * (J * ((0.016666666666666666 * math.pow(l, 5.0)) + ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))))
	return tmp
function code(J, l, K, U)
	t_0 = Float64(exp(l) - exp(Float64(-l)))
	tmp = 0.0
	if ((t_0 <= -0.1) || !(t_0 <= 4e-8))
		tmp = Float64(Float64(J * Float64(t_0 * cos(Float64(0.5 * K)))) + U);
	else
		tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(Float64(0.016666666666666666 * (l ^ 5.0)) + 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 = exp(l) - exp(-l);
	tmp = 0.0;
	if ((t_0 <= -0.1) || ~((t_0 <= 4e-8)))
		tmp = (J * (t_0 * cos((0.5 * K)))) + U;
	else
		tmp = U + (cos((K / 2.0)) * (J * ((0.016666666666666666 * (l ^ 5.0)) + ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.1], N[Not[LessEqual[t$95$0, 4e-8]], $MachinePrecision]], N[(N[(J * N[(t$95$0 * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(N[(0.016666666666666666 * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_0 \leq -0.1 \lor \neg \left(t_0 \leq 4 \cdot 10^{-8}\right):\\
\;\;\;\;J \cdot \left(t_0 \cdot \cos \left(0.5 \cdot K\right)\right) + U\\

\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.016666666666666666 \cdot {\ell}^{5} + \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\right)\\


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

    1. Initial program 99.9%

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

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

    if -0.10000000000000001 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 4.0000000000000001e-8

    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 99.9%

      \[\leadsto \left(J \cdot \color{blue}{\left(0.016666666666666666 \cdot {\ell}^{5} + \left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.9%

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

Alternative 2: 99.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(0.5 \cdot K\right)\\ t_1 := e^{\ell} - e^{-\ell}\\ \mathbf{if}\;t_1 \leq -0.02 \lor \neg \left(t_1 \leq 4 \cdot 10^{-8}\right):\\ \;\;\;\;J \cdot \left(t_1 \cdot t_0\right) + U\\ \mathbf{else}:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(t_0 \cdot 2\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (* 0.5 K))) (t_1 (- (exp l) (exp (- l)))))
   (if (or (<= t_1 -0.02) (not (<= t_1 4e-8)))
     (+ (* J (* t_1 t_0)) U)
     (+ U (* (* l J) (* t_0 2.0))))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((0.5 * K));
	double t_1 = exp(l) - exp(-l);
	double tmp;
	if ((t_1 <= -0.02) || !(t_1 <= 4e-8)) {
		tmp = (J * (t_1 * t_0)) + U;
	} else {
		tmp = U + ((l * J) * (t_0 * 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((0.5d0 * k))
    t_1 = exp(l) - exp(-l)
    if ((t_1 <= (-0.02d0)) .or. (.not. (t_1 <= 4d-8))) then
        tmp = (j * (t_1 * t_0)) + u
    else
        tmp = u + ((l * j) * (t_0 * 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((0.5 * K));
	double t_1 = Math.exp(l) - Math.exp(-l);
	double tmp;
	if ((t_1 <= -0.02) || !(t_1 <= 4e-8)) {
		tmp = (J * (t_1 * t_0)) + U;
	} else {
		tmp = U + ((l * J) * (t_0 * 2.0));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((0.5 * K))
	t_1 = math.exp(l) - math.exp(-l)
	tmp = 0
	if (t_1 <= -0.02) or not (t_1 <= 4e-8):
		tmp = (J * (t_1 * t_0)) + U
	else:
		tmp = U + ((l * J) * (t_0 * 2.0))
	return tmp
function code(J, l, K, U)
	t_0 = cos(Float64(0.5 * K))
	t_1 = Float64(exp(l) - exp(Float64(-l)))
	tmp = 0.0
	if ((t_1 <= -0.02) || !(t_1 <= 4e-8))
		tmp = Float64(Float64(J * Float64(t_1 * t_0)) + U);
	else
		tmp = Float64(U + Float64(Float64(l * J) * Float64(t_0 * 2.0)));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = cos((0.5 * K));
	t_1 = exp(l) - exp(-l);
	tmp = 0.0;
	if ((t_1 <= -0.02) || ~((t_1 <= 4e-8)))
		tmp = (J * (t_1 * t_0)) + U;
	else
		tmp = U + ((l * J) * (t_0 * 2.0));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -0.02], N[Not[LessEqual[t$95$1, 4e-8]], $MachinePrecision]], N[(N[(J * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[(l * J), $MachinePrecision] * N[(t$95$0 * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(0.5 \cdot K\right)\\
t_1 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_1 \leq -0.02 \lor \neg \left(t_1 \leq 4 \cdot 10^{-8}\right):\\
\;\;\;\;J \cdot \left(t_1 \cdot t_0\right) + U\\

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


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

    1. Initial program 99.9%

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

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

    if -0.0200000000000000004 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 4.0000000000000001e-8

    1. Initial program 76.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 99.9%

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

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

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

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

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

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

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

Alternative 3: 97.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\ell} - e^{-\ell}\\ \mathbf{if}\;t_0 \leq -0.1:\\ \;\;\;\;J \cdot \left(t_0 \cdot \cos \left(0.5 \cdot K\right)\right) + U\\ \mathbf{else}:\\ \;\;\;\;U + \left(0.0003968253968253968 \cdot \left(J \cdot {\ell}^{7}\right) + \left(0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\right) + \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right) + 2 \cdot \left(\ell \cdot J\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (- (exp l) (exp (- l)))))
   (if (<= t_0 -0.1)
     (+ (* J (* t_0 (cos (* 0.5 K)))) U)
     (+
      U
      (*
       (+
        (* 0.0003968253968253968 (* J (pow l 7.0)))
        (+
         (* 0.016666666666666666 (* J (pow l 5.0)))
         (+ (* 0.3333333333333333 (* J (pow l 3.0))) (* 2.0 (* l J)))))
       (cos (/ K 2.0)))))))
double code(double J, double l, double K, double U) {
	double t_0 = exp(l) - exp(-l);
	double tmp;
	if (t_0 <= -0.1) {
		tmp = (J * (t_0 * cos((0.5 * K)))) + U;
	} else {
		tmp = U + (((0.0003968253968253968 * (J * pow(l, 7.0))) + ((0.016666666666666666 * (J * pow(l, 5.0))) + ((0.3333333333333333 * (J * pow(l, 3.0))) + (2.0 * (l * J))))) * cos((K / 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 = exp(l) - exp(-l)
    if (t_0 <= (-0.1d0)) then
        tmp = (j * (t_0 * cos((0.5d0 * k)))) + u
    else
        tmp = u + (((0.0003968253968253968d0 * (j * (l ** 7.0d0))) + ((0.016666666666666666d0 * (j * (l ** 5.0d0))) + ((0.3333333333333333d0 * (j * (l ** 3.0d0))) + (2.0d0 * (l * j))))) * cos((k / 2.0d0)))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = Math.exp(l) - Math.exp(-l);
	double tmp;
	if (t_0 <= -0.1) {
		tmp = (J * (t_0 * Math.cos((0.5 * K)))) + U;
	} else {
		tmp = U + (((0.0003968253968253968 * (J * Math.pow(l, 7.0))) + ((0.016666666666666666 * (J * Math.pow(l, 5.0))) + ((0.3333333333333333 * (J * Math.pow(l, 3.0))) + (2.0 * (l * J))))) * Math.cos((K / 2.0)));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.exp(l) - math.exp(-l)
	tmp = 0
	if t_0 <= -0.1:
		tmp = (J * (t_0 * math.cos((0.5 * K)))) + U
	else:
		tmp = U + (((0.0003968253968253968 * (J * math.pow(l, 7.0))) + ((0.016666666666666666 * (J * math.pow(l, 5.0))) + ((0.3333333333333333 * (J * math.pow(l, 3.0))) + (2.0 * (l * J))))) * math.cos((K / 2.0)))
	return tmp
function code(J, l, K, U)
	t_0 = Float64(exp(l) - exp(Float64(-l)))
	tmp = 0.0
	if (t_0 <= -0.1)
		tmp = Float64(Float64(J * Float64(t_0 * cos(Float64(0.5 * K)))) + U);
	else
		tmp = Float64(U + Float64(Float64(Float64(0.0003968253968253968 * Float64(J * (l ^ 7.0))) + Float64(Float64(0.016666666666666666 * Float64(J * (l ^ 5.0))) + Float64(Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))) + Float64(2.0 * Float64(l * J))))) * cos(Float64(K / 2.0))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = exp(l) - exp(-l);
	tmp = 0.0;
	if (t_0 <= -0.1)
		tmp = (J * (t_0 * cos((0.5 * K)))) + U;
	else
		tmp = U + (((0.0003968253968253968 * (J * (l ^ 7.0))) + ((0.016666666666666666 * (J * (l ^ 5.0))) + ((0.3333333333333333 * (J * (l ^ 3.0))) + (2.0 * (l * J))))) * cos((K / 2.0)));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.1], N[(N[(J * N[(t$95$0 * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[(N[(0.0003968253968253968 * N[(J * N[Power[l, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(0.016666666666666666 * N[(J * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_0 \leq -0.1:\\
\;\;\;\;J \cdot \left(t_0 \cdot \cos \left(0.5 \cdot K\right)\right) + U\\

\mathbf{else}:\\
\;\;\;\;U + \left(0.0003968253968253968 \cdot \left(J \cdot {\ell}^{7}\right) + \left(0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\right) + \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right) + 2 \cdot \left(\ell \cdot J\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -0.10000000000000001

    1. Initial program 99.9%

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

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

    if -0.10000000000000001 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

    1. Initial program 83.4%

      \[\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 97.9%

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

      \[\leadsto \color{blue}{\left(0.0003968253968253968 \cdot \left(J \cdot {\ell}^{7}\right) + \left(0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\right) + \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right) + 2 \cdot \left(J \cdot \ell\right)\right)\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{\ell} - e^{-\ell} \leq -0.1:\\ \;\;\;\;J \cdot \left(\left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(0.5 \cdot K\right)\right) + U\\ \mathbf{else}:\\ \;\;\;\;U + \left(0.0003968253968253968 \cdot \left(J \cdot {\ell}^{7}\right) + \left(0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\right) + \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right) + 2 \cdot \left(\ell \cdot J\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right)\\ \end{array} \]

Alternative 4: 97.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\ell} - e^{-\ell}\\ \mathbf{if}\;t_0 \leq -0.1:\\ \;\;\;\;J \cdot \left(t_0 \cdot \cos \left(0.5 \cdot K\right)\right) + U\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.0003968253968253968 \cdot {\ell}^{7} + \left(0.016666666666666666 \cdot {\ell}^{5} + \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (- (exp l) (exp (- l)))))
   (if (<= t_0 -0.1)
     (+ (* J (* t_0 (cos (* 0.5 K)))) U)
     (+
      U
      (*
       (cos (/ K 2.0))
       (*
        J
        (+
         (* 0.0003968253968253968 (pow l 7.0))
         (+
          (* 0.016666666666666666 (pow l 5.0))
          (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0))))))))))
double code(double J, double l, double K, double U) {
	double t_0 = exp(l) - exp(-l);
	double tmp;
	if (t_0 <= -0.1) {
		tmp = (J * (t_0 * cos((0.5 * K)))) + U;
	} else {
		tmp = U + (cos((K / 2.0)) * (J * ((0.0003968253968253968 * pow(l, 7.0)) + ((0.016666666666666666 * pow(l, 5.0)) + ((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) :: tmp
    t_0 = exp(l) - exp(-l)
    if (t_0 <= (-0.1d0)) then
        tmp = (j * (t_0 * cos((0.5d0 * k)))) + u
    else
        tmp = u + (cos((k / 2.0d0)) * (j * ((0.0003968253968253968d0 * (l ** 7.0d0)) + ((0.016666666666666666d0 * (l ** 5.0d0)) + ((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.exp(l) - Math.exp(-l);
	double tmp;
	if (t_0 <= -0.1) {
		tmp = (J * (t_0 * Math.cos((0.5 * K)))) + U;
	} else {
		tmp = U + (Math.cos((K / 2.0)) * (J * ((0.0003968253968253968 * Math.pow(l, 7.0)) + ((0.016666666666666666 * Math.pow(l, 5.0)) + ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))))));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.exp(l) - math.exp(-l)
	tmp = 0
	if t_0 <= -0.1:
		tmp = (J * (t_0 * math.cos((0.5 * K)))) + U
	else:
		tmp = U + (math.cos((K / 2.0)) * (J * ((0.0003968253968253968 * math.pow(l, 7.0)) + ((0.016666666666666666 * math.pow(l, 5.0)) + ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))))))
	return tmp
function code(J, l, K, U)
	t_0 = Float64(exp(l) - exp(Float64(-l)))
	tmp = 0.0
	if (t_0 <= -0.1)
		tmp = Float64(Float64(J * Float64(t_0 * cos(Float64(0.5 * K)))) + U);
	else
		tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(Float64(0.0003968253968253968 * (l ^ 7.0)) + Float64(Float64(0.016666666666666666 * (l ^ 5.0)) + 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 = exp(l) - exp(-l);
	tmp = 0.0;
	if (t_0 <= -0.1)
		tmp = (J * (t_0 * cos((0.5 * K)))) + U;
	else
		tmp = U + (cos((K / 2.0)) * (J * ((0.0003968253968253968 * (l ^ 7.0)) + ((0.016666666666666666 * (l ^ 5.0)) + ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0))))));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.1], N[(N[(J * N[(t$95$0 * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(N[(0.0003968253968253968 * N[Power[l, 7.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.016666666666666666 * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_0 \leq -0.1:\\
\;\;\;\;J \cdot \left(t_0 \cdot \cos \left(0.5 \cdot K\right)\right) + U\\

\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.0003968253968253968 \cdot {\ell}^{7} + \left(0.016666666666666666 \cdot {\ell}^{5} + \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -0.10000000000000001

    1. Initial program 99.9%

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

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

    if -0.10000000000000001 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

    1. Initial program 83.4%

      \[\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 97.9%

      \[\leadsto \left(J \cdot \color{blue}{\left(0.0003968253968253968 \cdot {\ell}^{7} + \left(0.016666666666666666 \cdot {\ell}^{5} + \left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{\ell} - e^{-\ell} \leq -0.1:\\ \;\;\;\;J \cdot \left(\left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(0.5 \cdot K\right)\right) + U\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.0003968253968253968 \cdot {\ell}^{7} + \left(0.016666666666666666 \cdot {\ell}^{5} + \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\right)\right)\\ \end{array} \]

Alternative 5: 86.5% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;t_0 \leq -2 \cdot 10^{-40} \lor \neg \left(t_0 \leq 2 \cdot 10^{+46}\right):\\
\;\;\;\;U + t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < -1.9999999999999999e-40 or 2e46 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))))

    1. Initial program 99.9%

      \[\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 72.4%

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

    if -1.9999999999999999e-40 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < 2e46

    1. Initial program 76.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 99.4%

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

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

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

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

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

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

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

Alternative 6: 96.2% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ t_1 := U + t_0 \cdot \left({\ell}^{7} \cdot \left(J \cdot 0.0003968253968253968\right)\right)\\ \mathbf{if}\;\ell \leq -2.15 \cdot 10^{+49}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\ell \leq -0.4:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{elif}\;\ell \leq 5.5:\\ \;\;\;\;U + t_0 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0)))
        (t_1 (+ U (* t_0 (* (pow l 7.0) (* J 0.0003968253968253968))))))
   (if (<= l -2.15e+49)
     t_1
     (if (<= l -0.4)
       (+ U (* (- (exp l) (exp (- l))) J))
       (if (<= l 5.5)
         (+ U (* t_0 (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
         t_1)))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K / 2.0));
	double t_1 = U + (t_0 * (pow(l, 7.0) * (J * 0.0003968253968253968)));
	double tmp;
	if (l <= -2.15e+49) {
		tmp = t_1;
	} else if (l <= -0.4) {
		tmp = U + ((exp(l) - exp(-l)) * J);
	} else if (l <= 5.5) {
		tmp = U + (t_0 * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = cos((k / 2.0d0))
    t_1 = u + (t_0 * ((l ** 7.0d0) * (j * 0.0003968253968253968d0)))
    if (l <= (-2.15d+49)) then
        tmp = t_1
    else if (l <= (-0.4d0)) then
        tmp = u + ((exp(l) - exp(-l)) * j)
    else if (l <= 5.5d0) then
        tmp = u + (t_0 * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
    else
        tmp = t_1
    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 + (t_0 * (Math.pow(l, 7.0) * (J * 0.0003968253968253968)));
	double tmp;
	if (l <= -2.15e+49) {
		tmp = t_1;
	} else if (l <= -0.4) {
		tmp = U + ((Math.exp(l) - Math.exp(-l)) * J);
	} else if (l <= 5.5) {
		tmp = U + (t_0 * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K / 2.0))
	t_1 = U + (t_0 * (math.pow(l, 7.0) * (J * 0.0003968253968253968)))
	tmp = 0
	if l <= -2.15e+49:
		tmp = t_1
	elif l <= -0.4:
		tmp = U + ((math.exp(l) - math.exp(-l)) * J)
	elif l <= 5.5:
		tmp = U + (t_0 * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))))
	else:
		tmp = t_1
	return tmp
function code(J, l, K, U)
	t_0 = cos(Float64(K / 2.0))
	t_1 = Float64(U + Float64(t_0 * Float64((l ^ 7.0) * Float64(J * 0.0003968253968253968))))
	tmp = 0.0
	if (l <= -2.15e+49)
		tmp = t_1;
	elseif (l <= -0.4)
		tmp = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J));
	elseif (l <= 5.5)
		tmp = Float64(U + Float64(t_0 * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)))));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = cos((K / 2.0));
	t_1 = U + (t_0 * ((l ^ 7.0) * (J * 0.0003968253968253968)));
	tmp = 0.0;
	if (l <= -2.15e+49)
		tmp = t_1;
	elseif (l <= -0.4)
		tmp = U + ((exp(l) - exp(-l)) * J);
	elseif (l <= 5.5)
		tmp = U + (t_0 * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0))));
	else
		tmp = t_1;
	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[(t$95$0 * N[(N[Power[l, 7.0], $MachinePrecision] * N[(J * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.15e+49], t$95$1, If[LessEqual[l, -0.4], N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5.5], 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], t$95$1]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := U + t_0 \cdot \left({\ell}^{7} \cdot \left(J \cdot 0.0003968253968253968\right)\right)\\
\mathbf{if}\;\ell \leq -2.15 \cdot 10^{+49}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;\ell \leq -0.4:\\
\;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\

\mathbf{elif}\;\ell \leq 5.5:\\
\;\;\;\;U + t_0 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -2.15e49 or 5.5 < 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 96.3%

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

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

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

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

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

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

    if -2.15e49 < l < -0.40000000000000002

    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 K around 0 75.0%

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

    if -0.40000000000000002 < l < 5.5

    1. Initial program 77.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 98.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. Recombined 3 regimes into one program.
  4. Final simplification96.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.15 \cdot 10^{+49}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{7} \cdot \left(J \cdot 0.0003968253968253968\right)\right)\\ \mathbf{elif}\;\ell \leq -0.4:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{elif}\;\ell \leq 5.5:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{7} \cdot \left(J \cdot 0.0003968253968253968\right)\right)\\ \end{array} \]

Alternative 7: 96.0% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{7} \cdot \left(J \cdot 0.0003968253968253968\right)\right)\\ \mathbf{if}\;\ell \leq -2.15 \cdot 10^{+49}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -0.0024:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{elif}\;\ell \leq 4.2:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(\cos \left(0.5 \cdot K\right) \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0
         (+
          U
          (* (cos (/ K 2.0)) (* (pow l 7.0) (* J 0.0003968253968253968))))))
   (if (<= l -2.15e+49)
     t_0
     (if (<= l -0.0024)
       (+ U (* (- (exp l) (exp (- l))) J))
       (if (<= l 4.2) (+ U (* (* l J) (* (cos (* 0.5 K)) 2.0))) t_0)))))
double code(double J, double l, double K, double U) {
	double t_0 = U + (cos((K / 2.0)) * (pow(l, 7.0) * (J * 0.0003968253968253968)));
	double tmp;
	if (l <= -2.15e+49) {
		tmp = t_0;
	} else if (l <= -0.0024) {
		tmp = U + ((exp(l) - exp(-l)) * J);
	} else if (l <= 4.2) {
		tmp = U + ((l * J) * (cos((0.5 * K)) * 2.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: t_0
    real(8) :: tmp
    t_0 = u + (cos((k / 2.0d0)) * ((l ** 7.0d0) * (j * 0.0003968253968253968d0)))
    if (l <= (-2.15d+49)) then
        tmp = t_0
    else if (l <= (-0.0024d0)) then
        tmp = u + ((exp(l) - exp(-l)) * j)
    else if (l <= 4.2d0) then
        tmp = u + ((l * j) * (cos((0.5d0 * k)) * 2.0d0))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = U + (Math.cos((K / 2.0)) * (Math.pow(l, 7.0) * (J * 0.0003968253968253968)));
	double tmp;
	if (l <= -2.15e+49) {
		tmp = t_0;
	} else if (l <= -0.0024) {
		tmp = U + ((Math.exp(l) - Math.exp(-l)) * J);
	} else if (l <= 4.2) {
		tmp = U + ((l * J) * (Math.cos((0.5 * K)) * 2.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = U + (math.cos((K / 2.0)) * (math.pow(l, 7.0) * (J * 0.0003968253968253968)))
	tmp = 0
	if l <= -2.15e+49:
		tmp = t_0
	elif l <= -0.0024:
		tmp = U + ((math.exp(l) - math.exp(-l)) * J)
	elif l <= 4.2:
		tmp = U + ((l * J) * (math.cos((0.5 * K)) * 2.0))
	else:
		tmp = t_0
	return tmp
function code(J, l, K, U)
	t_0 = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64((l ^ 7.0) * Float64(J * 0.0003968253968253968))))
	tmp = 0.0
	if (l <= -2.15e+49)
		tmp = t_0;
	elseif (l <= -0.0024)
		tmp = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J));
	elseif (l <= 4.2)
		tmp = Float64(U + Float64(Float64(l * J) * Float64(cos(Float64(0.5 * K)) * 2.0)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = U + (cos((K / 2.0)) * ((l ^ 7.0) * (J * 0.0003968253968253968)));
	tmp = 0.0;
	if (l <= -2.15e+49)
		tmp = t_0;
	elseif (l <= -0.0024)
		tmp = U + ((exp(l) - exp(-l)) * J);
	elseif (l <= 4.2)
		tmp = U + ((l * J) * (cos((0.5 * K)) * 2.0));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[Power[l, 7.0], $MachinePrecision] * N[(J * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.15e+49], t$95$0, If[LessEqual[l, -0.0024], N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 4.2], N[(U + N[(N[(l * J), $MachinePrecision] * N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{7} \cdot \left(J \cdot 0.0003968253968253968\right)\right)\\
\mathbf{if}\;\ell \leq -2.15 \cdot 10^{+49}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq -0.0024:\\
\;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\

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

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -2.15e49 or 4.20000000000000018 < 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 96.3%

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

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

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

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

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

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

    if -2.15e49 < l < -0.00239999999999999979

    1. Initial program 99.4%

      \[\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 70.0%

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

    if -0.00239999999999999979 < l < 4.20000000000000018

    1. Initial program 77.4%

      \[\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 99.5%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.15 \cdot 10^{+49}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{7} \cdot \left(J \cdot 0.0003968253968253968\right)\right)\\ \mathbf{elif}\;\ell \leq -0.0024:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{elif}\;\ell \leq 4.2:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(\cos \left(0.5 \cdot K\right) \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{7} \cdot \left(J \cdot 0.0003968253968253968\right)\right)\\ \end{array} \]

Alternative 8: 67.7% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{log1p}\left(\mathsf{expm1}\left(U\right)\right)\\ t_1 := U + J \cdot \left(\ell \cdot 2 + \left(\ell \cdot {K}^{2}\right) \cdot -0.25\right)\\ \mathbf{if}\;\ell \leq -7.8 \cdot 10^{+158}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\ell \leq -620000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq 550:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(\cos \left(0.5 \cdot K\right) \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 4 \cdot 10^{+141}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (log1p (expm1 U)))
        (t_1 (+ U (* J (+ (* l 2.0) (* (* l (pow K 2.0)) -0.25))))))
   (if (<= l -7.8e+158)
     t_1
     (if (<= l -620000.0)
       t_0
       (if (<= l 550.0)
         (+ U (* (* l J) (* (cos (* 0.5 K)) 2.0)))
         (if (<= l 4e+141) t_0 t_1))))))
double code(double J, double l, double K, double U) {
	double t_0 = log1p(expm1(U));
	double t_1 = U + (J * ((l * 2.0) + ((l * pow(K, 2.0)) * -0.25)));
	double tmp;
	if (l <= -7.8e+158) {
		tmp = t_1;
	} else if (l <= -620000.0) {
		tmp = t_0;
	} else if (l <= 550.0) {
		tmp = U + ((l * J) * (cos((0.5 * K)) * 2.0));
	} else if (l <= 4e+141) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double J, double l, double K, double U) {
	double t_0 = Math.log1p(Math.expm1(U));
	double t_1 = U + (J * ((l * 2.0) + ((l * Math.pow(K, 2.0)) * -0.25)));
	double tmp;
	if (l <= -7.8e+158) {
		tmp = t_1;
	} else if (l <= -620000.0) {
		tmp = t_0;
	} else if (l <= 550.0) {
		tmp = U + ((l * J) * (Math.cos((0.5 * K)) * 2.0));
	} else if (l <= 4e+141) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.log1p(math.expm1(U))
	t_1 = U + (J * ((l * 2.0) + ((l * math.pow(K, 2.0)) * -0.25)))
	tmp = 0
	if l <= -7.8e+158:
		tmp = t_1
	elif l <= -620000.0:
		tmp = t_0
	elif l <= 550.0:
		tmp = U + ((l * J) * (math.cos((0.5 * K)) * 2.0))
	elif l <= 4e+141:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(J, l, K, U)
	t_0 = log1p(expm1(U))
	t_1 = Float64(U + Float64(J * Float64(Float64(l * 2.0) + Float64(Float64(l * (K ^ 2.0)) * -0.25))))
	tmp = 0.0
	if (l <= -7.8e+158)
		tmp = t_1;
	elseif (l <= -620000.0)
		tmp = t_0;
	elseif (l <= 550.0)
		tmp = Float64(U + Float64(Float64(l * J) * Float64(cos(Float64(0.5 * K)) * 2.0)));
	elseif (l <= 4e+141)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Log[1 + N[(Exp[U] - 1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(J * N[(N[(l * 2.0), $MachinePrecision] + N[(N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -7.8e+158], t$95$1, If[LessEqual[l, -620000.0], t$95$0, If[LessEqual[l, 550.0], N[(U + N[(N[(l * J), $MachinePrecision] * N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 4e+141], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{log1p}\left(\mathsf{expm1}\left(U\right)\right)\\
t_1 := U + J \cdot \left(\ell \cdot 2 + \left(\ell \cdot {K}^{2}\right) \cdot -0.25\right)\\
\mathbf{if}\;\ell \leq -7.8 \cdot 10^{+158}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;\ell \leq -620000:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;\ell \leq 4 \cdot 10^{+141}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -7.8e158 or 4.00000000000000007e141 < 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 41.2%

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(J \cdot \ell, \cos \left(0.5 \cdot K\right) \cdot 2, U\right)} \]
      6. *-commutative41.2%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\ell \cdot J}, \cos \left(0.5 \cdot K\right) \cdot 2, U\right) \]
      7. *-commutative41.2%

        \[\leadsto \mathsf{fma}\left(\ell \cdot J, \color{blue}{2 \cdot \cos \left(0.5 \cdot K\right)}, U\right) \]
    4. Simplified41.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\ell \cdot J, 2 \cdot \cos \left(0.5 \cdot K\right), U\right)} \]
    5. Taylor expanded in K around 0 34.2%

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

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

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

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

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

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

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

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

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

    if -7.8e158 < l < -6.2e5 or 550 < l < 4.00000000000000007e141

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(U\right)\right)} \]

    if -6.2e5 < l < 550

    1. Initial program 77.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 97.4%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -7.8 \cdot 10^{+158}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2 + \left(\ell \cdot {K}^{2}\right) \cdot -0.25\right)\\ \mathbf{elif}\;\ell \leq -620000:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(U\right)\right)\\ \mathbf{elif}\;\ell \leq 550:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(\cos \left(0.5 \cdot K\right) \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 4 \cdot 10^{+141}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(U\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2 + \left(\ell \cdot {K}^{2}\right) \cdot -0.25\right)\\ \end{array} \]

Alternative 9: 67.0% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := U + J \cdot \left(\ell \cdot 2 + \left(\ell \cdot {K}^{2}\right) \cdot -0.25\right)\\ \mathbf{if}\;\ell \leq -1.9 \cdot 10^{+58}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -2 \cdot 10^{+17}:\\ \;\;\;\;{U}^{-3}\\ \mathbf{elif}\;\ell \leq 0.01:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(\cos \left(0.5 \cdot K\right) \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (+ U (* J (+ (* l 2.0) (* (* l (pow K 2.0)) -0.25))))))
   (if (<= l -1.9e+58)
     t_0
     (if (<= l -2e+17)
       (pow U -3.0)
       (if (<= l 0.01) (+ U (* (* l J) (* (cos (* 0.5 K)) 2.0))) t_0)))))
double code(double J, double l, double K, double U) {
	double t_0 = U + (J * ((l * 2.0) + ((l * pow(K, 2.0)) * -0.25)));
	double tmp;
	if (l <= -1.9e+58) {
		tmp = t_0;
	} else if (l <= -2e+17) {
		tmp = pow(U, -3.0);
	} else if (l <= 0.01) {
		tmp = U + ((l * J) * (cos((0.5 * K)) * 2.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: t_0
    real(8) :: tmp
    t_0 = u + (j * ((l * 2.0d0) + ((l * (k ** 2.0d0)) * (-0.25d0))))
    if (l <= (-1.9d+58)) then
        tmp = t_0
    else if (l <= (-2d+17)) then
        tmp = u ** (-3.0d0)
    else if (l <= 0.01d0) then
        tmp = u + ((l * j) * (cos((0.5d0 * k)) * 2.0d0))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = U + (J * ((l * 2.0) + ((l * Math.pow(K, 2.0)) * -0.25)));
	double tmp;
	if (l <= -1.9e+58) {
		tmp = t_0;
	} else if (l <= -2e+17) {
		tmp = Math.pow(U, -3.0);
	} else if (l <= 0.01) {
		tmp = U + ((l * J) * (Math.cos((0.5 * K)) * 2.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = U + (J * ((l * 2.0) + ((l * math.pow(K, 2.0)) * -0.25)))
	tmp = 0
	if l <= -1.9e+58:
		tmp = t_0
	elif l <= -2e+17:
		tmp = math.pow(U, -3.0)
	elif l <= 0.01:
		tmp = U + ((l * J) * (math.cos((0.5 * K)) * 2.0))
	else:
		tmp = t_0
	return tmp
function code(J, l, K, U)
	t_0 = Float64(U + Float64(J * Float64(Float64(l * 2.0) + Float64(Float64(l * (K ^ 2.0)) * -0.25))))
	tmp = 0.0
	if (l <= -1.9e+58)
		tmp = t_0;
	elseif (l <= -2e+17)
		tmp = U ^ -3.0;
	elseif (l <= 0.01)
		tmp = Float64(U + Float64(Float64(l * J) * Float64(cos(Float64(0.5 * K)) * 2.0)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = U + (J * ((l * 2.0) + ((l * (K ^ 2.0)) * -0.25)));
	tmp = 0.0;
	if (l <= -1.9e+58)
		tmp = t_0;
	elseif (l <= -2e+17)
		tmp = U ^ -3.0;
	elseif (l <= 0.01)
		tmp = U + ((l * J) * (cos((0.5 * K)) * 2.0));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(J * N[(N[(l * 2.0), $MachinePrecision] + N[(N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.9e+58], t$95$0, If[LessEqual[l, -2e+17], N[Power[U, -3.0], $MachinePrecision], If[LessEqual[l, 0.01], N[(U + N[(N[(l * J), $MachinePrecision] * N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := U + J \cdot \left(\ell \cdot 2 + \left(\ell \cdot {K}^{2}\right) \cdot -0.25\right)\\
\mathbf{if}\;\ell \leq -1.9 \cdot 10^{+58}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq -2 \cdot 10^{+17}:\\
\;\;\;\;{U}^{-3}\\

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

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -1.8999999999999999e58 or 0.0100000000000000002 < l

    1. Initial program 99.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 30.2%

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(J \cdot \ell, \cos \left(0.5 \cdot K\right) \cdot 2, U\right)} \]
      6. *-commutative30.2%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\ell \cdot J}, \cos \left(0.5 \cdot K\right) \cdot 2, U\right) \]
      7. *-commutative30.2%

        \[\leadsto \mathsf{fma}\left(\ell \cdot J, \color{blue}{2 \cdot \cos \left(0.5 \cdot K\right)}, U\right) \]
    4. Simplified30.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\ell \cdot J, 2 \cdot \cos \left(0.5 \cdot K\right), U\right)} \]
    5. Taylor expanded in K around 0 30.6%

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

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

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

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

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

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

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

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

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

    if -1.8999999999999999e58 < l < -2e17

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{{U}^{-3}} \]

    if -2e17 < l < 0.0100000000000000002

    1. Initial program 78.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 95.8%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.9 \cdot 10^{+58}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2 + \left(\ell \cdot {K}^{2}\right) \cdot -0.25\right)\\ \mathbf{elif}\;\ell \leq -2 \cdot 10^{+17}:\\ \;\;\;\;{U}^{-3}\\ \mathbf{elif}\;\ell \leq 0.01:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(\cos \left(0.5 \cdot K\right) \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2 + \left(\ell \cdot {K}^{2}\right) \cdot -0.25\right)\\ \end{array} \]

Alternative 10: 66.0% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 2 \cdot \left(\ell \cdot \left(J + -0.125 \cdot \left(J \cdot {K}^{2}\right)\right)\right)\\ \mathbf{if}\;\ell \leq -3.7 \cdot 10^{+86}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -2 \cdot 10^{+17}:\\ \;\;\;\;{U}^{-3}\\ \mathbf{elif}\;\ell \leq 2450:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(\cos \left(0.5 \cdot K\right) \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (* 2.0 (* l (+ J (* -0.125 (* J (pow K 2.0))))))))
   (if (<= l -3.7e+86)
     t_0
     (if (<= l -2e+17)
       (pow U -3.0)
       (if (<= l 2450.0) (+ U (* (* l J) (* (cos (* 0.5 K)) 2.0))) t_0)))))
double code(double J, double l, double K, double U) {
	double t_0 = 2.0 * (l * (J + (-0.125 * (J * pow(K, 2.0)))));
	double tmp;
	if (l <= -3.7e+86) {
		tmp = t_0;
	} else if (l <= -2e+17) {
		tmp = pow(U, -3.0);
	} else if (l <= 2450.0) {
		tmp = U + ((l * J) * (cos((0.5 * K)) * 2.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 2.0d0 * (l * (j + ((-0.125d0) * (j * (k ** 2.0d0)))))
    if (l <= (-3.7d+86)) then
        tmp = t_0
    else if (l <= (-2d+17)) then
        tmp = u ** (-3.0d0)
    else if (l <= 2450.0d0) then
        tmp = u + ((l * j) * (cos((0.5d0 * k)) * 2.0d0))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = 2.0 * (l * (J + (-0.125 * (J * Math.pow(K, 2.0)))));
	double tmp;
	if (l <= -3.7e+86) {
		tmp = t_0;
	} else if (l <= -2e+17) {
		tmp = Math.pow(U, -3.0);
	} else if (l <= 2450.0) {
		tmp = U + ((l * J) * (Math.cos((0.5 * K)) * 2.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = 2.0 * (l * (J + (-0.125 * (J * math.pow(K, 2.0)))))
	tmp = 0
	if l <= -3.7e+86:
		tmp = t_0
	elif l <= -2e+17:
		tmp = math.pow(U, -3.0)
	elif l <= 2450.0:
		tmp = U + ((l * J) * (math.cos((0.5 * K)) * 2.0))
	else:
		tmp = t_0
	return tmp
function code(J, l, K, U)
	t_0 = Float64(2.0 * Float64(l * Float64(J + Float64(-0.125 * Float64(J * (K ^ 2.0))))))
	tmp = 0.0
	if (l <= -3.7e+86)
		tmp = t_0;
	elseif (l <= -2e+17)
		tmp = U ^ -3.0;
	elseif (l <= 2450.0)
		tmp = Float64(U + Float64(Float64(l * J) * Float64(cos(Float64(0.5 * K)) * 2.0)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = 2.0 * (l * (J + (-0.125 * (J * (K ^ 2.0)))));
	tmp = 0.0;
	if (l <= -3.7e+86)
		tmp = t_0;
	elseif (l <= -2e+17)
		tmp = U ^ -3.0;
	elseif (l <= 2450.0)
		tmp = U + ((l * J) * (cos((0.5 * K)) * 2.0));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(2.0 * N[(l * N[(J + N[(-0.125 * N[(J * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.7e+86], t$95$0, If[LessEqual[l, -2e+17], N[Power[U, -3.0], $MachinePrecision], If[LessEqual[l, 2450.0], N[(U + N[(N[(l * J), $MachinePrecision] * N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 2 \cdot \left(\ell \cdot \left(J + -0.125 \cdot \left(J \cdot {K}^{2}\right)\right)\right)\\
\mathbf{if}\;\ell \leq -3.7 \cdot 10^{+86}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq -2 \cdot 10^{+17}:\\
\;\;\;\;{U}^{-3}\\

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

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -3.69999999999999992e86 or 2450 < 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 30.0%

      \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right)} \]
    3. Step-by-step derivation
      1. +-commutative30.0%

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(J \cdot \ell, \cos \left(0.5 \cdot K\right) \cdot 2, U\right)} \]
      6. *-commutative30.0%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\ell \cdot J}, \cos \left(0.5 \cdot K\right) \cdot 2, U\right) \]
      7. *-commutative30.0%

        \[\leadsto \mathsf{fma}\left(\ell \cdot J, \color{blue}{2 \cdot \cos \left(0.5 \cdot K\right)}, U\right) \]
    4. Simplified30.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\ell \cdot J, 2 \cdot \cos \left(0.5 \cdot K\right), U\right)} \]
    5. Taylor expanded in l around inf 29.9%

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

        \[\leadsto 2 \cdot \color{blue}{\left(\left(J \cdot \ell\right) \cdot \cos \left(0.5 \cdot K\right)\right)} \]
    7. Simplified29.9%

      \[\leadsto \color{blue}{2 \cdot \left(\left(J \cdot \ell\right) \cdot \cos \left(0.5 \cdot K\right)\right)} \]
    8. Taylor expanded in K around 0 30.4%

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

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

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

        \[\leadsto 2 \cdot \left(J \cdot \ell + \color{blue}{\left(-0.125 \cdot \left(J \cdot {K}^{2}\right)\right) \cdot \ell}\right) \]
      4. distribute-rgt-out39.0%

        \[\leadsto 2 \cdot \color{blue}{\left(\ell \cdot \left(J + -0.125 \cdot \left(J \cdot {K}^{2}\right)\right)\right)} \]
    10. Simplified39.0%

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

    if -3.69999999999999992e86 < l < -2e17

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{{U}^{-3}} \]

    if -2e17 < l < 2450

    1. Initial program 78.5%

      \[\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.8%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.7 \cdot 10^{+86}:\\ \;\;\;\;2 \cdot \left(\ell \cdot \left(J + -0.125 \cdot \left(J \cdot {K}^{2}\right)\right)\right)\\ \mathbf{elif}\;\ell \leq -2 \cdot 10^{+17}:\\ \;\;\;\;{U}^{-3}\\ \mathbf{elif}\;\ell \leq 2450:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(\cos \left(0.5 \cdot K\right) \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\ell \cdot \left(J + -0.125 \cdot \left(J \cdot {K}^{2}\right)\right)\right)\\ \end{array} \]

Alternative 11: 56.9% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 2 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot J\right)\right)\\ \mathbf{if}\;\ell \leq -2.1 \cdot 10^{+62}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -2.2 \cdot 10^{+17}:\\ \;\;\;\;{U}^{-3}\\ \mathbf{elif}\;\ell \leq 2450:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\ \mathbf{elif}\;\ell \leq 1.9 \cdot 10^{+199}:\\ \;\;\;\;{U}^{-3}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (* 2.0 (* (cos (* 0.5 K)) (* l J)))))
   (if (<= l -2.1e+62)
     t_0
     (if (<= l -2.2e+17)
       (pow U -3.0)
       (if (<= l 2450.0)
         (+ U (* 2.0 (* l J)))
         (if (<= l 1.9e+199) (pow U -3.0) t_0))))))
double code(double J, double l, double K, double U) {
	double t_0 = 2.0 * (cos((0.5 * K)) * (l * J));
	double tmp;
	if (l <= -2.1e+62) {
		tmp = t_0;
	} else if (l <= -2.2e+17) {
		tmp = pow(U, -3.0);
	} else if (l <= 2450.0) {
		tmp = U + (2.0 * (l * J));
	} else if (l <= 1.9e+199) {
		tmp = pow(U, -3.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 2.0d0 * (cos((0.5d0 * k)) * (l * j))
    if (l <= (-2.1d+62)) then
        tmp = t_0
    else if (l <= (-2.2d+17)) then
        tmp = u ** (-3.0d0)
    else if (l <= 2450.0d0) then
        tmp = u + (2.0d0 * (l * j))
    else if (l <= 1.9d+199) then
        tmp = u ** (-3.0d0)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = 2.0 * (Math.cos((0.5 * K)) * (l * J));
	double tmp;
	if (l <= -2.1e+62) {
		tmp = t_0;
	} else if (l <= -2.2e+17) {
		tmp = Math.pow(U, -3.0);
	} else if (l <= 2450.0) {
		tmp = U + (2.0 * (l * J));
	} else if (l <= 1.9e+199) {
		tmp = Math.pow(U, -3.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = 2.0 * (math.cos((0.5 * K)) * (l * J))
	tmp = 0
	if l <= -2.1e+62:
		tmp = t_0
	elif l <= -2.2e+17:
		tmp = math.pow(U, -3.0)
	elif l <= 2450.0:
		tmp = U + (2.0 * (l * J))
	elif l <= 1.9e+199:
		tmp = math.pow(U, -3.0)
	else:
		tmp = t_0
	return tmp
function code(J, l, K, U)
	t_0 = Float64(2.0 * Float64(cos(Float64(0.5 * K)) * Float64(l * J)))
	tmp = 0.0
	if (l <= -2.1e+62)
		tmp = t_0;
	elseif (l <= -2.2e+17)
		tmp = U ^ -3.0;
	elseif (l <= 2450.0)
		tmp = Float64(U + Float64(2.0 * Float64(l * J)));
	elseif (l <= 1.9e+199)
		tmp = U ^ -3.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = 2.0 * (cos((0.5 * K)) * (l * J));
	tmp = 0.0;
	if (l <= -2.1e+62)
		tmp = t_0;
	elseif (l <= -2.2e+17)
		tmp = U ^ -3.0;
	elseif (l <= 2450.0)
		tmp = U + (2.0 * (l * J));
	elseif (l <= 1.9e+199)
		tmp = U ^ -3.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(2.0 * N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.1e+62], t$95$0, If[LessEqual[l, -2.2e+17], N[Power[U, -3.0], $MachinePrecision], If[LessEqual[l, 2450.0], N[(U + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.9e+199], N[Power[U, -3.0], $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 2 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot J\right)\right)\\
\mathbf{if}\;\ell \leq -2.1 \cdot 10^{+62}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq -2.2 \cdot 10^{+17}:\\
\;\;\;\;{U}^{-3}\\

\mathbf{elif}\;\ell \leq 2450:\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\

\mathbf{elif}\;\ell \leq 1.9 \cdot 10^{+199}:\\
\;\;\;\;{U}^{-3}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -2.1e62 or 1.9e199 < 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 36.5%

      \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right)} \]
    3. Step-by-step derivation
      1. +-commutative36.5%

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(J \cdot \ell, \cos \left(0.5 \cdot K\right) \cdot 2, U\right)} \]
      6. *-commutative36.5%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\ell \cdot J}, \cos \left(0.5 \cdot K\right) \cdot 2, U\right) \]
      7. *-commutative36.5%

        \[\leadsto \mathsf{fma}\left(\ell \cdot J, \color{blue}{2 \cdot \cos \left(0.5 \cdot K\right)}, U\right) \]
    4. Simplified36.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\ell \cdot J, 2 \cdot \cos \left(0.5 \cdot K\right), U\right)} \]
    5. Taylor expanded in l around inf 36.3%

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

        \[\leadsto 2 \cdot \color{blue}{\left(\left(J \cdot \ell\right) \cdot \cos \left(0.5 \cdot K\right)\right)} \]
    7. Simplified36.3%

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

    if -2.1e62 < l < -2.2e17 or 2450 < l < 1.9e199

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{{U}^{-3}} \]

    if -2.2e17 < l < 2450

    1. Initial program 78.5%

      \[\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.8%

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

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

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

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

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

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

      \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \ell\right)} \]
    6. Step-by-step derivation
      1. +-commutative81.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.1 \cdot 10^{+62}:\\ \;\;\;\;2 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot J\right)\right)\\ \mathbf{elif}\;\ell \leq -2.2 \cdot 10^{+17}:\\ \;\;\;\;{U}^{-3}\\ \mathbf{elif}\;\ell \leq 2450:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\ \mathbf{elif}\;\ell \leq 1.9 \cdot 10^{+199}:\\ \;\;\;\;{U}^{-3}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot J\right)\right)\\ \end{array} \]

Alternative 12: 63.4% accurate, 2.8× speedup?

\[\begin{array}{l} \\ U + \ell \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(J \cdot 2\right)\right) \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (+ U (* l (* (cos (* 0.5 K)) (* J 2.0)))))
double code(double J, double l, double K, double U) {
	return U + (l * (cos((0.5 * K)) * (J * 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 + (l * (cos((0.5d0 * k)) * (j * 2.0d0)))
end function
public static double code(double J, double l, double K, double U) {
	return U + (l * (Math.cos((0.5 * K)) * (J * 2.0)));
}
def code(J, l, K, U):
	return U + (l * (math.cos((0.5 * K)) * (J * 2.0)))
function code(J, l, K, U)
	return Float64(U + Float64(l * Float64(cos(Float64(0.5 * K)) * Float64(J * 2.0))))
end
function tmp = code(J, l, K, U)
	tmp = U + (l * (cos((0.5 * K)) * (J * 2.0)));
end
code[J_, l_, K_, U_] := N[(U + N[(l * N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
U + \ell \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(J \cdot 2\right)\right)
\end{array}
Derivation
  1. Initial program 87.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 65.1%

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

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

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

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

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

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

Alternative 13: 63.4% accurate, 2.8× speedup?

\[\begin{array}{l} \\ U + \left(\ell \cdot J\right) \cdot \left(\cos \left(0.5 \cdot K\right) \cdot 2\right) \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (+ U (* (* l J) (* (cos (* 0.5 K)) 2.0))))
double code(double J, double l, double K, double U) {
	return U + ((l * J) * (cos((0.5 * K)) * 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 + ((l * j) * (cos((0.5d0 * k)) * 2.0d0))
end function
public static double code(double J, double l, double K, double U) {
	return U + ((l * J) * (Math.cos((0.5 * K)) * 2.0));
}
def code(J, l, K, U):
	return U + ((l * J) * (math.cos((0.5 * K)) * 2.0))
function code(J, l, K, U)
	return Float64(U + Float64(Float64(l * J) * Float64(cos(Float64(0.5 * K)) * 2.0)))
end
function tmp = code(J, l, K, U)
	tmp = U + ((l * J) * (cos((0.5 * K)) * 2.0));
end
code[J_, l_, K_, U_] := N[(U + N[(N[(l * J), $MachinePrecision] * N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
U + \left(\ell \cdot J\right) \cdot \left(\cos \left(0.5 \cdot K\right) \cdot 2\right)
\end{array}
Derivation
  1. Initial program 87.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 65.1%

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

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

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

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

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

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

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

Alternative 14: 53.0% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2.9 \cdot 10^{+25}:\\ \;\;\;\;{U}^{-4}\\ \mathbf{elif}\;\ell \leq 220000 \lor \neg \left(\ell \leq 1.9 \cdot 10^{+243}\right):\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\ \mathbf{else}:\\ \;\;\;\;{U}^{-3}\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -2.9e+25)
   (pow U -4.0)
   (if (or (<= l 220000.0) (not (<= l 1.9e+243)))
     (+ U (* 2.0 (* l J)))
     (pow U -3.0))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -2.9e+25) {
		tmp = pow(U, -4.0);
	} else if ((l <= 220000.0) || !(l <= 1.9e+243)) {
		tmp = U + (2.0 * (l * J));
	} else {
		tmp = pow(U, -3.0);
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: tmp
    if (l <= (-2.9d+25)) then
        tmp = u ** (-4.0d0)
    else if ((l <= 220000.0d0) .or. (.not. (l <= 1.9d+243))) then
        tmp = u + (2.0d0 * (l * j))
    else
        tmp = u ** (-3.0d0)
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -2.9e+25) {
		tmp = Math.pow(U, -4.0);
	} else if ((l <= 220000.0) || !(l <= 1.9e+243)) {
		tmp = U + (2.0 * (l * J));
	} else {
		tmp = Math.pow(U, -3.0);
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -2.9e+25:
		tmp = math.pow(U, -4.0)
	elif (l <= 220000.0) or not (l <= 1.9e+243):
		tmp = U + (2.0 * (l * J))
	else:
		tmp = math.pow(U, -3.0)
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -2.9e+25)
		tmp = U ^ -4.0;
	elseif ((l <= 220000.0) || !(l <= 1.9e+243))
		tmp = Float64(U + Float64(2.0 * Float64(l * J)));
	else
		tmp = U ^ -3.0;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= -2.9e+25)
		tmp = U ^ -4.0;
	elseif ((l <= 220000.0) || ~((l <= 1.9e+243)))
		tmp = U + (2.0 * (l * J));
	else
		tmp = U ^ -3.0;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -2.9e+25], N[Power[U, -4.0], $MachinePrecision], If[Or[LessEqual[l, 220000.0], N[Not[LessEqual[l, 1.9e+243]], $MachinePrecision]], N[(U + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[U, -3.0], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.9 \cdot 10^{+25}:\\
\;\;\;\;{U}^{-4}\\

\mathbf{elif}\;\ell \leq 220000 \lor \neg \left(\ell \leq 1.9 \cdot 10^{+243}\right):\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\

\mathbf{else}:\\
\;\;\;\;{U}^{-3}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -2.8999999999999999e25

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{{U}^{-4}} \]

    if -2.8999999999999999e25 < l < 2.2e5 or 1.89999999999999999e243 < l

    1. Initial program 80.6%

      \[\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 88.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \ell\right)} \]
    6. Step-by-step derivation
      1. +-commutative75.6%

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

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

    if 2.2e5 < l < 1.89999999999999999e243

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{{U}^{-3}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification58.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.9 \cdot 10^{+25}:\\ \;\;\;\;{U}^{-4}\\ \mathbf{elif}\;\ell \leq 220000 \lor \neg \left(\ell \leq 1.9 \cdot 10^{+243}\right):\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\ \mathbf{else}:\\ \;\;\;\;{U}^{-3}\\ \end{array} \]

Alternative 15: 45.8% accurate, 34.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -0.0024 \lor \neg \left(\ell \leq 0.016\right):\\
\;\;\;\;2 \cdot \left(\ell \cdot J\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -0.00239999999999999979 or 0.016 < l

    1. Initial program 99.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 26.9%

      \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right)} \]
    3. Step-by-step derivation
      1. +-commutative26.9%

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(J \cdot \ell, \cos \left(0.5 \cdot K\right) \cdot 2, U\right)} \]
      6. *-commutative26.9%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\ell \cdot J}, \cos \left(0.5 \cdot K\right) \cdot 2, U\right) \]
      7. *-commutative26.9%

        \[\leadsto \mathsf{fma}\left(\ell \cdot J, \color{blue}{2 \cdot \cos \left(0.5 \cdot K\right)}, U\right) \]
    4. Simplified26.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\ell \cdot J, 2 \cdot \cos \left(0.5 \cdot K\right), U\right)} \]
    5. Taylor expanded in l around inf 26.7%

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

        \[\leadsto 2 \cdot \color{blue}{\left(\left(J \cdot \ell\right) \cdot \cos \left(0.5 \cdot K\right)\right)} \]
    7. Simplified26.7%

      \[\leadsto \color{blue}{2 \cdot \left(\left(J \cdot \ell\right) \cdot \cos \left(0.5 \cdot K\right)\right)} \]
    8. Taylor expanded in K around 0 19.1%

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

    if -0.00239999999999999979 < l < 0.016

    1. Initial program 77.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -0.0024 \lor \neg \left(\ell \leq 0.016\right):\\ \;\;\;\;2 \cdot \left(\ell \cdot J\right)\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \]

Alternative 16: 53.6% accurate, 44.6× speedup?

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{U + 2 \cdot \left(J \cdot \ell\right)} \]
  6. Step-by-step derivation
    1. +-commutative53.9%

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

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

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

Alternative 17: 39.2% accurate, 61.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -0.072:\\ \;\;\;\;U \cdot U\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \end{array} \]
(FPCore (J l K U) :precision binary64 (if (<= l -0.072) (* U U) U))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -0.072) {
		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 <= (-0.072d0)) 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 <= -0.072) {
		tmp = U * U;
	} else {
		tmp = U;
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -0.072:
		tmp = U * U
	else:
		tmp = U
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -0.072)
		tmp = Float64(U * U);
	else
		tmp = U;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= -0.072)
		tmp = U * U;
	else
		tmp = U;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -0.072], N[(U * U), $MachinePrecision], U]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -0.072:\\
\;\;\;\;U \cdot U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -0.0719999999999999946

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{U \cdot U} \]

    if -0.0719999999999999946 < l

    1. Initial program 83.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -0.072:\\ \;\;\;\;U \cdot U\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \]

Alternative 18: 2.7% accurate, 312.0× speedup?

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

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

    \[\leadsto \color{blue}{\frac{U}{U}} \]
  3. Step-by-step derivation
    1. *-inverses3.0%

      \[\leadsto \color{blue}{1} \]
  4. Simplified3.0%

    \[\leadsto \color{blue}{1} \]
  5. Final simplification3.0%

    \[\leadsto 1 \]

Alternative 19: 36.6% 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.9%

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

    \[\leadsto \color{blue}{U} \]
  3. Final simplification41.1%

    \[\leadsto U \]

Reproduce

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