Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.3% → 99.7%
Time: 12.7s
Alternatives: 22
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 22 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.3% 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.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\ell} - e^{-\ell}\\ \mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 4 \cdot 10^{-7}\right):\\ \;\;\;\;\cos \left(\frac{K}{2}\right) \cdot \left(t_0 \cdot J\right) + U\\ \mathbf{else}:\\ \;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \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 (- (exp l) (exp (- l)))))
   (if (or (<= t_0 (- INFINITY)) (not (<= t_0 4e-7)))
     (+ (* (cos (/ K 2.0)) (* t_0 J)) U)
     (+
      U
      (*
       (* J (cos (* K 0.5)))
       (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))))
double code(double J, double l, double K, double U) {
	double t_0 = exp(l) - exp(-l);
	double tmp;
	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 4e-7)) {
		tmp = (cos((K / 2.0)) * (t_0 * J)) + U;
	} else {
		tmp = U + ((J * cos((K * 0.5))) * ((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.exp(l) - Math.exp(-l);
	double tmp;
	if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 4e-7)) {
		tmp = (Math.cos((K / 2.0)) * (t_0 * J)) + U;
	} else {
		tmp = U + ((J * Math.cos((K * 0.5))) * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.exp(l) - math.exp(-l)
	tmp = 0
	if (t_0 <= -math.inf) or not (t_0 <= 4e-7):
		tmp = (math.cos((K / 2.0)) * (t_0 * J)) + U
	else:
		tmp = U + ((J * math.cos((K * 0.5))) * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))
	return tmp
function code(J, l, K, U)
	t_0 = Float64(exp(l) - exp(Float64(-l)))
	tmp = 0.0
	if ((t_0 <= Float64(-Inf)) || !(t_0 <= 4e-7))
		tmp = Float64(Float64(cos(Float64(K / 2.0)) * Float64(t_0 * J)) + U);
	else
		tmp = Float64(U + Float64(Float64(J * cos(Float64(K * 0.5))) * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = exp(l) - exp(-l);
	tmp = 0.0;
	if ((t_0 <= -Inf) || ~((t_0 <= 4e-7)))
		tmp = (cos((K / 2.0)) * (t_0 * J)) + U;
	else
		tmp = U + ((J * cos((K * 0.5))) * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 4e-7]], $MachinePrecision]], N[(N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(t$95$0 * J), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 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 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 4 \cdot 10^{-7}\right):\\
\;\;\;\;\cos \left(\frac{K}{2}\right) \cdot \left(t_0 \cdot J\right) + U\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 93.3% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.3333333333333333 \cdot {\ell}^{3}\\ t_1 := J \cdot \cos \left(K \cdot 0.5\right)\\ t_2 := U + t_1 \cdot t_0\\ t_3 := \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{if}\;\ell \leq -6.1 \cdot 10^{+85}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\ell \leq -7800000000:\\ \;\;\;\;U + \left(-0.125 \cdot \left(K \cdot K\right) + 1\right) \cdot t_3\\ \mathbf{elif}\;\ell \leq 0.07:\\ \;\;\;\;U + t_1 \cdot \left(t_0 + \ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 6 \cdot 10^{+51}:\\ \;\;\;\;U + t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (* 0.3333333333333333 (pow l 3.0)))
        (t_1 (* J (cos (* K 0.5))))
        (t_2 (+ U (* t_1 t_0)))
        (t_3 (* (- (exp l) (exp (- l))) J)))
   (if (<= l -6.1e+85)
     t_2
     (if (<= l -7800000000.0)
       (+ U (* (+ (* -0.125 (* K K)) 1.0) t_3))
       (if (<= l 0.07)
         (+ U (* t_1 (+ t_0 (* l 2.0))))
         (if (<= l 6e+51) (+ U t_3) t_2))))))
