Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.0% → 99.9%
Time: 14.7s
Alternatives: 23
Speedup: 2.7×

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 23 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.0% 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}\\ t_1 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t_0 \leq -0.1:\\ \;\;\;\;\mathsf{fma}\left(t_0, J \cdot t_1, U\right)\\ \mathbf{elif}\;t_0 \leq 0.001:\\ \;\;\;\;U + t_1 \cdot \left(2 \cdot \left(\ell \cdot J\right) + \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right) + 0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + t_1 \cdot \left(t_0 \cdot J\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (- (exp l) (exp (- l)))) (t_1 (cos (/ K 2.0))))
   (if (<= t_0 -0.1)
     (fma t_0 (* J t_1) U)
     (if (<= t_0 0.001)
       (+
        U
        (*
         t_1
         (+
          (* 2.0 (* l J))
          (+
           (* 0.3333333333333333 (* J (pow l 3.0)))
           (* 0.016666666666666666 (* J (pow l 5.0)))))))
       (+ U (* t_1 (* t_0 J)))))))
double code(double J, double l, double K, double U) {
	double t_0 = exp(l) - exp(-l);
	double t_1 = cos((K / 2.0));
	double tmp;
	if (t_0 <= -0.1) {
		tmp = fma(t_0, (J * t_1), U);
	} else if (t_0 <= 0.001) {
		tmp = U + (t_1 * ((2.0 * (l * J)) + ((0.3333333333333333 * (J * pow(l, 3.0))) + (0.016666666666666666 * (J * pow(l, 5.0))))));
	} else {
		tmp = U + (t_1 * (t_0 * J));
	}
	return tmp;
}
function code(J, l, K, U)
	t_0 = Float64(exp(l) - exp(Float64(-l)))
	t_1 = cos(Float64(K / 2.0))
	tmp = 0.0
	if (t_0 <= -0.1)
		tmp = fma(t_0, Float64(J * t_1), U);
	elseif (t_0 <= 0.001)
		tmp = Float64(U + Float64(t_1 * Float64(Float64(2.0 * Float64(l * J)) + Float64(Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))) + Float64(0.016666666666666666 * Float64(J * (l ^ 5.0)))))));
	else
		tmp = Float64(U + Float64(t_1 * Float64(t_0 * J)));
	end
	return tmp
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -0.1], N[(t$95$0 * N[(J * t$95$1), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, 0.001], N[(U + N[(t$95$1 * N[(N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision] + N[(N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.016666666666666666 * N[(J * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(t$95$1 * N[(t$95$0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
t_1 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t_0 \leq -0.1:\\
\;\;\;\;\mathsf{fma}\left(t_0, J \cdot t_1, U\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 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. Step-by-step derivation
      1. *-commutative99.9%

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

        \[\leadsto \color{blue}{\left(e^{\ell} - e^{-\ell}\right) \cdot \left(J \cdot \cos \left(\frac{K}{2}\right)\right)} + U \]
      3. fma-def99.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(e^{\ell} - e^{-\ell}, J \cdot \cos \left(\frac{K}{2}\right), U\right)} \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(e^{\ell} - e^{-\ell}, J \cdot \cos \left(\frac{K}{2}\right), U\right)} \]

    if -0.10000000000000001 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 1e-3

    1. Initial program 71.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.9%

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

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

    if 1e-3 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

    1. Initial program 100.0%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.9%

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

Alternative 2: 97.2% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\ell} - e^{-\ell}\\ \mathbf{if}\;t_0 \leq 0.001:\\ \;\;\;\;J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, \mathsf{fma}\left(0.0003968253968253968, {\ell}^{7}, \mathsf{fma}\left(0.016666666666666666, {\ell}^{5}, \ell \cdot 2\right)\right)\right)\right) + U\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(t_0 \cdot J\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (- (exp l) (exp (- l)))))
   (if (<= t_0 0.001)
     (+
      (*
       J
       (*
        (cos (* 0.5 K))
        (fma
         0.3333333333333333
         (pow l 3.0)
         (fma
          0.0003968253968253968
          (pow l 7.0)
          (fma 0.016666666666666666 (pow l 5.0) (* l 2.0))))))
      U)
     (+ U (* (cos (/ K 2.0)) (* t_0 J))))))
double code(double J, double l, double K, double U) {
	double t_0 = exp(l) - exp(-l);
	double tmp;
	if (t_0 <= 0.001) {
		tmp = (J * (cos((0.5 * K)) * fma(0.3333333333333333, pow(l, 3.0), fma(0.0003968253968253968, pow(l, 7.0), fma(0.016666666666666666, pow(l, 5.0), (l * 2.0)))))) + U;
	} else {
		tmp = U + (cos((K / 2.0)) * (t_0 * J));
	}
	return tmp;
}
function code(J, l, K, U)
	t_0 = Float64(exp(l) - exp(Float64(-l)))
	tmp = 0.0
	if (t_0 <= 0.001)
		tmp = Float64(Float64(J * Float64(cos(Float64(0.5 * K)) * fma(0.3333333333333333, (l ^ 3.0), fma(0.0003968253968253968, (l ^ 7.0), fma(0.016666666666666666, (l ^ 5.0), Float64(l * 2.0)))))) + U);
	else
		tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(t_0 * J)));
	end
	return 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.001], N[(N[(J * N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision] + N[(0.0003968253968253968 * N[Power[l, 7.0], $MachinePrecision] + N[(0.016666666666666666 * N[Power[l, 5.0], $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(t$95$0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_0 \leq 0.001:\\
\;\;\;\;J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, \mathsf{fma}\left(0.0003968253968253968, {\ell}^{7}, \mathsf{fma}\left(0.016666666666666666, {\ell}^{5}, \ell \cdot 2\right)\right)\right)\right) + U\\

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


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

    1. Initial program 79.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.3333333333333333 \cdot {\ell}^{3} + \left(0.0003968253968253968 \cdot {\ell}^{7} + \left(0.016666666666666666 \cdot {\ell}^{5} + 2 \cdot \ell\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in J around 0 97.9%

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

        \[\leadsto \color{blue}{\left(\cos \left(0.5 \cdot K\right) \cdot J\right) \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \left(0.0003968253968253968 \cdot {\ell}^{7} + \left(2 \cdot \ell + 0.016666666666666666 \cdot {\ell}^{5}\right)\right)\right)} + U \]
      2. *-commutative97.9%

        \[\leadsto \color{blue}{\left(J \cdot \cos \left(0.5 \cdot K\right)\right)} \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \left(0.0003968253968253968 \cdot {\ell}^{7} + \left(2 \cdot \ell + 0.016666666666666666 \cdot {\ell}^{5}\right)\right)\right) + U \]
      3. fma-def97.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \color{blue}{\mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.0003968253968253968 \cdot {\ell}^{7} + \left(2 \cdot \ell + 0.016666666666666666 \cdot {\ell}^{5}\right)\right)} + U \]
      4. +-commutative97.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.0003968253968253968 \cdot {\ell}^{7} + \color{blue}{\left(0.016666666666666666 \cdot {\ell}^{5} + 2 \cdot \ell\right)}\right) + U \]
      5. *-commutative97.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.0003968253968253968 \cdot {\ell}^{7} + \left(0.016666666666666666 \cdot {\ell}^{5} + \color{blue}{\ell \cdot 2}\right)\right) + U \]
      6. fma-udef97.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.0003968253968253968 \cdot {\ell}^{7} + \color{blue}{\mathsf{fma}\left(0.016666666666666666, {\ell}^{5}, \ell \cdot 2\right)}\right) + U \]
      7. fma-udef97.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, \color{blue}{\mathsf{fma}\left(0.0003968253968253968, {\ell}^{7}, \mathsf{fma}\left(0.016666666666666666, {\ell}^{5}, \ell \cdot 2\right)\right)}\right) + U \]
      8. associate-*r*97.9%

        \[\leadsto \color{blue}{J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, \mathsf{fma}\left(0.0003968253968253968, {\ell}^{7}, \mathsf{fma}\left(0.016666666666666666, {\ell}^{5}, \ell \cdot 2\right)\right)\right)\right)} + U \]
    5. Simplified97.9%

      \[\leadsto \color{blue}{J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, \mathsf{fma}\left(0.0003968253968253968, {\ell}^{7}, \mathsf{fma}\left(0.016666666666666666, {\ell}^{5}, \ell \cdot 2\right)\right)\right)\right)} + U \]

    if 1e-3 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

    1. Initial program 100.0%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.5%

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

Alternative 3: 99.9% accurate, 0.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;U + t_0 \cdot \left(2 \cdot \left(\ell \cdot J\right) + \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right) + 0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\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 1e-3 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

    1. Initial program 100.0%

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

    if -0.10000000000000001 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 1e-3

    1. Initial program 71.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.9%

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

      \[\leadsto \color{blue}{\left(2 \cdot \left(\ell \cdot J\right) + \left(0.3333333333333333 \cdot \left({\ell}^{3} \cdot J\right) + 0.016666666666666666 \cdot \left({\ell}^{5} \cdot J\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 0.001\right):\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right)\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(2 \cdot \left(\ell \cdot J\right) + \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right) + 0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\right)\right)\right)\\ \end{array} \]

Alternative 4: 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 0.001\right):\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(t_0 \cdot J\right)\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(0.5 \cdot K\right) \cdot \left(2 \cdot \left(\ell \cdot J\right) + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\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 0.001)))
     (+ U (* (cos (/ K 2.0)) (* t_0 J)))
     (+
      U
      (*
       (cos (* 0.5 K))
       (+ (* 2.0 (* l J)) (* (pow l 3.0) (* J 0.3333333333333333))))))))
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 <= 0.001)) {
		tmp = U + (cos((K / 2.0)) * (t_0 * J));
	} else {
		tmp = U + (cos((0.5 * K)) * ((2.0 * (l * J)) + (pow(l, 3.0) * (J * 0.3333333333333333))));
	}
	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 <= 0.001d0))) then
        tmp = u + (cos((k / 2.0d0)) * (t_0 * j))
    else
        tmp = u + (cos((0.5d0 * k)) * ((2.0d0 * (l * j)) + ((l ** 3.0d0) * (j * 0.3333333333333333d0))))
    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 <= 0.001)) {
		tmp = U + (Math.cos((K / 2.0)) * (t_0 * J));
	} else {
		tmp = U + (Math.cos((0.5 * K)) * ((2.0 * (l * J)) + (Math.pow(l, 3.0) * (J * 0.3333333333333333))));
	}
	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 <= 0.001):
		tmp = U + (math.cos((K / 2.0)) * (t_0 * J))
	else:
		tmp = U + (math.cos((0.5 * K)) * ((2.0 * (l * J)) + (math.pow(l, 3.0) * (J * 0.3333333333333333))))
	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 <= 0.001))
		tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(t_0 * J)));
	else
		tmp = Float64(U + Float64(cos(Float64(0.5 * K)) * Float64(Float64(2.0 * Float64(l * J)) + Float64((l ^ 3.0) * Float64(J * 0.3333333333333333)))));
	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 <= 0.001)))
		tmp = U + (cos((K / 2.0)) * (t_0 * J));
	else
		tmp = U + (cos((0.5 * K)) * ((2.0 * (l * J)) + ((l ^ 3.0) * (J * 0.3333333333333333))));
	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, 0.001]], $MachinePrecision]], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(t$95$0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision] + N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $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 0.001\right):\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(t_0 \cdot J\right)\\

