Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.5% → 99.8%
Time: 19.0s
Alternatives: 18
Speedup: 1.5×

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 18 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.5% 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.8% 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 -\infty \lor \neg \left(t_1 \leq 0.02\right):\\ \;\;\;\;\left(t_1 \cdot J\right) \cdot t_0 + U\\ \mathbf{else}:\\ \;\;\;\;U + t_0 \cdot \left(J \cdot \left(0.016666666666666666 \cdot {\ell}^{5} + \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))) (t_1 (- (exp l) (exp (- l)))))
   (if (or (<= t_1 (- INFINITY)) (not (<= t_1 0.02)))
     (+ (* (* t_1 J) t_0) U)
     (+
      U
      (*
       t_0
       (*
        J
        (+
         (* 0.016666666666666666 (pow l 5.0))
         (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K / 2.0));
	double t_1 = exp(l) - exp(-l);
	double tmp;
	if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 0.02)) {
		tmp = ((t_1 * J) * t_0) + U;
	} else {
		tmp = U + (t_0 * (J * ((0.016666666666666666 * pow(l, 5.0)) + ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0)))));
	}
	return tmp;
}
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 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 0.02)) {
		tmp = ((t_1 * J) * t_0) + U;
	} else {
		tmp = U + (t_0 * (J * ((0.016666666666666666 * Math.pow(l, 5.0)) + ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)))));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K / 2.0))
	t_1 = math.exp(l) - math.exp(-l)
	tmp = 0
	if (t_1 <= -math.inf) or not (t_1 <= 0.02):
		tmp = ((t_1 * J) * t_0) + U
	else:
		tmp = U + (t_0 * (J * ((0.016666666666666666 * math.pow(l, 5.0)) + ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))))
	return tmp