double code(double J, double l, double K, double U) {
	double t_0 = 0.3333333333333333 * pow(l, 3.0);
	double t_1 = J * cos((K * 0.5));
	double t_2 = U + (t_1 * t_0);
	double t_3 = (exp(l) - exp(-l)) * J;
	double tmp;
	if (l <= -6.1e+85) {
		tmp = t_2;
	} else if (l <= -7800000000.0) {
		tmp = U + (((-0.125 * (K * K)) + 1.0) * t_3);
	} else if (l <= 0.07) {
		tmp = U + (t_1 * (t_0 + (l * 2.0)));
	} else if (l <= 6e+51) {
		tmp = U + t_3;
	} 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) :: t_3
    real(8) :: tmp
    t_0 = 0.3333333333333333d0 * (l ** 3.0d0)
    t_1 = j * cos((k * 0.5d0))
    t_2 = u + (t_1 * t_0)
    t_3 = (exp(l) - exp(-l)) * j
    if (l <= (-6.1d+85)) then
        tmp = t_2
    else if (l <= (-7800000000.0d0)) then
        tmp = u + ((((-0.125d0) * (k * k)) + 1.0d0) * t_3)
    else if (l <= 0.07d0) then
        tmp = u + (t_1 * (t_0 + (l * 2.0d0)))
    else if (l <= 6d+51) then
        tmp = u + t_3
    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 = 0.3333333333333333 * Math.pow(l, 3.0);
	double t_1 = J * Math.cos((K * 0.5));
	double t_2 = U + (t_1 * t_0);
	double t_3 = (Math.exp(l) - Math.exp(-l)) * J;
	double tmp;
	if (l <= -6.1e+85) {
		tmp = t_2;
	} else if (l <= -7800000000.0) {
		tmp = U + (((-0.125 * (K * K)) + 1.0) * t_3);
	} else if (l <= 0.07) {
		tmp = U + (t_1 * (t_0 + (l * 2.0)));
	} else if (l <= 6e+51) {
		tmp = U + t_3;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = 0.3333333333333333 * math.pow(l, 3.0)
	t_1 = J * math.cos((K * 0.5))
	t_2 = U + (t_1 * t_0)
	t_3 = (math.exp(l) - math.exp(-l)) * J
	tmp = 0
	if l <= -6.1e+85:
		tmp = t_2
	elif l <= -7800000000.0:
		tmp = U + (((-0.125 * (K * K)) + 1.0) * t_3)
	elif l <= 0.07:
		tmp = U + (t_1 * (t_0 + (l * 2.0)))
	elif l <= 6e+51:
		tmp = U + t_3
	else:
		tmp = t_2
	return tmp
function code(J, l, K, U)
	t_0 = Float64(0.3333333333333333 * (l ^ 3.0))
	t_1 = Float64(J * cos(Float64(K * 0.5)))
	t_2 = Float64(U + Float64(t_1 * t_0))
	t_3 = Float64(Float64(exp(l) - exp(Float64(-l))) * J)
	tmp = 0.0
	if (l <= -6.1e+85)
		tmp = t_2;
	elseif (l <= -7800000000.0)
		tmp = Float64(U + Float64(Float64(Float64(-0.125 * Float64(K * K)) + 1.0) * t_3));
	elseif (l <= 0.07)
		tmp = Float64(U + Float64(t_1 * Float64(t_0 + Float64(l * 2.0))));
	elseif (l <= 6e+51)
		tmp = Float64(U + t_3);
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = 0.3333333333333333 * (l ^ 3.0);
	t_1 = J * cos((K * 0.5));
	t_2 = U + (t_1 * t_0);
	t_3 = (exp(l) - exp(-l)) * J;
	tmp = 0.0;
	if (l <= -6.1e+85)
		tmp = t_2;
	elseif (l <= -7800000000.0)
		tmp = U + (((-0.125 * (K * K)) + 1.0) * t_3);
	elseif (l <= 0.07)
		tmp = U + (t_1 * (t_0 + (l * 2.0)));
	elseif (l <= 6e+51)
		tmp = U + t_3;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(U + N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]}, If[LessEqual[l, -6.1e+85], t$95$2, If[LessEqual[l, -7800000000.0], N[(U + N[(N[(N[(-0.125 * N[(K * K), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 0.07], N[(U + N[(t$95$1 * N[(t$95$0 + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6e+51], N[(U + t$95$3), $MachinePrecision], t$95$2]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.3333333333333333 \cdot {\ell}^{3}\\
t_1 := J \cdot \cos \left(K \cdot 0.5\right)\\
t_2 := U + t_1 \cdot t_0\\
t_3 := \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;\ell \leq -6.1 \cdot 10^{+85}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;\ell \leq -7800000000:\\
\;\;\;\;U + \left(-0.125 \cdot \left(K \cdot K\right) + 1\right) \cdot t_3\\

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

\mathbf{elif}\;\ell \leq 6 \cdot 10^{+51}:\\
\;\;\;\;U + t_3\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -6.09999999999999981e85 or 6e51 < l

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.09999999999999981e85 < l < -7.8e9

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

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

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

      \[\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 \]

    if -7.8e9 < l < 0.070000000000000007

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.070000000000000007 < l < 6e51

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -6.1 \cdot 10^{+85}:\\ \;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\ \mathbf{elif}\;\ell \leq -7800000000:\\ \;\;\;\;U + \left(-0.125 \cdot \left(K \cdot K\right) + 1\right) \cdot \left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right)\\ \mathbf{elif}\;\ell \leq 0.07:\\ \;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 6 \cdot 10^{+51}:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{else}:\\ \;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\ \end{array} \]

Alternative 3: 94.0% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := J \cdot \cos \left(K \cdot 0.5\right)\\
t_1 := U + t_0 \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\
t_2 := \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;\ell \leq -2.65 \cdot 10^{+101}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;\ell \leq 6 \cdot 10^{+51}:\\
\;\;\;\;U + t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -2.65000000000000003e101 or 6e51 < 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.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.65000000000000003e101 < l < -225

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

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

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

    if -225 < l < 0.00235000000000000009

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.00235000000000000009 < l < 6e51

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.65 \cdot 10^{+101}:\\ \;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\ \mathbf{elif}\;\ell \leq -225:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{elif}\;\ell \leq 0.00235:\\ \;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(\ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 6 \cdot 10^{+51}:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{else}:\\ \;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\ \end{array} \]

Alternative 4: 79.1% accurate, 1.4× speedup?

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 88.4% accurate, 1.4× speedup?

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

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

    \[\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. Final simplification90.6%

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

Alternative 6: 88.4% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\cos \left(0.5 \cdot K\right) \cdot J\right) \cdot \color{blue}{\mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 2 \cdot \ell\right)} + U \]
  4. Simplified90.6%

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

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

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

Alternative 7: 85.2% accurate, 1.5× speedup?

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

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

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

\mathbf{elif}\;\ell \leq 6 \cdot 10^{+51}:\\
\;\;\;\;U + t_0\\

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


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

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

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

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

    if -260 < l < 9.39999999999999972e-4

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.39999999999999972e-4 < l < 6e51

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

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

    if 6e51 < 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 93.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\cos \left(0.5 \cdot K\right) \cdot J\right) \cdot \color{blue}{\mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 2 \cdot \ell\right)} + U \]
    4. Simplified93.8%

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

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

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

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

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

        \[\leadsto \left(0.3333333333333333 \cdot \left({\ell}^{3} \cdot J\right) + \color{blue}{\left(-0.041666666666666664 \cdot \left(K \cdot K\right)\right) \cdot \left({\ell}^{3} \cdot J\right)}\right) + U \]
      4. distribute-rgt-out76.6%

        \[\leadsto \color{blue}{\left({\ell}^{3} \cdot J\right) \cdot \left(0.3333333333333333 + -0.041666666666666664 \cdot \left(K \cdot K\right)\right)} + U \]
    8. Simplified76.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -260:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{elif}\;\ell \leq 0.00094:\\ \;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(\ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 6 \cdot 10^{+51}:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{else}:\\ \;\;\;\;U + \left(J \cdot {\ell}^{3}\right) \cdot \left(0.3333333333333333 + \left(K \cdot K\right) \cdot -0.041666666666666664\right)\\ \end{array} \]

Alternative 8: 85.1% accurate, 1.5× speedup?

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

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

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

\mathbf{elif}\;\ell \leq 5.8 \cdot 10^{+51}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -102 or 240 < l < 5.7999999999999997e51

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

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

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

    if -102 < l < 240

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.7999999999999997e51 < 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 93.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\cos \left(0.5 \cdot K\right) \cdot J\right) \cdot \color{blue}{\mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 2 \cdot \ell\right)} + U \]
    4. Simplified93.8%

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

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

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

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

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

        \[\leadsto \left(0.3333333333333333 \cdot \left({\ell}^{3} \cdot J\right) + \color{blue}{\left(-0.041666666666666664 \cdot \left(K \cdot K\right)\right) \cdot \left({\ell}^{3} \cdot J\right)}\right) + U \]
      4. distribute-rgt-out76.6%

        \[\leadsto \color{blue}{\left({\ell}^{3} \cdot J\right) \cdot \left(0.3333333333333333 + -0.041666666666666664 \cdot \left(K \cdot K\right)\right)} + U \]
    8. Simplified76.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -102:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{elif}\;\ell \leq 240:\\ \;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(\ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 5.8 \cdot 10^{+51}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{else}:\\ \;\;\;\;U + \left(J \cdot {\ell}^{3}\right) \cdot \left(0.3333333333333333 + \left(K \cdot K\right) \cdot -0.041666666666666664\right)\\ \end{array} \]

Alternative 9: 68.7% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 84.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 64.4%

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

      \[\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. +-commutative45.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 80.1% accurate, 1.5× speedup?

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

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

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

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

\mathbf{elif}\;\ell \leq 4.9 \cdot 10^{+51}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(U\right)\right)\\

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


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

    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 \color{blue}{\left(2 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot J\right)\right) + 0.3333333333333333 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left({\ell}^{3} \cdot J\right)\right)\right)} + U \]
    3. Step-by-step derivation
      1. *-commutative100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0000000000000001e142 < l < -7.8e9 or 4.89999999999999983e51 < 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 80.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(0.3333333333333333 \cdot \left({\ell}^{3} \cdot J\right) + \color{blue}{\left(-0.041666666666666664 \cdot \left(K \cdot K\right)\right) \cdot \left({\ell}^{3} \cdot J\right)}\right) + U \]
      4. distribute-rgt-out68.4%

        \[\leadsto \color{blue}{\left({\ell}^{3} \cdot J\right) \cdot \left(0.3333333333333333 + -0.041666666666666664 \cdot \left(K \cdot K\right)\right)} + U \]
    8. Simplified68.4%

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

    if -7.8e9 < l < 3500

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3500 < l < 4.89999999999999983e51

    1. Initial program 100.0%

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

      \[\leadsto \left(J \cdot \color{blue}{-8}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Applied egg-rr70.4%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(U\right)\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification86.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2 \cdot 10^{+142}:\\ \;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \mathbf{elif}\;\ell \leq -7800000000:\\ \;\;\;\;U + \left(J \cdot {\ell}^{3}\right) \cdot \left(0.3333333333333333 + \left(K \cdot K\right) \cdot -0.041666666666666664\right)\\ \mathbf{elif}\;\ell \leq 3500:\\ \;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(\ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 4.9 \cdot 10^{+51}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(U\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + \left(J \cdot {\ell}^{3}\right) \cdot \left(0.3333333333333333 + \left(K \cdot K\right) \cdot -0.041666666666666664\right)\\ \end{array} \]

Alternative 11: 79.9% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
t_0 := J \cdot {\ell}^{3}\\
\mathbf{if}\;\ell \leq -7 \cdot 10^{+140}:\\
\;\;\;\;U + 0.3333333333333333 \cdot t_0\\

\mathbf{elif}\;\ell \leq -7800000000 \lor \neg \left(\ell \leq 1.32 \cdot 10^{+26}\right):\\
\;\;\;\;U + t_0 \cdot \left(0.3333333333333333 + \left(K \cdot K\right) \cdot -0.041666666666666664\right)\\

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


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

    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 \color{blue}{\left(2 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot J\right)\right) + 0.3333333333333333 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left({\ell}^{3} \cdot J\right)\right)\right)} + U \]
    3. Step-by-step derivation
      1. *-commutative100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.99999999999999978e140 < l < -7.8e9 or 1.32e26 < 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 79.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(0.3333333333333333 \cdot \left({\ell}^{3} \cdot J\right) + \color{blue}{\left(-0.041666666666666664 \cdot \left(K \cdot K\right)\right) \cdot \left({\ell}^{3} \cdot J\right)}\right) + U \]
      4. distribute-rgt-out67.5%

        \[\leadsto \color{blue}{\left({\ell}^{3} \cdot J\right) \cdot \left(0.3333333333333333 + -0.041666666666666664 \cdot \left(K \cdot K\right)\right)} + U \]
    8. Simplified67.5%

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

    if -7.8e9 < l < 1.32e26

    1. Initial program 73.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 94.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -7 \cdot 10^{+140}:\\ \;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \mathbf{elif}\;\ell \leq -7800000000 \lor \neg \left(\ell \leq 1.32 \cdot 10^{+26}\right):\\ \;\;\;\;U + \left(J \cdot {\ell}^{3}\right) \cdot \left(0.3333333333333333 + \left(K \cdot K\right) \cdot -0.041666666666666664\right)\\ \mathbf{else}:\\ \;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(\ell \cdot 2\right)\\ \end{array} \]