\mathbf{else}:\\
\;\;\;\;U + \cos \left(0.5 \cdot K\right) \cdot \left(2 \cdot \left(\ell \cdot J\right) + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\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 1e-3 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

    1. Initial program 100.0%

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

    if -0.10000000000000001 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 1e-3

    1. Initial program 71.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.9%

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

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

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

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

        \[\leadsto \left(\cos \left(0.5 \cdot K\right) \cdot \left(\left(\ell \cdot J\right) \cdot 2\right) + \color{blue}{\cos \left(0.5 \cdot K\right) \cdot \left(\left({\ell}^{3} \cdot J\right) \cdot 0.3333333333333333\right)}\right) + U \]
      5. distribute-lft-out99.9%

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

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

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

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

      \[\leadsto \color{blue}{\cos \left(0.5 \cdot K\right) \cdot \left(2 \cdot \left(\ell \cdot J\right) + {\ell}^{3} \cdot \left(0.3333333333333333 \cdot J\right)\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 0.001\right):\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right)\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(0.5 \cdot K\right) \cdot \left(2 \cdot \left(\ell \cdot J\right) + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \end{array} \]

Alternative 5: 97.2% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
t_1 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t_0 \leq 0.001:\\
\;\;\;\;U + t_1 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \left(0.0003968253968253968 \cdot {\ell}^{7} + \left(0.016666666666666666 \cdot {\ell}^{5} + \ell \cdot 2\right)\right)\right)\right)\\

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


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

    1. Initial program 79.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.3333333333333333 \cdot {\ell}^{3} + \left(0.0003968253968253968 \cdot {\ell}^{7} + \left(0.016666666666666666 \cdot {\ell}^{5} + 2 \cdot \ell\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]

    if 1e-3 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

    1. Initial program 100.0%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.5%

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

Alternative 6: 97.5% accurate, 1.0× 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)\\ t_1 := e^{\ell} - e^{-\ell}\\ \mathbf{if}\;\ell \leq -3.2 \cdot 10^{+27}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -0.054:\\ \;\;\;\;\mathsf{fma}\left(t_1, J, U\right)\\ \mathbf{elif}\;\ell \leq 0.00112:\\ \;\;\;\;U + \cos \left(0.5 \cdot K\right) \cdot \left(2 \cdot \left(\ell \cdot J\right) + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \mathbf{elif}\;\ell \leq 3.8 \cdot 10^{+43}:\\ \;\;\;\;U + t_1 \cdot J\\ \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)))))
        (t_1 (- (exp l) (exp (- l)))))
   (if (<= l -3.2e+27)
     t_0
     (if (<= l -0.054)
       (fma t_1 J U)
       (if (<= l 0.00112)
         (+
          U
          (*
           (cos (* 0.5 K))
           (+ (* 2.0 (* l J)) (* (pow l 3.0) (* J 0.3333333333333333)))))
         (if (<= l 3.8e+43) (+ U (* t_1 J)) 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 t_1 = exp(l) - exp(-l);
	double tmp;
	if (l <= -3.2e+27) {
		tmp = t_0;
	} else if (l <= -0.054) {
		tmp = fma(t_1, J, U);
	} else if (l <= 0.00112) {
		tmp = U + (cos((0.5 * K)) * ((2.0 * (l * J)) + (pow(l, 3.0) * (J * 0.3333333333333333))));
	} else if (l <= 3.8e+43) {
		tmp = U + (t_1 * J);
	} 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))))
	t_1 = Float64(exp(l) - exp(Float64(-l)))
	tmp = 0.0
	if (l <= -3.2e+27)
		tmp = t_0;
	elseif (l <= -0.054)
		tmp = fma(t_1, J, U);
	elseif (l <= 0.00112)
		tmp = Float64(U + Float64(cos(Float64(0.5 * K)) * Float64(Float64(2.0 * Float64(l * J)) + Float64((l ^ 3.0) * Float64(J * 0.3333333333333333)))));
	elseif (l <= 3.8e+43)
		tmp = Float64(U + Float64(t_1 * J));
	else
		tmp = t_0;
	end
	return 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]}, Block[{t$95$1 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.2e+27], t$95$0, If[LessEqual[l, -0.054], N[(t$95$1 * J + U), $MachinePrecision], If[LessEqual[l, 0.00112], N[(U + N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision] + N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3.8e+43], N[(U + N[(t$95$1 * J), $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)\\
t_1 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;\ell \leq -3.2 \cdot 10^{+27}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq -0.054:\\
\;\;\;\;\mathsf{fma}\left(t_1, J, U\right)\\

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

\mathbf{elif}\;\ell \leq 3.8 \cdot 10^{+43}:\\
\;\;\;\;U + t_1 \cdot J\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -3.20000000000000015e27 or 3.80000000000000008e43 < 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 100.0%

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

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

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

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

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

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

    if -3.20000000000000015e27 < l < -0.0539999999999999994

    1. Initial program 99.3%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(e^{\ell} - e^{-\ell}, J, U\right)} \]
    4. Simplified99.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(e^{\ell} - e^{-\ell}, J, U\right)} \]

    if -0.0539999999999999994 < l < 0.0011199999999999999

    1. Initial program 71.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.9%

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

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

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

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

        \[\leadsto \left(\cos \left(0.5 \cdot K\right) \cdot \left(\left(\ell \cdot J\right) \cdot 2\right) + \color{blue}{\cos \left(0.5 \cdot K\right) \cdot \left(\left({\ell}^{3} \cdot J\right) \cdot 0.3333333333333333\right)}\right) + U \]
      5. distribute-lft-out99.9%

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

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

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

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

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

    if 0.0011199999999999999 < l < 3.80000000000000008e43

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

      \[\leadsto \color{blue}{\left(e^{\ell} - e^{-\ell}\right) \cdot J} + U \]
  3. Recombined 4 regimes into one program.
  4. Final simplification99.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.2 \cdot 10^{+27}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{7} \cdot \left(J \cdot 0.0003968253968253968\right)\right)\\ \mathbf{elif}\;\ell \leq -0.054:\\ \;\;\;\;\mathsf{fma}\left(e^{\ell} - e^{-\ell}, J, U\right)\\ \mathbf{elif}\;\ell \leq 0.00112:\\ \;\;\;\;U + \cos \left(0.5 \cdot K\right) \cdot \left(2 \cdot \left(\ell \cdot J\right) + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \mathbf{elif}\;\ell \leq 3.8 \cdot 10^{+43}:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \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: 97.5% 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)\\ t_1 := U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{if}\;\ell \leq -3.2 \cdot 10^{+27}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -0.052:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\ell \leq 0.00112:\\ \;\;\;\;U + \cos \left(0.5 \cdot K\right) \cdot \left(2 \cdot \left(\ell \cdot J\right) + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \mathbf{elif}\;\ell \leq 6.4 \cdot 10^{+43}:\\ \;\;\;\;t_1\\ \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)))))
        (t_1 (+ U (* (- (exp l) (exp (- l))) J))))
   (if (<= l -3.2e+27)
     t_0
     (if (<= l -0.052)
       t_1
       (if (<= l 0.00112)
         (+
          U
          (*
           (cos (* 0.5 K))
           (+ (* 2.0 (* l J)) (* (pow l 3.0) (* J 0.3333333333333333)))))
         (if (<= l 6.4e+43) t_1 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 t_1 = U + ((exp(l) - exp(-l)) * J);
	double tmp;
	if (l <= -3.2e+27) {
		tmp = t_0;
	} else if (l <= -0.052) {
		tmp = t_1;
	} else if (l <= 0.00112) {
		tmp = U + (cos((0.5 * K)) * ((2.0 * (l * J)) + (pow(l, 3.0) * (J * 0.3333333333333333))));
	} else if (l <= 6.4e+43) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_0 = u + (cos((k / 2.0d0)) * ((l ** 7.0d0) * (j * 0.0003968253968253968d0)))
    t_1 = u + ((exp(l) - exp(-l)) * j)
    if (l <= (-3.2d+27)) then
        tmp = t_0
    else if (l <= (-0.052d0)) then
        tmp = t_1
    else if (l <= 0.00112d0) then
        tmp = u + (cos((0.5d0 * k)) * ((2.0d0 * (l * j)) + ((l ** 3.0d0) * (j * 0.3333333333333333d0))))
    else if (l <= 6.4d+43) then
        tmp = t_1
    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 t_1 = U + ((Math.exp(l) - Math.exp(-l)) * J);
	double tmp;
	if (l <= -3.2e+27) {
		tmp = t_0;
	} else if (l <= -0.052) {
		tmp = t_1;
	} else if (l <= 0.00112) {
		tmp = U + (Math.cos((0.5 * K)) * ((2.0 * (l * J)) + (Math.pow(l, 3.0) * (J * 0.3333333333333333))));
	} else if (l <= 6.4e+43) {
		tmp = t_1;
	} 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)))
	t_1 = U + ((math.exp(l) - math.exp(-l)) * J)
	tmp = 0
	if l <= -3.2e+27:
		tmp = t_0
	elif l <= -0.052:
		tmp = t_1
	elif l <= 0.00112:
		tmp = U + (math.cos((0.5 * K)) * ((2.0 * (l * J)) + (math.pow(l, 3.0) * (J * 0.3333333333333333))))
	elif l <= 6.4e+43:
		tmp = t_1
	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))))
	t_1 = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J))
	tmp = 0.0
	if (l <= -3.2e+27)
		tmp = t_0;
	elseif (l <= -0.052)
		tmp = t_1;
	elseif (l <= 0.00112)
		tmp = Float64(U + Float64(cos(Float64(0.5 * K)) * Float64(Float64(2.0 * Float64(l * J)) + Float64((l ^ 3.0) * Float64(J * 0.3333333333333333)))));
	elseif (l <= 6.4e+43)
		tmp = t_1;
	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)));
	t_1 = U + ((exp(l) - exp(-l)) * J);
	tmp = 0.0;
	if (l <= -3.2e+27)
		tmp = t_0;
	elseif (l <= -0.052)
		tmp = t_1;
	elseif (l <= 0.00112)
		tmp = U + (cos((0.5 * K)) * ((2.0 * (l * J)) + ((l ^ 3.0) * (J * 0.3333333333333333))));
	elseif (l <= 6.4e+43)
		tmp = t_1;
	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]}, Block[{t$95$1 = N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.2e+27], t$95$0, If[LessEqual[l, -0.052], t$95$1, If[LessEqual[l, 0.00112], N[(U + N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision] + N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6.4e+43], t$95$1, 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)\\
t_1 := U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;\ell \leq -3.2 \cdot 10^{+27}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq -0.052:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;\ell \leq 6.4 \cdot 10^{+43}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -3.20000000000000015e27 or 6.40000000000000029e43 < 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 100.0%

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

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

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

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

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

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

    if -3.20000000000000015e27 < l < -0.0519999999999999976 or 0.0011199999999999999 < l < 6.40000000000000029e43

    1. Initial program 99.7%

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

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

    if -0.0519999999999999976 < l < 0.0011199999999999999

    1. Initial program 71.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.9%

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

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

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

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

        \[\leadsto \left(\cos \left(0.5 \cdot K\right) \cdot \left(\left(\ell \cdot J\right) \cdot 2\right) + \color{blue}{\cos \left(0.5 \cdot K\right) \cdot \left(\left({\ell}^{3} \cdot J\right) \cdot 0.3333333333333333\right)}\right) + U \]
      5. distribute-lft-out99.9%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.2 \cdot 10^{+27}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{7} \cdot \left(J \cdot 0.0003968253968253968\right)\right)\\ \mathbf{elif}\;\ell \leq -0.052:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{elif}\;\ell \leq 0.00112:\\ \;\;\;\;U + \cos \left(0.5 \cdot K\right) \cdot \left(2 \cdot \left(\ell \cdot J\right) + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \mathbf{elif}\;\ell \leq 6.4 \cdot 10^{+43}:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \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: 97.5% 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)\\ t_1 := U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{if}\;\ell \leq -3.2 \cdot 10^{+27}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -0.054:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\ell \leq 0.00112:\\ \;\;\;\;U + J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 7.2 \cdot 10^{+43}:\\ \;\;\;\;t_1\\ \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)))))
        (t_1 (+ U (* (- (exp l) (exp (- l))) J))))
   (if (<= l -3.2e+27)
     t_0
     (if (<= l -0.054)
       t_1
       (if (<= l 0.00112)
         (+
          U
          (*
           J
           (*
            (cos (* 0.5 K))
            (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
         (if (<= l 7.2e+43) t_1 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 t_1 = U + ((exp(l) - exp(-l)) * J);
	double tmp;
	if (l <= -3.2e+27) {
		tmp = t_0;
	} else if (l <= -0.054) {
		tmp = t_1;
	} else if (l <= 0.00112) {
		tmp = U + (J * (cos((0.5 * K)) * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
	} else if (l <= 7.2e+43) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_0 = u + (cos((k / 2.0d0)) * ((l ** 7.0d0) * (j * 0.0003968253968253968d0)))
    t_1 = u + ((exp(l) - exp(-l)) * j)
    if (l <= (-3.2d+27)) then
        tmp = t_0
    else if (l <= (-0.054d0)) then
        tmp = t_1
    else if (l <= 0.00112d0) then
        tmp = u + (j * (cos((0.5d0 * k)) * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
    else if (l <= 7.2d+43) then
        tmp = t_1
    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 t_1 = U + ((Math.exp(l) - Math.exp(-l)) * J);
	double tmp;
	if (l <= -3.2e+27) {
		tmp = t_0;
	} else if (l <= -0.054) {
		tmp = t_1;
	} else if (l <= 0.00112) {
		tmp = U + (J * (Math.cos((0.5 * K)) * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
	} else if (l <= 7.2e+43) {
		tmp = t_1;
	} 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)))
	t_1 = U + ((math.exp(l) - math.exp(-l)) * J)
	tmp = 0
	if l <= -3.2e+27:
		tmp = t_0
	elif l <= -0.054:
		tmp = t_1
	elif l <= 0.00112:
		tmp = U + (J * (math.cos((0.5 * K)) * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))))
	elif l <= 7.2e+43:
		tmp = t_1
	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))))
	t_1 = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J))
	tmp = 0.0
	if (l <= -3.2e+27)
		tmp = t_0;
	elseif (l <= -0.054)
		tmp = t_1;
	elseif (l <= 0.00112)
		tmp = Float64(U + Float64(J * Float64(cos(Float64(0.5 * K)) * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)))));
	elseif (l <= 7.2e+43)
		tmp = t_1;
	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)));
	t_1 = U + ((exp(l) - exp(-l)) * J);
	tmp = 0.0;
	if (l <= -3.2e+27)
		tmp = t_0;
	elseif (l <= -0.054)
		tmp = t_1;
	elseif (l <= 0.00112)
		tmp = U + (J * (cos((0.5 * K)) * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0))));
	elseif (l <= 7.2e+43)
		tmp = t_1;
	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]}, Block[{t$95$1 = N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.2e+27], t$95$0, If[LessEqual[l, -0.054], t$95$1, If[LessEqual[l, 0.00112], N[(U + N[(J * N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 7.2e+43], t$95$1, 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)\\
t_1 := U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;\ell \leq -3.2 \cdot 10^{+27}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq -0.054:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;\ell \leq 7.2 \cdot 10^{+43}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -3.20000000000000015e27 or 7.2000000000000002e43 < 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 100.0%

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

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

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

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

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

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

    if -3.20000000000000015e27 < l < -0.0539999999999999994 or 0.0011199999999999999 < l < 7.2000000000000002e43

    1. Initial program 99.7%

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

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

    if -0.0539999999999999994 < l < 0.0011199999999999999

    1. Initial program 71.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.9%

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

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

        \[\leadsto \color{blue}{\left(\cos \left(0.5 \cdot K\right) \cdot J\right) \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \left(0.0003968253968253968 \cdot {\ell}^{7} + \left(2 \cdot \ell + 0.016666666666666666 \cdot {\ell}^{5}\right)\right)\right)} + U \]
      2. *-commutative99.9%

        \[\leadsto \color{blue}{\left(J \cdot \cos \left(0.5 \cdot K\right)\right)} \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \left(0.0003968253968253968 \cdot {\ell}^{7} + \left(2 \cdot \ell + 0.016666666666666666 \cdot {\ell}^{5}\right)\right)\right) + U \]
      3. fma-def99.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \color{blue}{\mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.0003968253968253968 \cdot {\ell}^{7} + \left(2 \cdot \ell + 0.016666666666666666 \cdot {\ell}^{5}\right)\right)} + U \]
      4. +-commutative99.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.0003968253968253968 \cdot {\ell}^{7} + \color{blue}{\left(0.016666666666666666 \cdot {\ell}^{5} + 2 \cdot \ell\right)}\right) + U \]
      5. *-commutative99.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.0003968253968253968 \cdot {\ell}^{7} + \left(0.016666666666666666 \cdot {\ell}^{5} + \color{blue}{\ell \cdot 2}\right)\right) + U \]
      6. fma-udef99.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.0003968253968253968 \cdot {\ell}^{7} + \color{blue}{\mathsf{fma}\left(0.016666666666666666, {\ell}^{5}, \ell \cdot 2\right)}\right) + U \]
      7. fma-udef99.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, \color{blue}{\mathsf{fma}\left(0.0003968253968253968, {\ell}^{7}, \mathsf{fma}\left(0.016666666666666666, {\ell}^{5}, \ell \cdot 2\right)\right)}\right) + U \]
      8. associate-*r*99.9%

        \[\leadsto \color{blue}{J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, \mathsf{fma}\left(0.0003968253968253968, {\ell}^{7}, \mathsf{fma}\left(0.016666666666666666, {\ell}^{5}, \ell \cdot 2\right)\right)\right)\right)} + U \]
    5. Simplified99.9%

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

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

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

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

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

        \[\leadsto \left(\left(2 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \ell\right)\right) \cdot J + \color{blue}{\left(0.3333333333333333 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot {\ell}^{3}\right)\right) \cdot J}\right) + U \]
      5. distribute-rgt-out99.9%

        \[\leadsto \color{blue}{J \cdot \left(2 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \ell\right) + 0.3333333333333333 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot {\ell}^{3}\right)\right)} + U \]
      6. +-commutative99.9%

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

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

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

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

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

        \[\leadsto J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right) + \color{blue}{\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot 2\right)}\right) + U \]
      12. distribute-lft-out99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.2 \cdot 10^{+27}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{7} \cdot \left(J \cdot 0.0003968253968253968\right)\right)\\ \mathbf{elif}\;\ell \leq -0.054:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{elif}\;\ell \leq 0.00112:\\ \;\;\;\;U + J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 7.2 \cdot 10^{+43}:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{7} \cdot \left(J \cdot 0.0003968253968253968\right)\right)\\ \end{array} \]

