Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.1% → 100.0%
Time: 14.6s
Alternatives: 18
Speedup: 2.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 18 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 86.1% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.5× speedup?

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

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

    \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. associate-*l*N/A

      \[\leadsto \color{blue}{J \cdot \left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right)} + U \]
    2. *-commutativeN/A

      \[\leadsto \color{blue}{\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J} + U \]
    3. *-lowering-*.f64N/A

      \[\leadsto \color{blue}{\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J} + U \]
    4. *-lowering-*.f64N/A

      \[\leadsto \color{blue}{\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right)} \cdot J + U \]
    5. sinh-undefN/A

      \[\leadsto \left(\color{blue}{\left(2 \cdot \sinh \ell\right)} \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J + U \]
    6. *-lowering-*.f64N/A

      \[\leadsto \left(\color{blue}{\left(2 \cdot \sinh \ell\right)} \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J + U \]
    7. sinh-lowering-sinh.f64N/A

      \[\leadsto \left(\left(2 \cdot \color{blue}{\sinh \ell}\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J + U \]
    8. cos-lowering-cos.f64N/A

      \[\leadsto \left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)}\right) \cdot J + U \]
    9. /-lowering-/.f64100.0

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

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

Alternative 2: 91.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq 0.95:\\ \;\;\;\;U \cdot \left(1 + J \cdot \frac{t\_0 \cdot \left(\ell \cdot \left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right)\right)}{U}\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \ell \cdot \left(\ell \cdot \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right)\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))))
   (if (<= t_0 0.95)
     (*
      U
      (+ 1.0 (* J (/ (* t_0 (* l (+ 2.0 (* l (* l 0.3333333333333333))))) U))))
     (+
      U
      (*
       J
       (*
        l
        (+
         2.0
         (*
          (* l l)
          (+
           0.3333333333333333
           (*
            l
            (*
             l
             (+
              0.016666666666666666
              (* (* l l) 0.0003968253968253968)))))))))))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K / 2.0));
	double tmp;
	if (t_0 <= 0.95) {
		tmp = U * (1.0 + (J * ((t_0 * (l * (2.0 + (l * (l * 0.3333333333333333))))) / U)));
	} else {
		tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (l * (l * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))));
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: t_0
    real(8) :: tmp
    t_0 = cos((k / 2.0d0))
    if (t_0 <= 0.95d0) then
        tmp = u * (1.0d0 + (j * ((t_0 * (l * (2.0d0 + (l * (l * 0.3333333333333333d0))))) / u)))
    else
        tmp = u + (j * (l * (2.0d0 + ((l * l) * (0.3333333333333333d0 + (l * (l * (0.016666666666666666d0 + ((l * l) * 0.0003968253968253968d0)))))))))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = Math.cos((K / 2.0));
	double tmp;
	if (t_0 <= 0.95) {
		tmp = U * (1.0 + (J * ((t_0 * (l * (2.0 + (l * (l * 0.3333333333333333))))) / U)));
	} else {
		tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (l * (l * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K / 2.0))
	tmp = 0
	if t_0 <= 0.95:
		tmp = U * (1.0 + (J * ((t_0 * (l * (2.0 + (l * (l * 0.3333333333333333))))) / U)))
	else:
		tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (l * (l * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))))
	return tmp
function code(J, l, K, U)
	t_0 = cos(Float64(K / 2.0))
	tmp = 0.0
	if (t_0 <= 0.95)
		tmp = Float64(U * Float64(1.0 + Float64(J * Float64(Float64(t_0 * Float64(l * Float64(2.0 + Float64(l * Float64(l * 0.3333333333333333))))) / U))));
	else
		tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(l * Float64(l * Float64(0.016666666666666666 + Float64(Float64(l * l) * 0.0003968253968253968))))))))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = cos((K / 2.0));
	tmp = 0.0;
	if (t_0 <= 0.95)
		tmp = U * (1.0 + (J * ((t_0 * (l * (2.0 + (l * (l * 0.3333333333333333))))) / U)));
	else
		tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (l * (l * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 0.95], N[(U * N[(1.0 + N[(J * N[(N[(t$95$0 * N[(l * N[(2.0 + N[(l * N[(l * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * N[(0.3333333333333333 + N[(l * N[(l * N[(0.016666666666666666 + N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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.95:\\
\;\;\;\;U \cdot \left(1 + J \cdot \frac{t\_0 \cdot \left(\ell \cdot \left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right)\right)}{U}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.94999999999999996

    1. Initial program 86.1%

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

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

        \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{2}\right)}\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      2. associate-*r*N/A

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

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2}} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      4. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\ell \cdot \left(\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
      5. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      6. associate-*r*N/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \frac{1}{3}\right) \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      7. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2}\right)} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      8. distribute-rgt-outN/A

        \[\leadsto \ell \cdot \color{blue}{\left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \left(\frac{1}{3} \cdot {\ell}^{2} + 2\right)\right)} + U \]
      9. +-commutativeN/A

        \[\leadsto \ell \cdot \left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \color{blue}{\left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}\right) + U \]
      10. *-lowering-*.f64N/A

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

      \[\leadsto \color{blue}{\ell \cdot \left(\left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right)\right)} + U \]
    6. Taylor expanded in U around inf

      \[\leadsto \color{blue}{U \cdot \left(1 + \frac{J \cdot \left(\ell \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)}{U}\right)} \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{U \cdot \left(1 + \frac{J \cdot \left(\ell \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)}{U}\right)} \]
      2. +-lowering-+.f64N/A

        \[\leadsto U \cdot \color{blue}{\left(1 + \frac{J \cdot \left(\ell \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)}{U}\right)} \]
      3. /-lowering-/.f64N/A

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

      \[\leadsto \color{blue}{U \cdot \left(1 + \frac{J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)}{U}\right)} \]
    9. Step-by-step derivation
      1. associate-/l*N/A

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

        \[\leadsto U \cdot \left(1 + \color{blue}{\frac{\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\ell \cdot \left(2 + \frac{1}{3} \cdot \left(\ell \cdot \ell\right)\right)\right)}{U} \cdot J}\right) \]
      3. *-lowering-*.f64N/A

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

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

    if 0.94999999999999996 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

    1. Initial program 91.2%

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

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      2. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      3. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      4. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      6. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \color{blue}{\left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      7. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      8. associate-*l*N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      9. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      10. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \color{blue}{\left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      11. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \color{blue}{\left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      12. *-commutativeN/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      13. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      14. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{2520}\right)\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      15. *-lowering-*.f6496.7

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

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

      \[\leadsto \color{blue}{J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)} + U \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)} + U \]
      2. *-lowering-*.f64N/A

        \[\leadsto J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)} + U \]
      3. +-lowering-+.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \color{blue}{\left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)}\right) + U \]
      4. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right) + U \]
      5. unpow2N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right) + U \]
      6. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right) + U \]
      7. +-lowering-+.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \color{blue}{\left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right) + U \]
      8. unpow2N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right) + U \]
      9. associate-*l*N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) + U \]
      10. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) + U \]
      11. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \color{blue}{\left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) + U \]
      12. +-lowering-+.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \color{blue}{\left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)}\right)\right)\right)\right) + U \]
      13. *-commutativeN/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right) + U \]
      14. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right) + U \]
      15. unpow2N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{2520}\right)\right)\right)\right)\right) + U \]
      16. *-lowering-*.f6496.4

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \ell \cdot \left(\ell \cdot \left(0.016666666666666666 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot 0.0003968253968253968\right)\right)\right)\right)\right) + U \]
    8. Simplified96.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.95:\\ \;\;\;\;U \cdot \left(1 + J \cdot \frac{\cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right)\right)}{U}\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \ell \cdot \left(\ell \cdot \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right)\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 91.2% accurate, 1.4× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.94999999999999996

    1. Initial program 86.1%

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

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      2. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      3. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \frac{1}{3} \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      4. associate-*r*N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\frac{1}{3} \cdot \ell\right) \cdot \ell}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. *-commutativeN/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\ell \cdot \left(\frac{1}{3} \cdot \ell\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      6. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\ell \cdot \left(\frac{1}{3} \cdot \ell\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      7. *-commutativeN/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \ell \cdot \color{blue}{\left(\ell \cdot \frac{1}{3}\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      8. *-lowering-*.f6487.9

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

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

    if 0.94999999999999996 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

    1. Initial program 91.2%

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

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      2. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      3. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      4. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      6. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \color{blue}{\left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      7. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      8. associate-*l*N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      9. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      10. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \color{blue}{\left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      11. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \color{blue}{\left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      12. *-commutativeN/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      13. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      14. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{2520}\right)\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      15. *-lowering-*.f6496.7

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

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

      \[\leadsto \color{blue}{J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)} + U \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)} + U \]
      2. *-lowering-*.f64N/A

        \[\leadsto J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)} + U \]
      3. +-lowering-+.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \color{blue}{\left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)}\right) + U \]
      4. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right) + U \]
      5. unpow2N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right) + U \]
      6. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right) + U \]
      7. +-lowering-+.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \color{blue}{\left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right) + U \]
      8. unpow2N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right) + U \]
      9. associate-*l*N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) + U \]
      10. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) + U \]
      11. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \color{blue}{\left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) + U \]
      12. +-lowering-+.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \color{blue}{\left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)}\right)\right)\right)\right) + U \]
      13. *-commutativeN/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right) + U \]
      14. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right) + U \]
      15. unpow2N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{2520}\right)\right)\right)\right)\right) + U \]
      16. *-lowering-*.f6496.4

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \ell \cdot \left(\ell \cdot \left(0.016666666666666666 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot 0.0003968253968253968\right)\right)\right)\right)\right) + U \]
    8. Simplified96.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.95:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \ell \cdot \left(\ell \cdot \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right)\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 90.0% accurate, 1.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.94999999999999996

    1. Initial program 86.1%

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

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

        \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{2}\right)}\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      2. associate-*r*N/A

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

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2}} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      4. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\ell \cdot \left(\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
      5. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      6. associate-*r*N/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \frac{1}{3}\right) \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      7. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2}\right)} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      8. distribute-rgt-outN/A

        \[\leadsto \ell \cdot \color{blue}{\left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \left(\frac{1}{3} \cdot {\ell}^{2} + 2\right)\right)} + U \]
      9. +-commutativeN/A

        \[\leadsto \ell \cdot \left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \color{blue}{\left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}\right) + U \]
      10. *-lowering-*.f64N/A

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

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

    if 0.94999999999999996 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

    1. Initial program 91.2%

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

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      2. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      3. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      4. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      6. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \color{blue}{\left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      7. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      8. associate-*l*N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      9. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      10. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \color{blue}{\left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      11. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \color{blue}{\left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      12. *-commutativeN/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      13. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      14. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{2520}\right)\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      15. *-lowering-*.f6496.7

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

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

      \[\leadsto \color{blue}{J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)} + U \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)} + U \]
      2. *-lowering-*.f64N/A

        \[\leadsto J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)} + U \]
      3. +-lowering-+.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \color{blue}{\left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)}\right) + U \]
      4. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right) + U \]
      5. unpow2N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right) + U \]
      6. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right) + U \]
      7. +-lowering-+.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \color{blue}{\left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right) + U \]
      8. unpow2N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right) + U \]
      9. associate-*l*N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) + U \]
      10. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) + U \]
      11. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \color{blue}{\left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) + U \]
      12. +-lowering-+.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \color{blue}{\left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)}\right)\right)\right)\right) + U \]
      13. *-commutativeN/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right) + U \]
      14. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right) + U \]
      15. unpow2N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{2520}\right)\right)\right)\right)\right) + U \]
      16. *-lowering-*.f6496.4

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \ell \cdot \left(\ell \cdot \left(0.016666666666666666 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot 0.0003968253968253968\right)\right)\right)\right)\right) + U \]
    8. Simplified96.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.95:\\ \;\;\;\;U + \ell \cdot \left(\left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right) \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \ell \cdot \left(\ell \cdot \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right)\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 88.7% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(K \cdot 0.5\right)\\ t_1 := \left(\ell \cdot 0.3333333333333333\right) \cdot \left(t\_0 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right)\\ \mathbf{if}\;\ell \leq -4.2 \cdot 10^{+203}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\ell \leq -1200:\\ \;\;\;\;J \cdot \left(\left(1 + K \cdot \left(K \cdot -0.125\right)\right) \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 550000:\\ \;\;\;\;U + \ell \cdot \left(t\_0 \cdot \left(2 \cdot J\right)\right)\\ \mathbf{elif}\;\ell \leq 1.05 \cdot 10^{+128}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \ell \cdot \left(\ell \cdot \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (* K 0.5)))
        (t_1 (* (* l 0.3333333333333333) (* t_0 (* J (* l l))))))
   (if (<= l -4.2e+203)
     t_1
     (if (<= l -1200.0)
       (*
        J
        (*
         (+ 1.0 (* K (* K -0.125)))
         (*
          l
          (+
           2.0
           (*
            (* l l)
            (+ 0.3333333333333333 (* (* l l) 0.016666666666666666)))))))
       (if (<= l 550000.0)
         (+ U (* l (* t_0 (* 2.0 J))))
         (if (<= l 1.05e+128)
           (+
            U
            (*
             J
             (*
              l
              (+
               2.0
               (*
                (* l l)
                (+
                 0.3333333333333333
                 (*
                  l
                  (*
                   l
                   (+
                    0.016666666666666666
                    (* (* l l) 0.0003968253968253968))))))))))
           t_1))))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K * 0.5));
	double t_1 = (l * 0.3333333333333333) * (t_0 * (J * (l * l)));
	double tmp;
	if (l <= -4.2e+203) {
		tmp = t_1;
	} else if (l <= -1200.0) {
		tmp = J * ((1.0 + (K * (K * -0.125))) * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))));
	} else if (l <= 550000.0) {
		tmp = U + (l * (t_0 * (2.0 * J)));
	} else if (l <= 1.05e+128) {
		tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (l * (l * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))));
	} 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 = (l * 0.3333333333333333d0) * (t_0 * (j * (l * l)))
    if (l <= (-4.2d+203)) then
        tmp = t_1
    else if (l <= (-1200.0d0)) then
        tmp = j * ((1.0d0 + (k * (k * (-0.125d0)))) * (l * (2.0d0 + ((l * l) * (0.3333333333333333d0 + ((l * l) * 0.016666666666666666d0))))))
    else if (l <= 550000.0d0) then
        tmp = u + (l * (t_0 * (2.0d0 * j)))
    else if (l <= 1.05d+128) then
        tmp = u + (j * (l * (2.0d0 + ((l * l) * (0.3333333333333333d0 + (l * (l * (0.016666666666666666d0 + ((l * l) * 0.0003968253968253968d0)))))))))
    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 = (l * 0.3333333333333333) * (t_0 * (J * (l * l)));
	double tmp;
	if (l <= -4.2e+203) {
		tmp = t_1;
	} else if (l <= -1200.0) {
		tmp = J * ((1.0 + (K * (K * -0.125))) * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))));
	} else if (l <= 550000.0) {
		tmp = U + (l * (t_0 * (2.0 * J)));
	} else if (l <= 1.05e+128) {
		tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (l * (l * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K * 0.5))
	t_1 = (l * 0.3333333333333333) * (t_0 * (J * (l * l)))
	tmp = 0
	if l <= -4.2e+203:
		tmp = t_1
	elif l <= -1200.0:
		tmp = J * ((1.0 + (K * (K * -0.125))) * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))
	elif l <= 550000.0:
		tmp = U + (l * (t_0 * (2.0 * J)))
	elif l <= 1.05e+128:
		tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (l * (l * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))))
	else:
		tmp = t_1
	return tmp