Alternative 12: 74.0% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;J \leq -9.5 \cdot 10^{+17} \lor \neg \left(J \leq 2.9 \cdot 10^{+125}\right):\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if J < -9.5e17 or 2.89999999999999993e125 < J

    1. Initial program 68.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.4%

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

    if -9.5e17 < J < 2.89999999999999993e125

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 74.0% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;J \leq -5.4 \cdot 10^{+17} \lor \neg \left(J \leq 3.4 \cdot 10^{+125}\right):\\
\;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(\ell \cdot 2\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if J < -5.4e17 or 3.3999999999999999e125 < J

    1. Initial program 68.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\cos \left(0.5 \cdot K\right) \cdot J\right) \cdot \color{blue}{\mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 2 \cdot \ell\right)} + U \]
    4. Simplified95.1%

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

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

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

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

    if -5.4e17 < J < 3.3999999999999999e125

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;J \leq -5.4 \cdot 10^{+17} \lor \neg \left(J \leq 3.4 \cdot 10^{+125}\right):\\ \;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(\ell \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \end{array} \]

Alternative 14: 57.5% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := K \cdot \left(J \cdot K\right)\\ t_1 := U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{if}\;\ell \leq -1.9 \cdot 10^{+173}:\\ \;\;\;\;{U}^{-134217728}\\ \mathbf{elif}\;\ell \leq -13500000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\ell \leq 940:\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 6 \cdot 10^{+44}:\\ \;\;\;\;U + J \cdot \left(512 + \left(K \cdot K\right) \cdot \left(K \cdot \left(K \cdot 1.3333333333333333\right) + -64\right)\right)\\ \mathbf{elif}\;\ell \leq 8 \cdot 10^{+103} \lor \neg \left(\ell \leq 8.6 \cdot 10^{+142}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;U + \frac{t_0 \cdot t_0 - \left(J \cdot -8\right) \cdot \left(J \cdot -8\right)}{t_0 - J \cdot -8}\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (* K (* J K))) (t_1 (+ U (* (* l J) (+ 2.0 (* (* K K) -0.25))))))
   (if (<= l -1.9e+173)
     (pow U -134217728.0)
     (if (<= l -13500000000.0)
       t_1
       (if (<= l 940.0)
         (+ U (* J (* l 2.0)))
         (if (<= l 6e+44)
           (+
            U
            (*
             J
             (+ 512.0 (* (* K K) (+ (* K (* K 1.3333333333333333)) -64.0)))))
           (if (or (<= l 8e+103) (not (<= l 8.6e+142)))
             t_1
             (+
              U
              (/
               (- (* t_0 t_0) (* (* J -8.0) (* J -8.0)))
               (- t_0 (* J -8.0)))))))))))
