Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.3% → 99.7%
Time: 15.0s
Alternatives: 19
Speedup: 1.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 19 alternatives:

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

Initial Program: 86.3% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.6% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 94.7% accurate, 1.3× speedup?

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

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

\mathbf{elif}\;\ell \leq -0.08:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;\ell \leq 1.15 \cdot 10^{+82}:\\
\;\;\;\;t\_0\\

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


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

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

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. distribute-lft-in100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.50000000000000016e116 < l < -0.0800000000000000017 or 4.8e8 < l < 1.14999999999999994e82

    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 K around 0 80.6%

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

    if -0.0800000000000000017 < l < 4.8e8

    1. Initial program 69.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 98.7%

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

    if 1.14999999999999994e82 < 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 98.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.5 \cdot 10^{+116}:\\ \;\;\;\;\left(\cos \left(K \cdot 0.5\right) \cdot {\ell}^{3}\right) \cdot \left(J \cdot 0.3333333333333333\right)\\ \mathbf{elif}\;\ell \leq -0.08:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{elif}\;\ell \leq 480000000:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(J \cdot 2 + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{2}\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 1.15 \cdot 10^{+82}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{else}:\\ \;\;\;\;U + 0.3333333333333333 \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot {\ell}^{3}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 94.7% accurate, 1.3× speedup?

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

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

\mathbf{elif}\;\ell \leq -9.6 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;\ell \leq 7.8 \cdot 10^{+88}:\\
\;\;\;\;t\_0\\

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


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

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

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. distribute-lft-in100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.50000000000000016e116 < l < -9.6000000000000002e-5 or 4.8e8 < l < 7.8000000000000002e88

    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 K around 0 80.6%

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

    if -9.6000000000000002e-5 < l < 4.8e8

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

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

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

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

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

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

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

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

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

    if 7.8000000000000002e88 < 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 98.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.5 \cdot 10^{+116}:\\ \;\;\;\;\left(\cos \left(K \cdot 0.5\right) \cdot {\ell}^{3}\right) \cdot \left(J \cdot 0.3333333333333333\right)\\ \mathbf{elif}\;\ell \leq -9.6 \cdot 10^{-5}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{elif}\;\ell \leq 480000000:\\ \;\;\;\;U + \ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 7.8 \cdot 10^{+88}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{else}:\\ \;\;\;\;U + 0.3333333333333333 \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot {\ell}^{3}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 94.8% accurate, 1.3× speedup?

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

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

\mathbf{elif}\;\ell \leq -0.009:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;\ell \leq 1.55 \cdot 10^{+87}:\\
\;\;\;\;t\_0\\

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


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

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

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. distribute-lft-in100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.50000000000000016e116 < l < -0.00899999999999999932 or 4.8e8 < l < 1.55e87

    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 K around 0 80.6%

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

    if -0.00899999999999999932 < l < 4.8e8

    1. Initial program 69.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 98.7%

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

    if 1.55e87 < 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 98.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.5 \cdot 10^{+116}:\\ \;\;\;\;\left(\cos \left(K \cdot 0.5\right) \cdot {\ell}^{3}\right) \cdot \left(J \cdot 0.3333333333333333\right)\\ \mathbf{elif}\;\ell \leq -0.009:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{elif}\;\ell \leq 480000000:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 1.55 \cdot 10^{+87}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{else}:\\ \;\;\;\;U + 0.3333333333333333 \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot {\ell}^{3}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 94.8% accurate, 1.3× speedup?

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

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

\mathbf{elif}\;\ell \leq -0.05:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;\ell \leq 7.8 \cdot 10^{+88}:\\
\;\;\;\;t\_0\\

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


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

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

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. distribute-lft-in100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.50000000000000016e116 < l < -0.050000000000000003 or 4.8e8 < l < 7.8000000000000002e88

    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 K around 0 80.6%

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

    if -0.050000000000000003 < l < 4.8e8

    1. Initial program 69.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 98.7%

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. distribute-lft-in98.7%

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

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

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

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

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

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

    if 7.8000000000000002e88 < 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 98.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.5 \cdot 10^{+116}:\\ \;\;\;\;\left(\cos \left(K \cdot 0.5\right) \cdot {\ell}^{3}\right) \cdot \left(J \cdot 0.3333333333333333\right)\\ \mathbf{elif}\;\ell \leq -0.05:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{elif}\;\ell \leq 480000000:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2 + 0.3333333333333333 \cdot {\ell}^{3}\right)\right)\\ \mathbf{elif}\;\ell \leq 7.8 \cdot 10^{+88}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{else}:\\ \;\;\;\;U + 0.3333333333333333 \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot {\ell}^{3}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 94.7% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;\ell \leq -0.019:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;\ell \leq 7.8 \cdot 10^{+88}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -4.50000000000000016e116 or 7.8000000000000002e88 < 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 99.0%

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. distribute-lft-in99.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.50000000000000016e116 < l < -0.0189999999999999995 or 4.8e8 < l < 7.8000000000000002e88

    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 K around 0 80.6%

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

    if -0.0189999999999999995 < l < 4.8e8

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.5 \cdot 10^{+116}:\\ \;\;\;\;\left(\cos \left(K \cdot 0.5\right) \cdot {\ell}^{3}\right) \cdot \left(J \cdot 0.3333333333333333\right)\\ \mathbf{elif}\;\ell \leq -0.019:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{elif}\;\ell \leq 480000000:\\ \;\;\;\;U + \ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 7.8 \cdot 10^{+88}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{else}:\\ \;\;\;\;\left(\cos \left(K \cdot 0.5\right) \cdot {\ell}^{3}\right) \cdot \left(J \cdot 0.3333333333333333\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 86.3% accurate, 1.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -0.0023 or 4.8e8 < 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 K around 0 76.2%

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

    if -0.0023 < l < 4.8e8

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

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

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

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

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

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

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

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

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

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

Alternative 9: 77.2% accurate, 2.5× speedup?

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

\\
\begin{array}{l}
t_0 := J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\
\mathbf{if}\;\ell \leq -5.3 \cdot 10^{+45}:\\
\;\;\;\;t\_0\\

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

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

\mathbf{else}:\\
\;\;\;\;U + t\_0\\


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

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

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

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

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)} \]
    7. Step-by-step derivation
      1. associate-*r*71.4%

        \[\leadsto \color{blue}{\left(0.3333333333333333 \cdot J\right) \cdot {\ell}^{3}} \]
      2. *-commutative71.4%

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

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

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

    if -5.29999999999999991e45 < l < -8.5e16

    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. Applied egg-rr56.1%

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

    if -8.5e16 < l < 4.9999999999999998e98

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

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

    if 4.9999999999999998e98 < 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 100.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5.3 \cdot 10^{+45}:\\ \;\;\;\;J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\ \mathbf{elif}\;\ell \leq -8.5 \cdot 10^{+16}:\\ \;\;\;\;{U}^{-4}\\ \mathbf{elif}\;\ell \leq 5 \cdot 10^{+98}:\\ \;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 77.1% accurate, 2.5× speedup?

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