function code(J, l, K, U)
	t_0 = cos(Float64(K * 0.5))
	t_1 = Float64(Float64(l * 0.3333333333333333) * Float64(t_0 * Float64(J * Float64(l * l))))
	tmp = 0.0
	if (l <= -4.2e+203)
		tmp = t_1;
	elseif (l <= -1200.0)
		tmp = Float64(J * Float64(Float64(1.0 + Float64(K * Float64(K * -0.125))) * Float64(l * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(Float64(l * l) * 0.016666666666666666)))))));
	elseif (l <= 550000.0)
		tmp = Float64(U + Float64(l * Float64(t_0 * Float64(2.0 * J))));
	elseif (l <= 1.05e+128)
		tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(l * Float64(l * Float64(0.016666666666666666 + Float64(Float64(l * l) * 0.0003968253968253968))))))))));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = cos((K * 0.5));
	t_1 = (l * 0.3333333333333333) * (t_0 * (J * (l * l)));
	tmp = 0.0;
	if (l <= -4.2e+203)
		tmp = t_1;
	elseif (l <= -1200.0)
		tmp = J * ((1.0 + (K * (K * -0.125))) * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))));
	elseif (l <= 550000.0)
		tmp = U + (l * (t_0 * (2.0 * J)));
	elseif (l <= 1.05e+128)
		tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (l * (l * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))));
	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[(N[(l * 0.3333333333333333), $MachinePrecision] * N[(t$95$0 * N[(J * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -4.2e+203], t$95$1, If[LessEqual[l, -1200.0], N[(J * N[(N[(1.0 + N[(K * N[(K * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * N[(0.3333333333333333 + N[(N[(l * l), $MachinePrecision] * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 550000.0], N[(U + N[(l * N[(t$95$0 * N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.05e+128], N[(U + N[(J * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * N[(0.3333333333333333 + N[(l * N[(l * N[(0.016666666666666666 + N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
t_1 := \left(\ell \cdot 0.3333333333333333\right) \cdot \left(t\_0 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right)\\
\mathbf{if}\;\ell \leq -4.2 \cdot 10^{+203}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;\ell \leq -1200:\\
\;\;\;\;J \cdot \left(\left(1 + K \cdot \left(K \cdot -0.125\right)\right) \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right)\\

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

\mathbf{elif}\;\ell \leq 1.05 \cdot 10^{+128}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \ell \cdot \left(\ell \cdot \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right)\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -4.19999999999999967e203 or 1.05e128 < 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. Add Preprocessing
    3. Taylor expanded in l around 0

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

        \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{2}\right)}\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      2. associate-*r*N/A

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

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2}} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      4. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\ell \cdot \left(\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
      5. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      6. associate-*r*N/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \frac{1}{3}\right) \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      7. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2}\right)} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      8. distribute-rgt-outN/A

        \[\leadsto \ell \cdot \color{blue}{\left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \left(\frac{1}{3} \cdot {\ell}^{2} + 2\right)\right)} + U \]
      9. +-commutativeN/A

        \[\leadsto \ell \cdot \left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \color{blue}{\left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}\right) + U \]
      10. *-lowering-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
    7. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\frac{1}{3} \cdot J\right) \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} \]
      2. *-commutativeN/A

        \[\leadsto \left(\frac{1}{3} \cdot J\right) \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{3}\right)} \]
      3. unpow3N/A

        \[\leadsto \left(\frac{1}{3} \cdot J\right) \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(\left(\ell \cdot \ell\right) \cdot \ell\right)}\right) \]
      4. unpow2N/A

        \[\leadsto \left(\frac{1}{3} \cdot J\right) \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\color{blue}{{\ell}^{2}} \cdot \ell\right)\right) \]
      5. associate-*r*N/A

        \[\leadsto \left(\frac{1}{3} \cdot J\right) \cdot \color{blue}{\left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{2}\right) \cdot \ell\right)} \]
      6. *-commutativeN/A

        \[\leadsto \left(\frac{1}{3} \cdot J\right) \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} \cdot \ell\right) \]
      7. associate-*l*N/A

        \[\leadsto \color{blue}{\left(\left(\frac{1}{3} \cdot J\right) \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \ell} \]
      8. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)\right)} \cdot \ell \]
      9. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \frac{1}{3}\right)} \cdot \ell \]
      10. associate-*l*N/A

        \[\leadsto \color{blue}{\left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \left(\frac{1}{3} \cdot \ell\right)} \]
      11. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \left(\frac{1}{3} \cdot \ell\right)} \]
    8. Simplified98.2%

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

    if -4.19999999999999967e203 < l < -1200

    1. Initial program 100.0%

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

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      2. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      3. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      4. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      6. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \color{blue}{\left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      7. *-commutativeN/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{{\ell}^{2} \cdot \frac{1}{60}}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      8. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{{\ell}^{2} \cdot \frac{1}{60}}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      9. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{60}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      10. *-lowering-*.f6466.7

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

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

      \[\leadsto \color{blue}{\left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right) + J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)} + U \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) + \frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)} + U \]
      2. *-commutativeN/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) + \frac{-1}{8} \cdot \left(J \cdot \color{blue}{\left(\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) \cdot {K}^{2}\right)}\right)\right) + U \]
      3. associate-*r*N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) + \frac{-1}{8} \cdot \color{blue}{\left(\left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \cdot {K}^{2}\right)}\right) + U \]
      4. associate-*l*N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) + \color{blue}{\left(\frac{-1}{8} \cdot \left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot {K}^{2}}\right) + U \]
      5. +-lowering-+.f64N/A

        \[\leadsto \color{blue}{\left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) + \left(\frac{-1}{8} \cdot \left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot {K}^{2}\right)} + U \]
    8. Simplified20.6%

      \[\leadsto \color{blue}{\left(\ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right) + -0.125 \cdot \left(J \cdot \left(\left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right) \cdot \left(\ell \cdot \left(K \cdot K\right)\right)\right)\right)\right)} + U \]
    9. Taylor expanded in J around inf

      \[\leadsto \color{blue}{J \cdot \left(\frac{-1}{8} \cdot \left({K}^{2} \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) + \ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)} \]
    10. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{J \cdot \left(\frac{-1}{8} \cdot \left({K}^{2} \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) + \ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)} \]
      2. associate-*r*N/A

        \[\leadsto J \cdot \left(\color{blue}{\left(\frac{-1}{8} \cdot {K}^{2}\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)} + \ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) \]
      3. distribute-lft1-inN/A

        \[\leadsto J \cdot \color{blue}{\left(\left(\frac{-1}{8} \cdot {K}^{2} + 1\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)} \]
      4. +-commutativeN/A

        \[\leadsto J \cdot \left(\color{blue}{\left(1 + \frac{-1}{8} \cdot {K}^{2}\right)} \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto J \cdot \color{blue}{\left(\left(1 + \frac{-1}{8} \cdot {K}^{2}\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)} \]
      6. +-lowering-+.f64N/A

        \[\leadsto J \cdot \left(\color{blue}{\left(1 + \frac{-1}{8} \cdot {K}^{2}\right)} \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto J \cdot \left(\left(1 + \color{blue}{{K}^{2} \cdot \frac{-1}{8}}\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto J \cdot \left(\left(1 + \color{blue}{\left(K \cdot K\right)} \cdot \frac{-1}{8}\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \]
      9. associate-*l*N/A

        \[\leadsto J \cdot \left(\left(1 + \color{blue}{K \cdot \left(K \cdot \frac{-1}{8}\right)}\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\left(1 + \color{blue}{K \cdot \left(K \cdot \frac{-1}{8}\right)}\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\left(1 + K \cdot \color{blue}{\left(K \cdot \frac{-1}{8}\right)}\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\left(1 + K \cdot \left(K \cdot \frac{-1}{8}\right)\right) \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \]
    11. Simplified73.2%

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

    if -1200 < l < 5.5e5

    1. Initial program 79.8%

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

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

        \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{2}\right)}\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      2. associate-*r*N/A

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

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2}} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      4. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\ell \cdot \left(\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
      5. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      6. associate-*r*N/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \frac{1}{3}\right) \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      7. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2}\right)} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      8. distribute-rgt-outN/A

        \[\leadsto \ell \cdot \color{blue}{\left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \left(\frac{1}{3} \cdot {\ell}^{2} + 2\right)\right)} + U \]
      9. +-commutativeN/A

        \[\leadsto \ell \cdot \left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \color{blue}{\left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}\right) + U \]
      10. *-lowering-*.f64N/A

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

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

      \[\leadsto \ell \cdot \color{blue}{\left(2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
    7. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

        \[\leadsto \ell \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(2 \cdot J\right)}\right) + U \]
      5. *-lowering-*.f64N/A

        \[\leadsto \ell \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(2 \cdot J\right)\right)} + U \]
      6. cos-lowering-cos.f64N/A

        \[\leadsto \ell \cdot \left(\color{blue}{\cos \left(\frac{1}{2} \cdot K\right)} \cdot \left(2 \cdot J\right)\right) + U \]
      7. *-lowering-*.f64N/A

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

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

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

    if 5.5e5 < l < 1.05e128

    1. Initial program 100.0%

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

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      2. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      3. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      4. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      6. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \color{blue}{\left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      7. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      8. associate-*l*N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      9. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      10. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \color{blue}{\left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      11. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \color{blue}{\left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      12. *-commutativeN/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      13. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      14. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{2520}\right)\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      15. *-lowering-*.f6484.8

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

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

      \[\leadsto \color{blue}{J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)} + U \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)} + U \]
      2. *-lowering-*.f64N/A

        \[\leadsto J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)} + U \]
      3. +-lowering-+.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \color{blue}{\left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)}\right) + U \]
      4. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right) + U \]
      5. unpow2N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right) + U \]
      6. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right) + U \]
      7. +-lowering-+.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \color{blue}{\left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right) + U \]
      8. unpow2N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right) + U \]
      9. associate-*l*N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) + U \]
      10. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) + U \]
      11. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \color{blue}{\left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) + U \]
      12. +-lowering-+.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \color{blue}{\left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)}\right)\right)\right)\right) + U \]
      13. *-commutativeN/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right) + U \]
      14. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right) + U \]
      15. unpow2N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{2520}\right)\right)\right)\right)\right) + U \]
      16. *-lowering-*.f6464.6

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \ell \cdot \left(\ell \cdot \left(0.016666666666666666 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot 0.0003968253968253968\right)\right)\right)\right)\right) + U \]
    8. Simplified64.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.2 \cdot 10^{+203}:\\ \;\;\;\;\left(\ell \cdot 0.3333333333333333\right) \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right)\\ \mathbf{elif}\;\ell \leq -1200:\\ \;\;\;\;J \cdot \left(\left(1 + K \cdot \left(K \cdot -0.125\right)\right) \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 550000:\\ \;\;\;\;U + \ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(2 \cdot J\right)\right)\\ \mathbf{elif}\;\ell \leq 1.05 \cdot 10^{+128}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \ell \cdot \left(\ell \cdot \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\ell \cdot 0.3333333333333333\right) \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 88.4% accurate, 2.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(K \cdot 0.5\right)\\ \mathbf{if}\;\ell \leq -1 \cdot 10^{+204}:\\ \;\;\;\;\left(\ell \cdot 0.3333333333333333\right) \cdot \left(t\_0 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right)\\ \mathbf{elif}\;\ell \leq -1150:\\ \;\;\;\;J \cdot \left(\left(1 + K \cdot \left(K \cdot -0.125\right)\right) \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 1.26 \cdot 10^{+14}:\\ \;\;\;\;U + \ell \cdot \left(t\_0 \cdot \left(2 \cdot J\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(\left(t\_0 \cdot \left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\right) \cdot \frac{0.3333333333333333}{U}\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (* K 0.5))))
   (if (<= l -1e+204)
     (* (* l 0.3333333333333333) (* t_0 (* J (* l l))))
     (if (<= l -1150.0)
       (*
        J
        (*
         (+ 1.0 (* K (* K -0.125)))
         (*
          l
          (+
           2.0
           (*
            (* l l)
            (+ 0.3333333333333333 (* (* l l) 0.016666666666666666)))))))
       (if (<= l 1.26e+14)
         (+ U (* l (* t_0 (* 2.0 J))))
         (* U (* (* t_0 (* J (* l (* l l)))) (/ 0.3333333333333333 U))))))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K * 0.5));
	double tmp;
	if (l <= -1e+204) {
		tmp = (l * 0.3333333333333333) * (t_0 * (J * (l * l)));
	} else if (l <= -1150.0) {
		tmp = J * ((1.0 + (K * (K * -0.125))) * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))));
	} else if (l <= 1.26e+14) {
		tmp = U + (l * (t_0 * (2.0 * J)));
	} else {
		tmp = U * ((t_0 * (J * (l * (l * l)))) * (0.3333333333333333 / U));
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: t_0
    real(8) :: tmp
    t_0 = cos((k * 0.5d0))
    if (l <= (-1d+204)) then
        tmp = (l * 0.3333333333333333d0) * (t_0 * (j * (l * l)))
    else if (l <= (-1150.0d0)) then
        tmp = j * ((1.0d0 + (k * (k * (-0.125d0)))) * (l * (2.0d0 + ((l * l) * (0.3333333333333333d0 + ((l * l) * 0.016666666666666666d0))))))
    else if (l <= 1.26d+14) then
        tmp = u + (l * (t_0 * (2.0d0 * j)))
    else
        tmp = u * ((t_0 * (j * (l * (l * l)))) * (0.3333333333333333d0 / u))
    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 tmp;
	if (l <= -1e+204) {
		tmp = (l * 0.3333333333333333) * (t_0 * (J * (l * l)));
	} else if (l <= -1150.0) {
		tmp = J * ((1.0 + (K * (K * -0.125))) * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))));
	} else if (l <= 1.26e+14) {
		tmp = U + (l * (t_0 * (2.0 * J)));
	} else {
		tmp = U * ((t_0 * (J * (l * (l * l)))) * (0.3333333333333333 / U));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K * 0.5))
	tmp = 0
	if l <= -1e+204:
		tmp = (l * 0.3333333333333333) * (t_0 * (J * (l * l)))
	elif l <= -1150.0:
		tmp = J * ((1.0 + (K * (K * -0.125))) * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))
	elif l <= 1.26e+14:
		tmp = U + (l * (t_0 * (2.0 * J)))
	else:
		tmp = U * ((t_0 * (J * (l * (l * l)))) * (0.3333333333333333 / U))
	return tmp
