Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 85.9% → 99.7%
Time: 12.4s
Alternatives: 21
Speedup: 1.5×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 21 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: 85.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\ell} - e^{-\ell}\\ \mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 5 \cdot 10^{-10}\right):\\ \;\;\;\;\cos \left(\frac{K}{2}\right) \cdot \left(t_0 \cdot J\right) + U\\ \mathbf{else}:\\ \;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, \ell \cdot 2\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (- (exp l) (exp (- l)))))
   (if (or (<= t_0 (- INFINITY)) (not (<= t_0 5e-10)))
     (+ (* (cos (/ K 2.0)) (* t_0 J)) U)
     (+
      U
      (*
       (* J (cos (* K 0.5)))
       (fma 0.3333333333333333 (pow l 3.0) (* l 2.0)))))))
double code(double J, double l, double K, double U) {
	double t_0 = exp(l) - exp(-l);
	double tmp;
	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 5e-10)) {
		tmp = (cos((K / 2.0)) * (t_0 * J)) + U;
	} else {
		tmp = U + ((J * cos((K * 0.5))) * fma(0.3333333333333333, pow(l, 3.0), (l * 2.0)));
	}
	return tmp;
}
function code(J, l, K, U)
	t_0 = Float64(exp(l) - exp(Float64(-l)))
	tmp = 0.0
	if ((t_0 <= Float64(-Inf)) || !(t_0 <= 5e-10))
		tmp = Float64(Float64(cos(Float64(K / 2.0)) * Float64(t_0 * J)) + U);
	else
		tmp = Float64(U + Float64(Float64(J * cos(Float64(K * 0.5))) * fma(0.3333333333333333, (l ^ 3.0), Float64(l * 2.0))));
	end
	return tmp
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 5e-10]], $MachinePrecision]], N[(N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(t$95$0 * J), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 5.00000000000000031e-10 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

    1. Initial program 100.0%

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

    if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.00000000000000031e-10

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\ell} - e^{-\ell}\\ \mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 5 \cdot 10^{-10}\right):\\ \;\;\;\;\cos \left(\frac{K}{2}\right) \cdot \left(t_0 \cdot J\right) + U\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, \ell \cdot 2\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (- (exp l) (exp (- l)))))
   (if (or (<= t_0 (- INFINITY)) (not (<= t_0 5e-10)))
     (+ (* (cos (/ K 2.0)) (* t_0 J)) U)
     (+
      U
      (*
       J
       (* (cos (* K 0.5)) (fma 0.3333333333333333 (pow l 3.0) (* l 2.0))))))))
