Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.1% → 99.8%
Time: 13.6s
Alternatives: 20
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 20 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.1% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.4× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

    1. Initial program 69.6%

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

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

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

    1. Initial program 99.9%

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

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

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

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

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

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

Alternative 2: 99.8% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 69.6%

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

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

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

Alternative 3: 77.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ t_1 := U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{if}\;t_0 \leq -0.95:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq -0.35:\\ \;\;\;\;U + J \cdot \left(\ell \cdot \mathsf{fma}\left(-0.25, K \cdot K, 2\right)\right)\\ \mathbf{elif}\;t_0 \leq 0.05:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))) (t_1 (+ U (* 2.0 (* l (* J (cos (* K 0.5))))))))
   (if (<= t_0 -0.95)
     t_1
     (if (<= t_0 -0.35)
       (+ U (* J (* l (fma -0.25 (* K K) 2.0))))
       (if (<= t_0 0.05)
         t_1
         (+ U (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K / 2.0));
	double t_1 = U + (2.0 * (l * (J * cos((K * 0.5)))));
	double tmp;
	if (t_0 <= -0.95) {
		tmp = t_1;
	} else if (t_0 <= -0.35) {
		tmp = U + (J * (l * fma(-0.25, (K * K), 2.0)));
	} else if (t_0 <= 0.05) {
		tmp = t_1;
	} else {
		tmp = U + (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0)));
	}
	return tmp;
}
function code(J, l, K, U)
	t_0 = cos(Float64(K / 2.0))
	t_1 = Float64(U + Float64(2.0 * Float64(l * Float64(J * cos(Float64(K * 0.5))))))
	tmp = 0.0
	if (t_0 <= -0.95)
		tmp = t_1;
	elseif (t_0 <= -0.35)
		tmp = Float64(U + Float64(J * Float64(l * fma(-0.25, Float64(K * K), 2.0))));
	elseif (t_0 <= 0.05)
		tmp = t_1;
	else
		tmp = Float64(U + Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))));
	end
	return tmp
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(2.0 * N[(l * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.95], t$95$1, If[LessEqual[t$95$0, -0.35], N[(U + N[(J * N[(l * N[(-0.25 * N[(K * K), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.05], t$95$1, N[(U + N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t_0 \leq -0.35:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \mathsf{fma}\left(-0.25, K \cdot K, 2\right)\right)\\

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

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


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

    1. Initial program 83.2%

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

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

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

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

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

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

    if -0.94999999999999996 < (cos.f64 (/.f64 K 2)) < -0.34999999999999998

    1. Initial program 90.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\ell \cdot \left(2 \cdot J\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
    5. Taylor expanded in K around 0 44.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 \]
    6. Step-by-step derivation
      1. +-commutative44.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. associate-*r*44.0%

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

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

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

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

      \[\leadsto \color{blue}{\left(\ell \cdot J\right) \cdot \left(\left(K \cdot K\right) \cdot -0.25 + 2\right)} + U \]
    8. Taylor expanded in l around 0 64.1%

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

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

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

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

        \[\leadsto J \cdot \left(\ell \cdot \mathsf{fma}\left(-0.25, \color{blue}{K \cdot K}, 2\right)\right) + U \]
    10. Simplified68.8%

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

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

    1. Initial program 82.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.95:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\cos \left(\frac{K}{2}\right) \leq -0.35:\\ \;\;\;\;U + J \cdot \left(\ell \cdot \mathsf{fma}\left(-0.25, K \cdot K, 2\right)\right)\\ \mathbf{elif}\;\cos \left(\frac{K}{2}\right) \leq 0.05:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\ \end{array} \]

Alternative 4: 67.7% accurate, 1.0× speedup?

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

\mathbf{elif}\;t_0 \leq -0.04:\\
\;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(\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 3 regimes
  2. if (cos.f64 (/.f64 K 2)) < -0.94999999999999996

    1. Initial program 90.2%

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

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

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

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

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

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

      \[\leadsto \color{blue}{2 \cdot \left(\ell \cdot J\right) + U} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt50.1%

        \[\leadsto \color{blue}{\sqrt{2 \cdot \left(\ell \cdot J\right)} \cdot \sqrt{2 \cdot \left(\ell \cdot J\right)}} + U \]
      2. sqrt-unprod75.3%

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

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

        \[\leadsto \sqrt{\left(\left(\ell \cdot J\right) \cdot 2\right) \cdot \color{blue}{\left(\left(\ell \cdot J\right) \cdot 2\right)}} + U \]
      5. swap-sqr75.3%

        \[\leadsto \sqrt{\color{blue}{\left(\left(\ell \cdot J\right) \cdot \left(\ell \cdot J\right)\right) \cdot \left(2 \cdot 2\right)}} + U \]
      6. pow275.3%

        \[\leadsto \sqrt{\color{blue}{{\left(\ell \cdot J\right)}^{2}} \cdot \left(2 \cdot 2\right)} + U \]
      7. metadata-eval75.3%

        \[\leadsto \sqrt{{\left(\ell \cdot J\right)}^{2} \cdot \color{blue}{4}} + U \]
    7. Applied egg-rr75.3%

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

        \[\leadsto \sqrt{\color{blue}{\left(\left(\ell \cdot J\right) \cdot \left(\ell \cdot J\right)\right)} \cdot 4} + U \]
      2. metadata-eval75.3%

        \[\leadsto \sqrt{\left(\left(\ell \cdot J\right) \cdot \left(\ell \cdot J\right)\right) \cdot \color{blue}{\left(2 \cdot 2\right)}} + U \]
      3. swap-sqr75.3%

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

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

        \[\leadsto \sqrt{\left(\ell \cdot \left(J \cdot 2\right)\right) \cdot \color{blue}{\left(\ell \cdot \left(J \cdot 2\right)\right)}} + U \]
      6. rem-sqrt-square65.8%

        \[\leadsto \color{blue}{\left|\ell \cdot \left(J \cdot 2\right)\right|} + U \]
    9. Simplified65.8%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\ell \cdot \left(2 \cdot J\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
    5. Taylor expanded in K around 0 38.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 \]
    6. Step-by-step derivation
      1. +-commutative38.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. associate-*r*38.2%

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 81.5%

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

      \[\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. Taylor expanded in l around inf 71.8%

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

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

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

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

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

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

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

Alternative 5: 95.1% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := U + t_0 \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\
t_2 := U + \left(-0.125 \cdot \left(K \cdot K\right) + 1\right) \cdot \left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right)\\
\mathbf{if}\;\ell \leq -1.56 \cdot 10^{+91}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;\ell \leq 4.6 \cdot 10^{+86}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -1.5600000000000001e91 or 4.59999999999999979e86 < 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 98.9%

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

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

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

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

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

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

    if -1.5600000000000001e91 < l < -2.39999999999999991 or 1.7e5 < l < 4.59999999999999979e86

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

      \[\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*3.8%

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

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

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

      \[\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 -2.39999999999999991 < l < 1.7e5

    1. Initial program 70.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 98.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.56 \cdot 10^{+91}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \mathbf{elif}\;\ell \leq -2.4:\\ \;\;\;\;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 170000:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 4.6 \cdot 10^{+86}:\\ \;\;\;\;U + \left(-0.125 \cdot \left(K \cdot K\right) + 1\right) \cdot \left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right)\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \end{array} \]

Alternative 6: 95.1% accurate, 1.4× speedup?

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

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

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

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

\mathbf{elif}\;\ell \leq 2.5 \cdot 10^{+86}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -1.28e112 or 2.4999999999999999e86 < l

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if -1.28e112 < l < -0.00440000000000000027 or 0.25 < l < 2.4999999999999999e86

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

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

    if -0.00440000000000000027 < l < 0.25

    1. Initial program 69.8%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.28 \cdot 10^{+112}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \mathbf{elif}\;\ell \leq -0.0044:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{elif}\;\ell \leq 0.25:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 2.5 \cdot 10^{+86}:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \end{array} \]

Alternative 7: 87.6% accurate, 1.4× speedup?

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

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

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

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

\mathbf{elif}\;\ell \leq 5 \cdot 10^{+119}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -1.5199999999999999e112 or 4.9999999999999999e119 < l

    1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\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. associate-*r*0.0%

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

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

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

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

    if -1.5199999999999999e112 < l < -0.0264999999999999993 or 0.25 < l < 4.9999999999999999e119

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

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

    if -0.0264999999999999993 < l < 0.25

    1. Initial program 69.8%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.52 \cdot 10^{+112}:\\ \;\;\;\;U + \left(J \cdot {\ell}^{3}\right) \cdot \left(0.3333333333333333 + \left(K \cdot K\right) \cdot -0.041666666666666664\right)\\ \mathbf{elif}\;\ell \leq -0.0265:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{elif}\;\ell \leq 0.25:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 5 \cdot 10^{+119}:\\ \;\;\;\;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: 88.5% 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 84.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.5%

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

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

Alternative 9: 81.8% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := U + \left(J \cdot {\ell}^{3}\right) \cdot \left(0.3333333333333333 + \left(K \cdot K\right) \cdot -0.041666666666666664\right)\\ t_1 := U + \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(J \cdot 2\right)\right)\right)\\ \mathbf{if}\;\ell \leq -6.6 \cdot 10^{+68}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\ell \leq -60000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\ell \leq 98:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 8.5 \cdot 10^{+119}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0
         (+
          U
          (*
           (* J (pow l 3.0))
           (+ 0.3333333333333333 (* (* K K) -0.041666666666666664)))))
        (t_1 (+ U (log1p (expm1 (* l (* J 2.0)))))))
   (if (<= l -6.6e+68)
     t_0
     (if (<= l -60000000000.0)
       t_1
       (if (<= l 98.0)
         (+ U (* 2.0 (* l (* J (cos (* K 0.5))))))
         (if (<= l 8.5e+119) t_1 t_0))))))
double code(double J, double l, double K, double U) {
	double t_0 = U + ((J * pow(l, 3.0)) * (0.3333333333333333 + ((K * K) * -0.041666666666666664)));
	double t_1 = U + log1p(expm1((l * (J * 2.0))));
	double tmp;
	if (l <= -6.6e+68) {
		tmp = t_0;
	} else if (l <= -60000000000.0) {
		tmp = t_1;
	} else if (l <= 98.0) {
		tmp = U + (2.0 * (l * (J * cos((K * 0.5)))));
	} else if (l <= 8.5e+119) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
public static double code(double J, double l, double K, double U) {
	double t_0 = U + ((J * Math.pow(l, 3.0)) * (0.3333333333333333 + ((K * K) * -0.041666666666666664)));
	double t_1 = U + Math.log1p(Math.expm1((l * (J * 2.0))));
	double tmp;
	if (l <= -6.6e+68) {
		tmp = t_0;
	} else if (l <= -60000000000.0) {
		tmp = t_1;
	} else if (l <= 98.0) {
		tmp = U + (2.0 * (l * (J * Math.cos((K * 0.5)))));
	} else if (l <= 8.5e+119) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = U + ((J * math.pow(l, 3.0)) * (0.3333333333333333 + ((K * K) * -0.041666666666666664)))
	t_1 = U + math.log1p(math.expm1((l * (J * 2.0))))
	tmp = 0
	if l <= -6.6e+68:
		tmp = t_0
	elif l <= -60000000000.0:
		tmp = t_1
	elif l <= 98.0:
		tmp = U + (2.0 * (l * (J * math.cos((K * 0.5)))))
	elif l <= 8.5e+119:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(J, l, K, U)
	t_0 = Float64(U + Float64(Float64(J * (l ^ 3.0)) * Float64(0.3333333333333333 + Float64(Float64(K * K) * -0.041666666666666664))))
	t_1 = Float64(U + log1p(expm1(Float64(l * Float64(J * 2.0)))))
	tmp = 0.0
	if (l <= -6.6e+68)
		tmp = t_0;
	elseif (l <= -60000000000.0)
		tmp = t_1;
	elseif (l <= 98.0)
		tmp = Float64(U + Float64(2.0 * Float64(l * Float64(J * cos(Float64(K * 0.5))))));
	elseif (l <= 8.5e+119)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
code[J_, l_, K_, U_] := Block[{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]}, Block[{t$95$1 = N[(U + N[Log[1 + N[(Exp[N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -6.6e+68], t$95$0, If[LessEqual[l, -60000000000.0], t$95$1, If[LessEqual[l, 98.0], N[(U + N[(2.0 * N[(l * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 8.5e+119], t$95$1, t$95$0]]]]]]
\begin{array}{l}

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

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

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

\mathbf{elif}\;\ell \leq 8.5 \cdot 10^{+119}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -6.6000000000000001e68 or 8.49999999999999997e119 < l

    1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\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. associate-*r*4.4%

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

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

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

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

    if -6.6000000000000001e68 < l < -6e10 or 98 < l < 8.49999999999999997e119

    1. Initial program 99.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{2 \cdot \left(\ell \cdot J\right) + U} \]
    6. Step-by-step derivation
      1. log1p-expm1-u67.4%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(2 \cdot \left(\ell \cdot J\right)\right)\right)} + U \]
      2. *-commutative67.4%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\left(\ell \cdot J\right) \cdot 2}\right)\right) + U \]
      3. associate-*l*67.4%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\ell \cdot \left(J \cdot 2\right)}\right)\right) + U \]
    7. Applied egg-rr67.4%

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

    if -6e10 < l < 98

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -6.6 \cdot 10^{+68}:\\ \;\;\;\;U + \left(J \cdot {\ell}^{3}\right) \cdot \left(0.3333333333333333 + \left(K \cdot K\right) \cdot -0.041666666666666664\right)\\ \mathbf{elif}\;\ell \leq -60000000000:\\ \;\;\;\;U + \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(J \cdot 2\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 98:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 8.5 \cdot 10^{+119}:\\ \;\;\;\;U + \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(J \cdot 2\right)\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 10: 80.9% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6 \lor \neg \left(\ell \leq 170000\right):\\
\;\;\;\;U + \left(J \cdot {\ell}^{3}\right) \cdot \left(0.3333333333333333 + \left(K \cdot K\right) \cdot -0.041666666666666664\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -6 or 1.7e5 < 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 81.7%

      \[\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. Taylor expanded in l around inf 81.7%

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

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

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

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

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

      \[\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. associate-*r*5.0%

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

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

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

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

    if -6 < l < 1.7e5

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

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

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

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

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

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

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

Alternative 11: 74.5% accurate, 2.7× speedup?

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

    1. Initial program 70.2%

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

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

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

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

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

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

    if -7.79999999999999989e56 < J < 6.49999999999999967e-31

    1. Initial program 97.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 88.9%

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

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

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

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

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

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

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

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

Alternative 12: 59.2% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(K \cdot K\right) \cdot -0.25\\ t_1 := U + \left(\ell \cdot J\right) \cdot \left(2 + t_0\right)\\ \mathbf{if}\;\ell \leq -1.28 \cdot 10^{+112}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\ell \leq -8.5 \cdot 10^{+29}:\\ \;\;\;\;{U}^{-3}\\ \mathbf{elif}\;\ell \leq -470:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot t_0\\ \mathbf{elif}\;\ell \leq 5.4 \cdot 10^{+119}:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (* (* K K) -0.25)) (t_1 (+ U (* (* l J) (+ 2.0 t_0)))))
   (if (<= l -1.28e+112)
     t_1
     (if (<= l -8.5e+29)
       (pow U -3.0)
       (if (<= l -470.0)
         (+ U (* (* l J) t_0))
         (if (<= l 5.4e+119) (+ U (* 2.0 (* l J))) t_1))))))
double code(double J, double l, double K, double U) {
	double t_0 = (K * K) * -0.25;
	double t_1 = U + ((l * J) * (2.0 + t_0));
	double tmp;
	if (l <= -1.28e+112) {
		tmp = t_1;
	} else if (l <= -8.5e+29) {
		tmp = pow(U, -3.0);
	} else if (l <= -470.0) {
		tmp = U + ((l * J) * t_0);
	} else if (l <= 5.4e+119) {
		tmp = U + (2.0 * (l * J));
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (k * k) * (-0.25d0)
    t_1 = u + ((l * j) * (2.0d0 + t_0))
    if (l <= (-1.28d+112)) then
        tmp = t_1
    else if (l <= (-8.5d+29)) then
        tmp = u ** (-3.0d0)
    else if (l <= (-470.0d0)) then
        tmp = u + ((l * j) * t_0)
    else if (l <= 5.4d+119) then
        tmp = u + (2.0d0 * (l * j))
    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 = (K * K) * -0.25;
	double t_1 = U + ((l * J) * (2.0 + t_0));
	double tmp;
	if (l <= -1.28e+112) {
		tmp = t_1;
	} else if (l <= -8.5e+29) {
		tmp = Math.pow(U, -3.0);
	} else if (l <= -470.0) {
		tmp = U + ((l * J) * t_0);
	} else if (l <= 5.4e+119) {
		tmp = U + (2.0 * (l * J));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = (K * K) * -0.25
	t_1 = U + ((l * J) * (2.0 + t_0))
	tmp = 0
	if l <= -1.28e+112:
		tmp = t_1
	elif l <= -8.5e+29:
		tmp = math.pow(U, -3.0)
	elif l <= -470.0:
		tmp = U + ((l * J) * t_0)
	elif l <= 5.4e+119:
		tmp = U + (2.0 * (l * J))
	else:
		tmp = t_1
	return tmp
function code(J, l, K, U)
	t_0 = Float64(Float64(K * K) * -0.25)
	t_1 = Float64(U + Float64(Float64(l * J) * Float64(2.0 + t_0)))
	tmp = 0.0
	if (l <= -1.28e+112)
		tmp = t_1;
	elseif (l <= -8.5e+29)
		tmp = U ^ -3.0;
	elseif (l <= -470.0)
		tmp = Float64(U + Float64(Float64(l * J) * t_0));
	elseif (l <= 5.4e+119)
		tmp = Float64(U + Float64(2.0 * Float64(l * J)));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = (K * K) * -0.25;
	t_1 = U + ((l * J) * (2.0 + t_0));
	tmp = 0.0;
	if (l <= -1.28e+112)
		tmp = t_1;
	elseif (l <= -8.5e+29)
		tmp = U ^ -3.0;
	elseif (l <= -470.0)
		tmp = U + ((l * J) * t_0);
	elseif (l <= 5.4e+119)
		tmp = U + (2.0 * (l * J));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(K * K), $MachinePrecision] * -0.25), $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(N[(l * J), $MachinePrecision] * N[(2.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.28e+112], t$95$1, If[LessEqual[l, -8.5e+29], N[Power[U, -3.0], $MachinePrecision], If[LessEqual[l, -470.0], N[(U + N[(N[(l * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5.4e+119], N[(U + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -1.28e112 or 5.3999999999999997e119 < 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 39.9%

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

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

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

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

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

      \[\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 \]
    6. Step-by-step derivation
      1. +-commutative23.5%

        \[\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. associate-*r*23.5%

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

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

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

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

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

    if -1.28e112 < l < -8.5000000000000006e29

    1. Initial program 100.0%

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

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

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

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

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

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

    if -8.5000000000000006e29 < l < -470

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\ell \cdot \left(2 \cdot J\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
    5. Taylor expanded in K around 0 100.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 \]
    6. Step-by-step derivation
      1. +-commutative100.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. associate-*r*100.0%

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

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

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

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

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

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

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

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

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

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

    if -470 < l < 5.3999999999999997e119

    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 l around 0 90.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.28 \cdot 10^{+112}:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{elif}\;\ell \leq -8.5 \cdot 10^{+29}:\\ \;\;\;\;{U}^{-3}\\ \mathbf{elif}\;\ell \leq -470:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(\left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{elif}\;\ell \leq 5.4 \cdot 10^{+119}:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot J\right)\\ \mathbf{else}:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \end{array} \]

Alternative 13: 59.6% accurate, 18.2× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -320 or 4.4000000000000003e119 < 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 32.7%

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

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

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

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

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

      \[\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 \]
    6. Step-by-step derivation
      1. +-commutative20.7%

        \[\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. associate-*r*20.7%

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

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

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

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

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

    if -320 < l < 4.4000000000000003e119

    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 l around 0 90.0%

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

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

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

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

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

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

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

Alternative 14: 53.5% accurate, 23.9× speedup?

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

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

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


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

    1. Initial program 81.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 70.5%

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

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

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

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

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

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

    if 1.70000000000000005e121 < 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-rr3.6%

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

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

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

        \[\leadsto \left(\color{blue}{\left(-0.015625 \cdot {K}^{2}\right) \cdot J} + 0.125 \cdot J\right) + U \]
      3. distribute-rgt-out27.1%

        \[\leadsto \color{blue}{J \cdot \left(-0.015625 \cdot {K}^{2} + 0.125\right)} + U \]
      4. *-commutative27.1%

        \[\leadsto J \cdot \left(\color{blue}{{K}^{2} \cdot -0.015625} + 0.125\right) + U \]
      5. unpow227.1%

        \[\leadsto J \cdot \left(\color{blue}{\left(K \cdot K\right)} \cdot -0.015625 + 0.125\right) + U \]
    5. Simplified27.1%

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

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

Alternative 15: 54.0% accurate, 23.9× speedup?

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

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

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


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

    1. Initial program 81.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 70.5%

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

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

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

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

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

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

    if 1.45e121 < 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 40.4%

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

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

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

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

      \[\leadsto \color{blue}{\left(\ell \cdot \left(2 \cdot J\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
    5. Taylor expanded in K around 0 17.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 \]
    6. Step-by-step derivation
      1. +-commutative17.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. associate-*r*17.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 43.9% accurate, 34.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;J \leq -8.9 \cdot 10^{+74} \lor \neg \left(J \leq 1.95 \cdot 10^{+176}\right):\\
\;\;\;\;\ell \cdot \left(J \cdot 2\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if J < -8.9000000000000002e74 or 1.9500000000000001e176 < J

    1. Initial program 65.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 88.7%

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

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

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

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

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

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

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

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

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

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

    if -8.9000000000000002e74 < J < 1.9500000000000001e176

    1. Initial program 92.9%

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

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

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

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

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

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

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

Alternative 17: 55.2% accurate, 44.6× speedup?

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

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

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

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

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

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

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

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

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

Alternative 18: 40.6% accurate, 61.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6:\\
\;\;\;\;U \cdot U\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

    if -6 < l

    1. Initial program 77.9%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -6:\\ \;\;\;\;U \cdot U\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \]

Alternative 19: 2.7% accurate, 312.0× speedup?

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{1} \]
  7. Final simplification2.8%

    \[\leadsto 1 \]

Alternative 20: 37.6% accurate, 312.0× speedup?

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{U} \]
  5. Final simplification37.2%

    \[\leadsto U \]

Reproduce

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