function code(J, l, K, U)
	t_0 = cos(Float64(K * 0.5))
	tmp = 0.0
	if (l <= -1e+204)
		tmp = Float64(Float64(l * 0.3333333333333333) * Float64(t_0 * Float64(J * Float64(l * l))));
	elseif (l <= -1150.0)
		tmp = Float64(J * Float64(Float64(1.0 + Float64(K * Float64(K * -0.125))) * Float64(l * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(Float64(l * l) * 0.016666666666666666)))))));
	elseif (l <= 1.26e+14)
		tmp = Float64(U + Float64(l * Float64(t_0 * Float64(2.0 * J))));
	else
		tmp = Float64(U * Float64(Float64(t_0 * Float64(J * Float64(l * Float64(l * l)))) * Float64(0.3333333333333333 / U)));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = cos((K * 0.5));
	tmp = 0.0;
	if (l <= -1e+204)
		tmp = (l * 0.3333333333333333) * (t_0 * (J * (l * l)));
	elseif (l <= -1150.0)
		tmp = J * ((1.0 + (K * (K * -0.125))) * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))));
	elseif (l <= 1.26e+14)
		tmp = U + (l * (t_0 * (2.0 * J)));
	else
		tmp = U * ((t_0 * (J * (l * (l * l)))) * (0.3333333333333333 / U));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -1e+204], N[(N[(l * 0.3333333333333333), $MachinePrecision] * N[(t$95$0 * N[(J * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -1150.0], N[(J * N[(N[(1.0 + N[(K * N[(K * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * N[(0.3333333333333333 + N[(N[(l * l), $MachinePrecision] * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.26e+14], N[(U + N[(l * N[(t$95$0 * N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U * N[(N[(t$95$0 * N[(J * N[(l * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.3333333333333333 / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
\mathbf{if}\;\ell \leq -1 \cdot 10^{+204}:\\
\;\;\;\;\left(\ell \cdot 0.3333333333333333\right) \cdot \left(t\_0 \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right)\\

\mathbf{elif}\;\ell \leq -1150:\\
\;\;\;\;J \cdot \left(\left(1 + K \cdot \left(K \cdot -0.125\right)\right) \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right)\\

\mathbf{elif}\;\ell \leq 1.26 \cdot 10^{+14}:\\
\;\;\;\;U + \ell \cdot \left(t\_0 \cdot \left(2 \cdot J\right)\right)\\

\mathbf{else}:\\
\;\;\;\;U \cdot \left(\left(t\_0 \cdot \left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\right) \cdot \frac{0.3333333333333333}{U}\right)\\


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

    1. Initial program 100.0%

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

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

        \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{2}\right)}\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      2. associate-*r*N/A

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

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2}} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      4. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\ell \cdot \left(\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
      5. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      6. associate-*r*N/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \frac{1}{3}\right) \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      7. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2}\right)} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      8. distribute-rgt-outN/A

        \[\leadsto \ell \cdot \color{blue}{\left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \left(\frac{1}{3} \cdot {\ell}^{2} + 2\right)\right)} + U \]
      9. +-commutativeN/A

        \[\leadsto \ell \cdot \left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \color{blue}{\left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}\right) + U \]
      10. *-lowering-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} \]
    7. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\frac{1}{3} \cdot J\right) \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} \]
      2. *-commutativeN/A

        \[\leadsto \left(\frac{1}{3} \cdot J\right) \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{3}\right)} \]
      3. unpow3N/A

        \[\leadsto \left(\frac{1}{3} \cdot J\right) \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(\left(\ell \cdot \ell\right) \cdot \ell\right)}\right) \]
      4. unpow2N/A

        \[\leadsto \left(\frac{1}{3} \cdot J\right) \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(\color{blue}{{\ell}^{2}} \cdot \ell\right)\right) \]
      5. associate-*r*N/A

        \[\leadsto \left(\frac{1}{3} \cdot J\right) \cdot \color{blue}{\left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{2}\right) \cdot \ell\right)} \]
      6. *-commutativeN/A

        \[\leadsto \left(\frac{1}{3} \cdot J\right) \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} \cdot \ell\right) \]
      7. associate-*l*N/A

        \[\leadsto \color{blue}{\left(\left(\frac{1}{3} \cdot J\right) \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \ell} \]
      8. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)\right)} \cdot \ell \]
      9. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \frac{1}{3}\right)} \cdot \ell \]
      10. associate-*l*N/A

        \[\leadsto \color{blue}{\left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \left(\frac{1}{3} \cdot \ell\right)} \]
      11. *-lowering-*.f64N/A

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

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

    if -9.99999999999999989e203 < l < -1150

    1. Initial program 100.0%

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

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      2. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      3. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      4. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      6. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \color{blue}{\left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      7. *-commutativeN/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{{\ell}^{2} \cdot \frac{1}{60}}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      8. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{{\ell}^{2} \cdot \frac{1}{60}}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      9. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{60}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      10. *-lowering-*.f6466.7

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

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

      \[\leadsto \color{blue}{\left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right) + J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)} + U \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) + \frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)} + U \]
      2. *-commutativeN/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) + \frac{-1}{8} \cdot \left(J \cdot \color{blue}{\left(\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) \cdot {K}^{2}\right)}\right)\right) + U \]
      3. associate-*r*N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) + \frac{-1}{8} \cdot \color{blue}{\left(\left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \cdot {K}^{2}\right)}\right) + U \]
      4. associate-*l*N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) + \color{blue}{\left(\frac{-1}{8} \cdot \left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot {K}^{2}}\right) + U \]
      5. +-lowering-+.f64N/A

        \[\leadsto \color{blue}{\left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) + \left(\frac{-1}{8} \cdot \left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot {K}^{2}\right)} + U \]
    8. Simplified20.6%

      \[\leadsto \color{blue}{\left(\ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right) + -0.125 \cdot \left(J \cdot \left(\left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right) \cdot \left(\ell \cdot \left(K \cdot K\right)\right)\right)\right)\right)} + U \]
    9. Taylor expanded in J around inf

      \[\leadsto \color{blue}{J \cdot \left(\frac{-1}{8} \cdot \left({K}^{2} \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) + \ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)} \]
    10. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{J \cdot \left(\frac{-1}{8} \cdot \left({K}^{2} \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) + \ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)} \]
      2. associate-*r*N/A

        \[\leadsto J \cdot \left(\color{blue}{\left(\frac{-1}{8} \cdot {K}^{2}\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)} + \ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) \]
      3. distribute-lft1-inN/A

        \[\leadsto J \cdot \color{blue}{\left(\left(\frac{-1}{8} \cdot {K}^{2} + 1\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)} \]
      4. +-commutativeN/A

        \[\leadsto J \cdot \left(\color{blue}{\left(1 + \frac{-1}{8} \cdot {K}^{2}\right)} \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto J \cdot \color{blue}{\left(\left(1 + \frac{-1}{8} \cdot {K}^{2}\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)} \]
      6. +-lowering-+.f64N/A

        \[\leadsto J \cdot \left(\color{blue}{\left(1 + \frac{-1}{8} \cdot {K}^{2}\right)} \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto J \cdot \left(\left(1 + \color{blue}{{K}^{2} \cdot \frac{-1}{8}}\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto J \cdot \left(\left(1 + \color{blue}{\left(K \cdot K\right)} \cdot \frac{-1}{8}\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \]
      9. associate-*l*N/A

        \[\leadsto J \cdot \left(\left(1 + \color{blue}{K \cdot \left(K \cdot \frac{-1}{8}\right)}\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\left(1 + \color{blue}{K \cdot \left(K \cdot \frac{-1}{8}\right)}\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\left(1 + K \cdot \color{blue}{\left(K \cdot \frac{-1}{8}\right)}\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\left(1 + K \cdot \left(K \cdot \frac{-1}{8}\right)\right) \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \]
    11. Simplified73.2%

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

    if -1150 < l < 1.26e14

    1. Initial program 80.2%

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

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

        \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{2}\right)}\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      2. associate-*r*N/A

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

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2}} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      4. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\ell \cdot \left(\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
      5. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      6. associate-*r*N/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \frac{1}{3}\right) \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      7. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2}\right)} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      8. distribute-rgt-outN/A

        \[\leadsto \ell \cdot \color{blue}{\left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \left(\frac{1}{3} \cdot {\ell}^{2} + 2\right)\right)} + U \]
      9. +-commutativeN/A

        \[\leadsto \ell \cdot \left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \color{blue}{\left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}\right) + U \]
      10. *-lowering-*.f64N/A

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

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

      \[\leadsto \ell \cdot \color{blue}{\left(2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
    7. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

        \[\leadsto \ell \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(2 \cdot J\right)}\right) + U \]
      5. *-lowering-*.f64N/A

        \[\leadsto \ell \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(2 \cdot J\right)\right)} + U \]
      6. cos-lowering-cos.f64N/A

        \[\leadsto \ell \cdot \left(\color{blue}{\cos \left(\frac{1}{2} \cdot K\right)} \cdot \left(2 \cdot J\right)\right) + U \]
      7. *-lowering-*.f64N/A

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

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

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

    if 1.26e14 < 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. Add Preprocessing
    3. Taylor expanded in l around 0

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

        \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{2}\right)}\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      2. associate-*r*N/A

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

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2}} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      4. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\ell \cdot \left(\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
      5. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      6. associate-*r*N/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \frac{1}{3}\right) \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      7. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2}\right)} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      8. distribute-rgt-outN/A

        \[\leadsto \ell \cdot \color{blue}{\left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \left(\frac{1}{3} \cdot {\ell}^{2} + 2\right)\right)} + U \]
      9. +-commutativeN/A

        \[\leadsto \ell \cdot \left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \color{blue}{\left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}\right) + U \]
      10. *-lowering-*.f64N/A

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

      \[\leadsto \color{blue}{\ell \cdot \left(\left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right)\right)} + U \]
    6. Taylor expanded in U around inf

      \[\leadsto \color{blue}{U \cdot \left(1 + \frac{J \cdot \left(\ell \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)}{U}\right)} \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{U \cdot \left(1 + \frac{J \cdot \left(\ell \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)}{U}\right)} \]
      2. +-lowering-+.f64N/A

        \[\leadsto U \cdot \color{blue}{\left(1 + \frac{J \cdot \left(\ell \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)}{U}\right)} \]
      3. /-lowering-/.f64N/A

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

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

      \[\leadsto U \cdot \color{blue}{\left(\frac{1}{3} \cdot \frac{J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)}{U}\right)} \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto U \cdot \color{blue}{\left(\frac{J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)}{U} \cdot \frac{1}{3}\right)} \]
      2. associate-*l/N/A

        \[\leadsto U \cdot \color{blue}{\frac{\left(J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \frac{1}{3}}{U}} \]
      3. associate-/l*N/A

        \[\leadsto U \cdot \color{blue}{\left(\left(J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto U \cdot \color{blue}{\left(\left(J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right)} \]
      5. *-commutativeN/A

        \[\leadsto U \cdot \left(\color{blue}{\left(\left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot J\right)} \cdot \frac{\frac{1}{3}}{U}\right) \]
      6. *-commutativeN/A

        \[\leadsto U \cdot \left(\left(\color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{3}\right)} \cdot J\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      7. associate-*l*N/A

        \[\leadsto U \cdot \left(\color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left({\ell}^{3} \cdot J\right)\right)} \cdot \frac{\frac{1}{3}}{U}\right) \]
      8. *-commutativeN/A

        \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(J \cdot {\ell}^{3}\right)}\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto U \cdot \left(\color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot {\ell}^{3}\right)\right)} \cdot \frac{\frac{1}{3}}{U}\right) \]
      10. cos-lowering-cos.f64N/A

        \[\leadsto U \cdot \left(\left(\color{blue}{\cos \left(\frac{1}{2} \cdot K\right)} \cdot \left(J \cdot {\ell}^{3}\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto U \cdot \left(\left(\cos \color{blue}{\left(\frac{1}{2} \cdot K\right)} \cdot \left(J \cdot {\ell}^{3}\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(J \cdot {\ell}^{3}\right)}\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      13. cube-multN/A

        \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot \color{blue}{\left(\ell \cdot \left(\ell \cdot \ell\right)\right)}\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      14. unpow2N/A

        \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot \left(\ell \cdot \color{blue}{{\ell}^{2}}\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot \color{blue}{\left(\ell \cdot {\ell}^{2}\right)}\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      16. unpow2N/A

        \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot \left(\ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      17. *-lowering-*.f64N/A

        \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot \left(\ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      18. /-lowering-/.f6493.2

        \[\leadsto U \cdot \left(\left(\cos \left(0.5 \cdot K\right) \cdot \left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\right) \cdot \color{blue}{\frac{0.3333333333333333}{U}}\right) \]
    11. Simplified93.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1 \cdot 10^{+204}:\\ \;\;\;\;\left(\ell \cdot 0.3333333333333333\right) \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot \left(\ell \cdot \ell\right)\right)\right)\\ \mathbf{elif}\;\ell \leq -1150:\\ \;\;\;\;J \cdot \left(\left(1 + K \cdot \left(K \cdot -0.125\right)\right) \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 1.26 \cdot 10^{+14}:\\ \;\;\;\;U + \ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(2 \cdot J\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(\left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\right) \cdot \frac{0.3333333333333333}{U}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 82.9% accurate, 2.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.005:\\ \;\;\;\;U + \ell \cdot \left(\left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right) \cdot \left(J + J \cdot \left(-0.125 \cdot \left(K \cdot K\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \ell \cdot \left(\ell \cdot \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right)\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= (cos (/ K 2.0)) -0.005)
   (+
    U
    (*
     l
     (*
      (+ 2.0 (* l (* l 0.3333333333333333)))
      (+ J (* J (* -0.125 (* K K)))))))
   (+
    U
    (*
     J
     (*
      l
      (+
       2.0
       (*
        (* l l)
        (+
         0.3333333333333333
         (*
          l
          (*
           l
           (+ 0.016666666666666666 (* (* l l) 0.0003968253968253968))))))))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (cos((K / 2.0)) <= -0.005) {
		tmp = U + (l * ((2.0 + (l * (l * 0.3333333333333333))) * (J + (J * (-0.125 * (K * K))))));
	} else {
		tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (l * (l * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))));
	}
	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 * ((2.0d0 + (l * (l * 0.3333333333333333d0))) * (j + (j * ((-0.125d0) * (k * k))))))
    else
        tmp = u + (j * (l * (2.0d0 + ((l * l) * (0.3333333333333333d0 + (l * (l * (0.016666666666666666d0 + ((l * l) * 0.0003968253968253968d0)))))))))
    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 * ((2.0 + (l * (l * 0.3333333333333333))) * (J + (J * (-0.125 * (K * K))))));
	} else {
		tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (l * (l * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))));
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if math.cos((K / 2.0)) <= -0.005:
		tmp = U + (l * ((2.0 + (l * (l * 0.3333333333333333))) * (J + (J * (-0.125 * (K * K))))))
	else:
		tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (l * (l * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))))
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (cos(Float64(K / 2.0)) <= -0.005)
		tmp = Float64(U + Float64(l * Float64(Float64(2.0 + Float64(l * Float64(l * 0.3333333333333333))) * Float64(J + Float64(J * Float64(-0.125 * Float64(K * K)))))));
	else
		tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(l * Float64(l * Float64(0.016666666666666666 + Float64(Float64(l * l) * 0.0003968253968253968))))))))));
	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 * ((2.0 + (l * (l * 0.3333333333333333))) * (J + (J * (-0.125 * (K * K))))));
	else
		tmp = U + (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + (l * (l * (0.016666666666666666 + ((l * l) * 0.0003968253968253968)))))))));
	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[(l * N[(N[(2.0 + N[(l * N[(l * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(J + N[(J * N[(-0.125 * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * N[(0.3333333333333333 + N[(l * N[(l * N[(0.016666666666666666 + N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0050000000000000001

    1. Initial program 88.3%

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

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

        \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{2}\right)}\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      2. associate-*r*N/A

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

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2}} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      4. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\ell \cdot \left(\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
      5. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      6. associate-*r*N/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \frac{1}{3}\right) \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      7. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2}\right)} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      8. distribute-rgt-outN/A

        \[\leadsto \ell \cdot \color{blue}{\left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \left(\frac{1}{3} \cdot {\ell}^{2} + 2\right)\right)} + U \]
      9. +-commutativeN/A

        \[\leadsto \ell \cdot \left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \color{blue}{\left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}\right) + U \]
      10. *-lowering-*.f64N/A

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

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

      \[\leadsto \ell \cdot \left(\color{blue}{\left(J + \frac{-1}{8} \cdot \left(J \cdot {K}^{2}\right)\right)} \cdot \left(2 + \ell \cdot \left(\ell \cdot \frac{1}{3}\right)\right)\right) + U \]
    7. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \ell \cdot \left(\left(J + \color{blue}{\left(\frac{-1}{8} \cdot J\right) \cdot {K}^{2}}\right) \cdot \left(2 + \ell \cdot \left(\ell \cdot \frac{1}{3}\right)\right)\right) + U \]
      2. +-lowering-+.f64N/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left(J + \left(\frac{-1}{8} \cdot J\right) \cdot {K}^{2}\right)} \cdot \left(2 + \ell \cdot \left(\ell \cdot \frac{1}{3}\right)\right)\right) + U \]
      3. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\left(J + \color{blue}{\left(J \cdot \frac{-1}{8}\right)} \cdot {K}^{2}\right) \cdot \left(2 + \ell \cdot \left(\ell \cdot \frac{1}{3}\right)\right)\right) + U \]
      4. associate-*l*N/A

        \[\leadsto \ell \cdot \left(\left(J + \color{blue}{J \cdot \left(\frac{-1}{8} \cdot {K}^{2}\right)}\right) \cdot \left(2 + \ell \cdot \left(\ell \cdot \frac{1}{3}\right)\right)\right) + U \]
      5. *-lowering-*.f64N/A

        \[\leadsto \ell \cdot \left(\left(J + \color{blue}{J \cdot \left(\frac{-1}{8} \cdot {K}^{2}\right)}\right) \cdot \left(2 + \ell \cdot \left(\ell \cdot \frac{1}{3}\right)\right)\right) + U \]
      6. *-lowering-*.f64N/A

        \[\leadsto \ell \cdot \left(\left(J + J \cdot \color{blue}{\left(\frac{-1}{8} \cdot {K}^{2}\right)}\right) \cdot \left(2 + \ell \cdot \left(\ell \cdot \frac{1}{3}\right)\right)\right) + U \]
      7. unpow2N/A

        \[\leadsto \ell \cdot \left(\left(J + J \cdot \left(\frac{-1}{8} \cdot \color{blue}{\left(K \cdot K\right)}\right)\right) \cdot \left(2 + \ell \cdot \left(\ell \cdot \frac{1}{3}\right)\right)\right) + U \]
      8. *-lowering-*.f6463.0

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

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

    if -0.0050000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

    1. Initial program 89.4%

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

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      2. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      3. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      4. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      6. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \color{blue}{\left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      7. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      8. associate-*l*N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      9. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      10. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \color{blue}{\left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      11. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \color{blue}{\left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      12. *-commutativeN/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      13. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      14. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{2520}\right)\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      15. *-lowering-*.f6496.0

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

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

      \[\leadsto \color{blue}{J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)} + U \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)} + U \]
      2. *-lowering-*.f64N/A

        \[\leadsto J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)} + U \]
      3. +-lowering-+.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \color{blue}{\left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)}\right) + U \]
      4. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right) + U \]
      5. unpow2N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right) + U \]
      6. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right) + U \]
      7. +-lowering-+.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \color{blue}{\left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right) + U \]
      8. unpow2N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right) + U \]
      9. associate-*l*N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) + U \]
      10. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) + U \]
      11. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \color{blue}{\left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) + U \]
      12. +-lowering-+.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \color{blue}{\left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)}\right)\right)\right)\right) + U \]
      13. *-commutativeN/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right) + U \]
      14. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right) + U \]
      15. unpow2N/A

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{2520}\right)\right)\right)\right)\right) + U \]
      16. *-lowering-*.f6492.6

        \[\leadsto J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \ell \cdot \left(\ell \cdot \left(0.016666666666666666 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot 0.0003968253968253968\right)\right)\right)\right)\right) + U \]
    8. Simplified92.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.005:\\ \;\;\;\;U + \ell \cdot \left(\left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right) \cdot \left(J + J \cdot \left(-0.125 \cdot \left(K \cdot K\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \ell \cdot \left(\ell \cdot \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right)\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 94.8% accurate, 2.4× speedup?

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

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

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

    \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  4. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. +-lowering-+.f64N/A

      \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. *-lowering-*.f64N/A

      \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. unpow2N/A

      \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    5. *-lowering-*.f64N/A

      \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    6. +-lowering-+.f64N/A

      \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \color{blue}{\left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    7. unpow2N/A

      \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    8. associate-*l*N/A

      \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    9. *-lowering-*.f64N/A

      \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    10. *-lowering-*.f64N/A

      \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \color{blue}{\left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    11. +-lowering-+.f64N/A

      \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \color{blue}{\left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)}\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    12. *-commutativeN/A

      \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    13. *-lowering-*.f64N/A

      \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{{\ell}^{2} \cdot \frac{1}{2520}}\right)\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    14. unpow2N/A

      \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{2520}\right)\right)\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    15. *-lowering-*.f6494.6

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

    \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \ell \cdot \left(\ell \cdot \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right)\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  6. Final simplification94.6%

    \[\leadsto U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \ell \cdot \left(\ell \cdot \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right)\right)\right)\right)\right) \]
  7. Add Preprocessing

