Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.7% → 99.3%
Time: 16.6s
Alternatives: 19
Speedup: 1.3×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 19 alternatives:

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

Initial Program: 86.7% 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.3% 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 -1:\\ \;\;\;\;\mathsf{fma}\left(J, t\_0 \cdot t\_1, U\right)\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-9}:\\ \;\;\;\;\mathsf{fma}\left(J, \left(2 \cdot \ell\right) \cdot t\_1, U\right)\\ \mathbf{else}:\\ \;\;\;\;J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot t\_0\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 -1.0)
     (fma J (* t_0 t_1) U)
     (if (<= t_0 5e-9)
       (fma J (* (* 2.0 l) t_1) U)
       (* J (* (cos (* 0.5 K)) t_0))))))
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 <= -1.0) {
		tmp = fma(J, (t_0 * t_1), U);
	} else if (t_0 <= 5e-9) {
		tmp = fma(J, ((2.0 * l) * t_1), U);
	} else {
		tmp = J * (cos((0.5 * K)) * t_0);
	}
	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 <= -1.0)
		tmp = fma(J, Float64(t_0 * t_1), U);
	elseif (t_0 <= 5e-9)
		tmp = fma(J, Float64(Float64(2.0 * l) * t_1), U);
	else
		tmp = Float64(J * Float64(cos(Float64(0.5 * K)) * t_0));
	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, -1.0], N[(J * N[(t$95$0 * t$95$1), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, 5e-9], N[(J * N[(N[(2.0 * l), $MachinePrecision] * t$95$1), $MachinePrecision] + U), $MachinePrecision], N[(J * N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * t$95$0), $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 -1:\\
\;\;\;\;\mathsf{fma}\left(J, t\_0 \cdot t\_1, U\right)\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(J, \left(2 \cdot \ell\right) \cdot t\_1, U\right)\\

\mathbf{else}:\\
\;\;\;\;J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot t\_0\right)\\


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

    1. Initial program 100.0%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*100.0%

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

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

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

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

    1. Initial program 72.5%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*72.5%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), U\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in l around 0 99.9%

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

    if 5.0000000000000001e-9 < (-.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 \]
    2. Add Preprocessing
    3. Taylor expanded in J around inf 100.0%

      \[\leadsto \color{blue}{J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(e^{\ell} - e^{-\ell}\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 2: 99.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\ell} - e^{-\ell}\\ t_1 := J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot t\_0\right)\\ \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-9}:\\ \;\;\;\;\left(\ell \cdot \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{2}\right) + 2 \cdot J\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (- (exp l) (exp (- l)))) (t_1 (* J (* (cos (* 0.5 K)) t_0))))
   (if (<= t_0 (- INFINITY))
     t_1
     (if (<= t_0 5e-9)
       (+
        (*
         (* l (+ (* 0.3333333333333333 (* J (pow l 2.0))) (* 2.0 J)))
         (cos (/ K 2.0)))
        U)
       t_1))))