\\
\begin{array}{l}
t_0 := J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\
\mathbf{if}\;\ell \leq -1.05 \cdot 10^{+47}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+18}:\\
\;\;\;\;{U}^{-4}\\

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

\mathbf{else}:\\
\;\;\;\;U + t\_0\\


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

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

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

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

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)} \]
    7. Step-by-step derivation
      1. associate-*r*71.4%

        \[\leadsto \color{blue}{\left(0.3333333333333333 \cdot J\right) \cdot {\ell}^{3}} \]
      2. *-commutative71.4%

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

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

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

    if -1.05e47 < l < -7.8e18

    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. Applied egg-rr56.1%

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

    if -7.8e18 < l < 4.9999999999999998e98

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

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

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

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

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

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

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

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

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

    if 4.9999999999999998e98 < 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 100.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.05 \cdot 10^{+47}:\\ \;\;\;\;J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\ \mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+18}:\\ \;\;\;\;{U}^{-4}\\ \mathbf{elif}\;\ell \leq 5 \cdot 10^{+98}:\\ \;\;\;\;U + \ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 79.7% accurate, 2.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -8.5 \cdot 10^{+16}:\\
\;\;\;\;U \cdot \left(1 + 0.3333333333333333 \cdot \left(J \cdot \frac{{\ell}^{3}}{U}\right)\right)\\

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

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


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

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

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

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

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

      \[\leadsto U \cdot \left(1 + \color{blue}{0.3333333333333333 \cdot \frac{J \cdot {\ell}^{3}}{U}}\right) \]
    7. Step-by-step derivation
      1. associate-/l*67.9%

        \[\leadsto U \cdot \left(1 + 0.3333333333333333 \cdot \color{blue}{\left(J \cdot \frac{{\ell}^{3}}{U}\right)}\right) \]
    8. Simplified67.9%

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

    if -8.5e16 < l < 120

    1. Initial program 69.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 97.0%

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

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

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

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

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

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

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

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

    if 120 < 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 82.4%

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

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

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

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