Alternative 9: 97.5% 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)\\ t_2 := U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{if}\;\ell \leq -3.2 \cdot 10^{+27}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\ell \leq -0.052:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\ell \leq 0.00112:\\ \;\;\;\;U + t_0 \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 7.2 \cdot 10^{+43}:\\ \;\;\;\;t_2\\ \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)))))
        (t_2 (+ U (* (- (exp l) (exp (- l))) J))))
   (if (<= l -3.2e+27)
     t_1
     (if (<= l -0.052)
       t_2
       (if (<= l 0.00112)
         (+ U (* t_0 (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l)))))))
         (if (<= l 7.2e+43) t_2 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 t_2 = U + ((exp(l) - exp(-l)) * J);
	double tmp;
	if (l <= -3.2e+27) {
		tmp = t_1;
	} else if (l <= -0.052) {
		tmp = t_2;
	} else if (l <= 0.00112) {
		tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
	} else if (l <= 7.2e+43) {
		tmp = t_2;
	} 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) :: t_2
    real(8) :: tmp
    t_0 = cos((k / 2.0d0))
    t_1 = u + (t_0 * ((l ** 7.0d0) * (j * 0.0003968253968253968d0)))
    t_2 = u + ((exp(l) - exp(-l)) * j)
    if (l <= (-3.2d+27)) then
        tmp = t_1
    else if (l <= (-0.052d0)) then
        tmp = t_2
    else if (l <= 0.00112d0) then
        tmp = u + (t_0 * (j * (l * (2.0d0 + (0.3333333333333333d0 * (l * l))))))
    else if (l <= 7.2d+43) then
        tmp = t_2
    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 t_2 = U + ((Math.exp(l) - Math.exp(-l)) * J);
	double tmp;
	if (l <= -3.2e+27) {
		tmp = t_1;
	} else if (l <= -0.052) {
		tmp = t_2;
	} else if (l <= 0.00112) {
		tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
	} else if (l <= 7.2e+43) {
		tmp = t_2;
	} 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)))
	t_2 = U + ((math.exp(l) - math.exp(-l)) * J)
	tmp = 0
	if l <= -3.2e+27:
		tmp = t_1
	elif l <= -0.052:
		tmp = t_2
	elif l <= 0.00112:
		tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))))
	elif l <= 7.2e+43:
		tmp = t_2
	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))))
	t_2 = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J))
	tmp = 0.0
	if (l <= -3.2e+27)
		tmp = t_1;
	elseif (l <= -0.052)
		tmp = t_2;
	elseif (l <= 0.00112)
		tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * Float64(l * l)))))));
	elseif (l <= 7.2e+43)
		tmp = t_2;
	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)));
	t_2 = U + ((exp(l) - exp(-l)) * J);
	tmp = 0.0;
	if (l <= -3.2e+27)
		tmp = t_1;
	elseif (l <= -0.052)
		tmp = t_2;
	elseif (l <= 0.00112)
		tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
	elseif (l <= 7.2e+43)
		tmp = t_2;
	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]}, Block[{t$95$2 = N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.2e+27], t$95$1, If[LessEqual[l, -0.052], t$95$2, If[LessEqual[l, 0.00112], N[(U + N[(t$95$0 * N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 7.2e+43], t$95$2, 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)\\
t_2 := U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;\ell \leq -3.2 \cdot 10^{+27}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;\ell \leq -0.052:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;\ell \leq 7.2 \cdot 10^{+43}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -3.20000000000000015e27 or 7.2000000000000002e43 < 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 100.0%

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

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

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

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

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

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

    if -3.20000000000000015e27 < l < -0.0519999999999999976 or 0.0011199999999999999 < l < 7.2000000000000002e43

    1. Initial program 99.7%

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

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

    if -0.0519999999999999976 < l < 0.0011199999999999999

    1. Initial program 71.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.9%

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

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

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

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

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

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

        \[\leadsto \left(J \cdot \left(2 \cdot \ell + \color{blue}{\left(0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right) \cdot \ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      6. distribute-rgt-out99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.2 \cdot 10^{+27}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{7} \cdot \left(J \cdot 0.0003968253968253968\right)\right)\\ \mathbf{elif}\;\ell \leq -0.052:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{elif}\;\ell \leq 0.00112:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 7.2 \cdot 10^{+43}:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{7} \cdot \left(J \cdot 0.0003968253968253968\right)\right)\\ \end{array} \]

Alternative 10: 94.5% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -7.8 \cdot 10^{+170} \lor \neg \left(\ell \leq -0.05 \lor \neg \left(\ell \leq 0.00112\right) \land \ell \leq 1.2 \cdot 10^{+97}\right):\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (or (<= l -7.8e+170)
         (not (or (<= l -0.05) (and (not (<= l 0.00112)) (<= l 1.2e+97)))))
   (+ U (* (cos (/ K 2.0)) (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l)))))))
   (+ U (* (- (exp l) (exp (- l))) J))))
