Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.8% → 99.9%
Time: 12.5s
Alternatives: 12
Speedup: 1.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 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.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ t_1 := e^{\ell} - e^{-\ell}\\ \mathbf{if}\;t_1 \leq -500000 \lor \neg \left(t_1 \leq 0.001\right):\\ \;\;\;\;t_0 \cdot \left(t_1 \cdot J\right) + U\\ \mathbf{else}:\\ \;\;\;\;U + t_0 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \left(0.016666666666666666 \cdot {\ell}^{5} + \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 -500000.0) (not (<= t_1 0.001)))
     (+ (* t_0 (* t_1 J)) U)
     (+
      U
      (*
       t_0
       (*
        J
        (+
         (* 0.3333333333333333 (pow l 3.0))
         (+ (* 0.016666666666666666 (pow l 5.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 <= -500000.0) || !(t_1 <= 0.001)) {
		tmp = (t_0 * (t_1 * J)) + U;
	} else {
		tmp = U + (t_0 * (J * ((0.3333333333333333 * pow(l, 3.0)) + ((0.016666666666666666 * pow(l, 5.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 <= (-500000.0d0)) .or. (.not. (t_1 <= 0.001d0))) then
        tmp = (t_0 * (t_1 * j)) + u
    else
        tmp = u + (t_0 * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + ((0.016666666666666666d0 * (l ** 5.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 <= -500000.0) || !(t_1 <= 0.001)) {
		tmp = (t_0 * (t_1 * J)) + U;
	} else {
		tmp = U + (t_0 * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + ((0.016666666666666666 * Math.pow(l, 5.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 <= -500000.0) or not (t_1 <= 0.001):
		tmp = (t_0 * (t_1 * J)) + U
	else:
		tmp = U + (t_0 * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + ((0.016666666666666666 * math.pow(l, 5.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 <= -500000.0) || !(t_1 <= 0.001))
		tmp = Float64(Float64(t_0 * Float64(t_1 * J)) + U);
	else
		tmp = Float64(U + Float64(t_0 * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(Float64(0.016666666666666666 * (l ^ 5.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 <= -500000.0) || ~((t_1 <= 0.001)))
		tmp = (t_0 * (t_1 * J)) + U;
	else
		tmp = U + (t_0 * (J * ((0.3333333333333333 * (l ^ 3.0)) + ((0.016666666666666666 * (l ^ 5.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, -500000.0], N[Not[LessEqual[t$95$1, 0.001]], $MachinePrecision]], N[(N[(t$95$0 * N[(t$95$1 * J), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.016666666666666666 * N[Power[l, 5.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 -500000 \lor \neg \left(t_1 \leq 0.001\right):\\
\;\;\;\;t_0 \cdot \left(t_1 \cdot J\right) + U\\

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

    1. Initial program 100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{\ell} - e^{-\ell} \leq -500000 \lor \neg \left(e^{\ell} - e^{-\ell} \leq 0.001\right):\\ \;\;\;\;\cos \left(\frac{K}{2}\right) \cdot \left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right) + U\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \left(0.016666666666666666 \cdot {\ell}^{5} + \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 -500000 \lor \neg \left(t_1 \leq 0.001\right):\\ \;\;\;\;t_0 \cdot \left(t_1 \cdot J\right) + 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 -500000.0) (not (<= t_1 0.001)))
     (+ (* t_0 (* t_1 J)) 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 <= -500000.0) || !(t_1 <= 0.001)) {
		tmp = (t_0 * (t_1 * J)) + 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 <= (-500000.0d0)) .or. (.not. (t_1 <= 0.001d0))) then
        tmp = (t_0 * (t_1 * j)) + 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 <= -500000.0) || !(t_1 <= 0.001)) {
		tmp = (t_0 * (t_1 * J)) + 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 <= -500000.0) or not (t_1 <= 0.001):
		tmp = (t_0 * (t_1 * J)) + 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 <= -500000.0) || !(t_1 <= 0.001))
		tmp = Float64(Float64(t_0 * Float64(t_1 * J)) + 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 <= -500000.0) || ~((t_1 <= 0.001)))
		tmp = (t_0 * (t_1 * J)) + 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, -500000.0], N[Not[LessEqual[t$95$1, 0.001]], $MachinePrecision]], N[(N[(t$95$0 * N[(t$95$1 * J), $MachinePrecision]), $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 -500000 \lor \neg \left(t_1 \leq 0.001\right):\\
\;\;\;\;t_0 \cdot \left(t_1 \cdot J\right) + 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))) < -5e5 or 1e-3 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

    1. Initial program 100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{\ell} - e^{-\ell} \leq -500000 \lor \neg \left(e^{\ell} - e^{-\ell} \leq 0.001\right):\\ \;\;\;\;\cos \left(\frac{K}{2}\right) \cdot \left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\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: 97.5% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := U + \left(J \cdot {\ell}^{5}\right) \cdot \left(0.016666666666666666 \cdot \cos \left(K \cdot 0.5\right)\right)\\ t_1 := \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{if}\;\ell \leq -4.5 \cdot 10^{+65}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -0.23:\\ \;\;\;\;U + t_1\\ \mathbf{elif}\;\ell \leq 85:\\ \;\;\;\;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 3.2 \cdot 10^{+61}:\\ \;\;\;\;U + t_1 \cdot \left(-0.125 \cdot \left(K \cdot K\right) + 1\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0
         (+ U (* (* J (pow l 5.0)) (* 0.016666666666666666 (cos (* K 0.5))))))
        (t_1 (* (- (exp l) (exp (- l))) J)))
   (if (<= l -4.5e+65)
     t_0
     (if (<= l -0.23)
       (+ U t_1)
       (if (<= l 85.0)
         (+
          U
          (*
           (cos (/ K 2.0))
           (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
         (if (<= l 3.2e+61) (+ U (* t_1 (+ (* -0.125 (* K K)) 1.0))) t_0))))))
double code(double J, double l, double K, double U) {
	double t_0 = U + ((J * pow(l, 5.0)) * (0.016666666666666666 * cos((K * 0.5))));
	double t_1 = (exp(l) - exp(-l)) * J;
	double tmp;
	if (l <= -4.5e+65) {
		tmp = t_0;
	} else if (l <= -0.23) {
		tmp = U + t_1;
	} else if (l <= 85.0) {
		tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
	} else if (l <= 3.2e+61) {
		tmp = U + (t_1 * ((-0.125 * (K * K)) + 1.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = u + ((j * (l ** 5.0d0)) * (0.016666666666666666d0 * cos((k * 0.5d0))))
    t_1 = (exp(l) - exp(-l)) * j
    if (l <= (-4.5d+65)) then
        tmp = t_0
    else if (l <= (-0.23d0)) then
        tmp = u + t_1
    else if (l <= 85.0d0) then
        tmp = u + (cos((k / 2.0d0)) * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
    else if (l <= 3.2d+61) then
        tmp = u + (t_1 * (((-0.125d0) * (k * k)) + 1.0d0))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = U + ((J * Math.pow(l, 5.0)) * (0.016666666666666666 * Math.cos((K * 0.5))));
	double t_1 = (Math.exp(l) - Math.exp(-l)) * J;
	double tmp;
	if (l <= -4.5e+65) {
		tmp = t_0;
	} else if (l <= -0.23) {
		tmp = U + t_1;
	} else if (l <= 85.0) {
		tmp = U + (Math.cos((K / 2.0)) * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
	} else if (l <= 3.2e+61) {
		tmp = U + (t_1 * ((-0.125 * (K * K)) + 1.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = U + ((J * math.pow(l, 5.0)) * (0.016666666666666666 * math.cos((K * 0.5))))
	t_1 = (math.exp(l) - math.exp(-l)) * J
	tmp = 0
	if l <= -4.5e+65:
		tmp = t_0
	elif l <= -0.23:
		tmp = U + t_1
	elif l <= 85.0:
		tmp = U + (math.cos((K / 2.0)) * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))))
	elif l <= 3.2e+61:
		tmp = U + (t_1 * ((-0.125 * (K * K)) + 1.0))
	else:
		tmp = t_0
	return tmp
function code(J, l, K, U)
	t_0 = Float64(U + Float64(Float64(J * (l ^ 5.0)) * Float64(0.016666666666666666 * cos(Float64(K * 0.5)))))
	t_1 = Float64(Float64(exp(l) - exp(Float64(-l))) * J)
	tmp = 0.0
	if (l <= -4.5e+65)
		tmp = t_0;
	elseif (l <= -0.23)
		tmp = Float64(U + t_1);
	elseif (l <= 85.0)
		tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)))));
	elseif (l <= 3.2e+61)
		tmp = Float64(U + Float64(t_1 * Float64(Float64(-0.125 * Float64(K * K)) + 1.0)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = U + ((J * (l ^ 5.0)) * (0.016666666666666666 * cos((K * 0.5))));
	t_1 = (exp(l) - exp(-l)) * J;
	tmp = 0.0;
	if (l <= -4.5e+65)
		tmp = t_0;
	elseif (l <= -0.23)
		tmp = U + t_1;
	elseif (l <= 85.0)
		tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0))));
	elseif (l <= 3.2e+61)
		tmp = U + (t_1 * ((-0.125 * (K * K)) + 1.0));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(N[(J * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision] * N[(0.016666666666666666 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]}, If[LessEqual[l, -4.5e+65], t$95$0, If[LessEqual[l, -0.23], N[(U + t$95$1), $MachinePrecision], If[LessEqual[l, 85.0], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * 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, 3.2e+61], N[(U + N[(t$95$1 * N[(N[(-0.125 * N[(K * K), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;\ell \leq -0.23:\\
\;\;\;\;U + t_1\\

\mathbf{elif}\;\ell \leq 85:\\
\;\;\;\;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 3.2 \cdot 10^{+61}:\\
\;\;\;\;U + t_1 \cdot \left(-0.125 \cdot \left(K \cdot K\right) + 1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -4.5e65 or 3.1999999999999998e61 < l

    1. Initial program 100.0%

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

      \[\leadsto \left(J \cdot \color{blue}{\left(0.3333333333333333 \cdot {\ell}^{3} + \left(0.016666666666666666 \cdot {\ell}^{5} + 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}{0.016666666666666666 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left({\ell}^{5} \cdot J\right)\right)} + U \]
    4. Step-by-step derivation
      1. associate-*r*100.0%

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

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

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

    if -4.5e65 < l < -0.23000000000000001

    1. Initial program 99.9%

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

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

    if -0.23000000000000001 < l < 85

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

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

    if 85 < l < 3.1999999999999998e61

    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(\left(e^{\ell} - e^{-\ell}\right) \cdot J + -0.125 \cdot \left({K}^{2} \cdot \left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right)\right)\right)} + U \]
    3. Step-by-step derivation
      1. associate-*r*0.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.5 \cdot 10^{+65}:\\ \;\;\;\;U + \left(J \cdot {\ell}^{5}\right) \cdot \left(0.016666666666666666 \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{elif}\;\ell \leq -0.23:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{elif}\;\ell \leq 85:\\ \;\;\;\;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 3.2 \cdot 10^{+61}:\\ \;\;\;\;U + \left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right) \cdot \left(-0.125 \cdot \left(K \cdot K\right) + 1\right)\\ \mathbf{else}:\\ \;\;\;\;U + \left(J \cdot {\ell}^{5}\right) \cdot \left(0.016666666666666666 \cdot \cos \left(K \cdot 0.5\right)\right)\\ \end{array} \]

Alternative 4: 97.4% accurate, 1.4× speedup?

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

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

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

\mathbf{elif}\;\ell \leq 200:\\
\;\;\;\;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 4.5 \cdot 10^{+61}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -4.5e65 or 4.5e61 < l

    1. Initial program 100.0%

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

      \[\leadsto \left(J \cdot \color{blue}{\left(0.3333333333333333 \cdot {\ell}^{3} + \left(0.016666666666666666 \cdot {\ell}^{5} + 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}{0.016666666666666666 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left({\ell}^{5} \cdot J\right)\right)} + U \]
    4. Step-by-step derivation
      1. associate-*r*100.0%

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

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

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

    if -4.5e65 < l < -0.0529999999999999985 or 200 < l < 4.5e61

    1. Initial program 99.9%

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

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

    if -0.0529999999999999985 < l < 200

    1. Initial program 72.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.5 \cdot 10^{+65}:\\ \;\;\;\;U + \left(J \cdot {\ell}^{5}\right) \cdot \left(0.016666666666666666 \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{elif}\;\ell \leq -0.053:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{elif}\;\ell \leq 200:\\ \;\;\;\;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 4.5 \cdot 10^{+61}:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{else}:\\ \;\;\;\;U + \left(J \cdot {\ell}^{5}\right) \cdot \left(0.016666666666666666 \cdot \cos \left(K \cdot 0.5\right)\right)\\ \end{array} \]

Alternative 5: 97.3% accurate, 1.4× speedup?

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

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

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

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

\mathbf{elif}\;\ell \leq 1.95 \cdot 10^{+61}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -4.5e65 or 1.94999999999999994e61 < l

    1. Initial program 100.0%

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

      \[\leadsto \left(J \cdot \color{blue}{\left(0.3333333333333333 \cdot {\ell}^{3} + \left(0.016666666666666666 \cdot {\ell}^{5} + 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}{0.016666666666666666 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left({\ell}^{5} \cdot J\right)\right)} + U \]
    4. Step-by-step derivation
      1. associate-*r*100.0%

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

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

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

    if -4.5e65 < l < -0.0025999999999999999 or 200 < l < 1.94999999999999994e61

    1. Initial program 99.9%

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

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

    if -0.0025999999999999999 < l < 200

    1. Initial program 72.8%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.5 \cdot 10^{+65}:\\ \;\;\;\;U + \left(J \cdot {\ell}^{5}\right) \cdot \left(0.016666666666666666 \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{elif}\;\ell \leq -0.0026:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{elif}\;\ell \leq 200:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 1.95 \cdot 10^{+61}:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{else}:\\ \;\;\;\;U + \left(J \cdot {\ell}^{5}\right) \cdot \left(0.016666666666666666 \cdot \cos \left(K \cdot 0.5\right)\right)\\ \end{array} \]

Alternative 6: 86.8% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -0.00325 \lor \neg \left(\ell \leq 200\right):\\
\;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\

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


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

    1. Initial program 100.0%

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

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

    if -0.00324999999999999985 < l < 200

    1. Initial program 72.8%

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

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

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

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

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

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

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

Alternative 7: 71.9% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 85.5%

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

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

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

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

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

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

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

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

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

    1. Initial program 87.3%

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

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

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

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

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

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

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

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

Alternative 8: 82.1% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
t_0 := J \cdot {\ell}^{5}\\
t_1 := U + 0.016666666666666666 \cdot t_0\\
\mathbf{if}\;\ell \leq -6.5:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;\ell \leq 1.65 \cdot 10^{+47}:\\
\;\;\;\;U + t_0 \cdot \left(0.016666666666666666 + \left(K \cdot K\right) \cdot -0.0020833333333333333\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -6.5 or 1.65e47 < 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.3%

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

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

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

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

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

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

    if -6.5 < l < 196

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

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

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

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

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

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

    if 196 < l < 1.65e47

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 81.7% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -6.6 \lor \neg \left(\ell \leq 1520000\right):\\ \;\;\;\;U + 0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\right)\\ \mathbf{else}:\\ \;\;\;\;U + 2 \cdot \left(\ell \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 (or (<= l -6.6) (not (<= l 1520000.0)))
   (+ U (* 0.016666666666666666 (* J (pow l 5.0))))
   (+ U (* 2.0 (* l (* J (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if ((l <= -6.6) || !(l <= 1520000.0)) {
		tmp = U + (0.016666666666666666 * (J * pow(l, 5.0)));
	} else {
		tmp = U + (2.0 * (l * (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 <= (-6.6d0)) .or. (.not. (l <= 1520000.0d0))) then
        tmp = u + (0.016666666666666666d0 * (j * (l ** 5.0d0)))
    else
        tmp = u + (2.0d0 * (l * (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 <= -6.6) || !(l <= 1520000.0)) {
		tmp = U + (0.016666666666666666 * (J * Math.pow(l, 5.0)));
	} else {
		tmp = U + (2.0 * (l * (J * Math.cos((K * 0.5)))));
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if (l <= -6.6) or not (l <= 1520000.0):
		tmp = U + (0.016666666666666666 * (J * math.pow(l, 5.0)))
	else:
		tmp = U + (2.0 * (l * (J * math.cos((K * 0.5)))))
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if ((l <= -6.6) || !(l <= 1520000.0))
		tmp = Float64(U + Float64(0.016666666666666666 * Float64(J * (l ^ 5.0))));
	else
		tmp = Float64(U + Float64(2.0 * Float64(l * Float64(J * cos(Float64(K * 0.5))))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if ((l <= -6.6) || ~((l <= 1520000.0)))
		tmp = U + (0.016666666666666666 * (J * (l ^ 5.0)));
	else
		tmp = U + (2.0 * (l * (J * cos((K * 0.5)))));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -6.6], N[Not[LessEqual[l, 1520000.0]], $MachinePrecision]], N[(U + N[(0.016666666666666666 * N[(J * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(l * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6.6 \lor \neg \left(\ell \leq 1520000\right):\\
\;\;\;\;U + 0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -6.5999999999999996 or 1.52e6 < 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 85.1%

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

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

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

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

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

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

    if -6.5999999999999996 < l < 1.52e6

    1. Initial program 72.8%

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

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

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

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

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

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

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

Alternative 10: 58.2% accurate, 18.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.45 \cdot 10^{+78} \lor \neg \left(\ell \leq 1.45 \cdot 10^{-43}\right):\\
\;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -1.45000000000000008e78 or 1.4500000000000001e-43 < l

    1. Initial program 97.4%

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

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

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

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

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

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

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

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

    if -1.45000000000000008e78 < l < 1.4500000000000001e-43

    1. Initial program 76.4%

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

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

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

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

Alternative 11: 53.5% accurate, 44.6× speedup?

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

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

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

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

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

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

Alternative 12: 36.8% 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 86.9%

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

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

    \[\leadsto \color{blue}{U} \]
  4. Final simplification35.2%

    \[\leadsto U \]

Reproduce

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