double code(double J, double l, double K, double U) {
	double t_0 = K * (J * K);
	double t_1 = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
	double tmp;
	if (l <= -1.9e+173) {
		tmp = pow(U, -134217728.0);
	} else if (l <= -13500000000.0) {
		tmp = t_1;
	} else if (l <= 940.0) {
		tmp = U + (J * (l * 2.0));
	} else if (l <= 6e+44) {
		tmp = U + (J * (512.0 + ((K * K) * ((K * (K * 1.3333333333333333)) + -64.0))));
	} else if ((l <= 8e+103) || !(l <= 8.6e+142)) {
		tmp = t_1;
	} else {
		tmp = U + (((t_0 * t_0) - ((J * -8.0) * (J * -8.0))) / (t_0 - (J * -8.0)));
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = k * (j * k)
    t_1 = u + ((l * j) * (2.0d0 + ((k * k) * (-0.25d0))))
    if (l <= (-1.9d+173)) then
        tmp = u ** (-134217728.0d0)
    else if (l <= (-13500000000.0d0)) then
        tmp = t_1
    else if (l <= 940.0d0) then
        tmp = u + (j * (l * 2.0d0))
    else if (l <= 6d+44) then
        tmp = u + (j * (512.0d0 + ((k * k) * ((k * (k * 1.3333333333333333d0)) + (-64.0d0)))))
    else if ((l <= 8d+103) .or. (.not. (l <= 8.6d+142))) then
        tmp = t_1
    else
        tmp = u + (((t_0 * t_0) - ((j * (-8.0d0)) * (j * (-8.0d0)))) / (t_0 - (j * (-8.0d0))))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = K * (J * K);
	double t_1 = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
	double tmp;
	if (l <= -1.9e+173) {
		tmp = Math.pow(U, -134217728.0);
	} else if (l <= -13500000000.0) {
		tmp = t_1;
	} else if (l <= 940.0) {
		tmp = U + (J * (l * 2.0));
	} else if (l <= 6e+44) {
		tmp = U + (J * (512.0 + ((K * K) * ((K * (K * 1.3333333333333333)) + -64.0))));
	} else if ((l <= 8e+103) || !(l <= 8.6e+142)) {
		tmp = t_1;
	} else {
		tmp = U + (((t_0 * t_0) - ((J * -8.0) * (J * -8.0))) / (t_0 - (J * -8.0)));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = K * (J * K)
	t_1 = U + ((l * J) * (2.0 + ((K * K) * -0.25)))
	tmp = 0
	if l <= -1.9e+173:
		tmp = math.pow(U, -134217728.0)
	elif l <= -13500000000.0:
		tmp = t_1
	elif l <= 940.0:
		tmp = U + (J * (l * 2.0))
	elif l <= 6e+44:
		tmp = U + (J * (512.0 + ((K * K) * ((K * (K * 1.3333333333333333)) + -64.0))))
	elif (l <= 8e+103) or not (l <= 8.6e+142):
		tmp = t_1
	else:
		tmp = U + (((t_0 * t_0) - ((J * -8.0) * (J * -8.0))) / (t_0 - (J * -8.0)))
	return tmp
function code(J, l, K, U)
	t_0 = Float64(K * Float64(J * K))
	t_1 = Float64(U + Float64(Float64(l * J) * Float64(2.0 + Float64(Float64(K * K) * -0.25))))
	tmp = 0.0
	if (l <= -1.9e+173)
		tmp = U ^ -134217728.0;
	elseif (l <= -13500000000.0)
		tmp = t_1;
	elseif (l <= 940.0)
		tmp = Float64(U + Float64(J * Float64(l * 2.0)));
	elseif (l <= 6e+44)
		tmp = Float64(U + Float64(J * Float64(512.0 + Float64(Float64(K * K) * Float64(Float64(K * Float64(K * 1.3333333333333333)) + -64.0)))));
	elseif ((l <= 8e+103) || !(l <= 8.6e+142))
		tmp = t_1;
	else
		tmp = Float64(U + Float64(Float64(Float64(t_0 * t_0) - Float64(Float64(J * -8.0) * Float64(J * -8.0))) / Float64(t_0 - Float64(J * -8.0))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = K * (J * K);
	t_1 = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
	tmp = 0.0;
	if (l <= -1.9e+173)
		tmp = U ^ -134217728.0;
	elseif (l <= -13500000000.0)
		tmp = t_1;
	elseif (l <= 940.0)
		tmp = U + (J * (l * 2.0));
	elseif (l <= 6e+44)
		tmp = U + (J * (512.0 + ((K * K) * ((K * (K * 1.3333333333333333)) + -64.0))));
	elseif ((l <= 8e+103) || ~((l <= 8.6e+142)))
		tmp = t_1;
	else
		tmp = U + (((t_0 * t_0) - ((J * -8.0) * (J * -8.0))) / (t_0 - (J * -8.0)));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(K * N[(J * K), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(N[(l * J), $MachinePrecision] * N[(2.0 + N[(N[(K * K), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.9e+173], N[Power[U, -134217728.0], $MachinePrecision], If[LessEqual[l, -13500000000.0], t$95$1, If[LessEqual[l, 940.0], N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6e+44], N[(U + N[(J * N[(512.0 + N[(N[(K * K), $MachinePrecision] * N[(N[(K * N[(K * 1.3333333333333333), $MachinePrecision]), $MachinePrecision] + -64.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[l, 8e+103], N[Not[LessEqual[l, 8.6e+142]], $MachinePrecision]], t$95$1, N[(U + N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(N[(J * -8.0), $MachinePrecision] * N[(J * -8.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(J * -8.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

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

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

\mathbf{elif}\;\ell \leq 6 \cdot 10^{+44}:\\
\;\;\;\;U + J \cdot \left(512 + \left(K \cdot K\right) \cdot \left(K \cdot \left(K \cdot 1.3333333333333333\right) + -64\right)\right)\\

\mathbf{elif}\;\ell \leq 8 \cdot 10^{+103} \lor \neg \left(\ell \leq 8.6 \cdot 10^{+142}\right):\\
\;\;\;\;t_1\\

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


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

    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-rr2.8%

      \[\leadsto \left(J \cdot \color{blue}{-8}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Applied egg-rr38.8%

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

    if -1.90000000000000005e173 < l < -1.35e10 or 5.99999999999999974e44 < l < 8e103 or 8.60000000000000025e142 < l

    1. Initial program 100.0%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Taylor expanded in l around 0 30.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 20.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. +-commutative20.0%

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

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

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

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

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

    if -1.35e10 < l < 940

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

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

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

    if 940 < l < 5.99999999999999974e44

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

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

      \[\leadsto \color{blue}{\left(-64 \cdot \left({K}^{2} \cdot J\right) + \left(1.3333333333333333 \cdot \left({K}^{4} \cdot J\right) + 512 \cdot J\right)\right)} + U \]
    4. Step-by-step derivation
      1. associate-+r+2.1%

        \[\leadsto \color{blue}{\left(\left(-64 \cdot \left({K}^{2} \cdot J\right) + 1.3333333333333333 \cdot \left({K}^{4} \cdot J\right)\right) + 512 \cdot J\right)} + U \]
      2. +-commutative2.1%

        \[\leadsto \color{blue}{\left(512 \cdot J + \left(-64 \cdot \left({K}^{2} \cdot J\right) + 1.3333333333333333 \cdot \left({K}^{4} \cdot J\right)\right)\right)} + U \]
      3. associate-*r*2.1%

        \[\leadsto \left(512 \cdot J + \left(\color{blue}{\left(-64 \cdot {K}^{2}\right) \cdot J} + 1.3333333333333333 \cdot \left({K}^{4} \cdot J\right)\right)\right) + U \]
      4. associate-*r*2.1%

        \[\leadsto \left(512 \cdot J + \left(\left(-64 \cdot {K}^{2}\right) \cdot J + \color{blue}{\left(1.3333333333333333 \cdot {K}^{4}\right) \cdot J}\right)\right) + U \]
      5. distribute-rgt-out22.1%

        \[\leadsto \left(512 \cdot J + \color{blue}{J \cdot \left(-64 \cdot {K}^{2} + 1.3333333333333333 \cdot {K}^{4}\right)}\right) + U \]
      6. *-commutative22.1%

        \[\leadsto \left(512 \cdot J + \color{blue}{\left(-64 \cdot {K}^{2} + 1.3333333333333333 \cdot {K}^{4}\right) \cdot J}\right) + U \]
      7. distribute-rgt-in22.1%

        \[\leadsto \color{blue}{J \cdot \left(512 + \left(-64 \cdot {K}^{2} + 1.3333333333333333 \cdot {K}^{4}\right)\right)} + U \]
      8. +-commutative22.1%

        \[\leadsto J \cdot \left(512 + \color{blue}{\left(1.3333333333333333 \cdot {K}^{4} + -64 \cdot {K}^{2}\right)}\right) + U \]
      9. metadata-eval22.1%

        \[\leadsto J \cdot \left(512 + \left(1.3333333333333333 \cdot {K}^{\color{blue}{\left(2 \cdot 2\right)}} + -64 \cdot {K}^{2}\right)\right) + U \]
      10. pow-sqr22.1%

        \[\leadsto J \cdot \left(512 + \left(1.3333333333333333 \cdot \color{blue}{\left({K}^{2} \cdot {K}^{2}\right)} + -64 \cdot {K}^{2}\right)\right) + U \]
      11. associate-*r*22.1%

        \[\leadsto J \cdot \left(512 + \left(\color{blue}{\left(1.3333333333333333 \cdot {K}^{2}\right) \cdot {K}^{2}} + -64 \cdot {K}^{2}\right)\right) + U \]
      12. *-commutative22.1%

        \[\leadsto J \cdot \left(512 + \left(\color{blue}{{K}^{2} \cdot \left(1.3333333333333333 \cdot {K}^{2}\right)} + -64 \cdot {K}^{2}\right)\right) + U \]
      13. *-commutative22.1%

        \[\leadsto J \cdot \left(512 + \left({K}^{2} \cdot \left(1.3333333333333333 \cdot {K}^{2}\right) + \color{blue}{{K}^{2} \cdot -64}\right)\right) + U \]
      14. distribute-lft-out52.1%

        \[\leadsto J \cdot \left(512 + \color{blue}{{K}^{2} \cdot \left(1.3333333333333333 \cdot {K}^{2} + -64\right)}\right) + U \]
      15. unpow252.1%

        \[\leadsto J \cdot \left(512 + \color{blue}{\left(K \cdot K\right)} \cdot \left(1.3333333333333333 \cdot {K}^{2} + -64\right)\right) + U \]
      16. unpow252.1%

        \[\leadsto J \cdot \left(512 + \left(K \cdot K\right) \cdot \left(1.3333333333333333 \cdot \color{blue}{\left(K \cdot K\right)} + -64\right)\right) + U \]
      17. associate-*r*52.1%

        \[\leadsto J \cdot \left(512 + \left(K \cdot K\right) \cdot \left(\color{blue}{\left(1.3333333333333333 \cdot K\right) \cdot K} + -64\right)\right) + U \]
    5. Simplified52.1%

      \[\leadsto \color{blue}{J \cdot \left(512 + \left(K \cdot K\right) \cdot \left(\left(1.3333333333333333 \cdot K\right) \cdot K + -64\right)\right)} + U \]

    if 8e103 < l < 8.60000000000000025e142

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

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

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

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

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

      \[\leadsto \color{blue}{J \cdot \left(K \cdot K + -8\right)} + U \]
    6. Step-by-step derivation
      1. distribute-lft-in22.7%

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

        \[\leadsto \color{blue}{\frac{\left(J \cdot \left(K \cdot K\right)\right) \cdot \left(J \cdot \left(K \cdot K\right)\right) - \left(J \cdot -8\right) \cdot \left(J \cdot -8\right)}{J \cdot \left(K \cdot K\right) - J \cdot -8}} + U \]
      3. *-commutative21.7%

        \[\leadsto \frac{\color{blue}{\left(\left(K \cdot K\right) \cdot J\right)} \cdot \left(J \cdot \left(K \cdot K\right)\right) - \left(J \cdot -8\right) \cdot \left(J \cdot -8\right)}{J \cdot \left(K \cdot K\right) - J \cdot -8} + U \]
      4. *-commutative21.7%

        \[\leadsto \frac{\left(\left(K \cdot K\right) \cdot J\right) \cdot \color{blue}{\left(\left(K \cdot K\right) \cdot J\right)} - \left(J \cdot -8\right) \cdot \left(J \cdot -8\right)}{J \cdot \left(K \cdot K\right) - J \cdot -8} + U \]
      5. associate-*l*21.7%

        \[\leadsto \frac{\color{blue}{\left(K \cdot \left(K \cdot J\right)\right)} \cdot \left(\left(K \cdot K\right) \cdot J\right) - \left(J \cdot -8\right) \cdot \left(J \cdot -8\right)}{J \cdot \left(K \cdot K\right) - J \cdot -8} + U \]
      6. associate-*l*21.7%

        \[\leadsto \frac{\left(K \cdot \left(K \cdot J\right)\right) \cdot \color{blue}{\left(K \cdot \left(K \cdot J\right)\right)} - \left(J \cdot -8\right) \cdot \left(J \cdot -8\right)}{J \cdot \left(K \cdot K\right) - J \cdot -8} + U \]
      7. *-commutative21.7%

        \[\leadsto \frac{\left(K \cdot \left(K \cdot J\right)\right) \cdot \left(K \cdot \left(K \cdot J\right)\right) - \left(J \cdot -8\right) \cdot \left(J \cdot -8\right)}{\color{blue}{\left(K \cdot K\right) \cdot J} - J \cdot -8} + U \]
      8. associate-*l*41.7%

        \[\leadsto \frac{\left(K \cdot \left(K \cdot J\right)\right) \cdot \left(K \cdot \left(K \cdot J\right)\right) - \left(J \cdot -8\right) \cdot \left(J \cdot -8\right)}{\color{blue}{K \cdot \left(K \cdot J\right)} - J \cdot -8} + U \]
    7. Applied egg-rr41.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.9 \cdot 10^{+173}:\\ \;\;\;\;{U}^{-134217728}\\ \mathbf{elif}\;\ell \leq -13500000000:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{elif}\;\ell \leq 940:\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 6 \cdot 10^{+44}:\\ \;\;\;\;U + J \cdot \left(512 + \left(K \cdot K\right) \cdot \left(K \cdot \left(K \cdot 1.3333333333333333\right) + -64\right)\right)\\ \mathbf{elif}\;\ell \leq 8 \cdot 10^{+103} \lor \neg \left(\ell \leq 8.6 \cdot 10^{+142}\right):\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;U + \frac{\left(K \cdot \left(J \cdot K\right)\right) \cdot \left(K \cdot \left(J \cdot K\right)\right) - \left(J \cdot -8\right) \cdot \left(J \cdot -8\right)}{K \cdot \left(J \cdot K\right) - J \cdot -8}\\ \end{array} \]

Alternative 15: 59.1% accurate, 7.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := K \cdot \left(J \cdot K\right)\\ t_1 := U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{if}\;\ell \leq -13500000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\ell \leq 550:\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 2.6 \cdot 10^{+36}:\\ \;\;\;\;U + J \cdot \left(512 + \left(K \cdot K\right) \cdot \left(K \cdot \left(K \cdot 1.3333333333333333\right) + -64\right)\right)\\ \mathbf{elif}\;\ell \leq 8 \cdot 10^{+103} \lor \neg \left(\ell \leq 8.6 \cdot 10^{+142}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;U + \frac{t_0 \cdot t_0 - \left(J \cdot -8\right) \cdot \left(J \cdot -8\right)}{t_0 - J \cdot -8}\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (* K (* J K))) (t_1 (+ U (* (* l J) (+ 2.0 (* (* K K) -0.25))))))
   (if (<= l -13500000000.0)
     t_1
     (if (<= l 550.0)
       (+ U (* J (* l 2.0)))
       (if (<= l 2.6e+36)
         (+
          U
          (* J (+ 512.0 (* (* K K) (+ (* K (* K 1.3333333333333333)) -64.0)))))
         (if (or (<= l 8e+103) (not (<= l 8.6e+142)))
           t_1
           (+
            U
            (/
             (- (* t_0 t_0) (* (* J -8.0) (* J -8.0)))
             (- t_0 (* J -8.0))))))))))
double code(double J, double l, double K, double U) {
	double t_0 = K * (J * K);
	double t_1 = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
	double tmp;
	if (l <= -13500000000.0) {
		tmp = t_1;
	} else if (l <= 550.0) {
		tmp = U + (J * (l * 2.0));
	} else if (l <= 2.6e+36) {
		tmp = U + (J * (512.0 + ((K * K) * ((K * (K * 1.3333333333333333)) + -64.0))));
	} else if ((l <= 8e+103) || !(l <= 8.6e+142)) {
		tmp = t_1;
	} else {
		tmp = U + (((t_0 * t_0) - ((J * -8.0) * (J * -8.0))) / (t_0 - (J * -8.0)));
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = k * (j * k)
    t_1 = u + ((l * j) * (2.0d0 + ((k * k) * (-0.25d0))))
    if (l <= (-13500000000.0d0)) then
        tmp = t_1
    else if (l <= 550.0d0) then
        tmp = u + (j * (l * 2.0d0))
    else if (l <= 2.6d+36) then
        tmp = u + (j * (512.0d0 + ((k * k) * ((k * (k * 1.3333333333333333d0)) + (-64.0d0)))))
    else if ((l <= 8d+103) .or. (.not. (l <= 8.6d+142))) then
        tmp = t_1
    else
        tmp = u + (((t_0 * t_0) - ((j * (-8.0d0)) * (j * (-8.0d0)))) / (t_0 - (j * (-8.0d0))))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = K * (J * K);
	double t_1 = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
	double tmp;
	if (l <= -13500000000.0) {
		tmp = t_1;
	} else if (l <= 550.0) {
		tmp = U + (J * (l * 2.0));
	} else if (l <= 2.6e+36) {
		tmp = U + (J * (512.0 + ((K * K) * ((K * (K * 1.3333333333333333)) + -64.0))));
	} else if ((l <= 8e+103) || !(l <= 8.6e+142)) {
		tmp = t_1;
	} else {
		tmp = U + (((t_0 * t_0) - ((J * -8.0) * (J * -8.0))) / (t_0 - (J * -8.0)));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = K * (J * K)
	t_1 = U + ((l * J) * (2.0 + ((K * K) * -0.25)))
	tmp = 0
	if l <= -13500000000.0:
		tmp = t_1
	elif l <= 550.0:
		tmp = U + (J * (l * 2.0))
	elif l <= 2.6e+36:
		tmp = U + (J * (512.0 + ((K * K) * ((K * (K * 1.3333333333333333)) + -64.0))))
	elif (l <= 8e+103) or not (l <= 8.6e+142):
		tmp = t_1
	else:
		tmp = U + (((t_0 * t_0) - ((J * -8.0) * (J * -8.0))) / (t_0 - (J * -8.0)))
	return tmp
function code(J, l, K, U)
	t_0 = Float64(K * Float64(J * K))
	t_1 = Float64(U + Float64(Float64(l * J) * Float64(2.0 + Float64(Float64(K * K) * -0.25))))
	tmp = 0.0
	if (l <= -13500000000.0)
		tmp = t_1;
	elseif (l <= 550.0)
		tmp = Float64(U + Float64(J * Float64(l * 2.0)));
	elseif (l <= 2.6e+36)
		tmp = Float64(U + Float64(J * Float64(512.0 + Float64(Float64(K * K) * Float64(Float64(K * Float64(K * 1.3333333333333333)) + -64.0)))));
	elseif ((l <= 8e+103) || !(l <= 8.6e+142))
		tmp = t_1;
	else
		tmp = Float64(U + Float64(Float64(Float64(t_0 * t_0) - Float64(Float64(J * -8.0) * Float64(J * -8.0))) / Float64(t_0 - Float64(J * -8.0))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = K * (J * K);
	t_1 = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
	tmp = 0.0;
	if (l <= -13500000000.0)
		tmp = t_1;
	elseif (l <= 550.0)
		tmp = U + (J * (l * 2.0));
	elseif (l <= 2.6e+36)
		tmp = U + (J * (512.0 + ((K * K) * ((K * (K * 1.3333333333333333)) + -64.0))));
	elseif ((l <= 8e+103) || ~((l <= 8.6e+142)))
		tmp = t_1;
	else
		tmp = U + (((t_0 * t_0) - ((J * -8.0) * (J * -8.0))) / (t_0 - (J * -8.0)));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(K * N[(J * K), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(N[(l * J), $MachinePrecision] * N[(2.0 + N[(N[(K * K), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -13500000000.0], t$95$1, If[LessEqual[l, 550.0], N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.6e+36], N[(U + N[(J * N[(512.0 + N[(N[(K * K), $MachinePrecision] * N[(N[(K * N[(K * 1.3333333333333333), $MachinePrecision]), $MachinePrecision] + -64.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[l, 8e+103], N[Not[LessEqual[l, 8.6e+142]], $MachinePrecision]], t$95$1, N[(U + N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(N[(J * -8.0), $MachinePrecision] * N[(J * -8.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(J * -8.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;\ell \leq 2.6 \cdot 10^{+36}:\\
\;\;\;\;U + J \cdot \left(512 + \left(K \cdot K\right) \cdot \left(K \cdot \left(K \cdot 1.3333333333333333\right) + -64\right)\right)\\

\mathbf{elif}\;\ell \leq 8 \cdot 10^{+103} \lor \neg \left(\ell \leq 8.6 \cdot 10^{+142}\right):\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -1.35e10 or 2.6000000000000001e36 < l < 8e103 or 8.60000000000000025e142 < 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 28.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 17.4%

      \[\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. +-commutative17.4%

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

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

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

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

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

    if -1.35e10 < l < 550

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

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

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

    if 550 < l < 2.6000000000000001e36

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

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

      \[\leadsto \color{blue}{\left(-64 \cdot \left({K}^{2} \cdot J\right) + \left(1.3333333333333333 \cdot \left({K}^{4} \cdot J\right) + 512 \cdot J\right)\right)} + U \]
    4. Step-by-step derivation
      1. associate-+r+2.1%

        \[\leadsto \color{blue}{\left(\left(-64 \cdot \left({K}^{2} \cdot J\right) + 1.3333333333333333 \cdot \left({K}^{4} \cdot J\right)\right) + 512 \cdot J\right)} + U \]
      2. +-commutative2.1%

        \[\leadsto \color{blue}{\left(512 \cdot J + \left(-64 \cdot \left({K}^{2} \cdot J\right) + 1.3333333333333333 \cdot \left({K}^{4} \cdot J\right)\right)\right)} + U \]
      3. associate-*r*2.1%

        \[\leadsto \left(512 \cdot J + \left(\color{blue}{\left(-64 \cdot {K}^{2}\right) \cdot J} + 1.3333333333333333 \cdot \left({K}^{4} \cdot J\right)\right)\right) + U \]
      4. associate-*r*2.1%

        \[\leadsto \left(512 \cdot J + \left(\left(-64 \cdot {K}^{2}\right) \cdot J + \color{blue}{\left(1.3333333333333333 \cdot {K}^{4}\right) \cdot J}\right)\right) + U \]
      5. distribute-rgt-out22.1%

        \[\leadsto \left(512 \cdot J + \color{blue}{J \cdot \left(-64 \cdot {K}^{2} + 1.3333333333333333 \cdot {K}^{4}\right)}\right) + U \]
      6. *-commutative22.1%

        \[\leadsto \left(512 \cdot J + \color{blue}{\left(-64 \cdot {K}^{2} + 1.3333333333333333 \cdot {K}^{4}\right) \cdot J}\right) + U \]
      7. distribute-rgt-in22.1%

        \[\leadsto \color{blue}{J \cdot \left(512 + \left(-64 \cdot {K}^{2} + 1.3333333333333333 \cdot {K}^{4}\right)\right)} + U \]
      8. +-commutative22.1%

        \[\leadsto J \cdot \left(512 + \color{blue}{\left(1.3333333333333333 \cdot {K}^{4} + -64 \cdot {K}^{2}\right)}\right) + U \]
      9. metadata-eval22.1%

        \[\leadsto J \cdot \left(512 + \left(1.3333333333333333 \cdot {K}^{\color{blue}{\left(2 \cdot 2\right)}} + -64 \cdot {K}^{2}\right)\right) + U \]
      10. pow-sqr22.1%

        \[\leadsto J \cdot \left(512 + \left(1.3333333333333333 \cdot \color{blue}{\left({K}^{2} \cdot {K}^{2}\right)} + -64 \cdot {K}^{2}\right)\right) + U \]
      11. associate-*r*22.1%

        \[\leadsto J \cdot \left(512 + \left(\color{blue}{\left(1.3333333333333333 \cdot {K}^{2}\right) \cdot {K}^{2}} + -64 \cdot {K}^{2}\right)\right) + U \]
      12. *-commutative22.1%

        \[\leadsto J \cdot \left(512 + \left(\color{blue}{{K}^{2} \cdot \left(1.3333333333333333 \cdot {K}^{2}\right)} + -64 \cdot {K}^{2}\right)\right) + U \]
      13. *-commutative22.1%

        \[\leadsto J \cdot \left(512 + \left({K}^{2} \cdot \left(1.3333333333333333 \cdot {K}^{2}\right) + \color{blue}{{K}^{2} \cdot -64}\right)\right) + U \]
      14. distribute-lft-out52.1%

        \[\leadsto J \cdot \left(512 + \color{blue}{{K}^{2} \cdot \left(1.3333333333333333 \cdot {K}^{2} + -64\right)}\right) + U \]
      15. unpow252.1%

        \[\leadsto J \cdot \left(512 + \color{blue}{\left(K \cdot K\right)} \cdot \left(1.3333333333333333 \cdot {K}^{2} + -64\right)\right) + U \]
      16. unpow252.1%

        \[\leadsto J \cdot \left(512 + \left(K \cdot K\right) \cdot \left(1.3333333333333333 \cdot \color{blue}{\left(K \cdot K\right)} + -64\right)\right) + U \]
      17. associate-*r*52.1%

        \[\leadsto J \cdot \left(512 + \left(K \cdot K\right) \cdot \left(\color{blue}{\left(1.3333333333333333 \cdot K\right) \cdot K} + -64\right)\right) + U \]
    5. Simplified52.1%

      \[\leadsto \color{blue}{J \cdot \left(512 + \left(K \cdot K\right) \cdot \left(\left(1.3333333333333333 \cdot K\right) \cdot K + -64\right)\right)} + U \]

    if 8e103 < l < 8.60000000000000025e142

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

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

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

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

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

      \[\leadsto \color{blue}{J \cdot \left(K \cdot K + -8\right)} + U \]
    6. Step-by-step derivation
      1. distribute-lft-in22.7%

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

        \[\leadsto \color{blue}{\frac{\left(J \cdot \left(K \cdot K\right)\right) \cdot \left(J \cdot \left(K \cdot K\right)\right) - \left(J \cdot -8\right) \cdot \left(J \cdot -8\right)}{J \cdot \left(K \cdot K\right) - J \cdot -8}} + U \]
      3. *-commutative21.7%

        \[\leadsto \frac{\color{blue}{\left(\left(K \cdot K\right) \cdot J\right)} \cdot \left(J \cdot \left(K \cdot K\right)\right) - \left(J \cdot -8\right) \cdot \left(J \cdot -8\right)}{J \cdot \left(K \cdot K\right) - J \cdot -8} + U \]
      4. *-commutative21.7%

        \[\leadsto \frac{\left(\left(K \cdot K\right) \cdot J\right) \cdot \color{blue}{\left(\left(K \cdot K\right) \cdot J\right)} - \left(J \cdot -8\right) \cdot \left(J \cdot -8\right)}{J \cdot \left(K \cdot K\right) - J \cdot -8} + U \]
      5. associate-*l*21.7%

        \[\leadsto \frac{\color{blue}{\left(K \cdot \left(K \cdot J\right)\right)} \cdot \left(\left(K \cdot K\right) \cdot J\right) - \left(J \cdot -8\right) \cdot \left(J \cdot -8\right)}{J \cdot \left(K \cdot K\right) - J \cdot -8} + U \]
      6. associate-*l*21.7%

        \[\leadsto \frac{\left(K \cdot \left(K \cdot J\right)\right) \cdot \color{blue}{\left(K \cdot \left(K \cdot J\right)\right)} - \left(J \cdot -8\right) \cdot \left(J \cdot -8\right)}{J \cdot \left(K \cdot K\right) - J \cdot -8} + U \]
      7. *-commutative21.7%

        \[\leadsto \frac{\left(K \cdot \left(K \cdot J\right)\right) \cdot \left(K \cdot \left(K \cdot J\right)\right) - \left(J \cdot -8\right) \cdot \left(J \cdot -8\right)}{\color{blue}{\left(K \cdot K\right) \cdot J} - J \cdot -8} + U \]
      8. associate-*l*41.7%

        \[\leadsto \frac{\left(K \cdot \left(K \cdot J\right)\right) \cdot \left(K \cdot \left(K \cdot J\right)\right) - \left(J \cdot -8\right) \cdot \left(J \cdot -8\right)}{\color{blue}{K \cdot \left(K \cdot J\right)} - J \cdot -8} + U \]
    7. Applied egg-rr41.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -13500000000:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{elif}\;\ell \leq 550:\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 2.6 \cdot 10^{+36}:\\ \;\;\;\;U + J \cdot \left(512 + \left(K \cdot K\right) \cdot \left(K \cdot \left(K \cdot 1.3333333333333333\right) + -64\right)\right)\\ \mathbf{elif}\;\ell \leq 8 \cdot 10^{+103} \lor \neg \left(\ell \leq 8.6 \cdot 10^{+142}\right):\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;U + \frac{\left(K \cdot \left(J \cdot K\right)\right) \cdot \left(K \cdot \left(J \cdot K\right)\right) - \left(J \cdot -8\right) \cdot \left(J \cdot -8\right)}{K \cdot \left(J \cdot K\right) - J \cdot -8}\\ \end{array} \]

Alternative 16: 59.6% accurate, 18.2× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -1.35e10 or 1.32e26 < 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 27.0%

      \[\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 18.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. +-commutative18.0%

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

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

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

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

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

    if -1.35e10 < l < 1.32e26

    1. Initial program 73.2%

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

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

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

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

Alternative 17: 53.3% accurate, 20.6× speedup?

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

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

\mathbf{elif}\;\ell \leq 3.5 \cdot 10^{+253}:\\
\;\;\;\;U + J \cdot \left(512 + \left(K \cdot K\right) \cdot -64\right)\\

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


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

    1. Initial program 82.2%

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

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

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

    if 9.0000000000000005e29 < l < 3.49999999999999978e253

    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-rr4.5%

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

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

        \[\leadsto \left(\color{blue}{\left(-64 \cdot {K}^{2}\right) \cdot J} + 512 \cdot J\right) + U \]
      2. distribute-rgt-out33.4%

        \[\leadsto \color{blue}{J \cdot \left(-64 \cdot {K}^{2} + 512\right)} + U \]
      3. +-commutative33.4%

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

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

        \[\leadsto J \cdot \left(512 + \color{blue}{\left(K \cdot K\right)} \cdot -64\right) + U \]
    5. Simplified33.4%

      \[\leadsto \color{blue}{J \cdot \left(512 + \left(K \cdot K\right) \cdot -64\right)} + U \]

    if 3.49999999999999978e253 < 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-rr2.2%

      \[\leadsto \left(J \cdot \color{blue}{-8}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Applied egg-rr34.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 9 \cdot 10^{+29}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 3.5 \cdot 10^{+253}:\\ \;\;\;\;U + J \cdot \left(512 + \left(K \cdot K\right) \cdot -64\right)\\ \mathbf{else}:\\ \;\;\;\;U \cdot U\\ \end{array} \]

Alternative 18: 44.5% accurate, 23.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := U + J \cdot \left(K \cdot K\right)\\ \mathbf{if}\;\ell \leq -13500000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq 1.15 \cdot 10^{-7}:\\ \;\;\;\;U\\ \mathbf{elif}\;\ell \leq 4.1 \cdot 10^{+228}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;U \cdot U\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (+ U (* J (* K K)))))
   (if (<= l -13500000000.0)
     t_0
     (if (<= l 1.15e-7) U (if (<= l 4.1e+228) t_0 (* U U))))))
double code(double J, double l, double K, double U) {
	double t_0 = U + (J * (K * K));
	double tmp;
	if (l <= -13500000000.0) {
		tmp = t_0;
	} else if (l <= 1.15e-7) {
		tmp = U;
	} else if (l <= 4.1e+228) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = u + (j * (k * k))
    if (l <= (-13500000000.0d0)) then
        tmp = t_0
    else if (l <= 1.15d-7) then
        tmp = u
    else if (l <= 4.1d+228) then
        tmp = t_0
    else
        tmp = u * u
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = U + (J * (K * K));
	double tmp;
	if (l <= -13500000000.0) {
		tmp = t_0;
	} else if (l <= 1.15e-7) {
		tmp = U;
	} else if (l <= 4.1e+228) {
		tmp = t_0;
	} else {
		tmp = U * U;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = U + (J * (K * K))
	tmp = 0
	if l <= -13500000000.0:
		tmp = t_0
	elif l <= 1.15e-7:
		tmp = U
	elif l <= 4.1e+228:
		tmp = t_0
	else:
		tmp = U * U
	return tmp
function code(J, l, K, U)
	t_0 = Float64(U + Float64(J * Float64(K * K)))
	tmp = 0.0
	if (l <= -13500000000.0)
		tmp = t_0;
	elseif (l <= 1.15e-7)
		tmp = U;
	elseif (l <= 4.1e+228)
		tmp = t_0;
	else
		tmp = Float64(U * U);
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = U + (J * (K * K));
	tmp = 0.0;
	if (l <= -13500000000.0)
		tmp = t_0;
	elseif (l <= 1.15e-7)
		tmp = U;
	elseif (l <= 4.1e+228)
		tmp = t_0;
	else
		tmp = U * U;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(J * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -13500000000.0], t$95$0, If[LessEqual[l, 1.15e-7], U, If[LessEqual[l, 4.1e+228], t$95$0, N[(U * U), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;\ell \leq 1.15 \cdot 10^{-7}:\\
\;\;\;\;U\\

\mathbf{elif}\;\ell \leq 4.1 \cdot 10^{+228}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -1.35e10 or 1.14999999999999997e-7 < l < 4.1e228

    1. Initial program 99.7%

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

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

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

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

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

      \[\leadsto \color{blue}{J \cdot \left(K \cdot K + -8\right)} + U \]
    6. Taylor expanded in K around inf 17.9%

      \[\leadsto \color{blue}{{K}^{2} \cdot J} + U \]
    7. Step-by-step derivation
      1. unpow217.9%

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

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

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

    if -1.35e10 < l < 1.14999999999999997e-7

    1. Initial program 71.8%

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

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

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

    if 4.1e228 < l

    1. Initial program 100.0%

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

      \[\leadsto \left(J \cdot \color{blue}{-8}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Applied egg-rr28.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -13500000000:\\ \;\;\;\;U + J \cdot \left(K \cdot K\right)\\ \mathbf{elif}\;\ell \leq 1.15 \cdot 10^{-7}:\\ \;\;\;\;U\\ \mathbf{elif}\;\ell \leq 4.1 \cdot 10^{+228}:\\ \;\;\;\;U + J \cdot \left(K \cdot K\right)\\ \mathbf{else}:\\ \;\;\;\;U \cdot U\\ \end{array} \]

Alternative 19: 53.1% accurate, 23.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 2.6 \cdot 10^{+31}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 2.4 \cdot 10^{+252}:\\ \;\;\;\;U + J \cdot \left(K \cdot \left(K \cdot -64\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U \cdot U\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l 2.6e+31)
   (+ U (* J (* l 2.0)))
   (if (<= l 2.4e+252) (+ U (* J (* K (* K -64.0)))) (* U U))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= 2.6e+31) {
		tmp = U + (J * (l * 2.0));
	} else if (l <= 2.4e+252) {
		tmp = U + (J * (K * (K * -64.0)));
	} 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.6d+31) then
        tmp = u + (j * (l * 2.0d0))
    else if (l <= 2.4d+252) then
        tmp = u + (j * (k * (k * (-64.0d0))))
    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.6e+31) {
		tmp = U + (J * (l * 2.0));
	} else if (l <= 2.4e+252) {
		tmp = U + (J * (K * (K * -64.0)));
	} else {
		tmp = U * U;
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= 2.6e+31:
		tmp = U + (J * (l * 2.0))
	elif l <= 2.4e+252:
		tmp = U + (J * (K * (K * -64.0)))
	else:
		tmp = U * U
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= 2.6e+31)
		tmp = Float64(U + Float64(J * Float64(l * 2.0)));
	elseif (l <= 2.4e+252)
		tmp = Float64(U + Float64(J * Float64(K * Float64(K * -64.0))));
	else
		tmp = Float64(U * U);
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= 2.6e+31)
		tmp = U + (J * (l * 2.0));
	elseif (l <= 2.4e+252)
		tmp = U + (J * (K * (K * -64.0)));
	else
		tmp = U * U;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, 2.6e+31], N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.4e+252], N[(U + N[(J * N[(K * N[(K * -64.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U * U), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;\ell \leq 2.4 \cdot 10^{+252}:\\
\;\;\;\;U + J \cdot \left(K \cdot \left(K \cdot -64\right)\right)\\

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


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

    1. Initial program 82.2%

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

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

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

    if 2.6e31 < l < 2.3999999999999999e252

    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-rr4.5%

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

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

        \[\leadsto \left(\color{blue}{\left(-64 \cdot {K}^{2}\right) \cdot J} + 512 \cdot J\right) + U \]
      2. distribute-rgt-out33.4%

        \[\leadsto \color{blue}{J \cdot \left(-64 \cdot {K}^{2} + 512\right)} + U \]
      3. +-commutative33.4%

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

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

        \[\leadsto J \cdot \left(512 + \color{blue}{\left(K \cdot K\right)} \cdot -64\right) + U \]
    5. Simplified33.4%

      \[\leadsto \color{blue}{J \cdot \left(512 + \left(K \cdot K\right) \cdot -64\right)} + U \]
    6. Taylor expanded in K around inf 32.7%

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

        \[\leadsto \color{blue}{\left({K}^{2} \cdot J\right) \cdot -64} + U \]
      2. unpow232.7%

        \[\leadsto \left(\color{blue}{\left(K \cdot K\right)} \cdot J\right) \cdot -64 + U \]
      3. *-commutative32.7%

        \[\leadsto \color{blue}{\left(J \cdot \left(K \cdot K\right)\right)} \cdot -64 + U \]
      4. associate-*r*32.7%

        \[\leadsto \color{blue}{J \cdot \left(\left(K \cdot K\right) \cdot -64\right)} + U \]
      5. associate-*l*32.7%

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

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

    if 2.3999999999999999e252 < 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-rr2.2%

      \[\leadsto \left(J \cdot \color{blue}{-8}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Applied egg-rr34.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 2.6 \cdot 10^{+31}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 2.4 \cdot 10^{+252}:\\ \;\;\;\;U + J \cdot \left(K \cdot \left(K \cdot -64\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U \cdot U\\ \end{array} \]

Alternative 20: 41.3% accurate, 43.8× speedup?

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

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

\mathbf{elif}\;\ell \leq 2.35 \cdot 10^{+139}:\\
\;\;\;\;U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -2.20000000000000007e26 or 2.35e139 < 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-rr2.8%

      \[\leadsto \left(J \cdot \color{blue}{-8}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Applied egg-rr15.1%

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

    if -2.20000000000000007e26 < l < 2.35e139

    1. Initial program 76.1%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.2 \cdot 10^{+26}:\\ \;\;\;\;U \cdot U\\ \mathbf{elif}\;\ell \leq 2.35 \cdot 10^{+139}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot U\\ \end{array} \]

Alternative 21: 54.5% accurate, 44.6× speedup?

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

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

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

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

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

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

Alternative 22: 37.1% 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 85.6%

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

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

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

    \[\leadsto U \]

Reproduce

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