double code(double J, double l, double K, double U) {
	double t_0 = exp(l) - exp(-l);
	double tmp;
	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 5e-10)) {
		tmp = (cos((K / 2.0)) * (t_0 * J)) + U;
	} else {
		tmp = U + (J * (cos((K * 0.5)) * fma(0.3333333333333333, pow(l, 3.0), (l * 2.0))));
	}
	return tmp;
}
function code(J, l, K, U)
	t_0 = Float64(exp(l) - exp(Float64(-l)))
	tmp = 0.0
	if ((t_0 <= Float64(-Inf)) || !(t_0 <= 5e-10))
		tmp = Float64(Float64(cos(Float64(K / 2.0)) * Float64(t_0 * J)) + U);
	else
		tmp = Float64(U + Float64(J * Float64(cos(Float64(K * 0.5)) * fma(0.3333333333333333, (l ^ 3.0), Float64(l * 2.0)))));
	end
	return tmp
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 5e-10]], $MachinePrecision]], N[(N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(t$95$0 * J), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(J * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\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))) < -inf.0 or 5.00000000000000031e-10 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

    1. Initial program 100.0%

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

    if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.00000000000000031e-10

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.7% accurate, 0.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 5.00000000000000031e-10 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

    1. Initial program 100.0%

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

    if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.00000000000000031e-10

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 78.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t_0 \leq -0.3:\\ \;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(\ell \cdot 2\right)\\ \mathbf{elif}\;t_0 \leq -0.005:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(\left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2 + 0.3333333333333333 \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.3)
     (+ U (* (* J (cos (* K 0.5))) (* l 2.0)))
     (if (<= t_0 -0.005)
       (+ U (* (* l J) (* (* K K) -0.25)))
       (+ U (* J (+ (* l 2.0) (* 0.3333333333333333 (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.3) {
		tmp = U + ((J * cos((K * 0.5))) * (l * 2.0));
	} else if (t_0 <= -0.005) {
		tmp = U + ((l * J) * ((K * K) * -0.25));
	} else {
		tmp = U + (J * ((l * 2.0) + (0.3333333333333333 * 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.3d0)) then
        tmp = u + ((j * cos((k * 0.5d0))) * (l * 2.0d0))
    else if (t_0 <= (-0.005d0)) then
        tmp = u + ((l * j) * ((k * k) * (-0.25d0)))
    else
        tmp = u + (j * ((l * 2.0d0) + (0.3333333333333333d0 * (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.3) {
		tmp = U + ((J * Math.cos((K * 0.5))) * (l * 2.0));
	} else if (t_0 <= -0.005) {
		tmp = U + ((l * J) * ((K * K) * -0.25));
	} else {
		tmp = U + (J * ((l * 2.0) + (0.3333333333333333 * 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.3:
		tmp = U + ((J * math.cos((K * 0.5))) * (l * 2.0))
	elif t_0 <= -0.005:
		tmp = U + ((l * J) * ((K * K) * -0.25))
	else:
		tmp = U + (J * ((l * 2.0) + (0.3333333333333333 * 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.3)
		tmp = Float64(U + Float64(Float64(J * cos(Float64(K * 0.5))) * Float64(l * 2.0)));
	elseif (t_0 <= -0.005)
		tmp = Float64(U + Float64(Float64(l * J) * Float64(Float64(K * K) * -0.25)));
	else
		tmp = Float64(U + Float64(J * Float64(Float64(l * 2.0) + Float64(0.3333333333333333 * (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.3)
		tmp = U + ((J * cos((K * 0.5))) * (l * 2.0));
	elseif (t_0 <= -0.005)
		tmp = U + ((l * J) * ((K * K) * -0.25));
	else
		tmp = U + (J * ((l * 2.0) + (0.3333333333333333 * (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.3], N[(U + N[(N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.005], N[(U + N[(N[(l * J), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(N[(l * 2.0), $MachinePrecision] + N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.299999999999999989 < (cos.f64 (/.f64 K 2)) < -0.0050000000000000001

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 85.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 92.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 2 \cdot \ell\right)\right)} + U \]
    5. Taylor expanded in K 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.5%

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

Alternative 5: 94.0% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;\ell \leq -58000000:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;\ell \leq 3 \cdot 10^{+68}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.6e114 < l < -5.8e7 or 13.199999999999999 < l < 3.0000000000000002e68

    1. Initial program 100.0%

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

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

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

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

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

      \[\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 -5.8e7 < l < 13.199999999999999

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.0000000000000002e68 < 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.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.6 \cdot 10^{+114}:\\ \;\;\;\;U + \cos \left(K \cdot 0.5\right) \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \mathbf{elif}\;\ell \leq -58000000:\\ \;\;\;\;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 13.2:\\ \;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(\ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 3 \cdot 10^{+68}:\\ \;\;\;\;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(J \cdot \left(\ell \cdot 2 + 0.3333333333333333 \cdot {\ell}^{3}\right)\right)\\ \end{array} \]

Alternative 6: 91.6% accurate, 1.4× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -1.09999999999999989e99 or 9.0000000000000004e53 < l

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.09999999999999989e99 < l < -3.3e-4

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

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

    if -3.3e-4 < l < 760

    1. Initial program 72.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 760 < l < 9.0000000000000004e53

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

      \[\leadsto \color{blue}{{U}^{-8}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification96.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.1 \cdot 10^{+99}:\\ \;\;\;\;U + \cos \left(K \cdot 0.5\right) \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \mathbf{elif}\;\ell \leq -0.00033:\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{elif}\;\ell \leq 760:\\ \;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(\ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 9 \cdot 10^{+53}:\\ \;\;\;\;{U}^{-8}\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(K \cdot 0.5\right) \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\ \end{array} \]

Alternative 7: 88.0% accurate, 1.4× speedup?

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

\\
U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2 + 0.3333333333333333 \cdot {\ell}^{3}\right)\right)
\end{array}
Derivation
  1. Initial program 85.5%

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

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

Alternative 8: 87.5% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5 \cdot 10^{+149}:\\
\;\;\;\;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.0028 \lor \neg \left(\ell \leq 0.000215\right):\\
\;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.9999999999999999e149 < l < -0.00279999999999999997 or 2.14999999999999995e-4 < l

    1. Initial program 100.0%

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

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

    if -0.00279999999999999997 < l < 2.14999999999999995e-4

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{+149}:\\ \;\;\;\;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.0028 \lor \neg \left(\ell \leq 0.000215\right):\\ \;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\ \mathbf{else}:\\ \;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(\ell \cdot 2\right)\\ \end{array} \]

Alternative 9: 68.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.005:\\ \;\;\;\;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
 (if (<= (cos (/ K 2.0)) -0.005)
   (+ 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 tmp;
	if (cos((K / 2.0)) <= -0.005) {
		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) :: tmp
    if (cos((k / 2.0d0)) <= (-0.005d0)) 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 tmp;
	if (Math.cos((K / 2.0)) <= -0.005) {
		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):
	tmp = 0
	if math.cos((K / 2.0)) <= -0.005:
		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)
	tmp = 0.0
	if (cos(Float64(K / 2.0)) <= -0.005)
		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)
	tmp = 0.0;
	if (cos((K / 2.0)) <= -0.005)
		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_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.005], 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}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.005:\\
\;\;\;\;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 2 regimes
  2. if (cos.f64 (/.f64 K 2)) < -0.0050000000000000001

    1. Initial program 85.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 85.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 92.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.005:\\ \;\;\;\;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 10: 77.9% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
t_0 := U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{if}\;\ell \leq -2.6 \cdot 10^{+184}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq -1.8 \cdot 10^{+160}:\\
\;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\

\mathbf{elif}\;\ell \leq -3000000000:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;\ell \leq 2.3 \cdot 10^{+60}:\\
\;\;\;\;{U}^{-8}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -2.59999999999999993e184 or -1.80000000000000011e160 < l < -3e9 or 2.30000000000000017e60 < 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 87.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.59999999999999993e184 < l < -1.80000000000000011e160

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

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

      \[\leadsto \color{blue}{\left(2 \cdot \left(\ell \cdot J\right) + -0.25 \cdot \left({K}^{2} \cdot \left(\ell \cdot J\right)\right)\right)} + U \]
    4. Step-by-step derivation
      1. +-commutative25.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*25.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-out75.0%

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

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

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

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

    if -3e9 < l < 800

    1. Initial program 72.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 800 < l < 2.30000000000000017e60

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

      \[\leadsto \color{blue}{{U}^{-8}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification85.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.6 \cdot 10^{+184}:\\ \;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \mathbf{elif}\;\ell \leq -1.8 \cdot 10^{+160}:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{elif}\;\ell \leq -3000000000:\\ \;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \mathbf{elif}\;\ell \leq 800:\\ \;\;\;\;U + J \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(\ell \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 2.3 \cdot 10^{+60}:\\ \;\;\;\;{U}^{-8}\\ \mathbf{else}:\\ \;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \end{array} \]

Alternative 11: 77.8% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
t_0 := U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{if}\;\ell \leq -2.7 \cdot 10^{+184}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\ell \leq -1.8 \cdot 10^{+160}:\\
\;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\

\mathbf{elif}\;\ell \leq -8500000000:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;\ell \leq 4.6 \cdot 10^{+57}:\\
\;\;\;\;{U}^{-8}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -2.6999999999999999e184 or -1.80000000000000011e160 < l < -8.5e9 or 4.5999999999999998e57 < 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 87.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.6999999999999999e184 < l < -1.80000000000000011e160

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

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

      \[\leadsto \color{blue}{\left(2 \cdot \left(\ell \cdot J\right) + -0.25 \cdot \left({K}^{2} \cdot \left(\ell \cdot J\right)\right)\right)} + U \]
    4. Step-by-step derivation
      1. +-commutative25.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*25.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-out75.0%

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

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

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

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

    if -8.5e9 < l < 550

    1. Initial program 72.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 550 < l < 4.5999999999999998e57

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

      \[\leadsto \color{blue}{{U}^{-8}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification85.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.7 \cdot 10^{+184}:\\ \;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \mathbf{elif}\;\ell \leq -1.8 \cdot 10^{+160}:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{elif}\;\ell \leq -8500000000:\\ \;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \mathbf{elif}\;\ell \leq 550:\\ \;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(\ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 4.6 \cdot 10^{+57}:\\ \;\;\;\;{U}^{-8}\\ \mathbf{else}:\\ \;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \end{array} \]

Alternative 12: 79.4% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := J \cdot {\ell}^{3}\\ \mathbf{if}\;\ell \leq -58000000:\\ \;\;\;\;U + t_0 \cdot \left(0.3333333333333333 + \left(K \cdot K\right) \cdot -0.041666666666666664\right)\\ \mathbf{elif}\;\ell \leq 620:\\ \;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(\ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 7.5 \cdot 10^{+67}:\\ \;\;\;\;{U}^{-8}\\ \mathbf{else}:\\ \;\;\;\;U + 0.3333333333333333 \cdot t_0\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (* J (pow l 3.0))))
   (if (<= l -58000000.0)
     (+ U (* t_0 (+ 0.3333333333333333 (* (* K K) -0.041666666666666664))))
     (if (<= l 620.0)
       (+ U (* (* J (cos (* K 0.5))) (* l 2.0)))
       (if (<= l 7.5e+67) (pow U -8.0) (+ U (* 0.3333333333333333 t_0)))))))
double code(double J, double l, double K, double U) {
	double t_0 = J * pow(l, 3.0);
	double tmp;
	if (l <= -58000000.0) {
		tmp = U + (t_0 * (0.3333333333333333 + ((K * K) * -0.041666666666666664)));
	} else if (l <= 620.0) {
		tmp = U + ((J * cos((K * 0.5))) * (l * 2.0));
	} else if (l <= 7.5e+67) {
		tmp = pow(U, -8.0);
	} else {
		tmp = U + (0.3333333333333333 * 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) :: tmp
    t_0 = j * (l ** 3.0d0)
    if (l <= (-58000000.0d0)) then
        tmp = u + (t_0 * (0.3333333333333333d0 + ((k * k) * (-0.041666666666666664d0))))
    else if (l <= 620.0d0) then
        tmp = u + ((j * cos((k * 0.5d0))) * (l * 2.0d0))
    else if (l <= 7.5d+67) then
        tmp = u ** (-8.0d0)
    else
        tmp = u + (0.3333333333333333d0 * t_0)
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = J * Math.pow(l, 3.0);
	double tmp;
	if (l <= -58000000.0) {
		tmp = U + (t_0 * (0.3333333333333333 + ((K * K) * -0.041666666666666664)));
	} else if (l <= 620.0) {
		tmp = U + ((J * Math.cos((K * 0.5))) * (l * 2.0));
	} else if (l <= 7.5e+67) {
		tmp = Math.pow(U, -8.0);
	} else {
		tmp = U + (0.3333333333333333 * t_0);
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = J * math.pow(l, 3.0)
	tmp = 0
	if l <= -58000000.0:
		tmp = U + (t_0 * (0.3333333333333333 + ((K * K) * -0.041666666666666664)))
	elif l <= 620.0:
		tmp = U + ((J * math.cos((K * 0.5))) * (l * 2.0))
	elif l <= 7.5e+67:
		tmp = math.pow(U, -8.0)
	else:
		tmp = U + (0.3333333333333333 * t_0)
	return tmp
function code(J, l, K, U)
	t_0 = Float64(J * (l ^ 3.0))
	tmp = 0.0
	if (l <= -58000000.0)
		tmp = Float64(U + Float64(t_0 * Float64(0.3333333333333333 + Float64(Float64(K * K) * -0.041666666666666664))));
	elseif (l <= 620.0)
		tmp = Float64(U + Float64(Float64(J * cos(Float64(K * 0.5))) * Float64(l * 2.0)));
	elseif (l <= 7.5e+67)
		tmp = U ^ -8.0;
	else
		tmp = Float64(U + Float64(0.3333333333333333 * t_0));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = J * (l ^ 3.0);
	tmp = 0.0;
	if (l <= -58000000.0)
		tmp = U + (t_0 * (0.3333333333333333 + ((K * K) * -0.041666666666666664)));
	elseif (l <= 620.0)
		tmp = U + ((J * cos((K * 0.5))) * (l * 2.0));
	elseif (l <= 7.5e+67)
		tmp = U ^ -8.0;
	else
		tmp = U + (0.3333333333333333 * t_0);
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -58000000.0], N[(U + N[(t$95$0 * N[(0.3333333333333333 + N[(N[(K * K), $MachinePrecision] * -0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 620.0], N[(U + N[(N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 7.5e+67], N[Power[U, -8.0], $MachinePrecision], N[(U + N[(0.3333333333333333 * t$95$0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;\ell \leq 7.5 \cdot 10^{+67}:\\
\;\;\;\;{U}^{-8}\\

\mathbf{else}:\\
\;\;\;\;U + 0.3333333333333333 \cdot t_0\\


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\cos \left(0.5 \cdot K\right) \cdot J\right) \cdot \color{blue}{\left(0.3333333333333333 \cdot {\ell}^{3}\right)} + U \]
    9. Taylor expanded in K around 0 6.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 \]
    10. Step-by-step derivation
      1. +-commutative6.0%

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

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

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

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

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

    if -5.8e7 < l < 620

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 620 < l < 7.5000000000000005e67

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

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

    if 7.5000000000000005e67 < 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.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -58000000:\\ \;\;\;\;U + \left(J \cdot {\ell}^{3}\right) \cdot \left(0.3333333333333333 + \left(K \cdot K\right) \cdot -0.041666666666666664\right)\\ \mathbf{elif}\;\ell \leq 620:\\ \;\;\;\;U + \left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(\ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 7.5 \cdot 10^{+67}:\\ \;\;\;\;{U}^{-8}\\ \mathbf{else}:\\ \;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\ \end{array} \]

Alternative 13: 57.5% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -60000000:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{elif}\;\ell \leq 1020:\\ \;\;\;\;\mathsf{fma}\left(J, \ell \cdot 2, U\right)\\ \mathbf{elif}\;\ell \leq 1.16 \cdot 10^{+231}:\\ \;\;\;\;{U}^{-8}\\ \mathbf{else}:\\ \;\;\;\;U + \ell \cdot \left(J \cdot 2\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -60000000.0)
   (+ U (* (* l J) (+ 2.0 (* (* K K) -0.25))))
   (if (<= l 1020.0)
     (fma J (* l 2.0) U)
     (if (<= l 1.16e+231) (pow U -8.0) (+ U (* l (* J 2.0)))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -60000000.0) {
		tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
	} else if (l <= 1020.0) {
		tmp = fma(J, (l * 2.0), U);
	} else if (l <= 1.16e+231) {
		tmp = pow(U, -8.0);
	} else {
		tmp = U + (l * (J * 2.0));
	}
	return tmp;
}
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -60000000.0)
		tmp = Float64(U + Float64(Float64(l * J) * Float64(2.0 + Float64(Float64(K * K) * -0.25))));
	elseif (l <= 1020.0)
		tmp = fma(J, Float64(l * 2.0), U);
	elseif (l <= 1.16e+231)
		tmp = U ^ -8.0;
	else
		tmp = Float64(U + Float64(l * Float64(J * 2.0)));
	end
	return tmp
end
code[J_, l_, K_, U_] := If[LessEqual[l, -60000000.0], N[(U + N[(N[(l * J), $MachinePrecision] * N[(2.0 + N[(N[(K * K), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1020.0], N[(J * N[(l * 2.0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 1.16e+231], N[Power[U, -8.0], $MachinePrecision], N[(U + N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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

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

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


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

    1. Initial program 100.0%

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

      \[\leadsto \left(J \cdot \color{blue}{\left(2 \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in K around 0 21.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 \]
    4. Step-by-step derivation
      1. +-commutative21.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*21.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-out41.3%

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

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

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

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

    if -6e7 < l < 1020

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

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

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

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

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

        \[\leadsto \color{blue}{J \cdot \left(\ell \cdot 2\right)} + U \]
      4. fma-def86.9%

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

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

    if 1020 < l < 1.16e231

    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-rr41.2%

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

    if 1.16e231 < 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 47.5%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -60000000:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{elif}\;\ell \leq 1020:\\ \;\;\;\;\mathsf{fma}\left(J, \ell \cdot 2, U\right)\\ \mathbf{elif}\;\ell \leq 1.16 \cdot 10^{+231}:\\ \;\;\;\;{U}^{-8}\\ \mathbf{else}:\\ \;\;\;\;U + \ell \cdot \left(J \cdot 2\right)\\ \end{array} \]

Alternative 14: 57.4% accurate, 2.9× speedup?

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

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

\mathbf{elif}\;\ell \leq 620 \lor \neg \left(\ell \leq 4.2 \cdot 10^{+230}\right):\\
\;\;\;\;U + \ell \cdot \left(J \cdot 2\right)\\

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


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

    1. Initial program 100.0%

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

      \[\leadsto \left(J \cdot \color{blue}{\left(2 \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in K around 0 21.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 \]
    4. Step-by-step derivation
      1. +-commutative21.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*21.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-out41.3%

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

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

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

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

    if -7.2e7 < l < 620 or 4.19999999999999986e230 < l

    1. Initial program 75.7%

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

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

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

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

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

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

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

    if 620 < l < 4.19999999999999986e230

    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-rr41.2%

      \[\leadsto \color{blue}{{U}^{-8}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification65.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -72000000:\\ \;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{elif}\;\ell \leq 620 \lor \neg \left(\ell \leq 4.2 \cdot 10^{+230}\right):\\ \;\;\;\;U + \ell \cdot \left(J \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;{U}^{-8}\\ \end{array} \]

Alternative 15: 58.9% accurate, 16.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -64000000 \lor \neg \left(\ell \leq 470\right) \land \ell \leq 1.95 \cdot 10^{+246}:\\
\;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -6.4e7 or 470 < l < 1.95e246

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

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

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

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

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

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

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

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

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

    if -6.4e7 < l < 470 or 1.95e246 < l

    1. Initial program 75.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 94.1%

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

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

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

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

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

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

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

Alternative 16: 53.1% accurate, 23.9× speedup?

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

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

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


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

    1. Initial program 100.0%

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

      \[\leadsto \left(J \cdot \color{blue}{\left(2 \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. Taylor expanded in K around 0 21.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 \]
    4. Step-by-step derivation
      1. +-commutative21.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*21.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-out41.3%

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

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

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

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

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

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

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

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

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

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

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

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

    if -6e7 < l

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

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

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

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

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

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

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

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

Alternative 17: 40.0% accurate, 34.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3.4 \cdot 10^{-7} \lor \neg \left(\ell \leq 1.3 \cdot 10^{+85}\right):\\
\;\;\;\;U \cdot \left(U - -8\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -3.39999999999999974e-7 or 1.30000000000000005e85 < l

    1. Initial program 99.7%

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

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

    if -3.39999999999999974e-7 < l < 1.30000000000000005e85

    1. Initial program 74.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.4 \cdot 10^{-7} \lor \neg \left(\ell \leq 1.3 \cdot 10^{+85}\right):\\ \;\;\;\;U \cdot \left(U - -8\right)\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \]

Alternative 18: 40.4% accurate, 43.8× speedup?

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

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

\mathbf{elif}\;\ell \leq 5.6 \cdot 10^{+68}:\\
\;\;\;\;U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -2.7e9 or 5.6e68 < 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-rr16.1%

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

    if -2.7e9 < l < 5.6e68

    1. Initial program 74.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2700000000:\\ \;\;\;\;U \cdot U\\ \mathbf{elif}\;\ell \leq 5.6 \cdot 10^{+68}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot U\\ \end{array} \]

Alternative 19: 53.7% accurate, 44.6× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 20: 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 85.5%

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

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

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

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

    \[\leadsto 1 \]

Alternative 21: 36.0% accurate, 312.0× speedup?

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

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

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

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

    \[\leadsto U \]

Reproduce

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