double code(double J, double l, double K, double U) {
	double tmp;
	if ((l <= -7.8e+170) || !((l <= -0.05) || (!(l <= 0.00112) && (l <= 1.2e+97)))) {
		tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
	} else {
		tmp = U + ((exp(l) - exp(-l)) * J);
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: tmp
    if ((l <= (-7.8d+170)) .or. (.not. (l <= (-0.05d0)) .or. (.not. (l <= 0.00112d0)) .and. (l <= 1.2d+97))) then
        tmp = u + (cos((k / 2.0d0)) * (j * (l * (2.0d0 + (0.3333333333333333d0 * (l * l))))))
    else
        tmp = u + ((exp(l) - exp(-l)) * j)
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if ((l <= -7.8e+170) || !((l <= -0.05) || (!(l <= 0.00112) && (l <= 1.2e+97)))) {
		tmp = U + (Math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
	} else {
		tmp = U + ((Math.exp(l) - Math.exp(-l)) * J);
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if (l <= -7.8e+170) or not ((l <= -0.05) or (not (l <= 0.00112) and (l <= 1.2e+97))):
		tmp = U + (math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))))
	else:
		tmp = U + ((math.exp(l) - math.exp(-l)) * J)
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if ((l <= -7.8e+170) || !((l <= -0.05) || (!(l <= 0.00112) && (l <= 1.2e+97))))
		tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * Float64(l * l)))))));
	else
		tmp = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if ((l <= -7.8e+170) || ~(((l <= -0.05) || (~((l <= 0.00112)) && (l <= 1.2e+97)))))
		tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
	else
		tmp = U + ((exp(l) - exp(-l)) * J);
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -7.8e+170], N[Not[Or[LessEqual[l, -0.05], And[N[Not[LessEqual[l, 0.00112]], $MachinePrecision], LessEqual[l, 1.2e+97]]]], $MachinePrecision]], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -7.8 \cdot 10^{+170} \lor \neg \left(\ell \leq -0.05 \lor \neg \left(\ell \leq 0.00112\right) \land \ell \leq 1.2 \cdot 10^{+97}\right):\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -7.8000000000000005e170 or -0.050000000000000003 < l < 0.0011199999999999999 or 1.2e97 < l

    1. Initial program 81.1%

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

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

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

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

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

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

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

        \[\leadsto \left(J \cdot \left(2 \cdot \ell + \color{blue}{\left(0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right) \cdot \ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      6. distribute-rgt-out99.9%

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

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

    if -7.8000000000000005e170 < l < -0.050000000000000003 or 0.0011199999999999999 < l < 1.2e97

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -7.8 \cdot 10^{+170} \lor \neg \left(\ell \leq -0.05 \lor \neg \left(\ell \leq 0.00112\right) \land \ell \leq 1.2 \cdot 10^{+97}\right):\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \end{array} \]

Alternative 11: 94.4% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -7.8 \cdot 10^{+170} \lor \neg \left(\ell \leq -190 \lor \neg \left(\ell \leq 245\right) \land \ell \leq 8.6 \cdot 10^{+97}\right):\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (or (<= l -7.8e+170)
         (not (or (<= l -190.0) (and (not (<= l 245.0)) (<= l 8.6e+97)))))
   (+ U (* (cos (/ K 2.0)) (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l)))))))
   (* (- (exp l) (exp (- l))) J)))