Alternative 9: 76.2% accurate, 8.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\\ t_1 := J \cdot \left(\left(1 + K \cdot \left(K \cdot -0.125\right)\right) \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot t\_0\right)\right)\right)\\ \mathbf{if}\;\ell \leq -920:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\ell \leq 2.4 \cdot 10^{+67}:\\ \;\;\;\;U + \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot t\_0\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (+ 0.3333333333333333 (* (* l l) 0.016666666666666666)))
        (t_1
         (* J (* (+ 1.0 (* K (* K -0.125))) (* l (+ 2.0 (* (* l l) t_0)))))))
   (if (<= l -920.0)
     t_1
     (if (<= l 2.4e+67) (+ U (* l (* J (+ 2.0 (* l (* l t_0)))))) t_1))))
double code(double J, double l, double K, double U) {
	double t_0 = 0.3333333333333333 + ((l * l) * 0.016666666666666666);
	double t_1 = J * ((1.0 + (K * (K * -0.125))) * (l * (2.0 + ((l * l) * t_0))));
	double tmp;
	if (l <= -920.0) {
		tmp = t_1;
	} else if (l <= 2.4e+67) {
		tmp = U + (l * (J * (2.0 + (l * (l * t_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 = 0.3333333333333333d0 + ((l * l) * 0.016666666666666666d0)
    t_1 = j * ((1.0d0 + (k * (k * (-0.125d0)))) * (l * (2.0d0 + ((l * l) * t_0))))
    if (l <= (-920.0d0)) then
        tmp = t_1
    else if (l <= 2.4d+67) then
        tmp = u + (l * (j * (2.0d0 + (l * (l * t_0)))))
    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 = 0.3333333333333333 + ((l * l) * 0.016666666666666666);
	double t_1 = J * ((1.0 + (K * (K * -0.125))) * (l * (2.0 + ((l * l) * t_0))));
	double tmp;
	if (l <= -920.0) {
		tmp = t_1;
	} else if (l <= 2.4e+67) {
		tmp = U + (l * (J * (2.0 + (l * (l * t_0)))));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = 0.3333333333333333 + ((l * l) * 0.016666666666666666)
	t_1 = J * ((1.0 + (K * (K * -0.125))) * (l * (2.0 + ((l * l) * t_0))))
	tmp = 0
	if l <= -920.0:
		tmp = t_1
	elif l <= 2.4e+67:
		tmp = U + (l * (J * (2.0 + (l * (l * t_0)))))
	else:
		tmp = t_1
	return tmp
function code(J, l, K, U)
	t_0 = Float64(0.3333333333333333 + Float64(Float64(l * l) * 0.016666666666666666))
	t_1 = Float64(J * Float64(Float64(1.0 + Float64(K * Float64(K * -0.125))) * Float64(l * Float64(2.0 + Float64(Float64(l * l) * t_0)))))
	tmp = 0.0
	if (l <= -920.0)
		tmp = t_1;
	elseif (l <= 2.4e+67)
		tmp = Float64(U + Float64(l * Float64(J * Float64(2.0 + Float64(l * Float64(l * t_0))))));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = 0.3333333333333333 + ((l * l) * 0.016666666666666666);
	t_1 = J * ((1.0 + (K * (K * -0.125))) * (l * (2.0 + ((l * l) * t_0))));
	tmp = 0.0;
	if (l <= -920.0)
		tmp = t_1;
	elseif (l <= 2.4e+67)
		tmp = U + (l * (J * (2.0 + (l * (l * t_0)))));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(0.3333333333333333 + N[(N[(l * l), $MachinePrecision] * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(J * N[(N[(1.0 + N[(K * N[(K * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -920.0], t$95$1, If[LessEqual[l, 2.4e+67], N[(U + N[(l * N[(J * N[(2.0 + N[(l * N[(l * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\\
t_1 := J \cdot \left(\left(1 + K \cdot \left(K \cdot -0.125\right)\right) \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot t\_0\right)\right)\right)\\
\mathbf{if}\;\ell \leq -920:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;\ell \leq 2.4 \cdot 10^{+67}:\\
\;\;\;\;U + \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot t\_0\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -920 or 2.40000000000000002e67 < 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. Add Preprocessing
    3. Taylor expanded in l around 0

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      2. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      3. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      4. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      6. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \color{blue}{\left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      7. *-commutativeN/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{{\ell}^{2} \cdot \frac{1}{60}}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      8. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{{\ell}^{2} \cdot \frac{1}{60}}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      9. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{60}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      10. *-lowering-*.f6487.9

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

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

      \[\leadsto \color{blue}{\left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right) + J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)} + U \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) + \frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)} + U \]
      2. *-commutativeN/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) + \frac{-1}{8} \cdot \left(J \cdot \color{blue}{\left(\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) \cdot {K}^{2}\right)}\right)\right) + U \]
      3. associate-*r*N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) + \frac{-1}{8} \cdot \color{blue}{\left(\left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \cdot {K}^{2}\right)}\right) + U \]
      4. associate-*l*N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) + \color{blue}{\left(\frac{-1}{8} \cdot \left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot {K}^{2}}\right) + U \]
      5. +-lowering-+.f64N/A

        \[\leadsto \color{blue}{\left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) + \left(\frac{-1}{8} \cdot \left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right) \cdot {K}^{2}\right)} + U \]
    8. Simplified7.5%

      \[\leadsto \color{blue}{\left(\ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right) + -0.125 \cdot \left(J \cdot \left(\left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right) \cdot \left(\ell \cdot \left(K \cdot K\right)\right)\right)\right)\right)} + U \]
    9. Taylor expanded in J around inf

      \[\leadsto \color{blue}{J \cdot \left(\frac{-1}{8} \cdot \left({K}^{2} \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) + \ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)} \]
    10. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{J \cdot \left(\frac{-1}{8} \cdot \left({K}^{2} \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) + \ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)} \]
      2. associate-*r*N/A

        \[\leadsto J \cdot \left(\color{blue}{\left(\frac{-1}{8} \cdot {K}^{2}\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)} + \ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) \]
      3. distribute-lft1-inN/A

        \[\leadsto J \cdot \color{blue}{\left(\left(\frac{-1}{8} \cdot {K}^{2} + 1\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)} \]
      4. +-commutativeN/A

        \[\leadsto J \cdot \left(\color{blue}{\left(1 + \frac{-1}{8} \cdot {K}^{2}\right)} \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto J \cdot \color{blue}{\left(\left(1 + \frac{-1}{8} \cdot {K}^{2}\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)} \]
      6. +-lowering-+.f64N/A

        \[\leadsto J \cdot \left(\color{blue}{\left(1 + \frac{-1}{8} \cdot {K}^{2}\right)} \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto J \cdot \left(\left(1 + \color{blue}{{K}^{2} \cdot \frac{-1}{8}}\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto J \cdot \left(\left(1 + \color{blue}{\left(K \cdot K\right)} \cdot \frac{-1}{8}\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \]
      9. associate-*l*N/A

        \[\leadsto J \cdot \left(\left(1 + \color{blue}{K \cdot \left(K \cdot \frac{-1}{8}\right)}\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\left(1 + \color{blue}{K \cdot \left(K \cdot \frac{-1}{8}\right)}\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\left(1 + K \cdot \color{blue}{\left(K \cdot \frac{-1}{8}\right)}\right) \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto J \cdot \left(\left(1 + K \cdot \left(K \cdot \frac{-1}{8}\right)\right) \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \]
    11. Simplified75.7%

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

    if -920 < l < 2.40000000000000002e67

    1. Initial program 81.0%

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

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      2. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      3. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      4. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      6. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \color{blue}{\left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      7. *-commutativeN/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{{\ell}^{2} \cdot \frac{1}{60}}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      8. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{{\ell}^{2} \cdot \frac{1}{60}}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      9. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{60}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      10. *-lowering-*.f6495.0

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

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

      \[\leadsto \color{blue}{J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)} + U \]
    7. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \color{blue}{\left(J \cdot \ell\right) \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)} + U \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\ell \cdot J\right)} \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right) + U \]
      3. associate-*l*N/A

        \[\leadsto \color{blue}{\ell \cdot \left(J \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)} + U \]
      4. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\ell \cdot \left(J \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)} + U \]
      5. *-lowering-*.f64N/A

        \[\leadsto \ell \cdot \color{blue}{\left(J \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)} + U \]
      6. +-lowering-+.f64N/A

        \[\leadsto \ell \cdot \left(J \cdot \color{blue}{\left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}\right) + U \]
      7. unpow2N/A

        \[\leadsto \ell \cdot \left(J \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) + U \]
      8. associate-*l*N/A

        \[\leadsto \ell \cdot \left(J \cdot \left(2 + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}\right)\right) + U \]
      9. *-lowering-*.f64N/A

        \[\leadsto \ell \cdot \left(J \cdot \left(2 + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}\right)\right) + U \]
      10. *-lowering-*.f64N/A

        \[\leadsto \ell \cdot \left(J \cdot \left(2 + \ell \cdot \color{blue}{\left(\ell \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}\right)\right) + U \]
      11. +-lowering-+.f64N/A

        \[\leadsto \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \color{blue}{\left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)}\right)\right)\right) + U \]
      12. *-commutativeN/A

        \[\leadsto \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(\frac{1}{3} + \color{blue}{{\ell}^{2} \cdot \frac{1}{60}}\right)\right)\right)\right) + U \]
      13. *-lowering-*.f64N/A

        \[\leadsto \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(\frac{1}{3} + \color{blue}{{\ell}^{2} \cdot \frac{1}{60}}\right)\right)\right)\right) + U \]
      14. unpow2N/A

        \[\leadsto \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(\frac{1}{3} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{60}\right)\right)\right)\right) + U \]
      15. *-lowering-*.f6485.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -920:\\ \;\;\;\;J \cdot \left(\left(1 + K \cdot \left(K \cdot -0.125\right)\right) \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 2.4 \cdot 10^{+67}:\\ \;\;\;\;U + \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;J \cdot \left(\left(1 + K \cdot \left(K \cdot -0.125\right)\right) \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 75.2% accurate, 12.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 10^{+118}:\\ \;\;\;\;U + \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(\frac{0.3333333333333333}{U} \cdot \left(\left(1 + K \cdot \left(K \cdot -0.125\right)\right) \cdot \left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l 1e+118)
   (+
    U
    (*
     l
     (*
      J
      (+
       2.0
       (* l (* l (+ 0.3333333333333333 (* (* l l) 0.016666666666666666))))))))
   (*
    U
    (*
     (/ 0.3333333333333333 U)
     (* (+ 1.0 (* K (* K -0.125))) (* J (* l (* l l))))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= 1e+118) {
		tmp = U + (l * (J * (2.0 + (l * (l * (0.3333333333333333 + ((l * l) * 0.016666666666666666)))))));
	} else {
		tmp = U * ((0.3333333333333333 / U) * ((1.0 + (K * (K * -0.125))) * (J * (l * (l * l)))));
	}
	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 <= 1d+118) then
        tmp = u + (l * (j * (2.0d0 + (l * (l * (0.3333333333333333d0 + ((l * l) * 0.016666666666666666d0)))))))
    else
        tmp = u * ((0.3333333333333333d0 / u) * ((1.0d0 + (k * (k * (-0.125d0)))) * (j * (l * (l * l)))))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= 1e+118) {
		tmp = U + (l * (J * (2.0 + (l * (l * (0.3333333333333333 + ((l * l) * 0.016666666666666666)))))));
	} else {
		tmp = U * ((0.3333333333333333 / U) * ((1.0 + (K * (K * -0.125))) * (J * (l * (l * l)))));
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= 1e+118:
		tmp = U + (l * (J * (2.0 + (l * (l * (0.3333333333333333 + ((l * l) * 0.016666666666666666)))))))
	else:
		tmp = U * ((0.3333333333333333 / U) * ((1.0 + (K * (K * -0.125))) * (J * (l * (l * l)))))
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= 1e+118)
		tmp = Float64(U + Float64(l * Float64(J * Float64(2.0 + Float64(l * Float64(l * Float64(0.3333333333333333 + Float64(Float64(l * l) * 0.016666666666666666))))))));
	else
		tmp = Float64(U * Float64(Float64(0.3333333333333333 / U) * Float64(Float64(1.0 + Float64(K * Float64(K * -0.125))) * Float64(J * Float64(l * Float64(l * l))))));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= 1e+118)
		tmp = U + (l * (J * (2.0 + (l * (l * (0.3333333333333333 + ((l * l) * 0.016666666666666666)))))));
	else
		tmp = U * ((0.3333333333333333 / U) * ((1.0 + (K * (K * -0.125))) * (J * (l * (l * l)))));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, 1e+118], N[(U + N[(l * N[(J * N[(2.0 + N[(l * N[(l * N[(0.3333333333333333 + N[(N[(l * l), $MachinePrecision] * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U * N[(N[(0.3333333333333333 / U), $MachinePrecision] * N[(N[(1.0 + N[(K * N[(K * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(J * N[(l * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;U \cdot \left(\frac{0.3333333333333333}{U} \cdot \left(\left(1 + K \cdot \left(K \cdot -0.125\right)\right) \cdot \left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\right)\\


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

    1. Initial program 87.3%

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

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      2. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      3. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      4. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      6. +-lowering-+.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \color{blue}{\left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      7. *-commutativeN/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{{\ell}^{2} \cdot \frac{1}{60}}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      8. *-lowering-*.f64N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{{\ell}^{2} \cdot \frac{1}{60}}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      9. unpow2N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{60}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      10. *-lowering-*.f6490.6

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

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

      \[\leadsto \color{blue}{J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)} + U \]
    7. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \color{blue}{\left(J \cdot \ell\right) \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)} + U \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\ell \cdot J\right)} \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right) + U \]
      3. associate-*l*N/A

        \[\leadsto \color{blue}{\ell \cdot \left(J \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)} + U \]
      4. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\ell \cdot \left(J \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)} + U \]
      5. *-lowering-*.f64N/A

        \[\leadsto \ell \cdot \color{blue}{\left(J \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)} + U \]
      6. +-lowering-+.f64N/A

        \[\leadsto \ell \cdot \left(J \cdot \color{blue}{\left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}\right) + U \]
      7. unpow2N/A

        \[\leadsto \ell \cdot \left(J \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) + U \]
      8. associate-*l*N/A

        \[\leadsto \ell \cdot \left(J \cdot \left(2 + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}\right)\right) + U \]
      9. *-lowering-*.f64N/A

        \[\leadsto \ell \cdot \left(J \cdot \left(2 + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}\right)\right) + U \]
      10. *-lowering-*.f64N/A

        \[\leadsto \ell \cdot \left(J \cdot \left(2 + \ell \cdot \color{blue}{\left(\ell \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}\right)\right) + U \]
      11. +-lowering-+.f64N/A

        \[\leadsto \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \color{blue}{\left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)}\right)\right)\right) + U \]
      12. *-commutativeN/A

        \[\leadsto \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(\frac{1}{3} + \color{blue}{{\ell}^{2} \cdot \frac{1}{60}}\right)\right)\right)\right) + U \]
      13. *-lowering-*.f64N/A

        \[\leadsto \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(\frac{1}{3} + \color{blue}{{\ell}^{2} \cdot \frac{1}{60}}\right)\right)\right)\right) + U \]
      14. unpow2N/A

        \[\leadsto \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(\frac{1}{3} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{60}\right)\right)\right)\right) + U \]
      15. *-lowering-*.f6477.7

        \[\leadsto \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot 0.016666666666666666\right)\right)\right)\right) + U \]
    8. Simplified77.7%

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

    if 9.99999999999999967e117 < 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. Add Preprocessing
    3. Taylor expanded in l around 0

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

        \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{2}\right)}\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      2. associate-*r*N/A

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

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2}} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      4. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\ell \cdot \left(\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
      5. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      6. associate-*r*N/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \frac{1}{3}\right) \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      7. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2}\right)} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      8. distribute-rgt-outN/A

        \[\leadsto \ell \cdot \color{blue}{\left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \left(\frac{1}{3} \cdot {\ell}^{2} + 2\right)\right)} + U \]
      9. +-commutativeN/A

        \[\leadsto \ell \cdot \left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \color{blue}{\left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}\right) + U \]
      10. *-lowering-*.f64N/A

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

      \[\leadsto \color{blue}{\ell \cdot \left(\left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right)\right)} + U \]
    6. Taylor expanded in U around inf

      \[\leadsto \color{blue}{U \cdot \left(1 + \frac{J \cdot \left(\ell \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)}{U}\right)} \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{U \cdot \left(1 + \frac{J \cdot \left(\ell \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)}{U}\right)} \]
      2. +-lowering-+.f64N/A

        \[\leadsto U \cdot \color{blue}{\left(1 + \frac{J \cdot \left(\ell \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)}{U}\right)} \]
      3. /-lowering-/.f64N/A

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

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

      \[\leadsto U \cdot \color{blue}{\left(\frac{1}{3} \cdot \frac{J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)}{U}\right)} \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto U \cdot \color{blue}{\left(\frac{J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)}{U} \cdot \frac{1}{3}\right)} \]
      2. associate-*l/N/A

        \[\leadsto U \cdot \color{blue}{\frac{\left(J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \frac{1}{3}}{U}} \]
      3. associate-/l*N/A

        \[\leadsto U \cdot \color{blue}{\left(\left(J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto U \cdot \color{blue}{\left(\left(J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right)} \]
      5. *-commutativeN/A

        \[\leadsto U \cdot \left(\color{blue}{\left(\left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot J\right)} \cdot \frac{\frac{1}{3}}{U}\right) \]
      6. *-commutativeN/A

        \[\leadsto U \cdot \left(\left(\color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{3}\right)} \cdot J\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      7. associate-*l*N/A

        \[\leadsto U \cdot \left(\color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left({\ell}^{3} \cdot J\right)\right)} \cdot \frac{\frac{1}{3}}{U}\right) \]
      8. *-commutativeN/A

        \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(J \cdot {\ell}^{3}\right)}\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto U \cdot \left(\color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot {\ell}^{3}\right)\right)} \cdot \frac{\frac{1}{3}}{U}\right) \]
      10. cos-lowering-cos.f64N/A

        \[\leadsto U \cdot \left(\left(\color{blue}{\cos \left(\frac{1}{2} \cdot K\right)} \cdot \left(J \cdot {\ell}^{3}\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto U \cdot \left(\left(\cos \color{blue}{\left(\frac{1}{2} \cdot K\right)} \cdot \left(J \cdot {\ell}^{3}\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(J \cdot {\ell}^{3}\right)}\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      13. cube-multN/A

        \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot \color{blue}{\left(\ell \cdot \left(\ell \cdot \ell\right)\right)}\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      14. unpow2N/A

        \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot \left(\ell \cdot \color{blue}{{\ell}^{2}}\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot \color{blue}{\left(\ell \cdot {\ell}^{2}\right)}\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      16. unpow2N/A

        \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot \left(\ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      17. *-lowering-*.f64N/A

        \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot \left(\ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      18. /-lowering-/.f64100.0

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

      \[\leadsto U \cdot \color{blue}{\left(\left(\cos \left(0.5 \cdot K\right) \cdot \left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\right) \cdot \frac{0.3333333333333333}{U}\right)} \]
    12. Taylor expanded in K around 0

      \[\leadsto U \cdot \left(\left(\color{blue}{\left(1 + \frac{-1}{8} \cdot {K}^{2}\right)} \cdot \left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
    13. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto U \cdot \left(\left(\color{blue}{\left(1 + \frac{-1}{8} \cdot {K}^{2}\right)} \cdot \left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      2. *-commutativeN/A

        \[\leadsto U \cdot \left(\left(\left(1 + \color{blue}{{K}^{2} \cdot \frac{-1}{8}}\right) \cdot \left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      3. unpow2N/A

        \[\leadsto U \cdot \left(\left(\left(1 + \color{blue}{\left(K \cdot K\right)} \cdot \frac{-1}{8}\right) \cdot \left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      4. associate-*l*N/A

        \[\leadsto U \cdot \left(\left(\left(1 + \color{blue}{K \cdot \left(K \cdot \frac{-1}{8}\right)}\right) \cdot \left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto U \cdot \left(\left(\left(1 + \color{blue}{K \cdot \left(K \cdot \frac{-1}{8}\right)}\right) \cdot \left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      6. *-lowering-*.f6484.2

        \[\leadsto U \cdot \left(\left(\left(1 + K \cdot \color{blue}{\left(K \cdot -0.125\right)}\right) \cdot \left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\right) \cdot \frac{0.3333333333333333}{U}\right) \]
    14. Simplified84.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 10^{+118}:\\ \;\;\;\;U + \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(\frac{0.3333333333333333}{U} \cdot \left(\left(1 + K \cdot \left(K \cdot -0.125\right)\right) \cdot \left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 73.2% accurate, 16.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1300:\\ \;\;\;\;U \cdot \left(\left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right) \cdot \frac{0.3333333333333333}{U}\right)\\ \mathbf{elif}\;\ell \leq 4 \cdot 10^{+15}:\\ \;\;\;\;U + J \cdot \left(2 \cdot \ell\right)\\ \mathbf{else}:\\ \;\;\;\;J \cdot \left(\ell \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -1300.0)
   (* U (* (* J (* l (* l l))) (/ 0.3333333333333333 U)))
   (if (<= l 4e+15)
     (+ U (* J (* 2.0 l)))
     (* J (* l (* (* l l) 0.3333333333333333))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -1300.0) {
		tmp = U * ((J * (l * (l * l))) * (0.3333333333333333 / U));
	} else if (l <= 4e+15) {
		tmp = U + (J * (2.0 * l));
	} else {
		tmp = J * (l * ((l * l) * 0.3333333333333333));
	}
	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 <= (-1300.0d0)) then
        tmp = u * ((j * (l * (l * l))) * (0.3333333333333333d0 / u))
    else if (l <= 4d+15) then
        tmp = u + (j * (2.0d0 * l))
    else
        tmp = j * (l * ((l * l) * 0.3333333333333333d0))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -1300.0) {
		tmp = U * ((J * (l * (l * l))) * (0.3333333333333333 / U));
	} else if (l <= 4e+15) {
		tmp = U + (J * (2.0 * l));
	} else {
		tmp = J * (l * ((l * l) * 0.3333333333333333));
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -1300.0:
		tmp = U * ((J * (l * (l * l))) * (0.3333333333333333 / U))
	elif l <= 4e+15:
		tmp = U + (J * (2.0 * l))
	else:
		tmp = J * (l * ((l * l) * 0.3333333333333333))
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -1300.0)
		tmp = Float64(U * Float64(Float64(J * Float64(l * Float64(l * l))) * Float64(0.3333333333333333 / U)));
	elseif (l <= 4e+15)
		tmp = Float64(U + Float64(J * Float64(2.0 * l)));
	else
		tmp = Float64(J * Float64(l * Float64(Float64(l * l) * 0.3333333333333333)));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= -1300.0)
		tmp = U * ((J * (l * (l * l))) * (0.3333333333333333 / U));
	elseif (l <= 4e+15)
		tmp = U + (J * (2.0 * l));
	else
		tmp = J * (l * ((l * l) * 0.3333333333333333));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -1300.0], N[(U * N[(N[(J * N[(l * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.3333333333333333 / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 4e+15], N[(U + N[(J * N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(J * N[(l * N[(N[(l * l), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1300:\\
\;\;\;\;U \cdot \left(\left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right) \cdot \frac{0.3333333333333333}{U}\right)\\

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

\mathbf{else}:\\
\;\;\;\;J \cdot \left(\ell \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)\\


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

    1. Initial program 100.0%

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

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

        \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{2}\right)}\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      2. associate-*r*N/A

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

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2}} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      4. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\ell \cdot \left(\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
      5. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      6. associate-*r*N/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \frac{1}{3}\right) \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      7. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2}\right)} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      8. distribute-rgt-outN/A

        \[\leadsto \ell \cdot \color{blue}{\left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \left(\frac{1}{3} \cdot {\ell}^{2} + 2\right)\right)} + U \]
      9. +-commutativeN/A

        \[\leadsto \ell \cdot \left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \color{blue}{\left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}\right) + U \]
      10. *-lowering-*.f64N/A

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

      \[\leadsto \color{blue}{\ell \cdot \left(\left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right)\right)} + U \]
    6. Taylor expanded in U around inf

      \[\leadsto \color{blue}{U \cdot \left(1 + \frac{J \cdot \left(\ell \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)}{U}\right)} \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{U \cdot \left(1 + \frac{J \cdot \left(\ell \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)}{U}\right)} \]
      2. +-lowering-+.f64N/A

        \[\leadsto U \cdot \color{blue}{\left(1 + \frac{J \cdot \left(\ell \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)}{U}\right)} \]
      3. /-lowering-/.f64N/A

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

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

      \[\leadsto U \cdot \color{blue}{\left(\frac{1}{3} \cdot \frac{J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)}{U}\right)} \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto U \cdot \color{blue}{\left(\frac{J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)}{U} \cdot \frac{1}{3}\right)} \]
      2. associate-*l/N/A

        \[\leadsto U \cdot \color{blue}{\frac{\left(J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \frac{1}{3}}{U}} \]
      3. associate-/l*N/A

        \[\leadsto U \cdot \color{blue}{\left(\left(J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto U \cdot \color{blue}{\left(\left(J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right)} \]
      5. *-commutativeN/A

        \[\leadsto U \cdot \left(\color{blue}{\left(\left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot J\right)} \cdot \frac{\frac{1}{3}}{U}\right) \]
      6. *-commutativeN/A

        \[\leadsto U \cdot \left(\left(\color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{3}\right)} \cdot J\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      7. associate-*l*N/A

        \[\leadsto U \cdot \left(\color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left({\ell}^{3} \cdot J\right)\right)} \cdot \frac{\frac{1}{3}}{U}\right) \]
      8. *-commutativeN/A

        \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(J \cdot {\ell}^{3}\right)}\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto U \cdot \left(\color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot {\ell}^{3}\right)\right)} \cdot \frac{\frac{1}{3}}{U}\right) \]
      10. cos-lowering-cos.f64N/A

        \[\leadsto U \cdot \left(\left(\color{blue}{\cos \left(\frac{1}{2} \cdot K\right)} \cdot \left(J \cdot {\ell}^{3}\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto U \cdot \left(\left(\cos \color{blue}{\left(\frac{1}{2} \cdot K\right)} \cdot \left(J \cdot {\ell}^{3}\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(J \cdot {\ell}^{3}\right)}\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      13. cube-multN/A

        \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot \color{blue}{\left(\ell \cdot \left(\ell \cdot \ell\right)\right)}\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      14. unpow2N/A

        \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot \left(\ell \cdot \color{blue}{{\ell}^{2}}\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot \color{blue}{\left(\ell \cdot {\ell}^{2}\right)}\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      16. unpow2N/A

        \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot \left(\ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      17. *-lowering-*.f64N/A

        \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot \left(\ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      18. /-lowering-/.f6474.1

        \[\leadsto U \cdot \left(\left(\cos \left(0.5 \cdot K\right) \cdot \left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\right) \cdot \color{blue}{\frac{0.3333333333333333}{U}}\right) \]
    11. Simplified74.1%

      \[\leadsto U \cdot \color{blue}{\left(\left(\cos \left(0.5 \cdot K\right) \cdot \left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\right) \cdot \frac{0.3333333333333333}{U}\right)} \]
    12. Taylor expanded in K around 0

      \[\leadsto U \cdot \left(\color{blue}{\left(J \cdot {\ell}^{3}\right)} \cdot \frac{\frac{1}{3}}{U}\right) \]
    13. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto U \cdot \left(\color{blue}{\left(J \cdot {\ell}^{3}\right)} \cdot \frac{\frac{1}{3}}{U}\right) \]
      2. cube-multN/A

        \[\leadsto U \cdot \left(\left(J \cdot \color{blue}{\left(\ell \cdot \left(\ell \cdot \ell\right)\right)}\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      3. unpow2N/A

        \[\leadsto U \cdot \left(\left(J \cdot \left(\ell \cdot \color{blue}{{\ell}^{2}}\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto U \cdot \left(\left(J \cdot \color{blue}{\left(\ell \cdot {\ell}^{2}\right)}\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      5. unpow2N/A

        \[\leadsto U \cdot \left(\left(J \cdot \left(\ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
      6. *-lowering-*.f6456.9

        \[\leadsto U \cdot \left(\left(J \cdot \left(\ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right) \cdot \frac{0.3333333333333333}{U}\right) \]
    14. Simplified56.9%

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

    if -1300 < l < 4e15

    1. Initial program 80.3%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*l*N/A

        \[\leadsto \color{blue}{J \cdot \left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right)} + U \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J} + U \]
      3. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J} + U \]
      4. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right)} \cdot J + U \]
      5. sinh-undefN/A

        \[\leadsto \left(\color{blue}{\left(2 \cdot \sinh \ell\right)} \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J + U \]
      6. *-lowering-*.f64N/A

        \[\leadsto \left(\color{blue}{\left(2 \cdot \sinh \ell\right)} \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J + U \]
      7. sinh-lowering-sinh.f64N/A

        \[\leadsto \left(\left(2 \cdot \color{blue}{\sinh \ell}\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J + U \]
      8. cos-lowering-cos.f64N/A

        \[\leadsto \left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)}\right) \cdot J + U \]
      9. /-lowering-/.f6499.9

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

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

      \[\leadsto \left(\color{blue}{\left(2 \cdot \ell\right)} \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J + U \]
    6. Step-by-step derivation
      1. *-lowering-*.f6496.0

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

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

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

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

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

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

    if 4e15 < 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. Add Preprocessing
    3. Taylor expanded in l around 0

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

        \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{2}\right)}\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      2. associate-*r*N/A

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

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2}} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      4. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\ell \cdot \left(\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
      5. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      6. associate-*r*N/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \frac{1}{3}\right) \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      7. *-commutativeN/A

        \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2}\right)} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
      8. distribute-rgt-outN/A

        \[\leadsto \ell \cdot \color{blue}{\left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \left(\frac{1}{3} \cdot {\ell}^{2} + 2\right)\right)} + U \]
      9. +-commutativeN/A

        \[\leadsto \ell \cdot \left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \color{blue}{\left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}\right) + U \]
      10. *-lowering-*.f64N/A

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{3} \cdot \left(J \cdot {\ell}^{3}\right)} \]
      3. Step-by-step derivation
        1. associate-*r*N/A

          \[\leadsto \color{blue}{\left(\frac{1}{3} \cdot J\right) \cdot {\ell}^{3}} \]
        2. *-commutativeN/A

          \[\leadsto \color{blue}{\left(J \cdot \frac{1}{3}\right)} \cdot {\ell}^{3} \]
        3. associate-*l*N/A

          \[\leadsto \color{blue}{J \cdot \left(\frac{1}{3} \cdot {\ell}^{3}\right)} \]
        4. unpow3N/A

          \[\leadsto J \cdot \left(\frac{1}{3} \cdot \color{blue}{\left(\left(\ell \cdot \ell\right) \cdot \ell\right)}\right) \]
        5. unpow2N/A

          \[\leadsto J \cdot \left(\frac{1}{3} \cdot \left(\color{blue}{{\ell}^{2}} \cdot \ell\right)\right) \]
        6. associate-*r*N/A

          \[\leadsto J \cdot \color{blue}{\left(\left(\frac{1}{3} \cdot {\ell}^{2}\right) \cdot \ell\right)} \]
        7. *-lowering-*.f64N/A

          \[\leadsto \color{blue}{J \cdot \left(\left(\frac{1}{3} \cdot {\ell}^{2}\right) \cdot \ell\right)} \]
        8. associate-*r*N/A

          \[\leadsto J \cdot \color{blue}{\left(\frac{1}{3} \cdot \left({\ell}^{2} \cdot \ell\right)\right)} \]
        9. unpow2N/A

          \[\leadsto J \cdot \left(\frac{1}{3} \cdot \left(\color{blue}{\left(\ell \cdot \ell\right)} \cdot \ell\right)\right) \]
        10. unpow3N/A

          \[\leadsto J \cdot \left(\frac{1}{3} \cdot \color{blue}{{\ell}^{3}}\right) \]
        11. cube-multN/A

          \[\leadsto J \cdot \left(\frac{1}{3} \cdot \color{blue}{\left(\ell \cdot \left(\ell \cdot \ell\right)\right)}\right) \]
        12. unpow2N/A

          \[\leadsto J \cdot \left(\frac{1}{3} \cdot \left(\ell \cdot \color{blue}{{\ell}^{2}}\right)\right) \]
        13. associate-*r*N/A

          \[\leadsto J \cdot \color{blue}{\left(\left(\frac{1}{3} \cdot \ell\right) \cdot {\ell}^{2}\right)} \]
        14. *-commutativeN/A

          \[\leadsto J \cdot \left(\color{blue}{\left(\ell \cdot \frac{1}{3}\right)} \cdot {\ell}^{2}\right) \]
        15. associate-*r*N/A

          \[\leadsto J \cdot \color{blue}{\left(\ell \cdot \left(\frac{1}{3} \cdot {\ell}^{2}\right)\right)} \]
        16. *-lowering-*.f64N/A

          \[\leadsto J \cdot \color{blue}{\left(\ell \cdot \left(\frac{1}{3} \cdot {\ell}^{2}\right)\right)} \]
        17. *-lowering-*.f64N/A

          \[\leadsto J \cdot \left(\ell \cdot \color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2}\right)}\right) \]
        18. unpow2N/A

          \[\leadsto J \cdot \left(\ell \cdot \left(\frac{1}{3} \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right) \]
        19. *-lowering-*.f6462.8

          \[\leadsto J \cdot \left(\ell \cdot \left(0.3333333333333333 \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right) \]
      4. Simplified62.8%

        \[\leadsto \color{blue}{J \cdot \left(\ell \cdot \left(0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)} \]
    8. Recombined 3 regimes into one program.
    9. Final simplification74.3%

      \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1300:\\ \;\;\;\;U \cdot \left(\left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right) \cdot \frac{0.3333333333333333}{U}\right)\\ \mathbf{elif}\;\ell \leq 4 \cdot 10^{+15}:\\ \;\;\;\;U + J \cdot \left(2 \cdot \ell\right)\\ \mathbf{else}:\\ \;\;\;\;J \cdot \left(\ell \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)\\ \end{array} \]
    10. Add Preprocessing

    Alternative 12: 72.4% accurate, 16.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := J \cdot \left(\ell \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)\\ \mathbf{if}\;\ell \leq -2.3 \cdot 10^{+40}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq 1.45 \cdot 10^{+14}:\\ \;\;\;\;U + J \cdot \left(2 \cdot \ell\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (J l K U)
     :precision binary64
     (let* ((t_0 (* J (* l (* (* l l) 0.3333333333333333)))))
       (if (<= l -2.3e+40) t_0 (if (<= l 1.45e+14) (+ U (* J (* 2.0 l))) t_0))))
    double code(double J, double l, double K, double U) {
    	double t_0 = J * (l * ((l * l) * 0.3333333333333333));
    	double tmp;
    	if (l <= -2.3e+40) {
    		tmp = t_0;
    	} else if (l <= 1.45e+14) {
    		tmp = U + (J * (2.0 * l));
    	} 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 = j * (l * ((l * l) * 0.3333333333333333d0))
        if (l <= (-2.3d+40)) then
            tmp = t_0
        else if (l <= 1.45d+14) then
            tmp = u + (j * (2.0d0 * l))
        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 = J * (l * ((l * l) * 0.3333333333333333));
    	double tmp;
    	if (l <= -2.3e+40) {
    		tmp = t_0;
    	} else if (l <= 1.45e+14) {
    		tmp = U + (J * (2.0 * l));
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    def code(J, l, K, U):
    	t_0 = J * (l * ((l * l) * 0.3333333333333333))
    	tmp = 0
    	if l <= -2.3e+40:
    		tmp = t_0
    	elif l <= 1.45e+14:
    		tmp = U + (J * (2.0 * l))
    	else:
    		tmp = t_0
    	return tmp
    
    function code(J, l, K, U)
    	t_0 = Float64(J * Float64(l * Float64(Float64(l * l) * 0.3333333333333333)))
    	tmp = 0.0
    	if (l <= -2.3e+40)
    		tmp = t_0;
    	elseif (l <= 1.45e+14)
    		tmp = Float64(U + Float64(J * Float64(2.0 * l)));
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(J, l, K, U)
    	t_0 = J * (l * ((l * l) * 0.3333333333333333));
    	tmp = 0.0;
    	if (l <= -2.3e+40)
    		tmp = t_0;
    	elseif (l <= 1.45e+14)
    		tmp = U + (J * (2.0 * l));
    	else
    		tmp = t_0;
    	end
    	tmp_2 = tmp;
    end
    
    code[J_, l_, K_, U_] := Block[{t$95$0 = N[(J * N[(l * N[(N[(l * l), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.3e+40], t$95$0, If[LessEqual[l, 1.45e+14], N[(U + N[(J * N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := J \cdot \left(\ell \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)\\
    \mathbf{if}\;\ell \leq -2.3 \cdot 10^{+40}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;\ell \leq 1.45 \cdot 10^{+14}:\\
    \;\;\;\;U + J \cdot \left(2 \cdot \ell\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if l < -2.29999999999999994e40 or 1.45e14 < 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. Add Preprocessing
      3. Taylor expanded in l around 0

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

          \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{2}\right)}\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
        2. associate-*r*N/A

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

          \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2}} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
        4. *-lowering-*.f64N/A

          \[\leadsto \color{blue}{\ell \cdot \left(\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
        5. *-commutativeN/A

          \[\leadsto \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
        6. associate-*r*N/A

          \[\leadsto \ell \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \frac{1}{3}\right) \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
        7. *-commutativeN/A

          \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2}\right)} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
        8. distribute-rgt-outN/A

          \[\leadsto \ell \cdot \color{blue}{\left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \left(\frac{1}{3} \cdot {\ell}^{2} + 2\right)\right)} + U \]
        9. +-commutativeN/A

          \[\leadsto \ell \cdot \left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \color{blue}{\left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}\right) + U \]
        10. *-lowering-*.f64N/A

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

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

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

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

          \[\leadsto \color{blue}{\frac{1}{3} \cdot \left(J \cdot {\ell}^{3}\right)} \]
        3. Step-by-step derivation
          1. associate-*r*N/A

            \[\leadsto \color{blue}{\left(\frac{1}{3} \cdot J\right) \cdot {\ell}^{3}} \]
          2. *-commutativeN/A

            \[\leadsto \color{blue}{\left(J \cdot \frac{1}{3}\right)} \cdot {\ell}^{3} \]
          3. associate-*l*N/A

            \[\leadsto \color{blue}{J \cdot \left(\frac{1}{3} \cdot {\ell}^{3}\right)} \]
          4. unpow3N/A

            \[\leadsto J \cdot \left(\frac{1}{3} \cdot \color{blue}{\left(\left(\ell \cdot \ell\right) \cdot \ell\right)}\right) \]
          5. unpow2N/A

            \[\leadsto J \cdot \left(\frac{1}{3} \cdot \left(\color{blue}{{\ell}^{2}} \cdot \ell\right)\right) \]
          6. associate-*r*N/A

            \[\leadsto J \cdot \color{blue}{\left(\left(\frac{1}{3} \cdot {\ell}^{2}\right) \cdot \ell\right)} \]
          7. *-lowering-*.f64N/A

            \[\leadsto \color{blue}{J \cdot \left(\left(\frac{1}{3} \cdot {\ell}^{2}\right) \cdot \ell\right)} \]
          8. associate-*r*N/A

            \[\leadsto J \cdot \color{blue}{\left(\frac{1}{3} \cdot \left({\ell}^{2} \cdot \ell\right)\right)} \]
          9. unpow2N/A

            \[\leadsto J \cdot \left(\frac{1}{3} \cdot \left(\color{blue}{\left(\ell \cdot \ell\right)} \cdot \ell\right)\right) \]
          10. unpow3N/A

            \[\leadsto J \cdot \left(\frac{1}{3} \cdot \color{blue}{{\ell}^{3}}\right) \]
          11. cube-multN/A

            \[\leadsto J \cdot \left(\frac{1}{3} \cdot \color{blue}{\left(\ell \cdot \left(\ell \cdot \ell\right)\right)}\right) \]
          12. unpow2N/A

            \[\leadsto J \cdot \left(\frac{1}{3} \cdot \left(\ell \cdot \color{blue}{{\ell}^{2}}\right)\right) \]
          13. associate-*r*N/A

            \[\leadsto J \cdot \color{blue}{\left(\left(\frac{1}{3} \cdot \ell\right) \cdot {\ell}^{2}\right)} \]
          14. *-commutativeN/A

            \[\leadsto J \cdot \left(\color{blue}{\left(\ell \cdot \frac{1}{3}\right)} \cdot {\ell}^{2}\right) \]
          15. associate-*r*N/A

            \[\leadsto J \cdot \color{blue}{\left(\ell \cdot \left(\frac{1}{3} \cdot {\ell}^{2}\right)\right)} \]
          16. *-lowering-*.f64N/A

            \[\leadsto J \cdot \color{blue}{\left(\ell \cdot \left(\frac{1}{3} \cdot {\ell}^{2}\right)\right)} \]
          17. *-lowering-*.f64N/A

            \[\leadsto J \cdot \left(\ell \cdot \color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2}\right)}\right) \]
          18. unpow2N/A

            \[\leadsto J \cdot \left(\ell \cdot \left(\frac{1}{3} \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right) \]
          19. *-lowering-*.f6461.6

            \[\leadsto J \cdot \left(\ell \cdot \left(0.3333333333333333 \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right) \]
        4. Simplified61.6%

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

        if -2.29999999999999994e40 < l < 1.45e14

        1. Initial program 81.6%

          \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. associate-*l*N/A

            \[\leadsto \color{blue}{J \cdot \left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right)} + U \]
          2. *-commutativeN/A

            \[\leadsto \color{blue}{\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J} + U \]
          3. *-lowering-*.f64N/A

            \[\leadsto \color{blue}{\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J} + U \]
          4. *-lowering-*.f64N/A

            \[\leadsto \color{blue}{\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right)} \cdot J + U \]
          5. sinh-undefN/A

            \[\leadsto \left(\color{blue}{\left(2 \cdot \sinh \ell\right)} \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J + U \]
          6. *-lowering-*.f64N/A

            \[\leadsto \left(\color{blue}{\left(2 \cdot \sinh \ell\right)} \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J + U \]
          7. sinh-lowering-sinh.f64N/A

            \[\leadsto \left(\left(2 \cdot \color{blue}{\sinh \ell}\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J + U \]
          8. cos-lowering-cos.f64N/A

            \[\leadsto \left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)}\right) \cdot J + U \]
          9. /-lowering-/.f6499.9

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

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

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

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

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

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

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

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.3 \cdot 10^{+40}:\\ \;\;\;\;J \cdot \left(\ell \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)\\ \mathbf{elif}\;\ell \leq 1.45 \cdot 10^{+14}:\\ \;\;\;\;U + J \cdot \left(2 \cdot \ell\right)\\ \mathbf{else}:\\ \;\;\;\;J \cdot \left(\ell \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)\\ \end{array} \]
      10. Add Preprocessing

      Alternative 13: 75.3% accurate, 16.4× speedup?

      \[\begin{array}{l} \\ U + \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right) \end{array} \]
      (FPCore (J l K U)
       :precision binary64
       (+
        U
        (*
         l
         (*
          J
          (+
           2.0
           (* l (* l (+ 0.3333333333333333 (* (* l l) 0.016666666666666666)))))))))
      double code(double J, double l, double K, double U) {
      	return U + (l * (J * (2.0 + (l * (l * (0.3333333333333333 + ((l * l) * 0.016666666666666666)))))));
      }
      
      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 + (l * (l * (0.3333333333333333d0 + ((l * l) * 0.016666666666666666d0)))))))
      end function
      
      public static double code(double J, double l, double K, double U) {
      	return U + (l * (J * (2.0 + (l * (l * (0.3333333333333333 + ((l * l) * 0.016666666666666666)))))));
      }
      
      def code(J, l, K, U):
      	return U + (l * (J * (2.0 + (l * (l * (0.3333333333333333 + ((l * l) * 0.016666666666666666)))))))
      
      function code(J, l, K, U)
      	return Float64(U + Float64(l * Float64(J * Float64(2.0 + Float64(l * Float64(l * Float64(0.3333333333333333 + Float64(Float64(l * l) * 0.016666666666666666))))))))
      end
      
      function tmp = code(J, l, K, U)
      	tmp = U + (l * (J * (2.0 + (l * (l * (0.3333333333333333 + ((l * l) * 0.016666666666666666)))))));
      end
      
      code[J_, l_, K_, U_] := N[(U + N[(l * N[(J * N[(2.0 + N[(l * N[(l * N[(0.3333333333333333 + N[(N[(l * l), $MachinePrecision] * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      U + \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right)
      \end{array}
      
      Derivation
      1. Initial program 89.2%

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

        \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      4. Step-by-step derivation
        1. *-lowering-*.f64N/A

          \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
        2. +-lowering-+.f64N/A

          \[\leadsto \left(J \cdot \left(\ell \cdot \color{blue}{\left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
        3. *-lowering-*.f64N/A

          \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
        4. unpow2N/A

          \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
        5. *-lowering-*.f64N/A

          \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
        6. +-lowering-+.f64N/A

          \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \color{blue}{\left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
        7. *-commutativeN/A

          \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{{\ell}^{2} \cdot \frac{1}{60}}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
        8. *-lowering-*.f64N/A

          \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{{\ell}^{2} \cdot \frac{1}{60}}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
        9. unpow2N/A

          \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{60}\right)\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
        10. *-lowering-*.f6492.0

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

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

        \[\leadsto \color{blue}{J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)} + U \]
      7. Step-by-step derivation
        1. associate-*r*N/A

          \[\leadsto \color{blue}{\left(J \cdot \ell\right) \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)} + U \]
        2. *-commutativeN/A

          \[\leadsto \color{blue}{\left(\ell \cdot J\right)} \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right) + U \]
        3. associate-*l*N/A

          \[\leadsto \color{blue}{\ell \cdot \left(J \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)} + U \]
        4. *-lowering-*.f64N/A

          \[\leadsto \color{blue}{\ell \cdot \left(J \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)} + U \]
        5. *-lowering-*.f64N/A

          \[\leadsto \ell \cdot \color{blue}{\left(J \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)} + U \]
        6. +-lowering-+.f64N/A

          \[\leadsto \ell \cdot \left(J \cdot \color{blue}{\left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}\right) + U \]
        7. unpow2N/A

          \[\leadsto \ell \cdot \left(J \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right) + U \]
        8. associate-*l*N/A

          \[\leadsto \ell \cdot \left(J \cdot \left(2 + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}\right)\right) + U \]
        9. *-lowering-*.f64N/A

          \[\leadsto \ell \cdot \left(J \cdot \left(2 + \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}\right)\right) + U \]
        10. *-lowering-*.f64N/A

          \[\leadsto \ell \cdot \left(J \cdot \left(2 + \ell \cdot \color{blue}{\left(\ell \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)}\right)\right) + U \]
        11. +-lowering-+.f64N/A

          \[\leadsto \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \color{blue}{\left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)}\right)\right)\right) + U \]
        12. *-commutativeN/A

          \[\leadsto \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(\frac{1}{3} + \color{blue}{{\ell}^{2} \cdot \frac{1}{60}}\right)\right)\right)\right) + U \]
        13. *-lowering-*.f64N/A

          \[\leadsto \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(\frac{1}{3} + \color{blue}{{\ell}^{2} \cdot \frac{1}{60}}\right)\right)\right)\right) + U \]
        14. unpow2N/A

          \[\leadsto \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(\frac{1}{3} + \color{blue}{\left(\ell \cdot \ell\right)} \cdot \frac{1}{60}\right)\right)\right)\right) + U \]
        15. *-lowering-*.f6476.0

          \[\leadsto \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \color{blue}{\left(\ell \cdot \ell\right)} \cdot 0.016666666666666666\right)\right)\right)\right) + U \]
      8. Simplified76.0%

        \[\leadsto \color{blue}{\ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right)} + U \]
      9. Final simplification76.0%

        \[\leadsto U + \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right) \]
      10. Add Preprocessing

      Alternative 14: 72.3% accurate, 17.3× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1850:\\ \;\;\;\;U \cdot \left(\left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right) \cdot \frac{0.3333333333333333}{U}\right)\\ \mathbf{else}:\\ \;\;\;\;U + \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right)\right)\\ \end{array} \end{array} \]
      (FPCore (J l K U)
       :precision binary64
       (if (<= l -1850.0)
         (* U (* (* J (* l (* l l))) (/ 0.3333333333333333 U)))
         (+ U (* l (* J (+ 2.0 (* l (* l 0.3333333333333333))))))))
      double code(double J, double l, double K, double U) {
      	double tmp;
      	if (l <= -1850.0) {
      		tmp = U * ((J * (l * (l * l))) * (0.3333333333333333 / U));
      	} else {
      		tmp = U + (l * (J * (2.0 + (l * (l * 0.3333333333333333)))));
      	}
      	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 <= (-1850.0d0)) then
              tmp = u * ((j * (l * (l * l))) * (0.3333333333333333d0 / u))
          else
              tmp = u + (l * (j * (2.0d0 + (l * (l * 0.3333333333333333d0)))))
          end if
          code = tmp
      end function
      
      public static double code(double J, double l, double K, double U) {
      	double tmp;
      	if (l <= -1850.0) {
      		tmp = U * ((J * (l * (l * l))) * (0.3333333333333333 / U));
      	} else {
      		tmp = U + (l * (J * (2.0 + (l * (l * 0.3333333333333333)))));
      	}
      	return tmp;
      }
      
      def code(J, l, K, U):
      	tmp = 0
      	if l <= -1850.0:
      		tmp = U * ((J * (l * (l * l))) * (0.3333333333333333 / U))
      	else:
      		tmp = U + (l * (J * (2.0 + (l * (l * 0.3333333333333333)))))
      	return tmp
      
      function code(J, l, K, U)
      	tmp = 0.0
      	if (l <= -1850.0)
      		tmp = Float64(U * Float64(Float64(J * Float64(l * Float64(l * l))) * Float64(0.3333333333333333 / U)));
      	else
      		tmp = Float64(U + Float64(l * Float64(J * Float64(2.0 + Float64(l * Float64(l * 0.3333333333333333))))));
      	end
      	return tmp
      end
      
      function tmp_2 = code(J, l, K, U)
      	tmp = 0.0;
      	if (l <= -1850.0)
      		tmp = U * ((J * (l * (l * l))) * (0.3333333333333333 / U));
      	else
      		tmp = U + (l * (J * (2.0 + (l * (l * 0.3333333333333333)))));
      	end
      	tmp_2 = tmp;
      end
      
      code[J_, l_, K_, U_] := If[LessEqual[l, -1850.0], N[(U * N[(N[(J * N[(l * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.3333333333333333 / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(l * N[(J * N[(2.0 + N[(l * N[(l * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;\ell \leq -1850:\\
      \;\;\;\;U \cdot \left(\left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right) \cdot \frac{0.3333333333333333}{U}\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;U + \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right)\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if l < -1850

        1. Initial program 100.0%

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

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

            \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{2}\right)}\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
          2. associate-*r*N/A

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

            \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2}} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
          4. *-lowering-*.f64N/A

            \[\leadsto \color{blue}{\ell \cdot \left(\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
          5. *-commutativeN/A

            \[\leadsto \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
          6. associate-*r*N/A

            \[\leadsto \ell \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \frac{1}{3}\right) \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
          7. *-commutativeN/A

            \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2}\right)} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
          8. distribute-rgt-outN/A

            \[\leadsto \ell \cdot \color{blue}{\left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \left(\frac{1}{3} \cdot {\ell}^{2} + 2\right)\right)} + U \]
          9. +-commutativeN/A

            \[\leadsto \ell \cdot \left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \color{blue}{\left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}\right) + U \]
          10. *-lowering-*.f64N/A

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

          \[\leadsto \color{blue}{\ell \cdot \left(\left(J \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right)\right)} + U \]
        6. Taylor expanded in U around inf

          \[\leadsto \color{blue}{U \cdot \left(1 + \frac{J \cdot \left(\ell \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)}{U}\right)} \]
        7. Step-by-step derivation
          1. *-lowering-*.f64N/A

            \[\leadsto \color{blue}{U \cdot \left(1 + \frac{J \cdot \left(\ell \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)}{U}\right)} \]
          2. +-lowering-+.f64N/A

            \[\leadsto U \cdot \color{blue}{\left(1 + \frac{J \cdot \left(\ell \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)}{U}\right)} \]
          3. /-lowering-/.f64N/A

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

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

          \[\leadsto U \cdot \color{blue}{\left(\frac{1}{3} \cdot \frac{J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)}{U}\right)} \]
        10. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto U \cdot \color{blue}{\left(\frac{J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)}{U} \cdot \frac{1}{3}\right)} \]
          2. associate-*l/N/A

            \[\leadsto U \cdot \color{blue}{\frac{\left(J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \frac{1}{3}}{U}} \]
          3. associate-/l*N/A

            \[\leadsto U \cdot \color{blue}{\left(\left(J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right)} \]
          4. *-lowering-*.f64N/A

            \[\leadsto U \cdot \color{blue}{\left(\left(J \cdot \left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right)} \]
          5. *-commutativeN/A

            \[\leadsto U \cdot \left(\color{blue}{\left(\left({\ell}^{3} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot J\right)} \cdot \frac{\frac{1}{3}}{U}\right) \]
          6. *-commutativeN/A

            \[\leadsto U \cdot \left(\left(\color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{3}\right)} \cdot J\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
          7. associate-*l*N/A

            \[\leadsto U \cdot \left(\color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left({\ell}^{3} \cdot J\right)\right)} \cdot \frac{\frac{1}{3}}{U}\right) \]
          8. *-commutativeN/A

            \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(J \cdot {\ell}^{3}\right)}\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
          9. *-lowering-*.f64N/A

            \[\leadsto U \cdot \left(\color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot {\ell}^{3}\right)\right)} \cdot \frac{\frac{1}{3}}{U}\right) \]
          10. cos-lowering-cos.f64N/A

            \[\leadsto U \cdot \left(\left(\color{blue}{\cos \left(\frac{1}{2} \cdot K\right)} \cdot \left(J \cdot {\ell}^{3}\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
          11. *-lowering-*.f64N/A

            \[\leadsto U \cdot \left(\left(\cos \color{blue}{\left(\frac{1}{2} \cdot K\right)} \cdot \left(J \cdot {\ell}^{3}\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
          12. *-lowering-*.f64N/A

            \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \color{blue}{\left(J \cdot {\ell}^{3}\right)}\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
          13. cube-multN/A

            \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot \color{blue}{\left(\ell \cdot \left(\ell \cdot \ell\right)\right)}\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
          14. unpow2N/A

            \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot \left(\ell \cdot \color{blue}{{\ell}^{2}}\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
          15. *-lowering-*.f64N/A

            \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot \color{blue}{\left(\ell \cdot {\ell}^{2}\right)}\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
          16. unpow2N/A

            \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot \left(\ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
          17. *-lowering-*.f64N/A

            \[\leadsto U \cdot \left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot \left(\ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
          18. /-lowering-/.f6474.1

            \[\leadsto U \cdot \left(\left(\cos \left(0.5 \cdot K\right) \cdot \left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\right) \cdot \color{blue}{\frac{0.3333333333333333}{U}}\right) \]
        11. Simplified74.1%

          \[\leadsto U \cdot \color{blue}{\left(\left(\cos \left(0.5 \cdot K\right) \cdot \left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\right) \cdot \frac{0.3333333333333333}{U}\right)} \]
        12. Taylor expanded in K around 0

          \[\leadsto U \cdot \left(\color{blue}{\left(J \cdot {\ell}^{3}\right)} \cdot \frac{\frac{1}{3}}{U}\right) \]
        13. Step-by-step derivation
          1. *-lowering-*.f64N/A

            \[\leadsto U \cdot \left(\color{blue}{\left(J \cdot {\ell}^{3}\right)} \cdot \frac{\frac{1}{3}}{U}\right) \]
          2. cube-multN/A

            \[\leadsto U \cdot \left(\left(J \cdot \color{blue}{\left(\ell \cdot \left(\ell \cdot \ell\right)\right)}\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
          3. unpow2N/A

            \[\leadsto U \cdot \left(\left(J \cdot \left(\ell \cdot \color{blue}{{\ell}^{2}}\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
          4. *-lowering-*.f64N/A

            \[\leadsto U \cdot \left(\left(J \cdot \color{blue}{\left(\ell \cdot {\ell}^{2}\right)}\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
          5. unpow2N/A

            \[\leadsto U \cdot \left(\left(J \cdot \left(\ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right) \cdot \frac{\frac{1}{3}}{U}\right) \]
          6. *-lowering-*.f6456.9

            \[\leadsto U \cdot \left(\left(J \cdot \left(\ell \cdot \color{blue}{\left(\ell \cdot \ell\right)}\right)\right) \cdot \frac{0.3333333333333333}{U}\right) \]
        14. Simplified56.9%

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

        if -1850 < l

        1. Initial program 85.9%

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

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

            \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{2}\right)}\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
          2. associate-*r*N/A

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

            \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2}} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
          4. *-lowering-*.f64N/A

            \[\leadsto \color{blue}{\ell \cdot \left(\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
          5. *-commutativeN/A

            \[\leadsto \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
          6. associate-*r*N/A

            \[\leadsto \ell \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \frac{1}{3}\right) \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
          7. *-commutativeN/A

            \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2}\right)} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
          8. distribute-rgt-outN/A

            \[\leadsto \ell \cdot \color{blue}{\left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \left(\frac{1}{3} \cdot {\ell}^{2} + 2\right)\right)} + U \]
          9. +-commutativeN/A

            \[\leadsto \ell \cdot \left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \color{blue}{\left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}\right) + U \]
          10. *-lowering-*.f64N/A

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

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

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

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1850:\\ \;\;\;\;U \cdot \left(\left(J \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right) \cdot \frac{0.3333333333333333}{U}\right)\\ \mathbf{else}:\\ \;\;\;\;U + \ell \cdot \left(J \cdot \left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right)\right)\\ \end{array} \]
        10. Add Preprocessing

        Alternative 15: 46.3% accurate, 20.8× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := J \cdot \left(2 \cdot \ell\right)\\ \mathbf{if}\;\ell \leq -3.6 \cdot 10^{-23}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq 1.4 \cdot 10^{+14}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
        (FPCore (J l K U)
         :precision binary64
         (let* ((t_0 (* J (* 2.0 l))))
           (if (<= l -3.6e-23) t_0 (if (<= l 1.4e+14) U t_0))))
        double code(double J, double l, double K, double U) {
        	double t_0 = J * (2.0 * l);
        	double tmp;
        	if (l <= -3.6e-23) {
        		tmp = t_0;
        	} else if (l <= 1.4e+14) {
        		tmp = U;
        	} 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 = j * (2.0d0 * l)
            if (l <= (-3.6d-23)) then
                tmp = t_0
            else if (l <= 1.4d+14) then
                tmp = u
            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 = J * (2.0 * l);
        	double tmp;
        	if (l <= -3.6e-23) {
        		tmp = t_0;
        	} else if (l <= 1.4e+14) {
        		tmp = U;
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        def code(J, l, K, U):
        	t_0 = J * (2.0 * l)
        	tmp = 0
        	if l <= -3.6e-23:
        		tmp = t_0
        	elif l <= 1.4e+14:
        		tmp = U
        	else:
        		tmp = t_0
        	return tmp
        
        function code(J, l, K, U)
        	t_0 = Float64(J * Float64(2.0 * l))
        	tmp = 0.0
        	if (l <= -3.6e-23)
        		tmp = t_0;
        	elseif (l <= 1.4e+14)
        		tmp = U;
        	else
        		tmp = t_0;
        	end
        	return tmp
        end
        
        function tmp_2 = code(J, l, K, U)
        	t_0 = J * (2.0 * l);
        	tmp = 0.0;
        	if (l <= -3.6e-23)
        		tmp = t_0;
        	elseif (l <= 1.4e+14)
        		tmp = U;
        	else
        		tmp = t_0;
        	end
        	tmp_2 = tmp;
        end
        
        code[J_, l_, K_, U_] := Block[{t$95$0 = N[(J * N[(2.0 * l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.6e-23], t$95$0, If[LessEqual[l, 1.4e+14], U, t$95$0]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := J \cdot \left(2 \cdot \ell\right)\\
        \mathbf{if}\;\ell \leq -3.6 \cdot 10^{-23}:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;\ell \leq 1.4 \cdot 10^{+14}:\\
        \;\;\;\;U\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if l < -3.5999999999999998e-23 or 1.4e14 < l

          1. Initial program 98.5%

            \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
          2. Add Preprocessing
          3. Step-by-step derivation
            1. associate-*l*N/A

              \[\leadsto \color{blue}{J \cdot \left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right)} + U \]
            2. *-commutativeN/A

              \[\leadsto \color{blue}{\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J} + U \]
            3. *-lowering-*.f64N/A

              \[\leadsto \color{blue}{\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J} + U \]
            4. *-lowering-*.f64N/A

              \[\leadsto \color{blue}{\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right)} \cdot J + U \]
            5. sinh-undefN/A

              \[\leadsto \left(\color{blue}{\left(2 \cdot \sinh \ell\right)} \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J + U \]
            6. *-lowering-*.f64N/A

              \[\leadsto \left(\color{blue}{\left(2 \cdot \sinh \ell\right)} \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J + U \]
            7. sinh-lowering-sinh.f64N/A

              \[\leadsto \left(\left(2 \cdot \color{blue}{\sinh \ell}\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J + U \]
            8. cos-lowering-cos.f64N/A

              \[\leadsto \left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)}\right) \cdot J + U \]
            9. /-lowering-/.f64100.0

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

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

            \[\leadsto \left(\color{blue}{\left(2 \cdot \ell\right)} \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J + U \]
          6. Step-by-step derivation
            1. *-lowering-*.f6429.7

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

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

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

              \[\leadsto \color{blue}{\left(\ell \cdot 2\right)} \cdot J + U \]
            2. *-lowering-*.f6424.8

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

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

            \[\leadsto \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
          12. Step-by-step derivation
            1. *-commutativeN/A

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

              \[\leadsto \color{blue}{J \cdot \left(\ell \cdot 2\right)} \]
            3. *-commutativeN/A

              \[\leadsto J \cdot \color{blue}{\left(2 \cdot \ell\right)} \]
            4. *-lowering-*.f64N/A

              \[\leadsto \color{blue}{J \cdot \left(2 \cdot \ell\right)} \]
            5. *-commutativeN/A

              \[\leadsto J \cdot \color{blue}{\left(\ell \cdot 2\right)} \]
            6. *-lowering-*.f6422.3

              \[\leadsto J \cdot \color{blue}{\left(\ell \cdot 2\right)} \]
          13. Simplified22.3%

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

          if -3.5999999999999998e-23 < l < 1.4e14

          1. Initial program 80.5%

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

            \[\leadsto \color{blue}{U} \]
          4. Step-by-step derivation
            1. Simplified77.5%

              \[\leadsto \color{blue}{U} \]
          5. Recombined 2 regimes into one program.
          6. Final simplification50.9%

            \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.6 \cdot 10^{-23}:\\ \;\;\;\;J \cdot \left(2 \cdot \ell\right)\\ \mathbf{elif}\;\ell \leq 1.4 \cdot 10^{+14}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;J \cdot \left(2 \cdot \ell\right)\\ \end{array} \]
          7. Add Preprocessing

          Alternative 16: 72.6% accurate, 24.0× speedup?

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

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

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

              \[\leadsto \ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{2}\right)}\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
            2. associate-*r*N/A

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

              \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2}} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
            4. *-lowering-*.f64N/A

              \[\leadsto \color{blue}{\ell \cdot \left(\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + U \]
            5. *-commutativeN/A

              \[\leadsto \ell \cdot \left(\color{blue}{{\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
            6. associate-*r*N/A

              \[\leadsto \ell \cdot \left(\color{blue}{\left({\ell}^{2} \cdot \frac{1}{3}\right) \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
            7. *-commutativeN/A

              \[\leadsto \ell \cdot \left(\color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2}\right)} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + U \]
            8. distribute-rgt-outN/A

              \[\leadsto \ell \cdot \color{blue}{\left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \left(\frac{1}{3} \cdot {\ell}^{2} + 2\right)\right)} + U \]
            9. +-commutativeN/A

              \[\leadsto \ell \cdot \left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \color{blue}{\left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}\right) + U \]
            10. *-lowering-*.f64N/A

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

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

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

              \[\leadsto \ell \cdot \left(\color{blue}{J} \cdot \left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right)\right) + U \]
            2. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \ell \cdot \color{blue}{\left(\left(2 + \ell \cdot \left(\ell \cdot \frac{1}{3}\right)\right) \cdot J\right)} + U \]
              2. associate-*r*N/A

                \[\leadsto \color{blue}{\left(\ell \cdot \left(2 + \ell \cdot \left(\ell \cdot \frac{1}{3}\right)\right)\right) \cdot J} + U \]
              3. associate-*r*N/A

                \[\leadsto \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right) \cdot \frac{1}{3}}\right)\right) \cdot J + U \]
              4. *-commutativeN/A

                \[\leadsto \left(\ell \cdot \left(2 + \color{blue}{\frac{1}{3} \cdot \left(\ell \cdot \ell\right)}\right)\right) \cdot J + U \]
              5. *-lowering-*.f64N/A

                \[\leadsto \color{blue}{\left(\ell \cdot \left(2 + \frac{1}{3} \cdot \left(\ell \cdot \ell\right)\right)\right) \cdot J} + U \]
              6. *-commutativeN/A

                \[\leadsto \left(\ell \cdot \left(2 + \color{blue}{\left(\ell \cdot \ell\right) \cdot \frac{1}{3}}\right)\right) \cdot J + U \]
              7. associate-*r*N/A

                \[\leadsto \left(\ell \cdot \left(2 + \color{blue}{\ell \cdot \left(\ell \cdot \frac{1}{3}\right)}\right)\right) \cdot J + U \]
              8. *-lowering-*.f64N/A

                \[\leadsto \color{blue}{\left(\ell \cdot \left(2 + \ell \cdot \left(\ell \cdot \frac{1}{3}\right)\right)\right)} \cdot J + U \]
              9. +-lowering-+.f64N/A

                \[\leadsto \left(\ell \cdot \color{blue}{\left(2 + \ell \cdot \left(\ell \cdot \frac{1}{3}\right)\right)}\right) \cdot J + U \]
              10. *-lowering-*.f64N/A

                \[\leadsto \left(\ell \cdot \left(2 + \color{blue}{\ell \cdot \left(\ell \cdot \frac{1}{3}\right)}\right)\right) \cdot J + U \]
              11. *-lowering-*.f6473.3

                \[\leadsto \left(\ell \cdot \left(2 + \ell \cdot \color{blue}{\left(\ell \cdot 0.3333333333333333\right)}\right)\right) \cdot J + U \]
            3. Applied egg-rr73.3%

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

              \[\leadsto U + J \cdot \left(\ell \cdot \left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right)\right) \]
            5. Add Preprocessing

            Alternative 17: 54.8% accurate, 44.6× speedup?

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

              \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
            2. Add Preprocessing
            3. Step-by-step derivation
              1. associate-*l*N/A

                \[\leadsto \color{blue}{J \cdot \left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right)} + U \]
              2. *-commutativeN/A

                \[\leadsto \color{blue}{\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J} + U \]
              3. *-lowering-*.f64N/A

                \[\leadsto \color{blue}{\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J} + U \]
              4. *-lowering-*.f64N/A

                \[\leadsto \color{blue}{\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right)} \cdot J + U \]
              5. sinh-undefN/A

                \[\leadsto \left(\color{blue}{\left(2 \cdot \sinh \ell\right)} \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J + U \]
              6. *-lowering-*.f64N/A

                \[\leadsto \left(\color{blue}{\left(2 \cdot \sinh \ell\right)} \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J + U \]
              7. sinh-lowering-sinh.f64N/A

                \[\leadsto \left(\left(2 \cdot \color{blue}{\sinh \ell}\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J + U \]
              8. cos-lowering-cos.f64N/A

                \[\leadsto \left(\left(2 \cdot \sinh \ell\right) \cdot \color{blue}{\cos \left(\frac{K}{2}\right)}\right) \cdot J + U \]
              9. /-lowering-/.f64100.0

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

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

              \[\leadsto \left(\color{blue}{\left(2 \cdot \ell\right)} \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J + U \]
            6. Step-by-step derivation
              1. *-lowering-*.f6464.7

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

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

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

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

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

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

              \[\leadsto U + J \cdot \left(2 \cdot \ell\right) \]
            12. Add Preprocessing

            Alternative 18: 36.7% 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 89.2%

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

              \[\leadsto \color{blue}{U} \]
            4. Step-by-step derivation
              1. Simplified42.4%

                \[\leadsto \color{blue}{U} \]
              2. Add Preprocessing

              Reproduce

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