Alternative 12: 80.2% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -8.5 \cdot 10^{+16} \lor \neg \left(\ell \leq 62\right):\\
\;\;\;\;U \cdot \left(1 + 0.3333333333333333 \cdot \left(J \cdot \frac{{\ell}^{3}}{U}\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -8.5e16 or 62 < 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 81.0%

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

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

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

      \[\leadsto U \cdot \left(1 + \color{blue}{0.3333333333333333 \cdot \frac{J \cdot {\ell}^{3}}{U}}\right) \]
    7. Step-by-step derivation
      1. associate-/l*67.3%

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

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

    if -8.5e16 < l < 62

    1. Initial program 69.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 97.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -8.5 \cdot 10^{+16} \lor \neg \left(\ell \leq 62\right):\\ \;\;\;\;U \cdot \left(1 + 0.3333333333333333 \cdot \left(J \cdot \frac{{\ell}^{3}}{U}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + \ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 70.3% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
t_0 := J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\
\mathbf{if}\;\ell \leq -1.46 \cdot 10^{+49}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;\ell \leq 1.4 \cdot 10^{+33}:\\
\;\;\;\;U \cdot \left(1 + J \cdot \left(\ell \cdot \frac{2}{U}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;U + t\_0\\


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

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

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

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

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)} \]
    7. Step-by-step derivation
      1. associate-*r*72.8%

        \[\leadsto \color{blue}{\left(0.3333333333333333 \cdot J\right) \cdot {\ell}^{3}} \]
      2. *-commutative72.8%

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

        \[\leadsto \color{blue}{J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)} \]
    8. Simplified72.8%

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

    if -1.46000000000000008e49 < l < 1.4e33

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

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

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

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

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

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

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

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

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

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

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

    if 1.4e33 < 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 88.5%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.46 \cdot 10^{+49}:\\ \;\;\;\;J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\ \mathbf{elif}\;\ell \leq 1.4 \cdot 10^{+33}:\\ \;\;\;\;U \cdot \left(1 + J \cdot \left(\ell \cdot \frac{2}{U}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 70.3% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.95 \cdot 10^{+48} \lor \neg \left(\ell \leq 2.7 \cdot 10^{+30}\right):\\
\;\;\;\;J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -1.95e48 or 2.6999999999999999e30 < 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 89.9%

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

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

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)} \]
    7. Step-by-step derivation
      1. associate-*r*69.3%

        \[\leadsto \color{blue}{\left(0.3333333333333333 \cdot J\right) \cdot {\ell}^{3}} \]
      2. *-commutative69.3%

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

        \[\leadsto \color{blue}{J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)} \]
    8. Simplified69.3%

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

    if -1.95e48 < l < 2.6999999999999999e30

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.95 \cdot 10^{+48} \lor \neg \left(\ell \leq 2.7 \cdot 10^{+30}\right):\\ \;\;\;\;J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(1 + J \cdot \left(\ell \cdot \frac{2}{U}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 42.4% accurate, 23.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -950 \lor \neg \left(\ell \leq 660\right):\\
\;\;\;\;U \cdot U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -950 or 660 < 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. Applied egg-rr18.3%

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

    if -950 < l < 660

    1. Initial program 68.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 J around 0 67.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -950 \lor \neg \left(\ell \leq 660\right):\\ \;\;\;\;U \cdot U\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 50.8% accurate, 26.0× speedup?

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

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

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


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

    1. Initial program 80.7%

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

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

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

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

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

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

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

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

    if 1.42e56 < 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. Applied egg-rr29.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 1.42 \cdot 10^{+56}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;U \cdot U\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 59.2% accurate, 28.4× speedup?

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

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

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

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

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

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

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

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

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

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

      \[\leadsto U \cdot \left(1 + J \cdot \color{blue}{\left(\ell \cdot \frac{2}{U}\right)}\right) \]
  8. Simplified60.6%

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

    \[\leadsto U \cdot \left(1 + J \cdot \left(\ell \cdot \frac{2}{U}\right)\right) \]
  10. Add Preprocessing

Alternative 18: 2.8% accurate, 312.0× speedup?

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

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

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

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

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

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

    \[\leadsto 1 \]
  7. Add Preprocessing

Alternative 19: 36.0% accurate, 312.0× speedup?

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

\\
U
\end{array}
Derivation
  1. Initial program 84.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 J around 0 34.0%

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

    \[\leadsto U \]
  5. Add Preprocessing

Reproduce

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