double code(double J, double l, double K, double U) {
	double tmp;
	if ((l <= -7.8e+170) || !((l <= -190.0) || (!(l <= 245.0) && (l <= 8.6e+97)))) {
		tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
	} else {
		tmp = (exp(l) - exp(-l)) * J;
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: tmp
    if ((l <= (-7.8d+170)) .or. (.not. (l <= (-190.0d0)) .or. (.not. (l <= 245.0d0)) .and. (l <= 8.6d+97))) then
        tmp = u + (cos((k / 2.0d0)) * (j * (l * (2.0d0 + (0.3333333333333333d0 * (l * l))))))
    else
        tmp = (exp(l) - exp(-l)) * j
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if ((l <= -7.8e+170) || !((l <= -190.0) || (!(l <= 245.0) && (l <= 8.6e+97)))) {
		tmp = U + (Math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
	} else {
		tmp = (Math.exp(l) - Math.exp(-l)) * J;
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if (l <= -7.8e+170) or not ((l <= -190.0) or (not (l <= 245.0) and (l <= 8.6e+97))):
		tmp = U + (math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))))
	else:
		tmp = (math.exp(l) - math.exp(-l)) * J
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if ((l <= -7.8e+170) || !((l <= -190.0) || (!(l <= 245.0) && (l <= 8.6e+97))))
		tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * Float64(l * l)))))));
	else
		tmp = Float64(Float64(exp(l) - exp(Float64(-l))) * J);
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if ((l <= -7.8e+170) || ~(((l <= -190.0) || (~((l <= 245.0)) && (l <= 8.6e+97)))))
		tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
	else
		tmp = (exp(l) - exp(-l)) * J;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -7.8e+170], N[Not[Or[LessEqual[l, -190.0], And[N[Not[LessEqual[l, 245.0]], $MachinePrecision], LessEqual[l, 8.6e+97]]]], $MachinePrecision]], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -7.8 \cdot 10^{+170} \lor \neg \left(\ell \leq -190 \lor \neg \left(\ell \leq 245\right) \land \ell \leq 8.6 \cdot 10^{+97}\right):\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -7.8000000000000005e170 or -190 < l < 245 or 8.5999999999999996e97 < l

    1. Initial program 81.2%

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

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

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

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

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

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

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

        \[\leadsto \left(J \cdot \left(2 \cdot \ell + \color{blue}{\left(0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right) \cdot \ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      6. distribute-rgt-out99.7%

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

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

    if -7.8000000000000005e170 < l < -190 or 245 < l < 8.5999999999999996e97

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

      \[\leadsto \color{blue}{\left(e^{\ell} - e^{-\ell}\right) \cdot J} + U \]
    3. Taylor expanded in J around inf 81.6%

      \[\leadsto \color{blue}{\left(e^{\ell} - e^{-\ell}\right) \cdot J} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification96.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -7.8 \cdot 10^{+170} \lor \neg \left(\ell \leq -190 \lor \neg \left(\ell \leq 245\right) \land \ell \leq 8.6 \cdot 10^{+97}\right):\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \end{array} \]

Alternative 12: 78.7% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -7.5 \cdot 10^{+99}:\\ \;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq -2400000:\\ \;\;\;\;{U}^{-8}\\ \mathbf{elif}\;\ell \leq 1.2 \cdot 10^{+24}:\\ \;\;\;\;U + J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 7.2 \cdot 10^{+71}:\\ \;\;\;\;{U}^{-8}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\ell \cdot J\right) + \left(U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -7.5e+99)
   (+ U (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0))))
   (if (<= l -2400000.0)
     (pow U -8.0)
     (if (<= l 1.2e+24)
       (+ U (* J (* (cos (* 0.5 K)) (* l 2.0))))
       (if (<= l 7.2e+71)
         (pow U -8.0)
         (+
          (* 2.0 (* l J))
          (+ U (* 0.3333333333333333 (* J (pow l 3.0))))))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -7.5e+99) {
		tmp = U + (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0)));
	} else if (l <= -2400000.0) {
		tmp = pow(U, -8.0);
	} else if (l <= 1.2e+24) {
		tmp = U + (J * (cos((0.5 * K)) * (l * 2.0)));
	} else if (l <= 7.2e+71) {
		tmp = pow(U, -8.0);
	} else {
		tmp = (2.0 * (l * J)) + (U + (0.3333333333333333 * (J * pow(l, 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 <= (-7.5d+99)) then
        tmp = u + (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0)))
    else if (l <= (-2400000.0d0)) then
        tmp = u ** (-8.0d0)
    else if (l <= 1.2d+24) then
        tmp = u + (j * (cos((0.5d0 * k)) * (l * 2.0d0)))
    else if (l <= 7.2d+71) then
        tmp = u ** (-8.0d0)
    else
        tmp = (2.0d0 * (l * j)) + (u + (0.3333333333333333d0 * (j * (l ** 3.0d0))))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -7.5e+99) {
		tmp = U + (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)));
	} else if (l <= -2400000.0) {
		tmp = Math.pow(U, -8.0);
	} else if (l <= 1.2e+24) {
		tmp = U + (J * (Math.cos((0.5 * K)) * (l * 2.0)));
	} else if (l <= 7.2e+71) {
		tmp = Math.pow(U, -8.0);
	} else {
		tmp = (2.0 * (l * J)) + (U + (0.3333333333333333 * (J * Math.pow(l, 3.0))));
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -7.5e+99:
		tmp = U + (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))
	elif l <= -2400000.0:
		tmp = math.pow(U, -8.0)
	elif l <= 1.2e+24:
		tmp = U + (J * (math.cos((0.5 * K)) * (l * 2.0)))
	elif l <= 7.2e+71:
		tmp = math.pow(U, -8.0)
	else:
		tmp = (2.0 * (l * J)) + (U + (0.3333333333333333 * (J * math.pow(l, 3.0))))
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -7.5e+99)
		tmp = Float64(U + Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))));
	elseif (l <= -2400000.0)
		tmp = U ^ -8.0;
	elseif (l <= 1.2e+24)
		tmp = Float64(U + Float64(J * Float64(cos(Float64(0.5 * K)) * Float64(l * 2.0))));
	elseif (l <= 7.2e+71)
		tmp = U ^ -8.0;
	else
		tmp = Float64(Float64(2.0 * Float64(l * J)) + Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= -7.5e+99)
		tmp = U + (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)));
	elseif (l <= -2400000.0)
		tmp = U ^ -8.0;
	elseif (l <= 1.2e+24)
		tmp = U + (J * (cos((0.5 * K)) * (l * 2.0)));
	elseif (l <= 7.2e+71)
		tmp = U ^ -8.0;
	else
		tmp = (2.0 * (l * J)) + (U + (0.3333333333333333 * (J * (l ^ 3.0))));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -7.5e+99], N[(U + N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -2400000.0], N[Power[U, -8.0], $MachinePrecision], If[LessEqual[l, 1.2e+24], N[(U + N[(J * N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 7.2e+71], N[Power[U, -8.0], $MachinePrecision], N[(N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision] + N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -7.5 \cdot 10^{+99}:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\

\mathbf{elif}\;\ell \leq -2400000:\\
\;\;\;\;{U}^{-8}\\

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

\mathbf{elif}\;\ell \leq 7.2 \cdot 10^{+71}:\\
\;\;\;\;{U}^{-8}\\

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


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

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

      \[\leadsto \color{blue}{\left(e^{\ell} - e^{-\ell}\right) \cdot J} + U \]
    3. Taylor expanded in l around 0 82.9%

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

    if -7.49999999999999963e99 < l < -2.4e6 or 1.2e24 < l < 7.1999999999999999e71

    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-rr57.6%

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

    if -2.4e6 < l < 1.2e24

    1. Initial program 72.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 97.9%

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

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

        \[\leadsto \color{blue}{\left(\cos \left(0.5 \cdot K\right) \cdot J\right) \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \left(0.0003968253968253968 \cdot {\ell}^{7} + \left(2 \cdot \ell + 0.016666666666666666 \cdot {\ell}^{5}\right)\right)\right)} + U \]
      2. *-commutative97.9%

        \[\leadsto \color{blue}{\left(J \cdot \cos \left(0.5 \cdot K\right)\right)} \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \left(0.0003968253968253968 \cdot {\ell}^{7} + \left(2 \cdot \ell + 0.016666666666666666 \cdot {\ell}^{5}\right)\right)\right) + U \]
      3. fma-def97.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \color{blue}{\mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.0003968253968253968 \cdot {\ell}^{7} + \left(2 \cdot \ell + 0.016666666666666666 \cdot {\ell}^{5}\right)\right)} + U \]
      4. +-commutative97.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.0003968253968253968 \cdot {\ell}^{7} + \color{blue}{\left(0.016666666666666666 \cdot {\ell}^{5} + 2 \cdot \ell\right)}\right) + U \]
      5. *-commutative97.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.0003968253968253968 \cdot {\ell}^{7} + \left(0.016666666666666666 \cdot {\ell}^{5} + \color{blue}{\ell \cdot 2}\right)\right) + U \]
      6. fma-udef97.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.0003968253968253968 \cdot {\ell}^{7} + \color{blue}{\mathsf{fma}\left(0.016666666666666666, {\ell}^{5}, \ell \cdot 2\right)}\right) + U \]
      7. fma-udef97.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, \color{blue}{\mathsf{fma}\left(0.0003968253968253968, {\ell}^{7}, \mathsf{fma}\left(0.016666666666666666, {\ell}^{5}, \ell \cdot 2\right)\right)}\right) + U \]
      8. associate-*r*97.9%

        \[\leadsto \color{blue}{J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, \mathsf{fma}\left(0.0003968253968253968, {\ell}^{7}, \mathsf{fma}\left(0.016666666666666666, {\ell}^{5}, \ell \cdot 2\right)\right)\right)\right)} + U \]
    5. Simplified97.9%

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

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

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

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

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

    if 7.1999999999999999e71 < 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 K around 0 78.0%

      \[\leadsto \color{blue}{\left(e^{\ell} - e^{-\ell}\right) \cdot J} + U \]
    3. Taylor expanded in l around 0 72.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -7.5 \cdot 10^{+99}:\\ \;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq -2400000:\\ \;\;\;\;{U}^{-8}\\ \mathbf{elif}\;\ell \leq 1.2 \cdot 10^{+24}:\\ \;\;\;\;U + J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 7.2 \cdot 10^{+71}:\\ \;\;\;\;{U}^{-8}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\ell \cdot J\right) + \left(U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\right)\\ \end{array} \]

Alternative 13: 78.7% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\ \mathbf{if}\;\ell \leq -3.15 \cdot 10^{+100}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -2400000:\\ \;\;\;\;{U}^{-8}\\ \mathbf{elif}\;\ell \leq 1.05 \cdot 10^{+24}:\\ \;\;\;\;U + J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 2.8 \cdot 10^{+71}:\\ \;\;\;\;{U}^{-8}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (+ U (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0))))))
   (if (<= l -3.15e+100)
     t_0
     (if (<= l -2400000.0)
       (pow U -8.0)
       (if (<= l 1.05e+24)
         (+ U (* J (* (cos (* 0.5 K)) (* l 2.0))))
         (if (<= l 2.8e+71) (pow U -8.0) t_0))))))
