Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.5% → 99.8%
Time: 14.8s
Alternatives: 24
Speedup: 1.3×

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 24 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.5% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 70.2%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Add Preprocessing
    3. Taylor expanded in l around 0 99.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. Step-by-step derivation
      1. distribute-rgt-in99.9%

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

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

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

        \[\leadsto \left(J \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \cdot \color{blue}{{\ell}^{\left(2 + 1\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. metadata-eval99.9%

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

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

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

Alternative 2: 99.8% accurate, 0.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;U + t\_0 \cdot \left(\ell \cdot \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{2}\right) + 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 5.0000000000000001e-4 < (-.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))) < 5.0000000000000001e-4

    1. Initial program 70.2%

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

      \[\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 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.9%

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

Alternative 3: 87.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\ell} - e^{-\ell}\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-5} \lor \neg \left(t\_0 \leq 2 \cdot 10^{-16}\right):\\ \;\;\;\;t\_0 \cdot J + U\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \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 -1e-5) (not (<= t_0 2e-16)))
     (+ (* t_0 J) U)
     (+ U (* (cos (/ K 2.0)) (* l (* 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 <= -1e-5) || !(t_0 <= 2e-16)) {
		tmp = (t_0 * J) + U;
	} else {
		tmp = U + (cos((K / 2.0)) * (l * (J * 2.0)));
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: t_0
    real(8) :: tmp
    t_0 = exp(l) - exp(-l)
    if ((t_0 <= (-1d-5)) .or. (.not. (t_0 <= 2d-16))) then
        tmp = (t_0 * j) + u
    else
        tmp = u + (cos((k / 2.0d0)) * (l * (j * 2.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);
	double tmp;
	if ((t_0 <= -1e-5) || !(t_0 <= 2e-16)) {
		tmp = (t_0 * J) + U;
	} else {
		tmp = U + (Math.cos((K / 2.0)) * (l * (J * 2.0)));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.exp(l) - math.exp(-l)
	tmp = 0
	if (t_0 <= -1e-5) or not (t_0 <= 2e-16):
		tmp = (t_0 * J) + U
	else:
		tmp = U + (math.cos((K / 2.0)) * (l * (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 <= -1e-5) || !(t_0 <= 2e-16))
		tmp = Float64(Float64(t_0 * J) + U);
	else
		tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(l * 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 <= -1e-5) || ~((t_0 <= 2e-16)))
		tmp = (t_0 * J) + U;
	else
		tmp = U + (cos((K / 2.0)) * (l * (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, -1e-5], N[Not[LessEqual[t$95$0, 2e-16]], $MachinePrecision]], N[(N[(t$95$0 * J), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * 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 -1 \cdot 10^{-5} \lor \neg \left(t\_0 \leq 2 \cdot 10^{-16}\right):\\
\;\;\;\;t\_0 \cdot J + U\\

\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \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))) < -1.00000000000000008e-5 or 2e-16 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

    1. Initial program 99.7%

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

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

    if -1.00000000000000008e-5 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 2e-16

    1. Initial program 70.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}{\left(2 \cdot \left(J \cdot \ell\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. associate-*r*99.9%

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

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

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

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

Alternative 4: 87.2% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < -1.99999999999999997e-170

    1. Initial program 99.4%

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

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

    if -1.99999999999999997e-170 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))))

    1. Initial program 79.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 95.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 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification91.4%

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

Alternative 5: 93.8% accurate, 1.3× speedup?

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

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

\mathbf{elif}\;\ell \leq -0.13:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;\ell \leq 8.4 \cdot 10^{+77}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -9.40000000000000013e179 or 8.3999999999999995e77 < 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 96.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. Step-by-step derivation
      1. distribute-rgt-in96.4%

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

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

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

        \[\leadsto \left(J \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \cdot \color{blue}{{\ell}^{\left(2 + 1\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. metadata-eval96.4%

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

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

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

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

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

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

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

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

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

    if -9.40000000000000013e179 < l < -0.13 or 0.091999999999999998 < l < 8.3999999999999995e77

    1. Initial program 99.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 K around 0 85.4%

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

    if -0.13 < l < 0.091999999999999998

    1. Initial program 70.2%

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

      \[\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 \]
  3. Recombined 3 regimes into one program.
  4. Final simplification96.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -9.4 \cdot 10^{+179}:\\ \;\;\;\;U + \left(J \cdot {\ell}^{3}\right) \cdot \left(0.3333333333333333 \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{elif}\;\ell \leq -0.13:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{elif}\;\ell \leq 0.092:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{2}\right) + J \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 8.4 \cdot 10^{+77}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{else}:\\ \;\;\;\;U + \left(J \cdot {\ell}^{3}\right) \cdot \left(0.3333333333333333 \cdot \cos \left(K \cdot 0.5\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 93.7% accurate, 1.3× speedup?

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

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

\mathbf{elif}\;\ell \leq -8.5 \cdot 10^{-6}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;\ell \leq 8.4 \cdot 10^{+77}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -9.40000000000000013e179 or 8.3999999999999995e77 < 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 96.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. Step-by-step derivation
      1. distribute-rgt-in96.4%

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

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

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

        \[\leadsto \left(J \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \cdot \color{blue}{{\ell}^{\left(2 + 1\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. metadata-eval96.4%

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

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

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

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

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

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

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

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

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

    if -9.40000000000000013e179 < l < -8.4999999999999999e-6 or 1.7e-4 < l < 8.3999999999999995e77

    1. Initial program 99.2%

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

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

    if -8.4999999999999999e-6 < l < 1.7e-4

    1. Initial program 70.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}{\left(2 \cdot \left(J \cdot \ell\right)\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. associate-*r*99.9%

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

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

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

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

Alternative 7: 79.9% accurate, 1.4× speedup?

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

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

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


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

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

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

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

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

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

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

    1. Initial program 84.4%

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

      \[\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-rgt-in90.1%

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

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

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

        \[\leadsto \left(J \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \cdot \color{blue}{{\ell}^{\left(2 + 1\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. metadata-eval90.1%

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

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

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

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

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

Alternative 8: 79.4% accurate, 1.4× speedup?

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

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

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


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

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

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

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

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

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

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

    1. Initial program 84.4%

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

      \[\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-rgt-in90.1%

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

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

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

        \[\leadsto \left(J \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \cdot \color{blue}{{\ell}^{\left(2 + 1\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. metadata-eval90.1%

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

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

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

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

Alternative 9: 76.7% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -8.5 \cdot 10^{-6}:\\ \;\;\;\;J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 1050:\\ \;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 1.7 \cdot 10^{+72}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{elif}\;\ell \leq 4.3 \cdot 10^{+83} \lor \neg \left(\ell \leq 4.5 \cdot 10^{+172}\right) \land \ell \leq 1.3 \cdot 10^{+194}:\\ \;\;\;\;\left(J \cdot \left(\ell \cdot {K}^{2}\right)\right) \cdot -0.25\\ \mathbf{else}:\\ \;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -8.5e-6)
   (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))
   (if (<= l 1050.0)
     (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))
     (if (<= l 1.7e+72)
       (* U (- U -4.0))
       (if (or (<= l 4.3e+83) (and (not (<= l 4.5e+172)) (<= l 1.3e+194)))
         (* (* J (* l (pow K 2.0))) -0.25)
         (+ U (* (pow l 3.0) (* J 0.3333333333333333))))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -8.5e-6) {
		tmp = J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0));
	} else if (l <= 1050.0) {
		tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
	} else if (l <= 1.7e+72) {
		tmp = U * (U - -4.0);
	} else if ((l <= 4.3e+83) || (!(l <= 4.5e+172) && (l <= 1.3e+194))) {
		tmp = (J * (l * pow(K, 2.0))) * -0.25;
	} else {
		tmp = U + (pow(l, 3.0) * (J * 0.3333333333333333));
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: tmp
    if (l <= (-8.5d-6)) then
        tmp = j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))
    else if (l <= 1050.0d0) then
        tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
    else if (l <= 1.7d+72) then
        tmp = u * (u - (-4.0d0))
    else if ((l <= 4.3d+83) .or. (.not. (l <= 4.5d+172)) .and. (l <= 1.3d+194)) then
        tmp = (j * (l * (k ** 2.0d0))) * (-0.25d0)
    else
        tmp = u + ((l ** 3.0d0) * (j * 0.3333333333333333d0))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -8.5e-6) {
		tmp = J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0));
	} else if (l <= 1050.0) {
		tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
	} else if (l <= 1.7e+72) {
		tmp = U * (U - -4.0);
	} else if ((l <= 4.3e+83) || (!(l <= 4.5e+172) && (l <= 1.3e+194))) {
		tmp = (J * (l * Math.pow(K, 2.0))) * -0.25;
	} else {
		tmp = U + (Math.pow(l, 3.0) * (J * 0.3333333333333333));
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -8.5e-6:
		tmp = J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))
	elif l <= 1050.0:
		tmp = U + (2.0 * (J * (l * math.cos((K * 0.5)))))
	elif l <= 1.7e+72:
		tmp = U * (U - -4.0)
	elif (l <= 4.3e+83) or (not (l <= 4.5e+172) and (l <= 1.3e+194)):
		tmp = (J * (l * math.pow(K, 2.0))) * -0.25
	else:
		tmp = U + (math.pow(l, 3.0) * (J * 0.3333333333333333))
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -8.5e-6)
		tmp = Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)));
	elseif (l <= 1050.0)
		tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5))))));
	elseif (l <= 1.7e+72)
		tmp = Float64(U * Float64(U - -4.0));
	elseif ((l <= 4.3e+83) || (!(l <= 4.5e+172) && (l <= 1.3e+194)))
		tmp = Float64(Float64(J * Float64(l * (K ^ 2.0))) * -0.25);
	else
		tmp = Float64(U + Float64((l ^ 3.0) * Float64(J * 0.3333333333333333)));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= -8.5e-6)
		tmp = J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0));
	elseif (l <= 1050.0)
		tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
	elseif (l <= 1.7e+72)
		tmp = U * (U - -4.0);
	elseif ((l <= 4.3e+83) || (~((l <= 4.5e+172)) && (l <= 1.3e+194)))
		tmp = (J * (l * (K ^ 2.0))) * -0.25;
	else
		tmp = U + ((l ^ 3.0) * (J * 0.3333333333333333));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -8.5e-6], N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1050.0], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.7e+72], N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[l, 4.3e+83], And[N[Not[LessEqual[l, 4.5e+172]], $MachinePrecision], LessEqual[l, 1.3e+194]]], N[(N[(J * N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision], N[(U + N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;\ell \leq 1.7 \cdot 10^{+72}:\\
\;\;\;\;U \cdot \left(U - -4\right)\\

\mathbf{elif}\;\ell \leq 4.3 \cdot 10^{+83} \lor \neg \left(\ell \leq 4.5 \cdot 10^{+172}\right) \land \ell \leq 1.3 \cdot 10^{+194}:\\
\;\;\;\;\left(J \cdot \left(\ell \cdot {K}^{2}\right)\right) \cdot -0.25\\

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


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

    1. Initial program 99.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 83.8%

      \[\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-rgt-in83.8%

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

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

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

        \[\leadsto \left(J \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \cdot \color{blue}{{\ell}^{\left(2 + 1\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. metadata-eval83.8%

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

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

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

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

    if -8.4999999999999999e-6 < l < 1050

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

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

    if 1050 < l < 1.6999999999999999e72

    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-rr37.0%

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

    if 1.6999999999999999e72 < l < 4.3e83 or 4.5000000000000002e172 < l < 1.2999999999999999e194

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

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

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

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

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

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

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

    if 4.3e83 < l < 4.5000000000000002e172 or 1.2999999999999999e194 < 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 95.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-rgt-in95.0%

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

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

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

        \[\leadsto \left(J \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \cdot \color{blue}{{\ell}^{\left(2 + 1\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. metadata-eval95.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -8.5 \cdot 10^{-6}:\\ \;\;\;\;J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 1050:\\ \;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\ell \leq 1.7 \cdot 10^{+72}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{elif}\;\ell \leq 4.3 \cdot 10^{+83} \lor \neg \left(\ell \leq 4.5 \cdot 10^{+172}\right) \land \ell \leq 1.3 \cdot 10^{+194}:\\ \;\;\;\;\left(J \cdot \left(\ell \cdot {K}^{2}\right)\right) \cdot -0.25\\ \mathbf{else}:\\ \;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 76.7% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -8.5 \cdot 10^{-6}:\\ \;\;\;\;J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 1750:\\ \;\;\;\;U + \ell \cdot \left(\left(J \cdot 2\right) \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{elif}\;\ell \leq 3.7 \cdot 10^{+73}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{elif}\;\ell \leq 4.3 \cdot 10^{+83} \lor \neg \left(\ell \leq 4.5 \cdot 10^{+172}\right) \land \ell \leq 1.3 \cdot 10^{+194}:\\ \;\;\;\;\left(J \cdot \left(\ell \cdot {K}^{2}\right)\right) \cdot -0.25\\ \mathbf{else}:\\ \;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -8.5e-6)
   (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))
   (if (<= l 1750.0)
     (+ U (* l (* (* J 2.0) (cos (* K 0.5)))))
     (if (<= l 3.7e+73)
       (* U (- U -4.0))
       (if (or (<= l 4.3e+83) (and (not (<= l 4.5e+172)) (<= l 1.3e+194)))
         (* (* J (* l (pow K 2.0))) -0.25)
         (+ U (* (pow l 3.0) (* J 0.3333333333333333))))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -8.5e-6) {
		tmp = J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0));
	} else if (l <= 1750.0) {
		tmp = U + (l * ((J * 2.0) * cos((K * 0.5))));
	} else if (l <= 3.7e+73) {
		tmp = U * (U - -4.0);
	} else if ((l <= 4.3e+83) || (!(l <= 4.5e+172) && (l <= 1.3e+194))) {
		tmp = (J * (l * pow(K, 2.0))) * -0.25;
	} else {
		tmp = U + (pow(l, 3.0) * (J * 0.3333333333333333));
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: tmp
    if (l <= (-8.5d-6)) then
        tmp = j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))
    else if (l <= 1750.0d0) then
        tmp = u + (l * ((j * 2.0d0) * cos((k * 0.5d0))))
    else if (l <= 3.7d+73) then
        tmp = u * (u - (-4.0d0))
    else if ((l <= 4.3d+83) .or. (.not. (l <= 4.5d+172)) .and. (l <= 1.3d+194)) then
        tmp = (j * (l * (k ** 2.0d0))) * (-0.25d0)
    else
        tmp = u + ((l ** 3.0d0) * (j * 0.3333333333333333d0))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -8.5e-6) {
		tmp = J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0));
	} else if (l <= 1750.0) {
		tmp = U + (l * ((J * 2.0) * Math.cos((K * 0.5))));
	} else if (l <= 3.7e+73) {
		tmp = U * (U - -4.0);
	} else if ((l <= 4.3e+83) || (!(l <= 4.5e+172) && (l <= 1.3e+194))) {
		tmp = (J * (l * Math.pow(K, 2.0))) * -0.25;
	} else {
		tmp = U + (Math.pow(l, 3.0) * (J * 0.3333333333333333));
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -8.5e-6:
		tmp = J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))
	elif l <= 1750.0:
		tmp = U + (l * ((J * 2.0) * math.cos((K * 0.5))))
	elif l <= 3.7e+73:
		tmp = U * (U - -4.0)
	elif (l <= 4.3e+83) or (not (l <= 4.5e+172) and (l <= 1.3e+194)):
		tmp = (J * (l * math.pow(K, 2.0))) * -0.25
	else:
		tmp = U + (math.pow(l, 3.0) * (J * 0.3333333333333333))
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -8.5e-6)
		tmp = Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)));
	elseif (l <= 1750.0)
		tmp = Float64(U + Float64(l * Float64(Float64(J * 2.0) * cos(Float64(K * 0.5)))));
	elseif (l <= 3.7e+73)
		tmp = Float64(U * Float64(U - -4.0));
	elseif ((l <= 4.3e+83) || (!(l <= 4.5e+172) && (l <= 1.3e+194)))
		tmp = Float64(Float64(J * Float64(l * (K ^ 2.0))) * -0.25);
	else
		tmp = Float64(U + Float64((l ^ 3.0) * Float64(J * 0.3333333333333333)));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= -8.5e-6)
		tmp = J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0));
	elseif (l <= 1750.0)
		tmp = U + (l * ((J * 2.0) * cos((K * 0.5))));
	elseif (l <= 3.7e+73)
		tmp = U * (U - -4.0);
	elseif ((l <= 4.3e+83) || (~((l <= 4.5e+172)) && (l <= 1.3e+194)))
		tmp = (J * (l * (K ^ 2.0))) * -0.25;
	else
		tmp = U + ((l ^ 3.0) * (J * 0.3333333333333333));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -8.5e-6], N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1750.0], N[(U + N[(l * N[(N[(J * 2.0), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3.7e+73], N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[l, 4.3e+83], And[N[Not[LessEqual[l, 4.5e+172]], $MachinePrecision], LessEqual[l, 1.3e+194]]], N[(N[(J * N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision], N[(U + N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;\ell \leq 3.7 \cdot 10^{+73}:\\
\;\;\;\;U \cdot \left(U - -4\right)\\

\mathbf{elif}\;\ell \leq 4.3 \cdot 10^{+83} \lor \neg \left(\ell \leq 4.5 \cdot 10^{+172}\right) \land \ell \leq 1.3 \cdot 10^{+194}:\\
\;\;\;\;\left(J \cdot \left(\ell \cdot {K}^{2}\right)\right) \cdot -0.25\\

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


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

    1. Initial program 99.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 83.8%

      \[\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-rgt-in83.8%

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

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

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

        \[\leadsto \left(J \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \cdot \color{blue}{{\ell}^{\left(2 + 1\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. metadata-eval83.8%

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

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

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

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

    if -8.4999999999999999e-6 < l < 1750

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

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

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

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

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

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

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

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

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

    if 1750 < l < 3.69999999999999973e73

    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-rr37.0%

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

    if 3.69999999999999973e73 < l < 4.3e83 or 4.5000000000000002e172 < l < 1.2999999999999999e194

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

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

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

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

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

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

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

    if 4.3e83 < l < 4.5000000000000002e172 or 1.2999999999999999e194 < 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 95.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-rgt-in95.0%

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

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

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

        \[\leadsto \left(J \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \cdot \color{blue}{{\ell}^{\left(2 + 1\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. metadata-eval95.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -8.5 \cdot 10^{-6}:\\ \;\;\;\;J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 1750:\\ \;\;\;\;U + \ell \cdot \left(\left(J \cdot 2\right) \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{elif}\;\ell \leq 3.7 \cdot 10^{+73}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{elif}\;\ell \leq 4.3 \cdot 10^{+83} \lor \neg \left(\ell \leq 4.5 \cdot 10^{+172}\right) \land \ell \leq 1.3 \cdot 10^{+194}:\\ \;\;\;\;\left(J \cdot \left(\ell \cdot {K}^{2}\right)\right) \cdot -0.25\\ \mathbf{else}:\\ \;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 76.7% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -8.5 \cdot 10^{-6}:\\ \;\;\;\;J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 850:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(J \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 2.05 \cdot 10^{+72}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{elif}\;\ell \leq 6.5 \cdot 10^{+83} \lor \neg \left(\ell \leq 2.8 \cdot 10^{+172}\right) \land \ell \leq 1.3 \cdot 10^{+194}:\\ \;\;\;\;\left(J \cdot \left(\ell \cdot {K}^{2}\right)\right) \cdot -0.25\\ \mathbf{else}:\\ \;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -8.5e-6)
   (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))
   (if (<= l 850.0)
     (+ U (* (cos (/ K 2.0)) (* l (* J 2.0))))
     (if (<= l 2.05e+72)
       (* U (- U -4.0))
       (if (or (<= l 6.5e+83) (and (not (<= l 2.8e+172)) (<= l 1.3e+194)))
         (* (* J (* l (pow K 2.0))) -0.25)
         (+ U (* (pow l 3.0) (* J 0.3333333333333333))))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -8.5e-6) {
		tmp = J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0));
	} else if (l <= 850.0) {
		tmp = U + (cos((K / 2.0)) * (l * (J * 2.0)));
	} else if (l <= 2.05e+72) {
		tmp = U * (U - -4.0);
	} else if ((l <= 6.5e+83) || (!(l <= 2.8e+172) && (l <= 1.3e+194))) {
		tmp = (J * (l * pow(K, 2.0))) * -0.25;
	} else {
		tmp = U + (pow(l, 3.0) * (J * 0.3333333333333333));
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: tmp
    if (l <= (-8.5d-6)) then
        tmp = j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))
    else if (l <= 850.0d0) then
        tmp = u + (cos((k / 2.0d0)) * (l * (j * 2.0d0)))
    else if (l <= 2.05d+72) then
        tmp = u * (u - (-4.0d0))
    else if ((l <= 6.5d+83) .or. (.not. (l <= 2.8d+172)) .and. (l <= 1.3d+194)) then
        tmp = (j * (l * (k ** 2.0d0))) * (-0.25d0)
    else
        tmp = u + ((l ** 3.0d0) * (j * 0.3333333333333333d0))
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -8.5e-6) {
		tmp = J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0));
	} else if (l <= 850.0) {
		tmp = U + (Math.cos((K / 2.0)) * (l * (J * 2.0)));
	} else if (l <= 2.05e+72) {
		tmp = U * (U - -4.0);
	} else if ((l <= 6.5e+83) || (!(l <= 2.8e+172) && (l <= 1.3e+194))) {
		tmp = (J * (l * Math.pow(K, 2.0))) * -0.25;
	} else {
		tmp = U + (Math.pow(l, 3.0) * (J * 0.3333333333333333));
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -8.5e-6:
		tmp = J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))
	elif l <= 850.0:
		tmp = U + (math.cos((K / 2.0)) * (l * (J * 2.0)))
	elif l <= 2.05e+72:
		tmp = U * (U - -4.0)
	elif (l <= 6.5e+83) or (not (l <= 2.8e+172) and (l <= 1.3e+194)):
		tmp = (J * (l * math.pow(K, 2.0))) * -0.25
	else:
		tmp = U + (math.pow(l, 3.0) * (J * 0.3333333333333333))
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -8.5e-6)
		tmp = Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)));
	elseif (l <= 850.0)
		tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(l * Float64(J * 2.0))));
	elseif (l <= 2.05e+72)
		tmp = Float64(U * Float64(U - -4.0));
	elseif ((l <= 6.5e+83) || (!(l <= 2.8e+172) && (l <= 1.3e+194)))
		tmp = Float64(Float64(J * Float64(l * (K ^ 2.0))) * -0.25);
	else
		tmp = Float64(U + Float64((l ^ 3.0) * Float64(J * 0.3333333333333333)));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= -8.5e-6)
		tmp = J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0));
	elseif (l <= 850.0)
		tmp = U + (cos((K / 2.0)) * (l * (J * 2.0)));
	elseif (l <= 2.05e+72)
		tmp = U * (U - -4.0);
	elseif ((l <= 6.5e+83) || (~((l <= 2.8e+172)) && (l <= 1.3e+194)))
		tmp = (J * (l * (K ^ 2.0))) * -0.25;
	else
		tmp = U + ((l ^ 3.0) * (J * 0.3333333333333333));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -8.5e-6], N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 850.0], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.05e+72], N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[l, 6.5e+83], And[N[Not[LessEqual[l, 2.8e+172]], $MachinePrecision], LessEqual[l, 1.3e+194]]], N[(N[(J * N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision], N[(U + N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;\ell \leq 2.05 \cdot 10^{+72}:\\
\;\;\;\;U \cdot \left(U - -4\right)\\

\mathbf{elif}\;\ell \leq 6.5 \cdot 10^{+83} \lor \neg \left(\ell \leq 2.8 \cdot 10^{+172}\right) \land \ell \leq 1.3 \cdot 10^{+194}:\\
\;\;\;\;\left(J \cdot \left(\ell \cdot {K}^{2}\right)\right) \cdot -0.25\\

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


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

    1. Initial program 99.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 83.8%

      \[\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-rgt-in83.8%

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

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

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

        \[\leadsto \left(J \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \cdot \color{blue}{{\ell}^{\left(2 + 1\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. metadata-eval83.8%

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

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

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

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

    if -8.4999999999999999e-6 < l < 850

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

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

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

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

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

    if 850 < l < 2.04999999999999982e72

    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-rr37.0%

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

    if 2.04999999999999982e72 < l < 6.5000000000000003e83 or 2.8e172 < l < 1.2999999999999999e194

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

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

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

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

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

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

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

    if 6.5000000000000003e83 < l < 2.8e172 or 1.2999999999999999e194 < 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 95.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-rgt-in95.0%

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

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

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

        \[\leadsto \left(J \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \cdot \color{blue}{{\ell}^{\left(2 + 1\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. metadata-eval95.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -8.5 \cdot 10^{-6}:\\ \;\;\;\;J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 850:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(J \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 2.05 \cdot 10^{+72}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{elif}\;\ell \leq 6.5 \cdot 10^{+83} \lor \neg \left(\ell \leq 2.8 \cdot 10^{+172}\right) \land \ell \leq 1.3 \cdot 10^{+194}:\\ \;\;\;\;\left(J \cdot \left(\ell \cdot {K}^{2}\right)\right) \cdot -0.25\\ \mathbf{else}:\\ \;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 77.3% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\ \mathbf{if}\;\ell \leq -1.7 \cdot 10^{+35}:\\ \;\;\;\;U \cdot \left(1 + \frac{t\_0}{U}\right)\\ \mathbf{elif}\;\ell \leq 6600000:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(J \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 3.55 \cdot 10^{+74}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{elif}\;\ell \leq 4.3 \cdot 10^{+83} \lor \neg \left(\ell \leq 4.5 \cdot 10^{+172}\right) \land \ell \leq 1.3 \cdot 10^{+194}:\\ \;\;\;\;\left(J \cdot \left(\ell \cdot {K}^{2}\right)\right) \cdot -0.25\\ \mathbf{else}:\\ \;\;\;\;U + t\_0\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (* (pow l 3.0) (* J 0.3333333333333333))))
   (if (<= l -1.7e+35)
     (* U (+ 1.0 (/ t_0 U)))
     (if (<= l 6600000.0)
       (+ U (* (cos (/ K 2.0)) (* l (* J 2.0))))
       (if (<= l 3.55e+74)
         (* U (- U -4.0))
         (if (or (<= l 4.3e+83) (and (not (<= l 4.5e+172)) (<= l 1.3e+194)))
           (* (* J (* l (pow K 2.0))) -0.25)
           (+ U t_0)))))))
double code(double J, double l, double K, double U) {
	double t_0 = pow(l, 3.0) * (J * 0.3333333333333333);
	double tmp;
	if (l <= -1.7e+35) {
		tmp = U * (1.0 + (t_0 / U));
	} else if (l <= 6600000.0) {
		tmp = U + (cos((K / 2.0)) * (l * (J * 2.0)));
	} else if (l <= 3.55e+74) {
		tmp = U * (U - -4.0);
	} else if ((l <= 4.3e+83) || (!(l <= 4.5e+172) && (l <= 1.3e+194))) {
		tmp = (J * (l * pow(K, 2.0))) * -0.25;
	} 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 = (l ** 3.0d0) * (j * 0.3333333333333333d0)
    if (l <= (-1.7d+35)) then
        tmp = u * (1.0d0 + (t_0 / u))
    else if (l <= 6600000.0d0) then
        tmp = u + (cos((k / 2.0d0)) * (l * (j * 2.0d0)))
    else if (l <= 3.55d+74) then
        tmp = u * (u - (-4.0d0))
    else if ((l <= 4.3d+83) .or. (.not. (l <= 4.5d+172)) .and. (l <= 1.3d+194)) then
        tmp = (j * (l * (k ** 2.0d0))) * (-0.25d0)
    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 = Math.pow(l, 3.0) * (J * 0.3333333333333333);
	double tmp;
	if (l <= -1.7e+35) {
		tmp = U * (1.0 + (t_0 / U));
	} else if (l <= 6600000.0) {
		tmp = U + (Math.cos((K / 2.0)) * (l * (J * 2.0)));
	} else if (l <= 3.55e+74) {
		tmp = U * (U - -4.0);
	} else if ((l <= 4.3e+83) || (!(l <= 4.5e+172) && (l <= 1.3e+194))) {
		tmp = (J * (l * Math.pow(K, 2.0))) * -0.25;
	} else {
		tmp = U + t_0;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.pow(l, 3.0) * (J * 0.3333333333333333)
	tmp = 0
	if l <= -1.7e+35:
		tmp = U * (1.0 + (t_0 / U))
	elif l <= 6600000.0:
		tmp = U + (math.cos((K / 2.0)) * (l * (J * 2.0)))
	elif l <= 3.55e+74:
		tmp = U * (U - -4.0)
	elif (l <= 4.3e+83) or (not (l <= 4.5e+172) and (l <= 1.3e+194)):
		tmp = (J * (l * math.pow(K, 2.0))) * -0.25
	else:
		tmp = U + t_0
	return tmp
function code(J, l, K, U)
	t_0 = Float64((l ^ 3.0) * Float64(J * 0.3333333333333333))
	tmp = 0.0
	if (l <= -1.7e+35)
		tmp = Float64(U * Float64(1.0 + Float64(t_0 / U)));
	elseif (l <= 6600000.0)
		tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(l * Float64(J * 2.0))));
	elseif (l <= 3.55e+74)
		tmp = Float64(U * Float64(U - -4.0));
	elseif ((l <= 4.3e+83) || (!(l <= 4.5e+172) && (l <= 1.3e+194)))
		tmp = Float64(Float64(J * Float64(l * (K ^ 2.0))) * -0.25);
	else
		tmp = Float64(U + t_0);
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = (l ^ 3.0) * (J * 0.3333333333333333);
	tmp = 0.0;
	if (l <= -1.7e+35)
		tmp = U * (1.0 + (t_0 / U));
	elseif (l <= 6600000.0)
		tmp = U + (cos((K / 2.0)) * (l * (J * 2.0)));
	elseif (l <= 3.55e+74)
		tmp = U * (U - -4.0);
	elseif ((l <= 4.3e+83) || (~((l <= 4.5e+172)) && (l <= 1.3e+194)))
		tmp = (J * (l * (K ^ 2.0))) * -0.25;
	else
		tmp = U + t_0;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.7e+35], N[(U * N[(1.0 + N[(t$95$0 / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6600000.0], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3.55e+74], N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[l, 4.3e+83], And[N[Not[LessEqual[l, 4.5e+172]], $MachinePrecision], LessEqual[l, 1.3e+194]]], N[(N[(J * N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision], N[(U + t$95$0), $MachinePrecision]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;\ell \leq 3.55 \cdot 10^{+74}:\\
\;\;\;\;U \cdot \left(U - -4\right)\\

\mathbf{elif}\;\ell \leq 4.3 \cdot 10^{+83} \lor \neg \left(\ell \leq 4.5 \cdot 10^{+172}\right) \land \ell \leq 1.3 \cdot 10^{+194}:\\
\;\;\;\;\left(J \cdot \left(\ell \cdot {K}^{2}\right)\right) \cdot -0.25\\

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


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

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

      \[\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-rgt-in88.8%

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

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

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

        \[\leadsto \left(J \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \cdot \color{blue}{{\ell}^{\left(2 + 1\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. metadata-eval88.8%

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

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

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

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

      \[\leadsto U \cdot \left(1 + \frac{\color{blue}{0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)}}{U}\right) \]
    9. Step-by-step derivation
      1. *-commutative78.5%

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

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

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

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

    if -1.7000000000000001e35 < l < 6.6e6

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

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

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

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

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

    if 6.6e6 < l < 3.55000000000000001e74

    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-rr37.0%

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

    if 3.55000000000000001e74 < l < 4.3e83 or 4.5000000000000002e172 < l < 1.2999999999999999e194

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

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

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

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

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

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

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

    if 4.3e83 < l < 4.5000000000000002e172 or 1.2999999999999999e194 < 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 95.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-rgt-in95.0%

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

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

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

        \[\leadsto \left(J \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \cdot \color{blue}{{\ell}^{\left(2 + 1\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. metadata-eval95.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.7 \cdot 10^{+35}:\\ \;\;\;\;U \cdot \left(1 + \frac{{\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)}{U}\right)\\ \mathbf{elif}\;\ell \leq 6600000:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(J \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 3.55 \cdot 10^{+74}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{elif}\;\ell \leq 4.3 \cdot 10^{+83} \lor \neg \left(\ell \leq 4.5 \cdot 10^{+172}\right) \land \ell \leq 1.3 \cdot 10^{+194}:\\ \;\;\;\;\left(J \cdot \left(\ell \cdot {K}^{2}\right)\right) \cdot -0.25\\ \mathbf{else}:\\ \;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 75.7% accurate, 2.4× speedup?

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

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

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

\mathbf{elif}\;\ell \leq 1.45 \cdot 10^{+208}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell + -0.125 \cdot \left(\ell \cdot {K}^{2}\right)\right)\right)\\

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


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

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

      \[\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-rgt-in88.8%

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

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

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

        \[\leadsto \left(J \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \cdot \color{blue}{{\ell}^{\left(2 + 1\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. metadata-eval88.8%

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

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

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

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

      \[\leadsto U \cdot \left(1 + \frac{\color{blue}{0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)}}{U}\right) \]
    9. Step-by-step derivation
      1. *-commutative78.5%

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

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

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

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

    if -2.1499999999999999e32 < l < 1.74999999999999998e-4

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

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

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

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

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

    if 1.74999999999999998e-4 < l < 1.45000000000000004e208

    1. Initial program 99.6%

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

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

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

    if 1.45000000000000004e208 < 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. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \left(J \cdot \color{blue}{\mathsf{fma}\left(2, \ell, \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 \mathsf{fma}\left(2, \ell, \color{blue}{0.3333333333333333 \cdot \left({\ell}^{2} \cdot \ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      4. pow-plus100.0%

        \[\leadsto \left(J \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \cdot \color{blue}{{\ell}^{\left(2 + 1\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. metadata-eval100.0%

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

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

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

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

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

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

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

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

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

Alternative 14: 69.2% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -9500000000000:\\ \;\;\;\;J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\ \mathbf{elif}\;\ell \leq 1650:\\ \;\;\;\;\mathsf{fma}\left(J, \ell \cdot 2, U\right)\\ \mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+146}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{else}:\\ \;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -9500000000000.0)
   (* J (* 0.3333333333333333 (pow l 3.0)))
   (if (<= l 1650.0)
     (fma J (* l 2.0) U)
     (if (<= l 1.3e+146)
       (* U (- U -4.0))
       (+ U (* (pow l 3.0) (* J 0.3333333333333333)))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -9500000000000.0) {
		tmp = J * (0.3333333333333333 * pow(l, 3.0));
	} else if (l <= 1650.0) {
		tmp = fma(J, (l * 2.0), U);
	} else if (l <= 1.3e+146) {
		tmp = U * (U - -4.0);
	} else {
		tmp = U + (pow(l, 3.0) * (J * 0.3333333333333333));
	}
	return tmp;
}
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -9500000000000.0)
		tmp = Float64(J * Float64(0.3333333333333333 * (l ^ 3.0)));
	elseif (l <= 1650.0)
		tmp = fma(J, Float64(l * 2.0), U);
	elseif (l <= 1.3e+146)
		tmp = Float64(U * Float64(U - -4.0));
	else
		tmp = Float64(U + Float64((l ^ 3.0) * Float64(J * 0.3333333333333333)));
	end
	return tmp
end
code[J_, l_, K_, U_] := If[LessEqual[l, -9500000000000.0], N[(J * N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1650.0], N[(J * N[(l * 2.0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 1.3e+146], N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -9500000000000:\\
\;\;\;\;J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\

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

\mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+146}:\\
\;\;\;\;U \cdot \left(U - -4\right)\\

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


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

    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 86.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-rgt-in86.0%

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

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

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

        \[\leadsto \left(J \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \cdot \color{blue}{{\ell}^{\left(2 + 1\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. metadata-eval86.0%

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

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

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

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

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

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

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

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

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

    if -9.5e12 < l < 1650

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, 2 \cdot \ell, U\right)} \]
      6. *-commutative83.2%

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

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

    if 1650 < l < 1.30000000000000007e146

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

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

    if 1.30000000000000007e146 < 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. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \left(J \cdot \color{blue}{\mathsf{fma}\left(2, \ell, \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 \mathsf{fma}\left(2, \ell, \color{blue}{0.3333333333333333 \cdot \left({\ell}^{2} \cdot \ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      4. pow-plus100.0%

        \[\leadsto \left(J \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \cdot \color{blue}{{\ell}^{\left(2 + 1\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. metadata-eval100.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -9500000000000:\\ \;\;\;\;J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\ \mathbf{elif}\;\ell \leq 1650:\\ \;\;\;\;\mathsf{fma}\left(J, \ell \cdot 2, U\right)\\ \mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+146}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{else}:\\ \;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 68.9% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -8.5 \cdot 10^{-6}:\\ \;\;\;\;J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 980000:\\ \;\;\;\;\mathsf{fma}\left(J, \ell \cdot 2, U\right)\\ \mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+146}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{else}:\\ \;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -8.5e-6)
   (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))
   (if (<= l 980000.0)
     (fma J (* l 2.0) U)
     (if (<= l 1.3e+146)
       (* U (- U -4.0))
       (+ U (* (pow l 3.0) (* J 0.3333333333333333)))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -8.5e-6) {
		tmp = J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0));
	} else if (l <= 980000.0) {
		tmp = fma(J, (l * 2.0), U);
	} else if (l <= 1.3e+146) {
		tmp = U * (U - -4.0);
	} else {
		tmp = U + (pow(l, 3.0) * (J * 0.3333333333333333));
	}
	return tmp;
}
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -8.5e-6)
		tmp = Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)));
	elseif (l <= 980000.0)
		tmp = fma(J, Float64(l * 2.0), U);
	elseif (l <= 1.3e+146)
		tmp = Float64(U * Float64(U - -4.0));
	else
		tmp = Float64(U + Float64((l ^ 3.0) * Float64(J * 0.3333333333333333)));
	end
	return tmp
end
code[J_, l_, K_, U_] := If[LessEqual[l, -8.5e-6], N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 980000.0], N[(J * N[(l * 2.0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 1.3e+146], N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+146}:\\
\;\;\;\;U \cdot \left(U - -4\right)\\

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


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

    1. Initial program 99.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 83.8%

      \[\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-rgt-in83.8%

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

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

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

        \[\leadsto \left(J \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \cdot \color{blue}{{\ell}^{\left(2 + 1\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. metadata-eval83.8%

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

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

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

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

    if -8.4999999999999999e-6 < l < 9.8e5

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, 2 \cdot \ell, U\right)} \]
      6. *-commutative84.4%

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

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

    if 9.8e5 < l < 1.30000000000000007e146

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

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

    if 1.30000000000000007e146 < 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. Step-by-step derivation
      1. distribute-rgt-in100.0%

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

        \[\leadsto \left(J \cdot \color{blue}{\mathsf{fma}\left(2, \ell, \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 \mathsf{fma}\left(2, \ell, \color{blue}{0.3333333333333333 \cdot \left({\ell}^{2} \cdot \ell\right)}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      4. pow-plus100.0%

        \[\leadsto \left(J \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \cdot \color{blue}{{\ell}^{\left(2 + 1\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. metadata-eval100.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -8.5 \cdot 10^{-6}:\\ \;\;\;\;J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\ \mathbf{elif}\;\ell \leq 980000:\\ \;\;\;\;\mathsf{fma}\left(J, \ell \cdot 2, U\right)\\ \mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+146}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{else}:\\ \;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 69.2% 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 -650000000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq 1050:\\ \;\;\;\;\mathsf{fma}\left(J, \ell \cdot 2, U\right)\\ \mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+146}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{else}:\\ \;\;\;\;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 -650000000000.0)
     t_0
     (if (<= l 1050.0)
       (fma J (* l 2.0) U)
       (if (<= l 1.3e+146) (* U (- U -4.0)) 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 <= -650000000000.0) {
		tmp = t_0;
	} else if (l <= 1050.0) {
		tmp = fma(J, (l * 2.0), U);
	} else if (l <= 1.3e+146) {
		tmp = U * (U - -4.0);
	} else {
		tmp = 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 <= -650000000000.0)
		tmp = t_0;
	elseif (l <= 1050.0)
		tmp = fma(J, Float64(l * 2.0), U);
	elseif (l <= 1.3e+146)
		tmp = Float64(U * Float64(U - -4.0));
	else
		tmp = t_0;
	end
	return 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, -650000000000.0], t$95$0, If[LessEqual[l, 1050.0], N[(J * N[(l * 2.0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 1.3e+146], N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+146}:\\
\;\;\;\;U \cdot \left(U - -4\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -6.5e11 or 1.30000000000000007e146 < 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 90.8%

      \[\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-rgt-in90.8%

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

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

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

        \[\leadsto \left(J \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \cdot \color{blue}{{\ell}^{\left(2 + 1\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. metadata-eval90.8%

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

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

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

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

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

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

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

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

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

    if -6.5e11 < l < 1050

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, 2 \cdot \ell, U\right)} \]
      6. *-commutative83.2%

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

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

    if 1050 < l < 1.30000000000000007e146

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

      \[\leadsto \color{blue}{U \cdot \left(U - -4\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification76.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -650000000000:\\ \;\;\;\;J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\ \mathbf{elif}\;\ell \leq 1050:\\ \;\;\;\;\mathsf{fma}\left(J, \ell \cdot 2, U\right)\\ \mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+146}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{else}:\\ \;\;\;\;J \cdot \left(0.3333333333333333 \cdot {\ell}^{3}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 59.6% accurate, 14.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 2050000000 \lor \neg \left(\ell \leq 1.3 \cdot 10^{+146}\right):\\
\;\;\;\;U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell}{U}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;U \cdot \left(U - -4\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 2.05e9 or 1.30000000000000007e146 < l

    1. Initial program 82.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 94.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-rgt-in94.7%

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

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

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

        \[\leadsto \left(J \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \cdot \color{blue}{{\ell}^{\left(2 + 1\right)}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
      5. metadata-eval94.7%

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

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

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

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

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

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

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

    if 2.05e9 < l < 1.30000000000000007e146

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 2050000000 \lor \neg \left(\ell \leq 1.3 \cdot 10^{+146}\right):\\ \;\;\;\;U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell}{U}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 46.3% accurate, 15.6× speedup?

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

\\
\begin{array}{l}
t_0 := 2 \cdot \left(\ell \cdot J\right)\\
\mathbf{if}\;\ell \leq -3.1 \cdot 10^{-9}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;\ell \leq 500:\\
\;\;\;\;U\\

\mathbf{elif}\;\ell \leq 1.8 \cdot 10^{+146}:\\
\;\;\;\;U \cdot U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -3.10000000000000005e-9 or 1.7999999999999999e146 < l

    1. Initial program 99.4%

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

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

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

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

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

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

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

    if -3.10000000000000005e-9 < l < 500

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

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

    if 500 < l < 1.7999999999999999e146

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.1 \cdot 10^{-9}:\\ \;\;\;\;2 \cdot \left(\ell \cdot J\right)\\ \mathbf{elif}\;\ell \leq 500:\\ \;\;\;\;U\\ \mathbf{elif}\;\ell \leq 1.8 \cdot 10^{+146}:\\ \;\;\;\;U \cdot U\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\ell \cdot J\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 19: 46.3% accurate, 15.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 2 \cdot \left(\ell \cdot J\right)\\ \mathbf{if}\;\ell \leq -3.1 \cdot 10^{-9}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq 760:\\ \;\;\;\;U\\ \mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+146}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (* 2.0 (* l J))))
   (if (<= l -3.1e-9)
     t_0
     (if (<= l 760.0) U (if (<= l 1.3e+146) (* U (- U -4.0)) t_0)))))
double code(double J, double l, double K, double U) {
	double t_0 = 2.0 * (l * J);
	double tmp;
	if (l <= -3.1e-9) {
		tmp = t_0;
	} else if (l <= 760.0) {
		tmp = U;
	} else if (l <= 1.3e+146) {
		tmp = U * (U - -4.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 2.0d0 * (l * j)
    if (l <= (-3.1d-9)) then
        tmp = t_0
    else if (l <= 760.0d0) then
        tmp = u
    else if (l <= 1.3d+146) then
        tmp = u * (u - (-4.0d0))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = 2.0 * (l * J);
	double tmp;
	if (l <= -3.1e-9) {
		tmp = t_0;
	} else if (l <= 760.0) {
		tmp = U;
	} else if (l <= 1.3e+146) {
		tmp = U * (U - -4.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = 2.0 * (l * J)
	tmp = 0
	if l <= -3.1e-9:
		tmp = t_0
	elif l <= 760.0:
		tmp = U
	elif l <= 1.3e+146:
		tmp = U * (U - -4.0)
	else:
		tmp = t_0
	return tmp
function code(J, l, K, U)
	t_0 = Float64(2.0 * Float64(l * J))
	tmp = 0.0
	if (l <= -3.1e-9)
		tmp = t_0;
	elseif (l <= 760.0)
		tmp = U;
	elseif (l <= 1.3e+146)
		tmp = Float64(U * Float64(U - -4.0));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = 2.0 * (l * J);
	tmp = 0.0;
	if (l <= -3.1e-9)
		tmp = t_0;
	elseif (l <= 760.0)
		tmp = U;
	elseif (l <= 1.3e+146)
		tmp = U * (U - -4.0);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.1e-9], t$95$0, If[LessEqual[l, 760.0], U, If[LessEqual[l, 1.3e+146], N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 2 \cdot \left(\ell \cdot J\right)\\
\mathbf{if}\;\ell \leq -3.1 \cdot 10^{-9}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;\ell \leq 760:\\
\;\;\;\;U\\

\mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+146}:\\
\;\;\;\;U \cdot \left(U - -4\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -3.10000000000000005e-9 or 1.30000000000000007e146 < l

    1. Initial program 99.4%

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

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

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

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

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

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

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

    if -3.10000000000000005e-9 < l < 760

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

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

    if 760 < l < 1.30000000000000007e146

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

      \[\leadsto \color{blue}{U \cdot \left(U - -4\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification52.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.1 \cdot 10^{-9}:\\ \;\;\;\;2 \cdot \left(\ell \cdot J\right)\\ \mathbf{elif}\;\ell \leq 760:\\ \;\;\;\;U\\ \mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+146}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\ell \cdot J\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 20: 55.1% accurate, 16.4× speedup?

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

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

\mathbf{elif}\;\ell \leq 1.55 \cdot 10^{+146}:\\
\;\;\;\;U \cdot \left(U - -4\right)\\

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


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

    1. Initial program 80.2%

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

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

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

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

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

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

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

    if 520 < l < 1.5500000000000001e146

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

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

    if 1.5500000000000001e146 < 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 43.0%

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

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

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

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

Alternative 21: 54.3% accurate, 20.8× speedup?

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

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

\mathbf{elif}\;\ell \leq 1.45 \cdot 10^{+146}:\\
\;\;\;\;U \cdot \left(U - -4\right)\\

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


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

    1. Initial program 80.2%

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

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

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

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

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

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

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

    if 1100 < l < 1.4499999999999999e146

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

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

    if 1.4499999999999999e146 < 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 43.0%

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

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

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

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

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

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

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

Alternative 22: 42.4% accurate, 23.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1020000000 \lor \neg \left(\ell \leq 14000\right):\\ \;\;\;\;U \cdot U\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (or (<= l -1020000000.0) (not (<= l 14000.0))) (* U U) U))
double code(double J, double l, double K, double U) {
	double tmp;
	if ((l <= -1020000000.0) || !(l <= 14000.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 <= (-1020000000.0d0)) .or. (.not. (l <= 14000.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 <= -1020000000.0) || !(l <= 14000.0)) {
		tmp = U * U;
	} else {
		tmp = U;
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if (l <= -1020000000.0) or not (l <= 14000.0):
		tmp = U * U
	else:
		tmp = U
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if ((l <= -1020000000.0) || !(l <= 14000.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 <= -1020000000.0) || ~((l <= 14000.0)))
		tmp = U * U;
	else
		tmp = U;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -1020000000.0], N[Not[LessEqual[l, 14000.0]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -1.02e9 or 14000 < 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-rr20.2%

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

    if -1.02e9 < l < 14000

    1. Initial program 71.1%

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

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

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

Alternative 23: 2.7% accurate, 312.0× speedup?

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

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

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

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

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

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

    \[\leadsto 1 \]
  7. Add Preprocessing

Alternative 24: 36.9% 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.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 J around 0 36.6%

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

    \[\leadsto U \]
  5. Add Preprocessing

Reproduce

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