double code(double J, double l, double K, double U) {
	double t_0 = exp(l) - exp(-l);
	double t_1 = J * (cos((0.5 * K)) * t_0);
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_0 <= 5e-9) {
		tmp = ((l * ((0.3333333333333333 * (J * pow(l, 2.0))) + (2.0 * J))) * cos((K / 2.0))) + U;
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double J, double l, double K, double U) {
	double t_0 = Math.exp(l) - Math.exp(-l);
	double t_1 = J * (Math.cos((0.5 * K)) * t_0);
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else if (t_0 <= 5e-9) {
		tmp = ((l * ((0.3333333333333333 * (J * Math.pow(l, 2.0))) + (2.0 * J))) * Math.cos((K / 2.0))) + U;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.exp(l) - math.exp(-l)
	t_1 = J * (math.cos((0.5 * K)) * t_0)
	tmp = 0
	if t_0 <= -math.inf:
		tmp = t_1
	elif t_0 <= 5e-9:
		tmp = ((l * ((0.3333333333333333 * (J * math.pow(l, 2.0))) + (2.0 * J))) * math.cos((K / 2.0))) + U
	else:
		tmp = t_1
	return tmp
function code(J, l, K, U)
	t_0 = Float64(exp(l) - exp(Float64(-l)))
	t_1 = Float64(J * Float64(cos(Float64(0.5 * K)) * t_0))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = t_1;
	elseif (t_0 <= 5e-9)
		tmp = Float64(Float64(Float64(l * Float64(Float64(0.3333333333333333 * Float64(J * (l ^ 2.0))) + Float64(2.0 * J))) * cos(Float64(K / 2.0))) + U);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = exp(l) - exp(-l);
	t_1 = J * (cos((0.5 * K)) * t_0);
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = t_1;
	elseif (t_0 <= 5e-9)
		tmp = ((l * ((0.3333333333333333 * (J * (l ^ 2.0))) + (2.0 * J))) * cos((K / 2.0))) + U;
	else
		tmp = t_1;
	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[(J * N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$1, If[LessEqual[t$95$0, 5e-9], N[(N[(N[(l * N[(N[(0.3333333333333333 * N[(J * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
t_1 := J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot t\_0\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\left(\ell \cdot \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{2}\right) + 2 \cdot J\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 5.0000000000000001e-9 < (-.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 \]
    2. Add Preprocessing
    3. Taylor expanded in J around inf 100.0%

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

    if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.0000000000000001e-9

    1. Initial program 73.0%

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

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

Alternative 3: 99.3% 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 -1:\\ \;\;\;\;\left(J \cdot t\_1\right) \cdot t\_0 + U\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-9}:\\ \;\;\;\;\mathsf{fma}\left(J, \left(2 \cdot \ell\right) \cdot t\_0, U\right)\\ \mathbf{else}:\\ \;\;\;\;J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot t\_1\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 (<= t_1 -1.0)
     (+ (* (* J t_1) t_0) U)
     (if (<= t_1 5e-9)
       (fma J (* (* 2.0 l) t_0) U)
       (* J (* (cos (* 0.5 K)) t_1))))))
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 <= -1.0) {
		tmp = ((J * t_1) * t_0) + U;
	} else if (t_1 <= 5e-9) {
		tmp = fma(J, ((2.0 * l) * t_0), U);
	} else {
		tmp = J * (cos((0.5 * K)) * t_1);
	}
	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 <= -1.0)
		tmp = Float64(Float64(Float64(J * t_1) * t_0) + U);
	elseif (t_1 <= 5e-9)
		tmp = fma(J, Float64(Float64(2.0 * l) * t_0), U);
	else
		tmp = Float64(J * Float64(cos(Float64(0.5 * K)) * t_1));
	end
	return 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[LessEqual[t$95$1, -1.0], N[(N[(N[(J * t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$1, 5e-9], N[(J * N[(N[(2.0 * l), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(J * N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * t$95$1), $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 -1:\\
\;\;\;\;\left(J \cdot t\_1\right) \cdot t\_0 + U\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(J, \left(2 \cdot \ell\right) \cdot t\_0, U\right)\\

\mathbf{else}:\\
\;\;\;\;J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot t\_1\right)\\


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

    1. Initial program 100.0%

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

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

    1. Initial program 72.5%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*72.5%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), U\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in l around 0 99.9%

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

    if 5.0000000000000001e-9 < (-.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 \]
    2. Add Preprocessing
    3. Taylor expanded in J around inf 100.0%

      \[\leadsto \color{blue}{J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(e^{\ell} - e^{-\ell}\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 4: 86.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := J \cdot \left(e^{\ell} - e^{-\ell}\right)\\ t_1 := t\_0 + U\\ \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 10^{+35}:\\ \;\;\;\;\mathsf{fma}\left(J, \left(2 \cdot \ell\right) \cdot \cos \left(\frac{K}{2}\right), U\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (* J (- (exp l) (exp (- l))))) (t_1 (+ t_0 U)))
   (if (<= t_0 (- INFINITY))
     t_1
     (if (<= t_0 1e+35) (fma J (* (* 2.0 l) (cos (/ K 2.0))) U) t_1))))
double code(double J, double l, double K, double U) {
	double t_0 = J * (exp(l) - exp(-l));
	double t_1 = t_0 + U;
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_0 <= 1e+35) {
		tmp = fma(J, ((2.0 * l) * cos((K / 2.0))), U);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(J, l, K, U)
	t_0 = Float64(J * Float64(exp(l) - exp(Float64(-l))))
	t_1 = Float64(t_0 + U)
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = t_1;
	elseif (t_0 <= 1e+35)
		tmp = fma(J, Float64(Float64(2.0 * l) * cos(Float64(K / 2.0))), U);
	else
		tmp = t_1;
	end
	return tmp
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 + U), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$1, If[LessEqual[t$95$0, 1e+35], N[(J * N[(N[(2.0 * l), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
t_1 := t\_0 + U\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 10^{+35}:\\
\;\;\;\;\mathsf{fma}\left(J, \left(2 \cdot \ell\right) \cdot \cos \left(\frac{K}{2}\right), U\right)\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < -inf.0 or 9.9999999999999997e34 < (*.f64 J (-.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 \]
    2. Add Preprocessing
    3. Taylor expanded in K around 0 81.9%

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

    if -inf.0 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < 9.9999999999999997e34

    1. Initial program 73.0%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*73.0%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), U\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in l around 0 99.3%

      \[\leadsto \mathsf{fma}\left(J, \color{blue}{\left(2 \cdot \ell\right)} \cdot \cos \left(\frac{K}{2}\right), U\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 86.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\ell} - e^{-\ell}\\ t_1 := J \cdot t\_0 + U\\ \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-9}:\\ \;\;\;\;2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) + U\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (- (exp l) (exp (- l)))) (t_1 (+ (* J t_0) U)))
   (if (<= t_0 (- INFINITY))
     t_1
     (if (<= t_0 5e-9) (+ (* 2.0 (* J (* l (cos (* 0.5 K))))) U) t_1))))
double code(double J, double l, double K, double U) {
	double t_0 = exp(l) - exp(-l);
	double t_1 = (J * t_0) + U;
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_0 <= 5e-9) {
		tmp = (2.0 * (J * (l * cos((0.5 * K))))) + U;
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double J, double l, double K, double U) {
	double t_0 = Math.exp(l) - Math.exp(-l);
	double t_1 = (J * t_0) + U;
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else if (t_0 <= 5e-9) {
		tmp = (2.0 * (J * (l * Math.cos((0.5 * K))))) + U;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.exp(l) - math.exp(-l)
	t_1 = (J * t_0) + U
	tmp = 0
	if t_0 <= -math.inf:
		tmp = t_1
	elif t_0 <= 5e-9:
		tmp = (2.0 * (J * (l * math.cos((0.5 * K))))) + U
	else:
		tmp = t_1
	return tmp
function code(J, l, K, U)
	t_0 = Float64(exp(l) - exp(Float64(-l)))
	t_1 = Float64(Float64(J * t_0) + U)
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = t_1;
	elseif (t_0 <= 5e-9)
		tmp = Float64(Float64(2.0 * Float64(J * Float64(l * cos(Float64(0.5 * K))))) + U);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = exp(l) - exp(-l);
	t_1 = (J * t_0) + U;
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = t_1;
	elseif (t_0 <= 5e-9)
		tmp = (2.0 * (J * (l * cos((0.5 * K))))) + U;
	else
		tmp = t_1;
	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[(N[(J * t$95$0), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$1, If[LessEqual[t$95$0, 5e-9], N[(N[(2.0 * N[(J * N[(l * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
t_1 := J \cdot t\_0 + U\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-9}:\\
\;\;\;\;2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right) + U\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 5.0000000000000001e-9 < (-.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 \]
    2. Add Preprocessing
    3. Taylor expanded in K around 0 81.9%

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

    if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.0000000000000001e-9

    1. Initial program 73.0%

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

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

Alternative 6: 93.8% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ t_1 := \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\right) \cdot t\_0 + U\\ t_2 := J \cdot \left(e^{\ell} - e^{-\ell}\right) + U\\ \mathbf{if}\;\ell \leq -5.6 \cdot 10^{+111}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\ell \leq -1.46 \cdot 10^{+25}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;\ell \leq 0.03:\\ \;\;\;\;\left(\ell \cdot \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{2}\right) + 2 \cdot J\right)\right) \cdot t\_0 + U\\ \mathbf{elif}\;\ell \leq 6 \cdot 10^{+92}:\\ \;\;\;\;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 (+ (* (* J (* 0.3333333333333333 (pow l 3.0))) t_0) U))
        (t_2 (+ (* J (- (exp l) (exp (- l)))) U)))
   (if (<= l -5.6e+111)
     t_1
     (if (<= l -1.46e+25)
       t_2
       (if (<= l 0.03)
         (+
          (* (* l (+ (* 0.3333333333333333 (* J (pow l 2.0))) (* 2.0 J))) t_0)
          U)
         (if (<= l 6e+92) t_2 t_1))))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K / 2.0));
	double t_1 = ((J * (0.3333333333333333 * pow(l, 3.0))) * t_0) + U;
	double t_2 = (J * (exp(l) - exp(-l))) + U;
	double tmp;
	if (l <= -5.6e+111) {
		tmp = t_1;
	} else if (l <= -1.46e+25) {
		tmp = t_2;
	} else if (l <= 0.03) {
		tmp = ((l * ((0.3333333333333333 * (J * pow(l, 2.0))) + (2.0 * J))) * t_0) + U;
	} else if (l <= 6e+92) {
		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 = ((j * (0.3333333333333333d0 * (l ** 3.0d0))) * t_0) + u
    t_2 = (j * (exp(l) - exp(-l))) + u
    if (l <= (-5.6d+111)) then
        tmp = t_1
    else if (l <= (-1.46d+25)) then
        tmp = t_2
    else if (l <= 0.03d0) then
        tmp = ((l * ((0.3333333333333333d0 * (j * (l ** 2.0d0))) + (2.0d0 * j))) * t_0) + u
    else if (l <= 6d+92) 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 = ((J * (0.3333333333333333 * Math.pow(l, 3.0))) * t_0) + U;
	double t_2 = (J * (Math.exp(l) - Math.exp(-l))) + U;
	double tmp;
	if (l <= -5.6e+111) {
		tmp = t_1;
	} else if (l <= -1.46e+25) {
		tmp = t_2;
	} else if (l <= 0.03) {
		tmp = ((l * ((0.3333333333333333 * (J * Math.pow(l, 2.0))) + (2.0 * J))) * t_0) + U;
	} else if (l <= 6e+92) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K / 2.0))
	t_1 = ((J * (0.3333333333333333 * math.pow(l, 3.0))) * t_0) + U
	t_2 = (J * (math.exp(l) - math.exp(-l))) + U
	tmp = 0
	if l <= -5.6e+111:
		tmp = t_1
	elif l <= -1.46e+25:
		tmp = t_2
	elif l <= 0.03:
		tmp = ((l * ((0.3333333333333333 * (J * math.pow(l, 2.0))) + (2.0 * J))) * t_0) + U
	elif l <= 6e+92:
		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(Float64(Float64(J * Float64(0.3333333333333333 * (l ^ 3.0))) * t_0) + U)
	t_2 = Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) + U)
	tmp = 0.0
	if (l <= -5.6e+111)
		tmp = t_1;
	elseif (l <= -1.46e+25)
		tmp = t_2;
	elseif (l <= 0.03)
		tmp = Float64(Float64(Float64(l * Float64(Float64(0.3333333333333333 * Float64(J * (l ^ 2.0))) + Float64(2.0 * J))) * t_0) + U);
	elseif (l <= 6e+92)
		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 = ((J * (0.3333333333333333 * (l ^ 3.0))) * t_0) + U;
	t_2 = (J * (exp(l) - exp(-l))) + U;
	tmp = 0.0;
	if (l <= -5.6e+111)
		tmp = t_1;
	elseif (l <= -1.46e+25)
		tmp = t_2;
	elseif (l <= 0.03)
		tmp = ((l * ((0.3333333333333333 * (J * (l ^ 2.0))) + (2.0 * J))) * t_0) + U;
	elseif (l <= 6e+92)
		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[(N[(N[(J * N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision]}, Block[{t$95$2 = N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -5.6e+111], t$95$1, If[LessEqual[l, -1.46e+25], t$95$2, If[LessEqual[l, 0.03], N[(N[(N[(l * N[(N[(0.3333333333333333 * N[(J * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 6e+92], t$95$2, t$95$1]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\right) \cdot t\_0 + U\\
t_2 := J \cdot \left(e^{\ell} - e^{-\ell}\right) + U\\
\mathbf{if}\;\ell \leq -5.6 \cdot 10^{+111}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;\ell \leq -1.46 \cdot 10^{+25}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;\ell \leq 0.03:\\
\;\;\;\;\left(\ell \cdot \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{2}\right) + 2 \cdot J\right)\right) \cdot t\_0 + U\\

\mathbf{elif}\;\ell \leq 6 \cdot 10^{+92}:\\
\;\;\;\;t\_2\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -5.5999999999999999e111 or 6.00000000000000026e92 < 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. Add Preprocessing
    3. Taylor expanded in l around 0 99.0%

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

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

    if -5.5999999999999999e111 < l < -1.45999999999999996e25 or 0.029999999999999999 < l < 6.00000000000000026e92

    1. Initial program 100.0%

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

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

    if -1.45999999999999996e25 < l < 0.029999999999999999

    1. Initial program 73.5%

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

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

Alternative 7: 94.6% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ t_1 := \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\right) \cdot t\_0 + U\\ t_2 := J \cdot \left(e^{\ell} - e^{-\ell}\right) + U\\ \mathbf{if}\;\ell \leq -5.6 \cdot 10^{+111}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\ell \leq -1950000000:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;\ell \leq 0.00182:\\ \;\;\;\;\mathsf{fma}\left(J, \left(2 \cdot \ell\right) \cdot t\_0, U\right)\\ \mathbf{elif}\;\ell \leq 6 \cdot 10^{+92}:\\ \;\;\;\;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 (+ (* (* J (* 0.3333333333333333 (pow l 3.0))) t_0) U))
        (t_2 (+ (* J (- (exp l) (exp (- l)))) U)))
   (if (<= l -5.6e+111)
     t_1
     (if (<= l -1950000000.0)
       t_2
       (if (<= l 0.00182)
         (fma J (* (* 2.0 l) t_0) U)
         (if (<= l 6e+92) t_2 t_1))))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K / 2.0));
	double t_1 = ((J * (0.3333333333333333 * pow(l, 3.0))) * t_0) + U;
	double t_2 = (J * (exp(l) - exp(-l))) + U;
	double tmp;
	if (l <= -5.6e+111) {
		tmp = t_1;
	} else if (l <= -1950000000.0) {
		tmp = t_2;
	} else if (l <= 0.00182) {
		tmp = fma(J, ((2.0 * l) * t_0), U);
	} else if (l <= 6e+92) {
		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(Float64(Float64(J * Float64(0.3333333333333333 * (l ^ 3.0))) * t_0) + U)
	t_2 = Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) + U)
	tmp = 0.0
	if (l <= -5.6e+111)
		tmp = t_1;
	elseif (l <= -1950000000.0)
		tmp = t_2;
	elseif (l <= 0.00182)
		tmp = fma(J, Float64(Float64(2.0 * l) * t_0), U);
	elseif (l <= 6e+92)
		tmp = t_2;
	else
		tmp = t_1;
	end
	return 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[(N[(J * N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision]}, Block[{t$95$2 = N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -5.6e+111], t$95$1, If[LessEqual[l, -1950000000.0], t$95$2, If[LessEqual[l, 0.00182], N[(J * N[(N[(2.0 * l), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 6e+92], t$95$2, t$95$1]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\right) \cdot t\_0 + U\\
t_2 := J \cdot \left(e^{\ell} - e^{-\ell}\right) + U\\
\mathbf{if}\;\ell \leq -5.6 \cdot 10^{+111}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;\ell \leq -1950000000:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;\ell \leq 0.00182:\\
\;\;\;\;\mathsf{fma}\left(J, \left(2 \cdot \ell\right) \cdot t\_0, U\right)\\

\mathbf{elif}\;\ell \leq 6 \cdot 10^{+92}:\\
\;\;\;\;t\_2\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -5.5999999999999999e111 or 6.00000000000000026e92 < 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. Add Preprocessing
    3. Taylor expanded in l around 0 99.0%

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

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

    if -5.5999999999999999e111 < l < -1.95e9 or 0.00182 < l < 6.00000000000000026e92

    1. Initial program 100.0%

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

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

    if -1.95e9 < l < 0.00182

    1. Initial program 73.2%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*73.2%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), U\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in l around 0 98.5%

      \[\leadsto \mathsf{fma}\left(J, \color{blue}{\left(2 \cdot \ell\right)} \cdot \cos \left(\frac{K}{2}\right), U\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 8: 93.8% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ t_1 := \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\right) \cdot t\_0 + U\\ t_2 := J \cdot \left(e^{\ell} - e^{-\ell}\right) + U\\ \mathbf{if}\;\ell \leq -5.6 \cdot 10^{+111}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\ell \leq -1.46 \cdot 10^{+25}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;\ell \leq 0.12:\\ \;\;\;\;\left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\right) \cdot t\_0 + U\\ \mathbf{elif}\;\ell \leq 6 \cdot 10^{+92}:\\ \;\;\;\;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 (+ (* (* J (* 0.3333333333333333 (pow l 3.0))) t_0) U))
        (t_2 (+ (* J (- (exp l) (exp (- l)))) U)))
   (if (<= l -5.6e+111)
     t_1
     (if (<= l -1.46e+25)
       t_2
       (if (<= l 0.12)
         (+ (* (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))) t_0) U)
         (if (<= l 6e+92) t_2 t_1))))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K / 2.0));
	double t_1 = ((J * (0.3333333333333333 * pow(l, 3.0))) * t_0) + U;
	double t_2 = (J * (exp(l) - exp(-l))) + U;
	double tmp;
	if (l <= -5.6e+111) {
		tmp = t_1;
	} else if (l <= -1.46e+25) {
		tmp = t_2;
	} else if (l <= 0.12) {
		tmp = ((J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))))) * t_0) + U;
	} else if (l <= 6e+92) {
		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 = ((j * (0.3333333333333333d0 * (l ** 3.0d0))) * t_0) + u
    t_2 = (j * (exp(l) - exp(-l))) + u
    if (l <= (-5.6d+111)) then
        tmp = t_1
    else if (l <= (-1.46d+25)) then
        tmp = t_2
    else if (l <= 0.12d0) then
        tmp = ((j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0))))) * t_0) + u
    else if (l <= 6d+92) 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 = ((J * (0.3333333333333333 * Math.pow(l, 3.0))) * t_0) + U;
	double t_2 = (J * (Math.exp(l) - Math.exp(-l))) + U;
	double tmp;
	if (l <= -5.6e+111) {
		tmp = t_1;
	} else if (l <= -1.46e+25) {
		tmp = t_2;
	} else if (l <= 0.12) {
		tmp = ((J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))))) * t_0) + U;
	} else if (l <= 6e+92) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K / 2.0))
	t_1 = ((J * (0.3333333333333333 * math.pow(l, 3.0))) * t_0) + U
	t_2 = (J * (math.exp(l) - math.exp(-l))) + U
	tmp = 0
	if l <= -5.6e+111:
		tmp = t_1
	elif l <= -1.46e+25:
		tmp = t_2
	elif l <= 0.12:
		tmp = ((J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0))))) * t_0) + U
	elif l <= 6e+92:
		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(Float64(Float64(J * Float64(0.3333333333333333 * (l ^ 3.0))) * t_0) + U)
	t_2 = Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) + U)
	tmp = 0.0
	if (l <= -5.6e+111)
		tmp = t_1;
	elseif (l <= -1.46e+25)
		tmp = t_2;
	elseif (l <= 0.12)
		tmp = Float64(Float64(Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))) * t_0) + U);
	elseif (l <= 6e+92)
		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 = ((J * (0.3333333333333333 * (l ^ 3.0))) * t_0) + U;
	t_2 = (J * (exp(l) - exp(-l))) + U;
	tmp = 0.0;
	if (l <= -5.6e+111)
		tmp = t_1;
	elseif (l <= -1.46e+25)
		tmp = t_2;
	elseif (l <= 0.12)
		tmp = ((J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0))))) * t_0) + U;
	elseif (l <= 6e+92)
		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[(N[(N[(J * N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision]}, Block[{t$95$2 = N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -5.6e+111], t$95$1, If[LessEqual[l, -1.46e+25], t$95$2, If[LessEqual[l, 0.12], N[(N[(N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 6e+92], t$95$2, t$95$1]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\right) \cdot t\_0 + U\\
t_2 := J \cdot \left(e^{\ell} - e^{-\ell}\right) + U\\
\mathbf{if}\;\ell \leq -5.6 \cdot 10^{+111}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;\ell \leq -1.46 \cdot 10^{+25}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;\ell \leq 0.12:\\
\;\;\;\;\left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\right) \cdot t\_0 + U\\

\mathbf{elif}\;\ell \leq 6 \cdot 10^{+92}:\\
\;\;\;\;t\_2\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -5.5999999999999999e111 or 6.00000000000000026e92 < 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. Add Preprocessing
    3. Taylor expanded in l around 0 99.0%

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

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

    if -5.5999999999999999e111 < l < -1.45999999999999996e25 or 0.12 < l < 6.00000000000000026e92

    1. Initial program 100.0%

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

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

    if -1.45999999999999996e25 < l < 0.12

    1. Initial program 73.5%

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

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

Alternative 9: 80.1% accurate, 1.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.0400000000000000008

    1. Initial program 85.7%

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

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

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

    if 0.0400000000000000008 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

    1. Initial program 88.1%

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

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

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

Alternative 10: 79.0% accurate, 1.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.0400000000000000008

    1. Initial program 85.7%

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

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

    if 0.0400000000000000008 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

    1. Initial program 88.1%

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

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

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

Alternative 11: 79.5% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
t_0 := J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right) + U\\
\mathbf{if}\;\ell \leq -3.9 \cdot 10^{+129}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;\ell \leq -560:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{-4}{U} - U\right)\right)\\

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -3.8999999999999997e129 or 1.49999999999999991e-31 < l

    1. Initial program 96.9%

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

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

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

    if -3.8999999999999997e129 < l < -560

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\frac{-4}{U} - U} \]
    4. Step-by-step derivation
      1. log1p-expm1-u65.5%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{-4}{U} - U\right)\right)} \]
    5. Applied egg-rr65.5%

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

    if -560 < l < 1.49999999999999991e-31

    1. Initial program 74.5%

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

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

Alternative 12: 57.0% accurate, 2.4× speedup?

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

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

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

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

\mathbf{elif}\;\ell \leq 4.4 \cdot 10^{+269}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -1.4999999999999999e54 or 3.1999999999999997e132 < l < 4.3999999999999997e269

    1. Initial program 100.0%

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

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

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

    if -1.4999999999999999e54 < l < 3.90000000000000011e30

    1. Initial program 76.0%

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

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

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

    if 3.90000000000000011e30 < l < 3.1999999999999997e132

    1. Initial program 100.0%

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

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

    if 4.3999999999999997e269 < 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. Add Preprocessing
    3. Applied egg-rr60.5%

      \[\leadsto \color{blue}{{U}^{-4}} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 13: 63.3% accurate, 2.5× speedup?

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

\\
\begin{array}{l}
t_0 := 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right)\\
\mathbf{if}\;\ell \leq 2.45 \cdot 10^{+30}:\\
\;\;\;\;t\_0 + U\\

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

\mathbf{elif}\;\ell \leq 10^{+269}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < 2.44999999999999992e30

    1. Initial program 82.2%

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

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

    if 2.44999999999999992e30 < l < 1.75e130

    1. Initial program 100.0%

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

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

    if 1.75e130 < l < 1e269

    1. Initial program 100.0%

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

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

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

    if 1e269 < 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. Add Preprocessing
    3. Applied egg-rr60.5%

      \[\leadsto \color{blue}{{U}^{-4}} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 14: 54.3% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 2.45 \cdot 10^{+30}:\\ \;\;\;\;2 \cdot \left(J \cdot \ell\right) + U\\ \mathbf{elif}\;\ell \leq 1.16 \cdot 10^{+127}:\\ \;\;\;\;{U}^{-4}\\ \mathbf{elif}\;\ell \leq 2 \cdot 10^{+269}:\\ \;\;\;\;\ell \cdot \left(2 \cdot J + \frac{U}{\ell}\right)\\ \mathbf{else}:\\ \;\;\;\;{U}^{-4}\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l 2.45e+30)
   (+ (* 2.0 (* J l)) U)
   (if (<= l 1.16e+127)
     (pow U -4.0)
     (if (<= l 2e+269) (* l (+ (* 2.0 J) (/ U l))) (pow U -4.0)))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= 2.45e+30) {
		tmp = (2.0 * (J * l)) + U;
	} else if (l <= 1.16e+127) {
		tmp = pow(U, -4.0);
	} else if (l <= 2e+269) {
		tmp = l * ((2.0 * J) + (U / l));
	} else {
		tmp = pow(U, -4.0);
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: tmp
    if (l <= 2.45d+30) then
        tmp = (2.0d0 * (j * l)) + u
    else if (l <= 1.16d+127) then
        tmp = u ** (-4.0d0)
    else if (l <= 2d+269) then
        tmp = l * ((2.0d0 * j) + (u / l))
    else
        tmp = u ** (-4.0d0)
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= 2.45e+30) {
		tmp = (2.0 * (J * l)) + U;
	} else if (l <= 1.16e+127) {
		tmp = Math.pow(U, -4.0);
	} else if (l <= 2e+269) {
		tmp = l * ((2.0 * J) + (U / l));
	} else {
		tmp = Math.pow(U, -4.0);
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= 2.45e+30:
		tmp = (2.0 * (J * l)) + U
	elif l <= 1.16e+127:
		tmp = math.pow(U, -4.0)
	elif l <= 2e+269:
		tmp = l * ((2.0 * J) + (U / l))
	else:
		tmp = math.pow(U, -4.0)
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= 2.45e+30)
		tmp = Float64(Float64(2.0 * Float64(J * l)) + U);
	elseif (l <= 1.16e+127)
		tmp = U ^ -4.0;
	elseif (l <= 2e+269)
		tmp = Float64(l * Float64(Float64(2.0 * J) + Float64(U / l)));
	else
		tmp = U ^ -4.0;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= 2.45e+30)
		tmp = (2.0 * (J * l)) + U;
	elseif (l <= 1.16e+127)
		tmp = U ^ -4.0;
	elseif (l <= 2e+269)
		tmp = l * ((2.0 * J) + (U / l));
	else
		tmp = U ^ -4.0;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, 2.45e+30], N[(N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 1.16e+127], N[Power[U, -4.0], $MachinePrecision], If[LessEqual[l, 2e+269], N[(l * N[(N[(2.0 * J), $MachinePrecision] + N[(U / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[U, -4.0], $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;\ell \leq 1.16 \cdot 10^{+127}:\\
\;\;\;\;{U}^{-4}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < 2.44999999999999992e30

    1. Initial program 82.2%

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

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

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

    if 2.44999999999999992e30 < l < 1.15999999999999994e127 or 2.0000000000000001e269 < 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. Add Preprocessing
    3. Applied egg-rr45.5%

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

    if 1.15999999999999994e127 < l < 2.0000000000000001e269

    1. Initial program 100.0%

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

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

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

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

Alternative 15: 54.0% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 3.9 \cdot 10^{+30}:\\ \;\;\;\;2 \cdot \left(J \cdot \ell\right) + U\\ \mathbf{elif}\;\ell \leq 1.25 \cdot 10^{+134}:\\ \;\;\;\;{U}^{-3}\\ \mathbf{elif}\;\ell \leq 4.4 \cdot 10^{+269}:\\ \;\;\;\;\ell \cdot \left(2 \cdot J + \frac{U}{\ell}\right)\\ \mathbf{else}:\\ \;\;\;\;{U}^{-4}\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l 3.9e+30)
   (+ (* 2.0 (* J l)) U)
   (if (<= l 1.25e+134)
     (pow U -3.0)
     (if (<= l 4.4e+269) (* l (+ (* 2.0 J) (/ U l))) (pow U -4.0)))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= 3.9e+30) {
		tmp = (2.0 * (J * l)) + U;
	} else if (l <= 1.25e+134) {
		tmp = pow(U, -3.0);
	} else if (l <= 4.4e+269) {
		tmp = l * ((2.0 * J) + (U / l));
	} else {
		tmp = pow(U, -4.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 <= 3.9d+30) then
        tmp = (2.0d0 * (j * l)) + u
    else if (l <= 1.25d+134) then
        tmp = u ** (-3.0d0)
    else if (l <= 4.4d+269) then
        tmp = l * ((2.0d0 * j) + (u / l))
    else
        tmp = u ** (-4.0d0)
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= 3.9e+30) {
		tmp = (2.0 * (J * l)) + U;
	} else if (l <= 1.25e+134) {
		tmp = Math.pow(U, -3.0);
	} else if (l <= 4.4e+269) {
		tmp = l * ((2.0 * J) + (U / l));
	} else {
		tmp = Math.pow(U, -4.0);
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= 3.9e+30:
		tmp = (2.0 * (J * l)) + U
	elif l <= 1.25e+134:
		tmp = math.pow(U, -3.0)
	elif l <= 4.4e+269:
		tmp = l * ((2.0 * J) + (U / l))
	else:
		tmp = math.pow(U, -4.0)
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= 3.9e+30)
		tmp = Float64(Float64(2.0 * Float64(J * l)) + U);
	elseif (l <= 1.25e+134)
		tmp = U ^ -3.0;
	elseif (l <= 4.4e+269)
		tmp = Float64(l * Float64(Float64(2.0 * J) + Float64(U / l)));
	else
		tmp = U ^ -4.0;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= 3.9e+30)
		tmp = (2.0 * (J * l)) + U;
	elseif (l <= 1.25e+134)
		tmp = U ^ -3.0;
	elseif (l <= 4.4e+269)
		tmp = l * ((2.0 * J) + (U / l));
	else
		tmp = U ^ -4.0;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, 3.9e+30], N[(N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 1.25e+134], N[Power[U, -3.0], $MachinePrecision], If[LessEqual[l, 4.4e+269], N[(l * N[(N[(2.0 * J), $MachinePrecision] + N[(U / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[U, -4.0], $MachinePrecision]]]]
\begin{array}{l}

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < 3.90000000000000011e30

    1. Initial program 82.2%

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

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

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

    if 3.90000000000000011e30 < l < 1.24999999999999995e134

    1. Initial program 100.0%

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

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

    if 1.24999999999999995e134 < l < 4.3999999999999997e269

    1. Initial program 100.0%

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

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

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

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

    if 4.3999999999999997e269 < 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. Add Preprocessing
    3. Applied egg-rr60.5%

      \[\leadsto \color{blue}{{U}^{-4}} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 16: 41.6% accurate, 23.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -9.2 \cdot 10^{+48}:\\ \;\;\;\;U \cdot U\\ \mathbf{elif}\;\ell \leq 1.7 \cdot 10^{-9}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot U\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -9.2e+48) (* U U) (if (<= l 1.7e-9) U (* U U))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -9.2e+48) {
		tmp = U * U;
	} else if (l <= 1.7e-9) {
		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 <= (-9.2d+48)) then
        tmp = u * u
    else if (l <= 1.7d-9) 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 <= -9.2e+48) {
		tmp = U * U;
	} else if (l <= 1.7e-9) {
		tmp = U;
	} else {
		tmp = U * U;
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -9.2e+48:
		tmp = U * U
	elif l <= 1.7e-9:
		tmp = U
	else:
		tmp = U * U
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -9.2e+48)
		tmp = Float64(U * U);
	elseif (l <= 1.7e-9)
		tmp = U;
	else
		tmp = Float64(U * U);
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= -9.2e+48)
		tmp = U * U;
	elseif (l <= 1.7e-9)
		tmp = U;
	else
		tmp = U * U;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -9.2e+48], N[(U * U), $MachinePrecision], If[LessEqual[l, 1.7e-9], U, N[(U * U), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -9.2 \cdot 10^{+48}:\\
\;\;\;\;U \cdot U\\

\mathbf{elif}\;\ell \leq 1.7 \cdot 10^{-9}:\\
\;\;\;\;U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -9.2000000000000001e48 or 1.6999999999999999e-9 < l

    1. Initial program 99.3%

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

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

    if -9.2000000000000001e48 < l < 1.6999999999999999e-9

    1. Initial program 75.2%

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

      \[\leadsto \color{blue}{U} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 17: 42.0% accurate, 23.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -950:\\
\;\;\;\;-4 + \left(-U\right) \cdot U\\

\mathbf{elif}\;\ell \leq 1.7 \cdot 10^{-9}:\\
\;\;\;\;U\\

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


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

    1. Initial program 100.0%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*100.0%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), U\right)} \]
    4. Add Preprocessing
    5. Applied egg-rr17.4%

      \[\leadsto \color{blue}{-4 + \left(-U\right) \cdot U} \]

    if -950 < l < 1.6999999999999999e-9

    1. Initial program 73.3%

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

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

    if 1.6999999999999999e-9 < l

    1. Initial program 99.0%

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

      \[\leadsto \color{blue}{U \cdot U} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 18: 54.2% accurate, 44.6× speedup?

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

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

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

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

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

Alternative 19: 36.7% accurate, 312.0× speedup?

\[\begin{array}{l} \\ U \end{array} \]
(FPCore (J l K U) :precision binary64 U)
double code(double J, double l, double K, double U) {
	return U;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    code = u
end function
public static double code(double J, double l, double K, double U) {
	return U;
}
def code(J, l, K, U):
	return U
function code(J, l, K, U)
	return U
end
function tmp = code(J, l, K, U)
	tmp = U;
end
code[J_, l_, K_, U_] := U
\begin{array}{l}

\\
U
\end{array}
Derivation
  1. Initial program 87.6%

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

    \[\leadsto \color{blue}{U} \]
  4. Add Preprocessing

Reproduce

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