double code(double J, double l, double K, double U) {
	double t_0 = U + (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0)));
	double tmp;
	if (l <= -3.15e+100) {
		tmp = t_0;
	} else if (l <= -2400000.0) {
		tmp = pow(U, -8.0);
	} else if (l <= 1.05e+24) {
		tmp = U + (J * (cos((0.5 * K)) * (l * 2.0)));
	} else if (l <= 2.8e+71) {
		tmp = pow(U, -8.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 * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0)))
    if (l <= (-3.15d+100)) then
        tmp = t_0
    else if (l <= (-2400000.0d0)) then
        tmp = u ** (-8.0d0)
    else if (l <= 1.05d+24) then
        tmp = u + (j * (cos((0.5d0 * k)) * (l * 2.0d0)))
    else if (l <= 2.8d+71) then
        tmp = u ** (-8.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 * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)));
	double tmp;
	if (l <= -3.15e+100) {
		tmp = t_0;
	} else if (l <= -2400000.0) {
		tmp = Math.pow(U, -8.0);
	} else if (l <= 1.05e+24) {
		tmp = U + (J * (Math.cos((0.5 * K)) * (l * 2.0)));
	} else if (l <= 2.8e+71) {
		tmp = Math.pow(U, -8.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = U + (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))
	tmp = 0
	if l <= -3.15e+100:
		tmp = t_0
	elif l <= -2400000.0:
		tmp = math.pow(U, -8.0)
	elif l <= 1.05e+24:
		tmp = U + (J * (math.cos((0.5 * K)) * (l * 2.0)))
	elif l <= 2.8e+71:
		tmp = math.pow(U, -8.0)
	else:
		tmp = t_0
	return tmp
function code(J, l, K, U)
	t_0 = Float64(U + Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))
	tmp = 0.0
	if (l <= -3.15e+100)
		tmp = t_0;
	elseif (l <= -2400000.0)
		tmp = U ^ -8.0;
	elseif (l <= 1.05e+24)
		tmp = Float64(U + Float64(J * Float64(cos(Float64(0.5 * K)) * Float64(l * 2.0))));
	elseif (l <= 2.8e+71)
		tmp = U ^ -8.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = U + (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)));
	tmp = 0.0;
	if (l <= -3.15e+100)
		tmp = t_0;
	elseif (l <= -2400000.0)
		tmp = U ^ -8.0;
	elseif (l <= 1.05e+24)
		tmp = U + (J * (cos((0.5 * K)) * (l * 2.0)));
	elseif (l <= 2.8e+71)
		tmp = U ^ -8.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[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.15e+100], t$95$0, If[LessEqual[l, -2400000.0], N[Power[U, -8.0], $MachinePrecision], If[LessEqual[l, 1.05e+24], N[(U + N[(J * N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.8e+71], N[Power[U, -8.0], $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\
\mathbf{if}\;\ell \leq -3.15 \cdot 10^{+100}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq -2400000:\\
\;\;\;\;{U}^{-8}\\

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

\mathbf{elif}\;\ell \leq 2.8 \cdot 10^{+71}:\\
\;\;\;\;{U}^{-8}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -3.1500000000000002e100 or 2.80000000000000002e71 < 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 K around 0 80.0%

      \[\leadsto \color{blue}{\left(e^{\ell} - e^{-\ell}\right) \cdot J} + U \]
    3. Taylor expanded in l around 0 76.6%

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

    if -3.1500000000000002e100 < l < -2.4e6 or 1.0500000000000001e24 < l < 2.80000000000000002e71

    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-rr57.6%

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

    if -2.4e6 < l < 1.0500000000000001e24

    1. Initial program 72.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 97.9%

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

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

        \[\leadsto \color{blue}{\left(\cos \left(0.5 \cdot K\right) \cdot J\right) \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \left(0.0003968253968253968 \cdot {\ell}^{7} + \left(2 \cdot \ell + 0.016666666666666666 \cdot {\ell}^{5}\right)\right)\right)} + U \]
      2. *-commutative97.9%

        \[\leadsto \color{blue}{\left(J \cdot \cos \left(0.5 \cdot K\right)\right)} \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \left(0.0003968253968253968 \cdot {\ell}^{7} + \left(2 \cdot \ell + 0.016666666666666666 \cdot {\ell}^{5}\right)\right)\right) + U \]
      3. fma-def97.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \color{blue}{\mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.0003968253968253968 \cdot {\ell}^{7} + \left(2 \cdot \ell + 0.016666666666666666 \cdot {\ell}^{5}\right)\right)} + U \]
      4. +-commutative97.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.0003968253968253968 \cdot {\ell}^{7} + \color{blue}{\left(0.016666666666666666 \cdot {\ell}^{5} + 2 \cdot \ell\right)}\right) + U \]
      5. *-commutative97.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.0003968253968253968 \cdot {\ell}^{7} + \left(0.016666666666666666 \cdot {\ell}^{5} + \color{blue}{\ell \cdot 2}\right)\right) + U \]
      6. fma-udef97.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.0003968253968253968 \cdot {\ell}^{7} + \color{blue}{\mathsf{fma}\left(0.016666666666666666, {\ell}^{5}, \ell \cdot 2\right)}\right) + U \]
      7. fma-udef97.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, \color{blue}{\mathsf{fma}\left(0.0003968253968253968, {\ell}^{7}, \mathsf{fma}\left(0.016666666666666666, {\ell}^{5}, \ell \cdot 2\right)\right)}\right) + U \]
      8. associate-*r*97.9%

        \[\leadsto \color{blue}{J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, \mathsf{fma}\left(0.0003968253968253968, {\ell}^{7}, \mathsf{fma}\left(0.016666666666666666, {\ell}^{5}, \ell \cdot 2\right)\right)\right)\right)} + U \]
    5. Simplified97.9%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.15 \cdot 10^{+100}:\\ \;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq -2400000:\\ \;\;\;\;{U}^{-8}\\ \mathbf{elif}\;\ell \leq 1.05 \cdot 10^{+24}:\\ \;\;\;\;U + J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 2.8 \cdot 10^{+71}:\\ \;\;\;\;{U}^{-8}\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\ \end{array} \]