function code(J, l, K, U)
	t_0 = cos(Float64(K / 2.0))
	t_1 = Float64(exp(l) - exp(Float64(-l)))
	tmp = 0.0
	if ((t_1 <= Float64(-Inf)) || !(t_1 <= 0.02))
		tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U);
	else
		tmp = Float64(U + Float64(t_0 * Float64(J * Float64(Float64(0.016666666666666666 * (l ^ 5.0)) + Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = cos((K / 2.0));
	t_1 = exp(l) - exp(-l);
	tmp = 0.0;
	if ((t_1 <= -Inf) || ~((t_1 <= 0.02)))
		tmp = ((t_1 * J) * t_0) + U;
	else
		tmp = U + (t_0 * (J * ((0.016666666666666666 * (l ^ 5.0)) + ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[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, (-Infinity)], N[Not[LessEqual[t$95$1, 0.02]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(J * N[(N[(0.016666666666666666 * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 0.0200000000000000004 < (-.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 -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0200000000000000004

    1. Initial program 80.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 100.0%

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

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

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

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

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


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

    1. Initial program 99.8%

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

    if -2e-3 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.00000000000000041e-6

    1. Initial program 79.7%

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

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

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

Alternative 3: 78.9% accurate, 0.7× speedup?

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

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

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

\mathbf{elif}\;t_0 \leq 0.04:\\
\;\;\;\;t_1\\

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


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

    1. Initial program 86.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 68.3%

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

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

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

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

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

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

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

    if -0.640000000000000013 < (cos.f64 (/.f64 K 2)) < -0.450000000000000011

    1. Initial program 98.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 35.5%

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 91.1%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.64:\\ \;\;\;\;U + \ell \cdot \left(2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\cos \left(\frac{K}{2}\right) \leq -0.45:\\ \;\;\;\;U + \ell \cdot \left(2 \cdot \left(J + -0.125 \cdot \left(J \cdot \left(K \cdot K\right)\right)\right)\right)\\ \mathbf{elif}\;\cos \left(\frac{K}{2}\right) \leq 0.04:\\ \;\;\;\;U + \ell \cdot \left(2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\ \end{array} \]

Alternative 4: 76.5% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ t_1 := U + \ell \cdot \left(2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{if}\;t_0 \leq -0.64:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq -0.45:\\ \;\;\;\;U + \ell \cdot \left(2 \cdot \left(J + -0.125 \cdot \left(J \cdot \left(K \cdot K\right)\right)\right)\right)\\ \mathbf{elif}\;t_0 \leq 0.04:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot J, 2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right), U\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))) (t_1 (+ U (* l (* 2.0 (* J (cos (* K 0.5))))))))
   (if (<= t_0 -0.64)
     t_1
     (if (<= t_0 -0.45)
       (+ U (* l (* 2.0 (+ J (* -0.125 (* J (* K K)))))))
       (if (<= t_0 0.04)
         t_1
         (fma (* l J) (+ 2.0 (* 0.3333333333333333 (* l l))) U))))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K / 2.0));
	double t_1 = U + (l * (2.0 * (J * cos((K * 0.5)))));
	double tmp;
	if (t_0 <= -0.64) {
		tmp = t_1;
	} else if (t_0 <= -0.45) {
		tmp = U + (l * (2.0 * (J + (-0.125 * (J * (K * K))))));
	} else if (t_0 <= 0.04) {
		tmp = t_1;
	} else {
		tmp = fma((l * J), (2.0 + (0.3333333333333333 * (l * l))), U);
	}
	return tmp;
}
function code(J, l, K, U)
	t_0 = cos(Float64(K / 2.0))
	t_1 = Float64(U + Float64(l * Float64(2.0 * Float64(J * cos(Float64(K * 0.5))))))
	tmp = 0.0
	if (t_0 <= -0.64)
		tmp = t_1;
	elseif (t_0 <= -0.45)
		tmp = Float64(U + Float64(l * Float64(2.0 * Float64(J + Float64(-0.125 * Float64(J * Float64(K * K)))))));
	elseif (t_0 <= 0.04)
		tmp = t_1;
	else
		tmp = fma(Float64(l * J), Float64(2.0 + Float64(0.3333333333333333 * Float64(l * l))), U);
	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[(U + N[(l * N[(2.0 * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.64], t$95$1, If[LessEqual[t$95$0, -0.45], N[(U + N[(l * N[(2.0 * N[(J + N[(-0.125 * N[(J * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.04], t$95$1, N[(N[(l * J), $MachinePrecision] * N[(2.0 + N[(0.3333333333333333 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;t_0 \leq 0.04:\\
\;\;\;\;t_1\\

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


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

    1. Initial program 86.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 68.3%

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

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

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

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

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

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

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

    if -0.640000000000000013 < (cos.f64 (/.f64 K 2)) < -0.450000000000000011

    1. Initial program 98.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 35.5%

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 91.1%

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

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

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

        \[\leadsto \color{blue}{\left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right) + 2 \cdot \left(J \cdot \ell\right)\right) + U} \]
      2. remove-double-neg82.1%

        \[\leadsto \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right) + 2 \cdot \left(J \cdot \ell\right)\right) + \color{blue}{\left(-\left(-U\right)\right)} \]
      3. unsub-neg82.1%

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

        \[\leadsto \left(\color{blue}{\left(J \cdot {\ell}^{3}\right) \cdot 0.3333333333333333} + 2 \cdot \left(J \cdot \ell\right)\right) - \left(-U\right) \]
      5. cube-mult82.1%

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

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

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

        \[\leadsto \left(\left(J \cdot \ell\right) \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right) + \color{blue}{\left(J \cdot \ell\right) \cdot 2}\right) - \left(-U\right) \]
      9. distribute-lft-out75.5%

        \[\leadsto \color{blue}{\left(J \cdot \ell\right) \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333 + 2\right)} - \left(-U\right) \]
      10. fma-neg75.5%

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

        \[\leadsto \mathsf{fma}\left(J \cdot \ell, \color{blue}{2 + \left(\ell \cdot \ell\right) \cdot 0.3333333333333333}, -\left(-U\right)\right) \]
      12. remove-double-neg75.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.64:\\ \;\;\;\;U + \ell \cdot \left(2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\cos \left(\frac{K}{2}\right) \leq -0.45:\\ \;\;\;\;U + \ell \cdot \left(2 \cdot \left(J + -0.125 \cdot \left(J \cdot \left(K \cdot K\right)\right)\right)\right)\\ \mathbf{elif}\;\cos \left(\frac{K}{2}\right) \leq 0.04:\\ \;\;\;\;U + \ell \cdot \left(2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot J, 2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right), U\right)\\ \end{array} \]

Alternative 5: 96.6% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
t_1 := \cos \left(\frac{K}{2}\right)\\
t_2 := U + t_1 \cdot \left({\ell}^{5} \cdot \left(J \cdot 0.016666666666666666\right)\right)\\
\mathbf{if}\;\ell \leq -2.15 \cdot 10^{+79}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;\ell \leq -64:\\
\;\;\;\;U + t_0 \cdot \left(J + J \cdot \left(-0.125 \cdot \left(K \cdot K\right)\right)\right)\\

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

\mathbf{elif}\;\ell \leq 8 \cdot 10^{+53}:\\
\;\;\;\;t_0 \cdot J + U\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -2.1500000000000002e79 or 7.9999999999999999e53 < 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.016666666666666666 \cdot {\ell}^{5} + \left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in l around inf 100.0%

      \[\leadsto \color{blue}{\left(0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\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.016666666666666666 \cdot J\right) \cdot {\ell}^{5}\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
    5. Simplified100.0%

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

    if -2.1500000000000002e79 < l < -64

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(e^{\ell} - e^{-\ell}\right) \cdot \left(J + J \cdot \left(-0.125 \cdot \color{blue}{\left(K \cdot K\right)}\right)\right) + U \]
    4. Simplified93.8%

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

    if -64 < l < 0.00166

    1. Initial program 80.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.8%

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

    if 0.00166 < l < 7.9999999999999999e53

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.15 \cdot 10^{+79}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{5} \cdot \left(J \cdot 0.016666666666666666\right)\right)\\ \mathbf{elif}\;\ell \leq -64:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot \left(J + J \cdot \left(-0.125 \cdot \left(K \cdot K\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 0.00166:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 8 \cdot 10^{+53}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{5} \cdot \left(J \cdot 0.016666666666666666\right)\right)\\ \end{array} \]

Alternative 6: 96.0% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{5} \cdot \left(J \cdot 0.016666666666666666\right)\right)\\ t_1 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{if}\;\ell \leq -4.6 \cdot 10^{+33}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -0.00086:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\ell \leq 4.2 \cdot 10^{-5}:\\ \;\;\;\;U + \ell \cdot \left(2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 8 \cdot 10^{+53}:\\ \;\;\;\;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 5.0) (* J 0.016666666666666666)))))
        (t_1 (+ (* (- (exp l) (exp (- l))) J) U)))
   (if (<= l -4.6e+33)
     t_0
     (if (<= l -0.00086)
       t_1
       (if (<= l 4.2e-5)
         (+ U (* l (* 2.0 (* J (cos (* K 0.5))))))
         (if (<= l 8e+53) t_1 t_0))))))
double code(double J, double l, double K, double U) {
	double t_0 = U + (cos((K / 2.0)) * (pow(l, 5.0) * (J * 0.016666666666666666)));
	double t_1 = ((exp(l) - exp(-l)) * J) + U;
	double tmp;
	if (l <= -4.6e+33) {
		tmp = t_0;
	} else if (l <= -0.00086) {
		tmp = t_1;
	} else if (l <= 4.2e-5) {
		tmp = U + (l * (2.0 * (J * cos((K * 0.5)))));
	} else if (l <= 8e+53) {
		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 ** 5.0d0) * (j * 0.016666666666666666d0)))
    t_1 = ((exp(l) - exp(-l)) * j) + u
    if (l <= (-4.6d+33)) then
        tmp = t_0
    else if (l <= (-0.00086d0)) then
        tmp = t_1
    else if (l <= 4.2d-5) then
        tmp = u + (l * (2.0d0 * (j * cos((k * 0.5d0)))))
    else if (l <= 8d+53) 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, 5.0) * (J * 0.016666666666666666)));
	double t_1 = ((Math.exp(l) - Math.exp(-l)) * J) + U;
	double tmp;
	if (l <= -4.6e+33) {
		tmp = t_0;
	} else if (l <= -0.00086) {
		tmp = t_1;
	} else if (l <= 4.2e-5) {
		tmp = U + (l * (2.0 * (J * Math.cos((K * 0.5)))));
	} else if (l <= 8e+53) {
		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, 5.0) * (J * 0.016666666666666666)))
	t_1 = ((math.exp(l) - math.exp(-l)) * J) + U
	tmp = 0
	if l <= -4.6e+33:
		tmp = t_0
	elif l <= -0.00086:
		tmp = t_1
	elif l <= 4.2e-5:
		tmp = U + (l * (2.0 * (J * math.cos((K * 0.5)))))
	elif l <= 8e+53:
		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 ^ 5.0) * Float64(J * 0.016666666666666666))))
	t_1 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U)
	tmp = 0.0
	if (l <= -4.6e+33)
		tmp = t_0;
	elseif (l <= -0.00086)
		tmp = t_1;
	elseif (l <= 4.2e-5)
		tmp = Float64(U + Float64(l * Float64(2.0 * Float64(J * cos(Float64(K * 0.5))))));
	elseif (l <= 8e+53)
		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 ^ 5.0) * (J * 0.016666666666666666)));
	t_1 = ((exp(l) - exp(-l)) * J) + U;
	tmp = 0.0;
	if (l <= -4.6e+33)
		tmp = t_0;
	elseif (l <= -0.00086)
		tmp = t_1;
	elseif (l <= 4.2e-5)
		tmp = U + (l * (2.0 * (J * cos((K * 0.5)))));
	elseif (l <= 8e+53)
		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, 5.0], $MachinePrecision] * N[(J * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -4.6e+33], t$95$0, If[LessEqual[l, -0.00086], t$95$1, If[LessEqual[l, 4.2e-5], N[(U + N[(l * N[(2.0 * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 8e+53], t$95$1, t$95$0]]]]]]
\begin{array}{l}

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

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

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

\mathbf{elif}\;\ell \leq 8 \cdot 10^{+53}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -4.60000000000000021e33 or 7.9999999999999999e53 < 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 97.4%

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

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

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

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

    if -4.60000000000000021e33 < l < -8.59999999999999979e-4 or 4.19999999999999977e-5 < l < 7.9999999999999999e53

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

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

    if -8.59999999999999979e-4 < l < 4.19999999999999977e-5

    1. Initial program 79.7%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.6 \cdot 10^{+33}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{5} \cdot \left(J \cdot 0.016666666666666666\right)\right)\\ \mathbf{elif}\;\ell \leq -0.00086:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{elif}\;\ell \leq 4.2 \cdot 10^{-5}:\\ \;\;\;\;U + \ell \cdot \left(2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 8 \cdot 10^{+53}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{5} \cdot \left(J \cdot 0.016666666666666666\right)\right)\\ \end{array} \]

Alternative 7: 94.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}^{5} \cdot \left(J \cdot 0.016666666666666666\right)\right)\\ \mathbf{if}\;\ell \leq -1260000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\ell \leq 0.0027:\\ \;\;\;\;U + t_0 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 8 \cdot 10^{+53}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \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 5.0) (* J 0.016666666666666666))))))
   (if (<= l -1260000.0)
     t_1
     (if (<= l 0.0027)
       (+ U (* t_0 (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
       (if (<= l 8e+53) (+ (* (- (exp l) (exp (- l))) J) U) 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, 5.0) * (J * 0.016666666666666666)));
	double tmp;
	if (l <= -1260000.0) {
		tmp = t_1;
	} else if (l <= 0.0027) {
		tmp = U + (t_0 * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
	} else if (l <= 8e+53) {
		tmp = ((exp(l) - exp(-l)) * J) + U;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = cos((k / 2.0d0))
    t_1 = u + (t_0 * ((l ** 5.0d0) * (j * 0.016666666666666666d0)))
    if (l <= (-1260000.0d0)) then
        tmp = t_1
    else if (l <= 0.0027d0) then
        tmp = u + (t_0 * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
    else if (l <= 8d+53) then
        tmp = ((exp(l) - exp(-l)) * j) + u
    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, 5.0) * (J * 0.016666666666666666)));
	double tmp;
	if (l <= -1260000.0) {
		tmp = t_1;
	} else if (l <= 0.0027) {
		tmp = U + (t_0 * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
	} else if (l <= 8e+53) {
		tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
	} 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, 5.0) * (J * 0.016666666666666666)))
	tmp = 0
	if l <= -1260000.0:
		tmp = t_1
	elif l <= 0.0027:
		tmp = U + (t_0 * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))))
	elif l <= 8e+53:
		tmp = ((math.exp(l) - math.exp(-l)) * J) + U
	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 ^ 5.0) * Float64(J * 0.016666666666666666))))
	tmp = 0.0
	if (l <= -1260000.0)
		tmp = t_1;
	elseif (l <= 0.0027)
		tmp = Float64(U + Float64(t_0 * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)))));
	elseif (l <= 8e+53)
		tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U);
	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 ^ 5.0) * (J * 0.016666666666666666)));
	tmp = 0.0;
	if (l <= -1260000.0)
		tmp = t_1;
	elseif (l <= 0.0027)
		tmp = U + (t_0 * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0))));
	elseif (l <= 8e+53)
		tmp = ((exp(l) - exp(-l)) * J) + U;
	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, 5.0], $MachinePrecision] * N[(J * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1260000.0], t$95$1, If[LessEqual[l, 0.0027], N[(U + N[(t$95$0 * N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 8e+53], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -1.26e6 or 7.9999999999999999e53 < 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 92.8%

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

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

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

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

    if -1.26e6 < l < 0.0027000000000000001

    1. Initial program 80.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.0%

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

    if 0.0027000000000000001 < l < 7.9999999999999999e53

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

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

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

Alternative 8: 87.4% accurate, 1.5× speedup?

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

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

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

\mathbf{elif}\;\ell \leq 5 \cdot 10^{+93}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;U + \left(J \cdot {\ell}^{5}\right) \cdot \left(0.016666666666666666 + \left(K \cdot K\right) \cdot -0.0020833333333333333\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -1.55e-4 or 2e-3 < l < 5.0000000000000001e93

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

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

    if -1.55e-4 < l < 2e-3

    1. Initial program 79.7%

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

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

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

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

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

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

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

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

    if 5.0000000000000001e93 < 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.016666666666666666 \cdot {\ell}^{5} + \left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in l around inf 100.0%

      \[\leadsto \color{blue}{\left(0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\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.016666666666666666 \cdot J\right) \cdot {\ell}^{5}\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
    5. Simplified100.0%

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

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

        \[\leadsto \color{blue}{\left(0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\right) + -0.0020833333333333333 \cdot \left(J \cdot \left({K}^{2} \cdot {\ell}^{5}\right)\right)\right)} + U \]
      2. *-commutative0.0%

        \[\leadsto \left(\color{blue}{\left(J \cdot {\ell}^{5}\right) \cdot 0.016666666666666666} + -0.0020833333333333333 \cdot \left(J \cdot \left({K}^{2} \cdot {\ell}^{5}\right)\right)\right) + U \]
      3. *-commutative0.0%

        \[\leadsto \left(\left(J \cdot {\ell}^{5}\right) \cdot 0.016666666666666666 + \color{blue}{\left(J \cdot \left({K}^{2} \cdot {\ell}^{5}\right)\right) \cdot -0.0020833333333333333}\right) + U \]
      4. *-commutative0.0%

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

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

        \[\leadsto \left(\left(J \cdot {\ell}^{5}\right) \cdot 0.016666666666666666 + \color{blue}{\left(J \cdot {\ell}^{5}\right) \cdot \left({K}^{2} \cdot -0.0020833333333333333\right)}\right) + U \]
      7. distribute-lft-out82.0%

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

        \[\leadsto \left(J \cdot {\ell}^{5}\right) \cdot \left(0.016666666666666666 + \color{blue}{\left(K \cdot K\right)} \cdot -0.0020833333333333333\right) + U \]
    8. Simplified82.0%

      \[\leadsto \color{blue}{\left(J \cdot {\ell}^{5}\right) \cdot \left(0.016666666666666666 + \left(K \cdot K\right) \cdot -0.0020833333333333333\right)} + U \]
  3. Recombined 3 regimes into one program.
  4. Final simplification90.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -0.000155:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{elif}\;\ell \leq 0.002:\\ \;\;\;\;U + \ell \cdot \left(2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 5 \cdot 10^{+93}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{else}:\\ \;\;\;\;U + \left(J \cdot {\ell}^{5}\right) \cdot \left(0.016666666666666666 + \left(K \cdot K\right) \cdot -0.0020833333333333333\right)\\ \end{array} \]

Alternative 9: 86.6% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
t_0 := \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;\ell \leq -1850000000000:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;\ell \leq 5 \cdot 10^{+93}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;U + \left(J \cdot {\ell}^{5}\right) \cdot \left(0.016666666666666666 + \left(K \cdot K\right) \cdot -0.0020833333333333333\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -1.85e12 or 230 < l < 5.0000000000000001e93

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

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

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

    if -1.85e12 < l < 230

    1. Initial program 80.6%

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

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

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

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

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

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

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

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

    if 5.0000000000000001e93 < 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.016666666666666666 \cdot {\ell}^{5} + \left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in l around inf 100.0%

      \[\leadsto \color{blue}{\left(0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\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.016666666666666666 \cdot J\right) \cdot {\ell}^{5}\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
    5. Simplified100.0%

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

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

        \[\leadsto \color{blue}{\left(0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\right) + -0.0020833333333333333 \cdot \left(J \cdot \left({K}^{2} \cdot {\ell}^{5}\right)\right)\right)} + U \]
      2. *-commutative0.0%

        \[\leadsto \left(\color{blue}{\left(J \cdot {\ell}^{5}\right) \cdot 0.016666666666666666} + -0.0020833333333333333 \cdot \left(J \cdot \left({K}^{2} \cdot {\ell}^{5}\right)\right)\right) + U \]
      3. *-commutative0.0%

        \[\leadsto \left(\left(J \cdot {\ell}^{5}\right) \cdot 0.016666666666666666 + \color{blue}{\left(J \cdot \left({K}^{2} \cdot {\ell}^{5}\right)\right) \cdot -0.0020833333333333333}\right) + U \]
      4. *-commutative0.0%

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

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

        \[\leadsto \left(\left(J \cdot {\ell}^{5}\right) \cdot 0.016666666666666666 + \color{blue}{\left(J \cdot {\ell}^{5}\right) \cdot \left({K}^{2} \cdot -0.0020833333333333333\right)}\right) + U \]
      7. distribute-lft-out82.0%

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

        \[\leadsto \left(J \cdot {\ell}^{5}\right) \cdot \left(0.016666666666666666 + \color{blue}{\left(K \cdot K\right)} \cdot -0.0020833333333333333\right) + U \]
    8. Simplified82.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1850000000000:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{elif}\;\ell \leq 230:\\ \;\;\;\;U + \ell \cdot \left(2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 5 \cdot 10^{+93}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{else}:\\ \;\;\;\;U + \left(J \cdot {\ell}^{5}\right) \cdot \left(0.016666666666666666 + \left(K \cdot K\right) \cdot -0.0020833333333333333\right)\\ \end{array} \]

Alternative 10: 83.0% accurate, 2.6× speedup?

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

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

\mathbf{elif}\;\ell \leq -450 \lor \neg \left(\ell \leq 1650000000000\right):\\
\;\;\;\;U + \left(J \cdot {\ell}^{5}\right) \cdot \left(0.016666666666666666 + \left(K \cdot K\right) \cdot -0.0020833333333333333\right)\\

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


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

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

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

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

    if -7.9999999999999994e125 < l < -450 or 1.65e12 < 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 82.2%

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

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

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

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

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

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

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

        \[\leadsto \left(\left(J \cdot {\ell}^{5}\right) \cdot 0.016666666666666666 + \color{blue}{\left(J \cdot \left({K}^{2} \cdot {\ell}^{5}\right)\right) \cdot -0.0020833333333333333}\right) + U \]
      4. *-commutative6.7%

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

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

        \[\leadsto \left(\left(J \cdot {\ell}^{5}\right) \cdot 0.016666666666666666 + \color{blue}{\left(J \cdot {\ell}^{5}\right) \cdot \left({K}^{2} \cdot -0.0020833333333333333\right)}\right) + U \]
      7. distribute-lft-out68.5%

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

        \[\leadsto \left(J \cdot {\ell}^{5}\right) \cdot \left(0.016666666666666666 + \color{blue}{\left(K \cdot K\right)} \cdot -0.0020833333333333333\right) + U \]
    8. Simplified68.5%

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

    if -450 < l < 1.65e12

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

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

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

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

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

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

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

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

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

Alternative 11: 58.0% accurate, 2.6× speedup?

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

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

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


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

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 90.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 61.2%

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

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

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

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

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

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

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

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

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

Alternative 12: 64.1% accurate, 2.8× speedup?

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

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

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

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

Alternative 13: 64.1% accurate, 2.8× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 14: 46.5% accurate, 34.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.05 \cdot 10^{+17} \lor \neg \left(\ell \leq 0.00166\right):\\
\;\;\;\;J \cdot \left(\ell \cdot 2\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -2.05e17 or 0.00166 < l

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

      \[\leadsto \ell \cdot \left(2 \cdot \color{blue}{J}\right) + U \]
    6. Taylor expanded in l around inf 24.5%

      \[\leadsto \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
    7. Step-by-step derivation
      1. *-commutative24.5%

        \[\leadsto \color{blue}{\left(J \cdot \ell\right) \cdot 2} \]
      2. associate-*l*24.5%

        \[\leadsto \color{blue}{J \cdot \left(\ell \cdot 2\right)} \]
    8. Simplified24.5%

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

    if -2.05e17 < l < 0.00166

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.05 \cdot 10^{+17} \lor \neg \left(\ell \leq 0.00166\right):\\ \;\;\;\;J \cdot \left(\ell \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \]

Alternative 15: 41.7% accurate, 43.8× speedup?

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

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

\mathbf{elif}\;\ell \leq 1.65 \cdot 10^{+38}:\\
\;\;\;\;U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -2.5e64 or 1.65e38 < 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.8%

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

    if -2.5e64 < l < 1.65e38

    1. Initial program 83.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 63.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.5 \cdot 10^{+64}:\\ \;\;\;\;U \cdot U\\ \mathbf{elif}\;\ell \leq 1.65 \cdot 10^{+38}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot U\\ \end{array} \]

Alternative 16: 54.3% accurate, 44.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

Alternative 17: 2.7% accurate, 312.0× speedup?

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

\\
1
\end{array}
Derivation
  1. Initial program 90.8%

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

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

      \[\leadsto \color{blue}{1} \]
  4. Simplified2.6%

    \[\leadsto \color{blue}{1} \]
  5. Final simplification2.6%

    \[\leadsto 1 \]

Alternative 18: 37.2% 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 90.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 37.0%

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

    \[\leadsto U \]

Reproduce

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