Alternative 14: 61.9% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -7500000000:\\ \;\;\;\;{U}^{-3}\\ \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+24} \lor \neg \left(\ell \leq 6 \cdot 10^{+125}\right):\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(0.5 \cdot K\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{U}^{-8}\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -7500000000.0)
   (pow U -3.0)
   (if (or (<= l 1.1e+24) (not (<= l 6e+125)))
     (+ U (* 2.0 (* l (* J (cos (* 0.5 K))))))
     (pow U -8.0))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -7500000000.0) {
		tmp = pow(U, -3.0);
	} else if ((l <= 1.1e+24) || !(l <= 6e+125)) {
		tmp = U + (2.0 * (l * (J * cos((0.5 * K)))));
	} else {
		tmp = pow(U, -8.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 <= (-7500000000.0d0)) then
        tmp = u ** (-3.0d0)
    else if ((l <= 1.1d+24) .or. (.not. (l <= 6d+125))) then
        tmp = u + (2.0d0 * (l * (j * cos((0.5d0 * k)))))
    else
        tmp = u ** (-8.0d0)
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -7500000000.0) {
		tmp = Math.pow(U, -3.0);
	} else if ((l <= 1.1e+24) || !(l <= 6e+125)) {
		tmp = U + (2.0 * (l * (J * Math.cos((0.5 * K)))));
	} else {
		tmp = Math.pow(U, -8.0);
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -7500000000.0:
		tmp = math.pow(U, -3.0)
	elif (l <= 1.1e+24) or not (l <= 6e+125):
		tmp = U + (2.0 * (l * (J * math.cos((0.5 * K)))))
	else:
		tmp = math.pow(U, -8.0)
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -7500000000.0)
		tmp = U ^ -3.0;
	elseif ((l <= 1.1e+24) || !(l <= 6e+125))
		tmp = Float64(U + Float64(2.0 * Float64(l * Float64(J * cos(Float64(0.5 * K))))));
	else
		tmp = U ^ -8.0;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= -7500000000.0)
		tmp = U ^ -3.0;
	elseif ((l <= 1.1e+24) || ~((l <= 6e+125)))
		tmp = U + (2.0 * (l * (J * cos((0.5 * K)))));
	else
		tmp = U ^ -8.0;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -7500000000.0], N[Power[U, -3.0], $MachinePrecision], If[Or[LessEqual[l, 1.1e+24], N[Not[LessEqual[l, 6e+125]], $MachinePrecision]], N[(U + N[(2.0 * N[(l * N[(J * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[U, -8.0], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -7500000000:\\
\;\;\;\;{U}^{-3}\\

\mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+24} \lor \neg \left(\ell \leq 6 \cdot 10^{+125}\right):\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(0.5 \cdot K\right)\right)\right)\\

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


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

    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-rr35.6%

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

    if -7.5e9 < l < 1.10000000000000001e24 or 6.0000000000000003e125 < l

    1. Initial program 78.3%

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

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

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

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

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

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

    if 1.10000000000000001e24 < l < 6.0000000000000003e125

    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-rr36.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -7500000000:\\ \;\;\;\;{U}^{-3}\\ \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+24} \lor \neg \left(\ell \leq 6 \cdot 10^{+125}\right):\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(0.5 \cdot K\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{U}^{-8}\\ \end{array} \]

Alternative 15: 61.9% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(0.5 \cdot K\right)\\ \mathbf{if}\;\ell \leq -155000000:\\ \;\;\;\;{U}^{-3}\\ \mathbf{elif}\;\ell \leq 2 \cdot 10^{+24}:\\ \;\;\;\;U + J \cdot \left(t_0 \cdot \left(\ell \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 4.8 \cdot 10^{+125}:\\ \;\;\;\;{U}^{-8}\\ \mathbf{else}:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot t_0\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (* 0.5 K))))
   (if (<= l -155000000.0)
     (pow U -3.0)
     (if (<= l 2e+24)
       (+ U (* J (* t_0 (* l 2.0))))
       (if (<= l 4.8e+125) (pow U -8.0) (+ U (* 2.0 (* l (* J t_0)))))))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((0.5 * K));
	double tmp;
	if (l <= -155000000.0) {
		tmp = pow(U, -3.0);
	} else if (l <= 2e+24) {
		tmp = U + (J * (t_0 * (l * 2.0)));
	} else if (l <= 4.8e+125) {
		tmp = pow(U, -8.0);
	} else {
		tmp = U + (2.0 * (l * (J * 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 = cos((0.5d0 * k))
    if (l <= (-155000000.0d0)) then
        tmp = u ** (-3.0d0)
    else if (l <= 2d+24) then
        tmp = u + (j * (t_0 * (l * 2.0d0)))
    else if (l <= 4.8d+125) then
        tmp = u ** (-8.0d0)
    else
        tmp = u + (2.0d0 * (l * (j * t_0)))
    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 tmp;
	if (l <= -155000000.0) {
		tmp = Math.pow(U, -3.0);
	} else if (l <= 2e+24) {
		tmp = U + (J * (t_0 * (l * 2.0)));
	} else if (l <= 4.8e+125) {
		tmp = Math.pow(U, -8.0);
	} else {
		tmp = U + (2.0 * (l * (J * t_0)));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((0.5 * K))
	tmp = 0
	if l <= -155000000.0:
		tmp = math.pow(U, -3.0)
	elif l <= 2e+24:
		tmp = U + (J * (t_0 * (l * 2.0)))
	elif l <= 4.8e+125:
		tmp = math.pow(U, -8.0)
	else:
		tmp = U + (2.0 * (l * (J * t_0)))
	return tmp
function code(J, l, K, U)
	t_0 = cos(Float64(0.5 * K))
	tmp = 0.0
	if (l <= -155000000.0)
		tmp = U ^ -3.0;
	elseif (l <= 2e+24)
		tmp = Float64(U + Float64(J * Float64(t_0 * Float64(l * 2.0))));
	elseif (l <= 4.8e+125)
		tmp = U ^ -8.0;
	else
		tmp = Float64(U + Float64(2.0 * Float64(l * Float64(J * t_0))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = cos((0.5 * K));
	tmp = 0.0;
	if (l <= -155000000.0)
		tmp = U ^ -3.0;
	elseif (l <= 2e+24)
		tmp = U + (J * (t_0 * (l * 2.0)));
	elseif (l <= 4.8e+125)
		tmp = U ^ -8.0;
	else
		tmp = U + (2.0 * (l * (J * t_0)));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -155000000.0], N[Power[U, -3.0], $MachinePrecision], If[LessEqual[l, 2e+24], N[(U + N[(J * N[(t$95$0 * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 4.8e+125], N[Power[U, -8.0], $MachinePrecision], N[(U + N[(2.0 * N[(l * N[(J * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;\ell \leq 4.8 \cdot 10^{+125}:\\
\;\;\;\;{U}^{-8}\\

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


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

    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-rr35.6%

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

    if -1.55e8 < l < 2e24

    1. Initial program 72.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 97.9%

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

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

        \[\leadsto \color{blue}{\left(\cos \left(0.5 \cdot K\right) \cdot J\right) \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \left(0.0003968253968253968 \cdot {\ell}^{7} + \left(2 \cdot \ell + 0.016666666666666666 \cdot {\ell}^{5}\right)\right)\right)} + U \]
      2. *-commutative97.9%

        \[\leadsto \color{blue}{\left(J \cdot \cos \left(0.5 \cdot K\right)\right)} \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \left(0.0003968253968253968 \cdot {\ell}^{7} + \left(2 \cdot \ell + 0.016666666666666666 \cdot {\ell}^{5}\right)\right)\right) + U \]
      3. fma-def97.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \color{blue}{\mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.0003968253968253968 \cdot {\ell}^{7} + \left(2 \cdot \ell + 0.016666666666666666 \cdot {\ell}^{5}\right)\right)} + U \]
      4. +-commutative97.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.0003968253968253968 \cdot {\ell}^{7} + \color{blue}{\left(0.016666666666666666 \cdot {\ell}^{5} + 2 \cdot \ell\right)}\right) + U \]
      5. *-commutative97.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.0003968253968253968 \cdot {\ell}^{7} + \left(0.016666666666666666 \cdot {\ell}^{5} + \color{blue}{\ell \cdot 2}\right)\right) + U \]
      6. fma-udef97.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 0.0003968253968253968 \cdot {\ell}^{7} + \color{blue}{\mathsf{fma}\left(0.016666666666666666, {\ell}^{5}, \ell \cdot 2\right)}\right) + U \]
      7. fma-udef97.9%

        \[\leadsto \left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, \color{blue}{\mathsf{fma}\left(0.0003968253968253968, {\ell}^{7}, \mathsf{fma}\left(0.016666666666666666, {\ell}^{5}, \ell \cdot 2\right)\right)}\right) + U \]
      8. associate-*r*97.9%

        \[\leadsto \color{blue}{J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, \mathsf{fma}\left(0.0003968253968253968, {\ell}^{7}, \mathsf{fma}\left(0.016666666666666666, {\ell}^{5}, \ell \cdot 2\right)\right)\right)\right)} + U \]
    5. Simplified97.9%

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

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

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

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

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

    if 2e24 < l < 4.7999999999999999e125

    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-rr36.4%

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

    if 4.7999999999999999e125 < 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.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -155000000:\\ \;\;\;\;{U}^{-3}\\ \mathbf{elif}\;\ell \leq 2 \cdot 10^{+24}:\\ \;\;\;\;U + J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 4.8 \cdot 10^{+125}:\\ \;\;\;\;{U}^{-8}\\ \mathbf{else}:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(0.5 \cdot K\right)\right)\right)\\ \end{array} \]

Alternative 16: 88.2% accurate, 2.7× speedup?

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

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

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

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

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

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

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

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

      \[\leadsto \left(J \cdot \left(2 \cdot \ell + \color{blue}{\left(0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right) \cdot \ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    6. distribute-rgt-out89.0%

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

    \[\leadsto \color{blue}{\left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
  6. Final simplification89.0%

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

Alternative 17: 55.1% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := U + J \cdot \left(\ell \cdot 2\right)\\ \mathbf{if}\;\ell \leq -18000000:\\ \;\;\;\;{U}^{-8}\\ \mathbf{elif}\;\ell \leq 860:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq 2.9 \cdot 10^{+120}:\\ \;\;\;\;{U}^{-8}\\ \mathbf{elif}\;\ell \leq 1.65 \cdot 10^{+218}:\\ \;\;\;\;U + J \cdot \left(-8 + K \cdot K\right)\\ \mathbf{elif}\;\ell \leq 3.4 \cdot 10^{+238}:\\ \;\;\;\;{U}^{-8}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (+ U (* J (* l 2.0)))))
   (if (<= l -18000000.0)
     (pow U -8.0)
     (if (<= l 860.0)
       t_0
       (if (<= l 2.9e+120)
         (pow U -8.0)
         (if (<= l 1.65e+218)
           (+ U (* J (+ -8.0 (* K K))))
           (if (<= l 3.4e+238) (pow U -8.0) t_0)))))))
double code(double J, double l, double K, double U) {
	double t_0 = U + (J * (l * 2.0));
	double tmp;
	if (l <= -18000000.0) {
		tmp = pow(U, -8.0);
	} else if (l <= 860.0) {
		tmp = t_0;
	} else if (l <= 2.9e+120) {
		tmp = pow(U, -8.0);
	} else if (l <= 1.65e+218) {
		tmp = U + (J * (-8.0 + (K * K)));
	} else if (l <= 3.4e+238) {
		tmp = pow(U, -8.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))
    if (l <= (-18000000.0d0)) then
        tmp = u ** (-8.0d0)
    else if (l <= 860.0d0) then
        tmp = t_0
    else if (l <= 2.9d+120) then
        tmp = u ** (-8.0d0)
    else if (l <= 1.65d+218) then
        tmp = u + (j * ((-8.0d0) + (k * k)))
    else if (l <= 3.4d+238) then
        tmp = u ** (-8.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));
	double tmp;
	if (l <= -18000000.0) {
		tmp = Math.pow(U, -8.0);
	} else if (l <= 860.0) {
		tmp = t_0;
	} else if (l <= 2.9e+120) {
		tmp = Math.pow(U, -8.0);
	} else if (l <= 1.65e+218) {
		tmp = U + (J * (-8.0 + (K * K)));
	} else if (l <= 3.4e+238) {
		tmp = Math.pow(U, -8.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = U + (J * (l * 2.0))
	tmp = 0
	if l <= -18000000.0:
		tmp = math.pow(U, -8.0)
	elif l <= 860.0:
		tmp = t_0
	elif l <= 2.9e+120:
		tmp = math.pow(U, -8.0)
	elif l <= 1.65e+218:
		tmp = U + (J * (-8.0 + (K * K)))
	elif l <= 3.4e+238:
		tmp = math.pow(U, -8.0)
	else:
		tmp = t_0
	return tmp
function code(J, l, K, U)
	t_0 = Float64(U + Float64(J * Float64(l * 2.0)))
	tmp = 0.0
	if (l <= -18000000.0)
		tmp = U ^ -8.0;
	elseif (l <= 860.0)
		tmp = t_0;
	elseif (l <= 2.9e+120)
		tmp = U ^ -8.0;
	elseif (l <= 1.65e+218)
		tmp = Float64(U + Float64(J * Float64(-8.0 + Float64(K * K))));
	elseif (l <= 3.4e+238)
		tmp = U ^ -8.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = U + (J * (l * 2.0));
	tmp = 0.0;
	if (l <= -18000000.0)
		tmp = U ^ -8.0;
	elseif (l <= 860.0)
		tmp = t_0;
	elseif (l <= 2.9e+120)
		tmp = U ^ -8.0;
	elseif (l <= 1.65e+218)
		tmp = U + (J * (-8.0 + (K * K)));
	elseif (l <= 3.4e+238)
		tmp = U ^ -8.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -18000000.0], N[Power[U, -8.0], $MachinePrecision], If[LessEqual[l, 860.0], t$95$0, If[LessEqual[l, 2.9e+120], N[Power[U, -8.0], $MachinePrecision], If[LessEqual[l, 1.65e+218], N[(U + N[(J * N[(-8.0 + N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3.4e+238], N[Power[U, -8.0], $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := U + J \cdot \left(\ell \cdot 2\right)\\
\mathbf{if}\;\ell \leq -18000000:\\
\;\;\;\;{U}^{-8}\\

\mathbf{elif}\;\ell \leq 860:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq 2.9 \cdot 10^{+120}:\\
\;\;\;\;{U}^{-8}\\

\mathbf{elif}\;\ell \leq 1.65 \cdot 10^{+218}:\\
\;\;\;\;U + J \cdot \left(-8 + K \cdot K\right)\\

\mathbf{elif}\;\ell \leq 3.4 \cdot 10^{+238}:\\
\;\;\;\;{U}^{-8}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -1.8e7 or 860 < l < 2.9000000000000001e120 or 1.64999999999999999e218 < l < 3.3999999999999998e238

    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-rr33.9%

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

    if -1.8e7 < l < 860 or 3.3999999999999998e238 < l

    1. Initial program 74.3%

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

      \[\leadsto \color{blue}{\left(e^{\ell} - e^{-\ell}\right) \cdot J} + U \]
    3. Taylor expanded in l around 0 80.9%

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

    if 2.9000000000000001e120 < l < 1.64999999999999999e218

    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-rr1.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -18000000:\\ \;\;\;\;{U}^{-8}\\ \mathbf{elif}\;\ell \leq 860:\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 2.9 \cdot 10^{+120}:\\ \;\;\;\;{U}^{-8}\\ \mathbf{elif}\;\ell \leq 1.65 \cdot 10^{+218}:\\ \;\;\;\;U + J \cdot \left(-8 + K \cdot K\right)\\ \mathbf{elif}\;\ell \leq 3.4 \cdot 10^{+238}:\\ \;\;\;\;{U}^{-8}\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\ \end{array} \]

Alternative 18: 53.6% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := U + J \cdot \left(\ell \cdot 2\right)\\ \mathbf{if}\;\ell \leq -3200000:\\ \;\;\;\;{U}^{-3}\\ \mathbf{elif}\;\ell \leq 800:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq 2.5 \cdot 10^{+120}:\\ \;\;\;\;{U}^{-8}\\ \mathbf{elif}\;\ell \leq 3 \cdot 10^{+220}:\\ \;\;\;\;U + J \cdot \left(-8 + K \cdot K\right)\\ \mathbf{elif}\;\ell \leq 2.05 \cdot 10^{+239}:\\ \;\;\;\;{U}^{-8}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (+ U (* J (* l 2.0)))))
   (if (<= l -3200000.0)
     (pow U -3.0)
     (if (<= l 800.0)
       t_0
       (if (<= l 2.5e+120)
         (pow U -8.0)
         (if (<= l 3e+220)
           (+ U (* J (+ -8.0 (* K K))))
           (if (<= l 2.05e+239) (pow U -8.0) t_0)))))))
double code(double J, double l, double K, double U) {
	double t_0 = U + (J * (l * 2.0));
	double tmp;
	if (l <= -3200000.0) {
		tmp = pow(U, -3.0);
	} else if (l <= 800.0) {
		tmp = t_0;
	} else if (l <= 2.5e+120) {
		tmp = pow(U, -8.0);
	} else if (l <= 3e+220) {
		tmp = U + (J * (-8.0 + (K * K)));
	} else if (l <= 2.05e+239) {
		tmp = pow(U, -8.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))
    if (l <= (-3200000.0d0)) then
        tmp = u ** (-3.0d0)
    else if (l <= 800.0d0) then
        tmp = t_0
    else if (l <= 2.5d+120) then
        tmp = u ** (-8.0d0)
    else if (l <= 3d+220) then
        tmp = u + (j * ((-8.0d0) + (k * k)))
    else if (l <= 2.05d+239) then
        tmp = u ** (-8.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));
	double tmp;
	if (l <= -3200000.0) {
		tmp = Math.pow(U, -3.0);
	} else if (l <= 800.0) {
		tmp = t_0;
	} else if (l <= 2.5e+120) {
		tmp = Math.pow(U, -8.0);
	} else if (l <= 3e+220) {
		tmp = U + (J * (-8.0 + (K * K)));
	} else if (l <= 2.05e+239) {
		tmp = Math.pow(U, -8.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = U + (J * (l * 2.0))
	tmp = 0
	if l <= -3200000.0:
		tmp = math.pow(U, -3.0)
	elif l <= 800.0:
		tmp = t_0
	elif l <= 2.5e+120:
		tmp = math.pow(U, -8.0)
	elif l <= 3e+220:
		tmp = U + (J * (-8.0 + (K * K)))
	elif l <= 2.05e+239:
		tmp = math.pow(U, -8.0)
	else:
		tmp = t_0
	return tmp
function code(J, l, K, U)
	t_0 = Float64(U + Float64(J * Float64(l * 2.0)))
	tmp = 0.0
	if (l <= -3200000.0)
		tmp = U ^ -3.0;
	elseif (l <= 800.0)
		tmp = t_0;
	elseif (l <= 2.5e+120)
		tmp = U ^ -8.0;
	elseif (l <= 3e+220)
		tmp = Float64(U + Float64(J * Float64(-8.0 + Float64(K * K))));
	elseif (l <= 2.05e+239)
		tmp = U ^ -8.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = U + (J * (l * 2.0));
	tmp = 0.0;
	if (l <= -3200000.0)
		tmp = U ^ -3.0;
	elseif (l <= 800.0)
		tmp = t_0;
	elseif (l <= 2.5e+120)
		tmp = U ^ -8.0;
	elseif (l <= 3e+220)
		tmp = U + (J * (-8.0 + (K * K)));
	elseif (l <= 2.05e+239)
		tmp = U ^ -8.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3200000.0], N[Power[U, -3.0], $MachinePrecision], If[LessEqual[l, 800.0], t$95$0, If[LessEqual[l, 2.5e+120], N[Power[U, -8.0], $MachinePrecision], If[LessEqual[l, 3e+220], N[(U + N[(J * N[(-8.0 + N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.05e+239], N[Power[U, -8.0], $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := U + J \cdot \left(\ell \cdot 2\right)\\
\mathbf{if}\;\ell \leq -3200000:\\
\;\;\;\;{U}^{-3}\\

\mathbf{elif}\;\ell \leq 800:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq 2.5 \cdot 10^{+120}:\\
\;\;\;\;{U}^{-8}\\

\mathbf{elif}\;\ell \leq 3 \cdot 10^{+220}:\\
\;\;\;\;U + J \cdot \left(-8 + K \cdot K\right)\\

\mathbf{elif}\;\ell \leq 2.05 \cdot 10^{+239}:\\
\;\;\;\;{U}^{-8}\\

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


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

    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-rr35.6%

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

    if -3.2e6 < l < 800 or 2.0500000000000001e239 < l

    1. Initial program 74.3%

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

      \[\leadsto \color{blue}{\left(e^{\ell} - e^{-\ell}\right) \cdot J} + U \]
    3. Taylor expanded in l around 0 80.9%

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

    if 800 < l < 2.50000000000000009e120 or 3.00000000000000024e220 < l < 2.0500000000000001e239

    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-rr35.0%

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

    if 2.50000000000000009e120 < l < 3.00000000000000024e220

    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-rr1.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3200000:\\ \;\;\;\;{U}^{-3}\\ \mathbf{elif}\;\ell \leq 800:\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 2.5 \cdot 10^{+120}:\\ \;\;\;\;{U}^{-8}\\ \mathbf{elif}\;\ell \leq 3 \cdot 10^{+220}:\\ \;\;\;\;U + J \cdot \left(-8 + K \cdot K\right)\\ \mathbf{elif}\;\ell \leq 2.05 \cdot 10^{+239}:\\ \;\;\;\;{U}^{-8}\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\ \end{array} \]

Alternative 19: 52.8% accurate, 28.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 1.45 \cdot 10^{+24}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(-8 + K \cdot K\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l 1.45e+24) (+ U (* J (* l 2.0))) (+ U (* J (+ -8.0 (* K K))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= 1.45e+24) {
		tmp = U + (J * (l * 2.0));
	} else {
		tmp = U + (J * (-8.0 + (K * K)));
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: tmp
    if (l <= 1.45d+24) then
        tmp = u + (j * (l * 2.0d0))
    else
        tmp = u + (j * ((-8.0d0) + (k * k)))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= 1.45e+24) {
		tmp = U + (J * (l * 2.0));
	} else {
		tmp = U + (J * (-8.0 + (K * K)));
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= 1.45e+24:
		tmp = U + (J * (l * 2.0))
	else:
		tmp = U + (J * (-8.0 + (K * K)))
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= 1.45e+24)
		tmp = Float64(U + Float64(J * Float64(l * 2.0)));
	else
		tmp = Float64(U + Float64(J * Float64(-8.0 + Float64(K * K))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= 1.45e+24)
		tmp = U + (J * (l * 2.0));
	else
		tmp = U + (J * (-8.0 + (K * K)));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, 1.45e+24], N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(-8.0 + N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.45 \cdot 10^{+24}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\

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


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

    1. Initial program 79.8%

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

      \[\leadsto \color{blue}{\left(e^{\ell} - e^{-\ell}\right) \cdot J} + U \]
    3. Taylor expanded in l around 0 64.8%

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

    if 1.4499999999999999e24 < 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. Applied egg-rr1.2%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 1.45 \cdot 10^{+24}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(-8 + K \cdot K\right)\\ \end{array} \]

Alternative 20: 39.1% accurate, 44.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 1.1 \cdot 10^{+49}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(U - -8\right)\\ \end{array} \end{array} \]
(FPCore (J l K U) :precision binary64 (if (<= l 1.1e+49) U (* U (- U -8.0))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= 1.1e+49) {
		tmp = U;
	} else {
		tmp = U * (U - -8.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 <= 1.1d+49) then
        tmp = u
    else
        tmp = u * (u - (-8.0d0))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= 1.1e+49) {
		tmp = U;
	} else {
		tmp = U * (U - -8.0);
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= 1.1e+49:
		tmp = U
	else:
		tmp = U * (U - -8.0)
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= 1.1e+49)
		tmp = U;
	else
		tmp = Float64(U * Float64(U - -8.0));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= 1.1e+49)
		tmp = U;
	else
		tmp = U * (U - -8.0);
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, 1.1e+49], U, N[(U * N[(U - -8.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.1 \cdot 10^{+49}:\\
\;\;\;\;U\\

\mathbf{else}:\\
\;\;\;\;U \cdot \left(U - -8\right)\\


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

    1. Initial program 80.7%

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

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

    if 1.1e49 < 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. Applied egg-rr16.3%

      \[\leadsto \color{blue}{U \cdot \left(U - -8\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification41.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 1.1 \cdot 10^{+49}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(U - -8\right)\\ \end{array} \]

Alternative 21: 54.5% accurate, 44.6× speedup?

\[\begin{array}{l} \\ U + J \cdot \left(\ell \cdot 2\right) \end{array} \]
(FPCore (J l K U) :precision binary64 (+ U (* J (* l 2.0))))
double code(double J, double l, double K, double U) {
	return U + (J * (l * 2.0));
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    code = u + (j * (l * 2.0d0))
end function
public static double code(double J, double l, double K, double U) {
	return U + (J * (l * 2.0));
}
def code(J, l, K, U):
	return U + (J * (l * 2.0))
function code(J, l, K, U)
	return Float64(U + Float64(J * Float64(l * 2.0)))
end
function tmp = code(J, l, K, U)
	tmp = U + (J * (l * 2.0));
end
code[J_, l_, K_, U_] := N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
U + J \cdot \left(\ell \cdot 2\right)
\end{array}
Derivation
  1. Initial program 84.8%

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

    \[\leadsto \color{blue}{\left(e^{\ell} - e^{-\ell}\right) \cdot J} + U \]
  3. Taylor expanded in l around 0 53.6%

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

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

Alternative 22: 38.7% accurate, 61.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 1.05 \cdot 10^{+94}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot U\\ \end{array} \end{array} \]
(FPCore (J l K U) :precision binary64 (if (<= l 1.05e+94) U (* U U)))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= 1.05e+94) {
		tmp = U;
	} else {
		tmp = U * U;
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: tmp
    if (l <= 1.05d+94) then
        tmp = u
    else
        tmp = u * u
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= 1.05e+94) {
		tmp = U;
	} else {
		tmp = U * U;
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= 1.05e+94:
		tmp = U
	else:
		tmp = U * U
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= 1.05e+94)
		tmp = U;
	else
		tmp = Float64(U * U);
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= 1.05e+94)
		tmp = U;
	else
		tmp = U * U;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, 1.05e+94], U, N[(U * U), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.05 \cdot 10^{+94}:\\
\;\;\;\;U\\

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


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

    1. Initial program 81.5%

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

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

    if 1.04999999999999995e94 < 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. Applied egg-rr19.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 1.05 \cdot 10^{+94}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot U\\ \end{array} \]

Alternative 23: 36.9% 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 84.8%

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

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

    \[\leadsto U \]

Reproduce

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