Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 87.2% → 99.6%
Time: 10.6s
Alternatives: 20
Speedup: 1.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 20 alternatives:

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

Initial Program: 87.2% 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.6% 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 10^{-7}\right):\\ \;\;\;\;\left(t\_1 \cdot J\right) \cdot t\_0 + U\\ \mathbf{else}:\\ \;\;\;\;U + t\_0 \cdot \left(\ell \cdot \left(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 1e-7)))
     (+ (* (* t_1 J) t_0) U)
     (+ U (* t_0 (* l (* 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 <= 1e-7)) {
		tmp = ((t_1 * J) * t_0) + U;
	} else {
		tmp = U + (t_0 * (l * (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 <= 1e-7)) {
		tmp = ((t_1 * J) * t_0) + U;
	} else {
		tmp = U + (t_0 * (l * (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 <= 1e-7):
		tmp = ((t_1 * J) * t_0) + U
	else:
		tmp = U + (t_0 * (l * (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 <= 1e-7))
		tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U);
	else
		tmp = Float64(U + Float64(t_0 * Float64(l * 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 <= 1e-7)))
		tmp = ((t_1 * J) * t_0) + U;
	else
		tmp = U + (t_0 * (l * (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, 1e-7]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(l * N[(J * 2.0), $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 10^{-7}\right):\\
\;\;\;\;\left(t\_1 \cdot J\right) \cdot t\_0 + U\\

\mathbf{else}:\\
\;\;\;\;U + t\_0 \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))) < -inf.0 or 9.9999999999999995e-8 < (-.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))) < 9.9999999999999995e-8

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{\ell} - e^{-\ell} \leq -\infty \lor \neg \left(e^{\ell} - e^{-\ell} \leq 10^{-7}\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(J \cdot 2\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 94.7% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := U + {\ell}^{3} \cdot \left(\left(J \cdot 0.3333333333333333\right) \cdot \cos \left(K \cdot 0.5\right)\right)\\ t_1 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{if}\;\ell \leq -5.6 \cdot 10^{+75}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq -0.118:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\ell \leq 7.8 \cdot 10^{-6}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(J \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 5 \cdot 10^{+102}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0
         (+ U (* (pow l 3.0) (* (* J 0.3333333333333333) (cos (* K 0.5))))))
        (t_1 (+ (* (- (exp l) (exp (- l))) J) U)))
   (if (<= l -5.6e+75)
     t_0
     (if (<= l -0.118)
       t_1
       (if (<= l 7.8e-6)
         (+ U (* (cos (/ K 2.0)) (* l (* J 2.0))))
         (if (<= l 5e+102) t_1 t_0))))))
double code(double J, double l, double K, double U) {
	double t_0 = U + (pow(l, 3.0) * ((J * 0.3333333333333333) * cos((K * 0.5))));
	double t_1 = ((exp(l) - exp(-l)) * J) + U;
	double tmp;
	if (l <= -5.6e+75) {
		tmp = t_0;
	} else if (l <= -0.118) {
		tmp = t_1;
	} else if (l <= 7.8e-6) {
		tmp = U + (cos((K / 2.0)) * (l * (J * 2.0)));
	} else if (l <= 5e+102) {
		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 + ((l ** 3.0d0) * ((j * 0.3333333333333333d0) * cos((k * 0.5d0))))
    t_1 = ((exp(l) - exp(-l)) * j) + u
    if (l <= (-5.6d+75)) then
        tmp = t_0
    else if (l <= (-0.118d0)) then
        tmp = t_1
    else if (l <= 7.8d-6) then
        tmp = u + (cos((k / 2.0d0)) * (l * (j * 2.0d0)))
    else if (l <= 5d+102) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double t_0 = U + (Math.pow(l, 3.0) * ((J * 0.3333333333333333) * Math.cos((K * 0.5))));
	double t_1 = ((Math.exp(l) - Math.exp(-l)) * J) + U;
	double tmp;
	if (l <= -5.6e+75) {
		tmp = t_0;
	} else if (l <= -0.118) {
		tmp = t_1;
	} else if (l <= 7.8e-6) {
		tmp = U + (Math.cos((K / 2.0)) * (l * (J * 2.0)));
	} else if (l <= 5e+102) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = U + (math.pow(l, 3.0) * ((J * 0.3333333333333333) * math.cos((K * 0.5))))
	t_1 = ((math.exp(l) - math.exp(-l)) * J) + U
	tmp = 0
	if l <= -5.6e+75:
		tmp = t_0
	elif l <= -0.118:
		tmp = t_1
	elif l <= 7.8e-6:
		tmp = U + (math.cos((K / 2.0)) * (l * (J * 2.0)))
	elif l <= 5e+102:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(J, l, K, U)
	t_0 = Float64(U + Float64((l ^ 3.0) * Float64(Float64(J * 0.3333333333333333) * cos(Float64(K * 0.5)))))
	t_1 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U)
	tmp = 0.0
	if (l <= -5.6e+75)
		tmp = t_0;
	elseif (l <= -0.118)
		tmp = t_1;
	elseif (l <= 7.8e-6)
		tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(l * Float64(J * 2.0))));
	elseif (l <= 5e+102)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = U + ((l ^ 3.0) * ((J * 0.3333333333333333) * cos((K * 0.5))));
	t_1 = ((exp(l) - exp(-l)) * J) + U;
	tmp = 0.0;
	if (l <= -5.6e+75)
		tmp = t_0;
	elseif (l <= -0.118)
		tmp = t_1;
	elseif (l <= 7.8e-6)
		tmp = U + (cos((K / 2.0)) * (l * (J * 2.0)));
	elseif (l <= 5e+102)
		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[Power[l, 3.0], $MachinePrecision] * N[(N[(J * 0.3333333333333333), $MachinePrecision] * 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, -5.6e+75], t$95$0, If[LessEqual[l, -0.118], t$95$1, If[LessEqual[l, 7.8e-6], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5e+102], t$95$1, t$95$0]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;\ell \leq 7.8 \cdot 10^{-6}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(J \cdot 2\right)\right)\\

\mathbf{elif}\;\ell \leq 5 \cdot 10^{+102}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -5.60000000000000023e75 or 5e102 < 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.9%

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

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

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

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

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

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

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

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

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

    if -5.60000000000000023e75 < l < -0.11799999999999999 or 7.7999999999999999e-6 < l < 5e102

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

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

    if -0.11799999999999999 < l < 7.7999999999999999e-6

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

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

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

      \[\leadsto \color{blue}{\left(\left(2 \cdot J\right) \cdot \ell\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 -5.6 \cdot 10^{+75}:\\ \;\;\;\;U + {\ell}^{3} \cdot \left(\left(J \cdot 0.3333333333333333\right) \cdot \cos \left(K \cdot 0.5\right)\right)\\ \mathbf{elif}\;\ell \leq -0.118:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{elif}\;\ell \leq 7.8 \cdot 10^{-6}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(J \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 5 \cdot 10^{+102}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{else}:\\ \;\;\;\;U + {\ell}^{3} \cdot \left(\left(J \cdot 0.3333333333333333\right) \cdot \cos \left(K \cdot 0.5\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 77.5% accurate, 1.4× speedup?

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

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

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


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

    1. Initial program 84.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 86.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 92.2%

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

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

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

Alternative 4: 86.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -0.06 \lor \neg \left(\ell \leq 7.8 \cdot 10^{-6}\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} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (or (<= l -0.06) (not (<= l 7.8e-6)))
   (+ (* (- (exp l) (exp (- l))) J) U)
   (+ U (* (cos (/ K 2.0)) (* l (* J 2.0))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if ((l <= -0.06) || !(l <= 7.8e-6)) {
		tmp = ((exp(l) - exp(-l)) * 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) :: tmp
    if ((l <= (-0.06d0)) .or. (.not. (l <= 7.8d-6))) then
        tmp = ((exp(l) - exp(-l)) * 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 tmp;
	if ((l <= -0.06) || !(l <= 7.8e-6)) {
		tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
	} else {
		tmp = U + (Math.cos((K / 2.0)) * (l * (J * 2.0)));
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if (l <= -0.06) or not (l <= 7.8e-6):
		tmp = ((math.exp(l) - math.exp(-l)) * J) + U
	else:
		tmp = U + (math.cos((K / 2.0)) * (l * (J * 2.0)))
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if ((l <= -0.06) || !(l <= 7.8e-6))
		tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * 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)
	tmp = 0.0;
	if ((l <= -0.06) || ~((l <= 7.8e-6)))
		tmp = ((exp(l) - exp(-l)) * J) + U;
	else
		tmp = U + (cos((K / 2.0)) * (l * (J * 2.0)));
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -0.06], N[Not[LessEqual[l, 7.8e-6]], $MachinePrecision]], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * 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}
\mathbf{if}\;\ell \leq -0.06 \lor \neg \left(\ell \leq 7.8 \cdot 10^{-6}\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}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -0.059999999999999998 or 7.7999999999999999e-6 < l

    1. Initial program 100.0%

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

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

    if -0.059999999999999998 < l < 7.7999999999999999e-6

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -0.06 \lor \neg \left(\ell \leq 7.8 \cdot 10^{-6}\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 5: 88.0% accurate, 1.4× speedup?

\[\begin{array}{l} \\ 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} \]
(FPCore (J l K U)
 :precision binary64
 (+
  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) {
	return U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))))));
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    code = u + (cos((k / 2.0d0)) * (j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0))))))
end function
public static double code(double J, double l, double K, double U) {
	return U + (Math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))))));
}
def code(J, l, K, U):
	return U + (math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0))))))
function code(J, l, K, U)
	return Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0)))))))
end
function tmp = code(J, l, K, U)
	tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0))))));
end
code[J_, l_, K_, U_] := N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  2. 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. Final simplification90.8%

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

Alternative 6: 44.2% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -3 \cdot 10^{+197}:\\ \;\;\;\;-4 - U \cdot U\\ \mathbf{elif}\;\ell \leq -1.05 \cdot 10^{+62}:\\ \;\;\;\;U + J \cdot \left(8 - {K}^{2}\right)\\ \mathbf{elif}\;\ell \leq -72000000000000:\\ \;\;\;\;{U}^{-4}\\ \mathbf{elif}\;\ell \leq 12200:\\ \;\;\;\;U\\ \mathbf{elif}\;\ell \leq 6.7 \cdot 10^{+140} \lor \neg \left(\ell \leq 4.1 \cdot 10^{+273}\right):\\ \;\;\;\;\frac{{U}^{3}}{U + -4}\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(0.4444444444444444 + U \cdot \left(U \cdot 0.7901234567901234 - 0.5925925925925926\right)\right) - 0.3333333333333333\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -3e+197)
   (- -4.0 (* U U))
   (if (<= l -1.05e+62)
     (+ U (* J (- 8.0 (pow K 2.0))))
     (if (<= l -72000000000000.0)
       (pow U -4.0)
       (if (<= l 12200.0)
         U
         (if (or (<= l 6.7e+140) (not (<= l 4.1e+273)))
           (/ (pow U 3.0) (+ U -4.0))
           (-
            (*
             U
             (+
              0.4444444444444444
              (* U (- (* U 0.7901234567901234) 0.5925925925925926))))
            0.3333333333333333)))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -3e+197) {
		tmp = -4.0 - (U * U);
	} else if (l <= -1.05e+62) {
		tmp = U + (J * (8.0 - pow(K, 2.0)));
	} else if (l <= -72000000000000.0) {
		tmp = pow(U, -4.0);
	} else if (l <= 12200.0) {
		tmp = U;
	} else if ((l <= 6.7e+140) || !(l <= 4.1e+273)) {
		tmp = pow(U, 3.0) / (U + -4.0);
	} else {
		tmp = (U * (0.4444444444444444 + (U * ((U * 0.7901234567901234) - 0.5925925925925926)))) - 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 <= (-3d+197)) then
        tmp = (-4.0d0) - (u * u)
    else if (l <= (-1.05d+62)) then
        tmp = u + (j * (8.0d0 - (k ** 2.0d0)))
    else if (l <= (-72000000000000.0d0)) then
        tmp = u ** (-4.0d0)
    else if (l <= 12200.0d0) then
        tmp = u
    else if ((l <= 6.7d+140) .or. (.not. (l <= 4.1d+273))) then
        tmp = (u ** 3.0d0) / (u + (-4.0d0))
    else
        tmp = (u * (0.4444444444444444d0 + (u * ((u * 0.7901234567901234d0) - 0.5925925925925926d0)))) - 0.3333333333333333d0
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -3e+197) {
		tmp = -4.0 - (U * U);
	} else if (l <= -1.05e+62) {
		tmp = U + (J * (8.0 - Math.pow(K, 2.0)));
	} else if (l <= -72000000000000.0) {
		tmp = Math.pow(U, -4.0);
	} else if (l <= 12200.0) {
		tmp = U;
	} else if ((l <= 6.7e+140) || !(l <= 4.1e+273)) {
		tmp = Math.pow(U, 3.0) / (U + -4.0);
	} else {
		tmp = (U * (0.4444444444444444 + (U * ((U * 0.7901234567901234) - 0.5925925925925926)))) - 0.3333333333333333;
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -3e+197:
		tmp = -4.0 - (U * U)
	elif l <= -1.05e+62:
		tmp = U + (J * (8.0 - math.pow(K, 2.0)))
	elif l <= -72000000000000.0:
		tmp = math.pow(U, -4.0)
	elif l <= 12200.0:
		tmp = U
	elif (l <= 6.7e+140) or not (l <= 4.1e+273):
		tmp = math.pow(U, 3.0) / (U + -4.0)
	else:
		tmp = (U * (0.4444444444444444 + (U * ((U * 0.7901234567901234) - 0.5925925925925926)))) - 0.3333333333333333
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -3e+197)
		tmp = Float64(-4.0 - Float64(U * U));
	elseif (l <= -1.05e+62)
		tmp = Float64(U + Float64(J * Float64(8.0 - (K ^ 2.0))));
	elseif (l <= -72000000000000.0)
		tmp = U ^ -4.0;
	elseif (l <= 12200.0)
		tmp = U;
	elseif ((l <= 6.7e+140) || !(l <= 4.1e+273))
		tmp = Float64((U ^ 3.0) / Float64(U + -4.0));
	else
		tmp = Float64(Float64(U * Float64(0.4444444444444444 + Float64(U * Float64(Float64(U * 0.7901234567901234) - 0.5925925925925926)))) - 0.3333333333333333);
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= -3e+197)
		tmp = -4.0 - (U * U);
	elseif (l <= -1.05e+62)
		tmp = U + (J * (8.0 - (K ^ 2.0)));
	elseif (l <= -72000000000000.0)
		tmp = U ^ -4.0;
	elseif (l <= 12200.0)
		tmp = U;
	elseif ((l <= 6.7e+140) || ~((l <= 4.1e+273)))
		tmp = (U ^ 3.0) / (U + -4.0);
	else
		tmp = (U * (0.4444444444444444 + (U * ((U * 0.7901234567901234) - 0.5925925925925926)))) - 0.3333333333333333;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -3e+197], N[(-4.0 - N[(U * U), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -1.05e+62], N[(U + N[(J * N[(8.0 - N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -72000000000000.0], N[Power[U, -4.0], $MachinePrecision], If[LessEqual[l, 12200.0], U, If[Or[LessEqual[l, 6.7e+140], N[Not[LessEqual[l, 4.1e+273]], $MachinePrecision]], N[(N[Power[U, 3.0], $MachinePrecision] / N[(U + -4.0), $MachinePrecision]), $MachinePrecision], N[(N[(U * N[(0.4444444444444444 + N[(U * N[(N[(U * 0.7901234567901234), $MachinePrecision] - 0.5925925925925926), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3 \cdot 10^{+197}:\\
\;\;\;\;-4 - U \cdot U\\

\mathbf{elif}\;\ell \leq -1.05 \cdot 10^{+62}:\\
\;\;\;\;U + J \cdot \left(8 - {K}^{2}\right)\\

\mathbf{elif}\;\ell \leq -72000000000000:\\
\;\;\;\;{U}^{-4}\\

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

\mathbf{elif}\;\ell \leq 6.7 \cdot 10^{+140} \lor \neg \left(\ell \leq 4.1 \cdot 10^{+273}\right):\\
\;\;\;\;\frac{{U}^{3}}{U + -4}\\

\mathbf{else}:\\
\;\;\;\;U \cdot \left(0.4444444444444444 + U \cdot \left(U \cdot 0.7901234567901234 - 0.5925925925925926\right)\right) - 0.3333333333333333\\


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

    1. Initial program 100.0%

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

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

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

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

      \[\leadsto \color{blue}{-4 + \left(-U\right) \cdot U} \]
    6. Step-by-step derivation
      1. cancel-sign-sub-inv27.7%

        \[\leadsto \color{blue}{-4 - U \cdot U} \]
    7. Simplified27.7%

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

    if -3.0000000000000002e197 < l < -1.05e62

    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-rr1.1%

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

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

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

        \[\leadsto \color{blue}{\left(8 \cdot J + \left(-1 \cdot J\right) \cdot {K}^{2}\right)} + U \]
      3. mul-1-neg23.3%

        \[\leadsto \left(8 \cdot J + \color{blue}{\left(-J\right)} \cdot {K}^{2}\right) + U \]
      4. cancel-sign-sub-inv23.3%

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

        \[\leadsto \left(\color{blue}{J \cdot 8} - J \cdot {K}^{2}\right) + U \]
      6. distribute-lft-out--26.5%

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

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

    if -1.05e62 < l < -7.2e13

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

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

    if -7.2e13 < l < 12200

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

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

    if 12200 < l < 6.7e140 or 4.09999999999999991e273 < 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-rr31.6%

      \[\leadsto \color{blue}{U \cdot \left(U - -4\right)} \]
    4. Step-by-step derivation
      1. *-commutative31.6%

        \[\leadsto \color{blue}{\left(U - -4\right) \cdot U} \]
      2. flip--31.6%

        \[\leadsto \color{blue}{\frac{U \cdot U - -4 \cdot -4}{U + -4}} \cdot U \]
      3. associate-*l/34.3%

        \[\leadsto \color{blue}{\frac{\left(U \cdot U - -4 \cdot -4\right) \cdot U}{U + -4}} \]
      4. fmm-def34.3%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(U, U, --4 \cdot -4\right)} \cdot U}{U + -4} \]
      5. metadata-eval34.3%

        \[\leadsto \frac{\mathsf{fma}\left(U, U, -\color{blue}{16}\right) \cdot U}{U + -4} \]
      6. metadata-eval34.3%

        \[\leadsto \frac{\mathsf{fma}\left(U, U, \color{blue}{-16}\right) \cdot U}{U + -4} \]
    5. Applied egg-rr34.3%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(U, U, -16\right) \cdot U}{U + -4}} \]
    6. Taylor expanded in U around inf 34.3%

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

    if 6.7e140 < l < 4.09999999999999991e273

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

      \[\leadsto \color{blue}{\frac{U}{U + \left(-4 \cdot U + U \cdot \left(-4 \cdot U\right)\right)}} \]
    4. Step-by-step derivation
      1. associate-+r+1.8%

        \[\leadsto \frac{U}{\color{blue}{\left(U + -4 \cdot U\right) + U \cdot \left(-4 \cdot U\right)}} \]
      2. distribute-rgt1-in1.8%

        \[\leadsto \frac{U}{\color{blue}{\left(-4 + 1\right) \cdot U} + U \cdot \left(-4 \cdot U\right)} \]
      3. metadata-eval1.8%

        \[\leadsto \frac{U}{\color{blue}{-3} \cdot U + U \cdot \left(-4 \cdot U\right)} \]
      4. *-commutative1.8%

        \[\leadsto \frac{U}{\color{blue}{U \cdot -3} + U \cdot \left(-4 \cdot U\right)} \]
      5. distribute-lft-out1.8%

        \[\leadsto \frac{U}{\color{blue}{U \cdot \left(-3 + -4 \cdot U\right)}} \]
      6. associate-/r*1.7%

        \[\leadsto \color{blue}{\frac{\frac{U}{U}}{-3 + -4 \cdot U}} \]
      7. *-inverses1.7%

        \[\leadsto \frac{\color{blue}{1}}{-3 + -4 \cdot U} \]
      8. +-commutative1.7%

        \[\leadsto \frac{1}{\color{blue}{-4 \cdot U + -3}} \]
      9. *-commutative1.7%

        \[\leadsto \frac{1}{\color{blue}{U \cdot -4} + -3} \]
    5. Simplified1.7%

      \[\leadsto \color{blue}{\frac{1}{U \cdot -4 + -3}} \]
    6. Taylor expanded in U around 0 36.9%

      \[\leadsto \color{blue}{U \cdot \left(0.4444444444444444 + U \cdot \left(0.7901234567901234 \cdot U - 0.5925925925925926\right)\right) - 0.3333333333333333} \]
  3. Recombined 6 regimes into one program.
  4. Final simplification51.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3 \cdot 10^{+197}:\\ \;\;\;\;-4 - U \cdot U\\ \mathbf{elif}\;\ell \leq -1.05 \cdot 10^{+62}:\\ \;\;\;\;U + J \cdot \left(8 - {K}^{2}\right)\\ \mathbf{elif}\;\ell \leq -72000000000000:\\ \;\;\;\;{U}^{-4}\\ \mathbf{elif}\;\ell \leq 12200:\\ \;\;\;\;U\\ \mathbf{elif}\;\ell \leq 6.7 \cdot 10^{+140} \lor \neg \left(\ell \leq 4.1 \cdot 10^{+273}\right):\\ \;\;\;\;\frac{{U}^{3}}{U + -4}\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(0.4444444444444444 + U \cdot \left(U \cdot 0.7901234567901234 - 0.5925925925925926\right)\right) - 0.3333333333333333\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 77.7% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.8 \cdot 10^{+84} \lor \neg \left(\ell \leq 0.47\right):\\
\;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -2.79999999999999982e84 or 0.46999999999999997 < l

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.79999999999999982e84 < l < 0.46999999999999997

    1. Initial program 74.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 91.4%

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

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

Alternative 8: 77.7% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.8 \cdot 10^{+84} \lor \neg \left(\ell \leq 0.47\right):\\
\;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -2.79999999999999982e84 or 0.46999999999999997 < l

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.79999999999999982e84 < l < 0.46999999999999997

    1. Initial program 74.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 92.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 77.7% accurate, 2.6× speedup?

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

\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 l < -2.89999999999999989e84 or 0.46999999999999997 < l

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.89999999999999989e84 < l < 0.46999999999999997

    1. Initial program 74.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 91.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*91.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.9 \cdot 10^{+84} \lor \neg \left(\ell \leq 0.47\right):\\ \;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\ \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 10: 45.1% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -940:\\ \;\;\;\;\frac{\frac{0.1875 + \frac{-0.140625}{U}}{U} - 0.25}{U}\\ \mathbf{elif}\;\ell \leq 12200:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;\frac{{U}^{3}}{U + -4}\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -940.0)
   (/ (- (/ (+ 0.1875 (/ -0.140625 U)) U) 0.25) U)
   (if (<= l 12200.0) U (/ (pow U 3.0) (+ U -4.0)))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -940.0) {
		tmp = (((0.1875 + (-0.140625 / U)) / U) - 0.25) / U;
	} else if (l <= 12200.0) {
		tmp = U;
	} else {
		tmp = pow(U, 3.0) / (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 <= (-940.0d0)) then
        tmp = (((0.1875d0 + ((-0.140625d0) / u)) / u) - 0.25d0) / u
    else if (l <= 12200.0d0) then
        tmp = u
    else
        tmp = (u ** 3.0d0) / (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 <= -940.0) {
		tmp = (((0.1875 + (-0.140625 / U)) / U) - 0.25) / U;
	} else if (l <= 12200.0) {
		tmp = U;
	} else {
		tmp = Math.pow(U, 3.0) / (U + -4.0);
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -940.0:
		tmp = (((0.1875 + (-0.140625 / U)) / U) - 0.25) / U
	elif l <= 12200.0:
		tmp = U
	else:
		tmp = math.pow(U, 3.0) / (U + -4.0)
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -940.0)
		tmp = Float64(Float64(Float64(Float64(0.1875 + Float64(-0.140625 / U)) / U) - 0.25) / U);
	elseif (l <= 12200.0)
		tmp = U;
	else
		tmp = Float64((U ^ 3.0) / Float64(U + -4.0));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= -940.0)
		tmp = (((0.1875 + (-0.140625 / U)) / U) - 0.25) / U;
	elseif (l <= 12200.0)
		tmp = U;
	else
		tmp = (U ^ 3.0) / (U + -4.0);
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -940.0], N[(N[(N[(N[(0.1875 + N[(-0.140625 / U), $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision] - 0.25), $MachinePrecision] / U), $MachinePrecision], If[LessEqual[l, 12200.0], U, N[(N[Power[U, 3.0], $MachinePrecision] / N[(U + -4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -940:\\
\;\;\;\;\frac{\frac{0.1875 + \frac{-0.140625}{U}}{U} - 0.25}{U}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{{U}^{3}}{U + -4}\\


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

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

      \[\leadsto \color{blue}{\frac{U}{U + \left(-4 \cdot U + U \cdot \left(-4 \cdot U\right)\right)}} \]
    4. Step-by-step derivation
      1. associate-+r+1.6%

        \[\leadsto \frac{U}{\color{blue}{\left(U + -4 \cdot U\right) + U \cdot \left(-4 \cdot U\right)}} \]
      2. distribute-rgt1-in1.6%

        \[\leadsto \frac{U}{\color{blue}{\left(-4 + 1\right) \cdot U} + U \cdot \left(-4 \cdot U\right)} \]
      3. metadata-eval1.6%

        \[\leadsto \frac{U}{\color{blue}{-3} \cdot U + U \cdot \left(-4 \cdot U\right)} \]
      4. *-commutative1.6%

        \[\leadsto \frac{U}{\color{blue}{U \cdot -3} + U \cdot \left(-4 \cdot U\right)} \]
      5. distribute-lft-out1.6%

        \[\leadsto \frac{U}{\color{blue}{U \cdot \left(-3 + -4 \cdot U\right)}} \]
      6. associate-/r*1.5%

        \[\leadsto \color{blue}{\frac{\frac{U}{U}}{-3 + -4 \cdot U}} \]
      7. *-inverses1.5%

        \[\leadsto \frac{\color{blue}{1}}{-3 + -4 \cdot U} \]
      8. +-commutative1.5%

        \[\leadsto \frac{1}{\color{blue}{-4 \cdot U + -3}} \]
      9. *-commutative1.5%

        \[\leadsto \frac{1}{\color{blue}{U \cdot -4} + -3} \]
    5. Simplified1.5%

      \[\leadsto \color{blue}{\frac{1}{U \cdot -4 + -3}} \]
    6. Taylor expanded in U around inf 18.8%

      \[\leadsto \color{blue}{\frac{0.1875 \cdot \frac{1}{U} - \left(0.25 + \frac{0.140625}{{U}^{2}}\right)}{U}} \]
    7. Step-by-step derivation
      1. +-commutative18.8%

        \[\leadsto \frac{0.1875 \cdot \frac{1}{U} - \color{blue}{\left(\frac{0.140625}{{U}^{2}} + 0.25\right)}}{U} \]
      2. associate--r+18.8%

        \[\leadsto \frac{\color{blue}{\left(0.1875 \cdot \frac{1}{U} - \frac{0.140625}{{U}^{2}}\right) - 0.25}}{U} \]
      3. associate-*r/18.8%

        \[\leadsto \frac{\left(\color{blue}{\frac{0.1875 \cdot 1}{U}} - \frac{0.140625}{{U}^{2}}\right) - 0.25}{U} \]
      4. metadata-eval18.8%

        \[\leadsto \frac{\left(\frac{\color{blue}{0.1875}}{U} - \frac{0.140625}{{U}^{2}}\right) - 0.25}{U} \]
      5. unpow218.8%

        \[\leadsto \frac{\left(\frac{0.1875}{U} - \frac{0.140625}{\color{blue}{U \cdot U}}\right) - 0.25}{U} \]
      6. associate-/r*18.8%

        \[\leadsto \frac{\left(\frac{0.1875}{U} - \color{blue}{\frac{\frac{0.140625}{U}}{U}}\right) - 0.25}{U} \]
      7. metadata-eval18.8%

        \[\leadsto \frac{\left(\frac{0.1875}{U} - \frac{\frac{\color{blue}{0.140625 \cdot 1}}{U}}{U}\right) - 0.25}{U} \]
      8. associate-*r/18.8%

        \[\leadsto \frac{\left(\frac{0.1875}{U} - \frac{\color{blue}{0.140625 \cdot \frac{1}{U}}}{U}\right) - 0.25}{U} \]
      9. div-sub18.8%

        \[\leadsto \frac{\color{blue}{\frac{0.1875 - 0.140625 \cdot \frac{1}{U}}{U}} - 0.25}{U} \]
      10. sub-neg18.8%

        \[\leadsto \frac{\frac{\color{blue}{0.1875 + \left(-0.140625 \cdot \frac{1}{U}\right)}}{U} - 0.25}{U} \]
      11. associate-*r/18.8%

        \[\leadsto \frac{\frac{0.1875 + \left(-\color{blue}{\frac{0.140625 \cdot 1}{U}}\right)}{U} - 0.25}{U} \]
      12. metadata-eval18.8%

        \[\leadsto \frac{\frac{0.1875 + \left(-\frac{\color{blue}{0.140625}}{U}\right)}{U} - 0.25}{U} \]
      13. distribute-neg-frac18.8%

        \[\leadsto \frac{\frac{0.1875 + \color{blue}{\frac{-0.140625}{U}}}{U} - 0.25}{U} \]
      14. metadata-eval18.8%

        \[\leadsto \frac{\frac{0.1875 + \frac{\color{blue}{-0.140625}}{U}}{U} - 0.25}{U} \]
    8. Simplified18.8%

      \[\leadsto \color{blue}{\frac{\frac{0.1875 + \frac{-0.140625}{U}}{U} - 0.25}{U}} \]

    if -940 < l < 12200

    1. Initial program 72.2%

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

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

    if 12200 < 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-rr21.9%

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

        \[\leadsto \color{blue}{\left(U - -4\right) \cdot U} \]
      2. flip--21.9%

        \[\leadsto \color{blue}{\frac{U \cdot U - -4 \cdot -4}{U + -4}} \cdot U \]
      3. associate-*l/27.7%

        \[\leadsto \color{blue}{\frac{\left(U \cdot U - -4 \cdot -4\right) \cdot U}{U + -4}} \]
      4. fmm-def27.7%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(U, U, --4 \cdot -4\right)} \cdot U}{U + -4} \]
      5. metadata-eval27.7%

        \[\leadsto \frac{\mathsf{fma}\left(U, U, -\color{blue}{16}\right) \cdot U}{U + -4} \]
      6. metadata-eval27.7%

        \[\leadsto \frac{\mathsf{fma}\left(U, U, \color{blue}{-16}\right) \cdot U}{U + -4} \]
    5. Applied egg-rr27.7%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(U, U, -16\right) \cdot U}{U + -4}} \]
    6. Taylor expanded in U around inf 27.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -940:\\ \;\;\;\;\frac{\frac{0.1875 + \frac{-0.140625}{U}}{U} - 0.25}{U}\\ \mathbf{elif}\;\ell \leq 12200:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;\frac{{U}^{3}}{U + -4}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 65.0% accurate, 2.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto U + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right) \]
  11. Add Preprocessing

Alternative 12: 44.5% accurate, 11.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -600:\\
\;\;\;\;\frac{\frac{0.1875 + \frac{-0.140625}{U}}{U} - 0.25}{U}\\

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

\mathbf{elif}\;\ell \leq 4 \cdot 10^{+141}:\\
\;\;\;\;U \cdot U\\

\mathbf{else}:\\
\;\;\;\;U \cdot \left(0.4444444444444444 + U \cdot \left(U \cdot 0.7901234567901234 - 0.5925925925925926\right)\right) - 0.3333333333333333\\


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

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

      \[\leadsto \color{blue}{\frac{U}{U + \left(-4 \cdot U + U \cdot \left(-4 \cdot U\right)\right)}} \]
    4. Step-by-step derivation
      1. associate-+r+1.6%

        \[\leadsto \frac{U}{\color{blue}{\left(U + -4 \cdot U\right) + U \cdot \left(-4 \cdot U\right)}} \]
      2. distribute-rgt1-in1.6%

        \[\leadsto \frac{U}{\color{blue}{\left(-4 + 1\right) \cdot U} + U \cdot \left(-4 \cdot U\right)} \]
      3. metadata-eval1.6%

        \[\leadsto \frac{U}{\color{blue}{-3} \cdot U + U \cdot \left(-4 \cdot U\right)} \]
      4. *-commutative1.6%

        \[\leadsto \frac{U}{\color{blue}{U \cdot -3} + U \cdot \left(-4 \cdot U\right)} \]
      5. distribute-lft-out1.6%

        \[\leadsto \frac{U}{\color{blue}{U \cdot \left(-3 + -4 \cdot U\right)}} \]
      6. associate-/r*1.5%

        \[\leadsto \color{blue}{\frac{\frac{U}{U}}{-3 + -4 \cdot U}} \]
      7. *-inverses1.5%

        \[\leadsto \frac{\color{blue}{1}}{-3 + -4 \cdot U} \]
      8. +-commutative1.5%

        \[\leadsto \frac{1}{\color{blue}{-4 \cdot U + -3}} \]
      9. *-commutative1.5%

        \[\leadsto \frac{1}{\color{blue}{U \cdot -4} + -3} \]
    5. Simplified1.5%

      \[\leadsto \color{blue}{\frac{1}{U \cdot -4 + -3}} \]
    6. Taylor expanded in U around inf 18.8%

      \[\leadsto \color{blue}{\frac{0.1875 \cdot \frac{1}{U} - \left(0.25 + \frac{0.140625}{{U}^{2}}\right)}{U}} \]
    7. Step-by-step derivation
      1. +-commutative18.8%

        \[\leadsto \frac{0.1875 \cdot \frac{1}{U} - \color{blue}{\left(\frac{0.140625}{{U}^{2}} + 0.25\right)}}{U} \]
      2. associate--r+18.8%

        \[\leadsto \frac{\color{blue}{\left(0.1875 \cdot \frac{1}{U} - \frac{0.140625}{{U}^{2}}\right) - 0.25}}{U} \]
      3. associate-*r/18.8%

        \[\leadsto \frac{\left(\color{blue}{\frac{0.1875 \cdot 1}{U}} - \frac{0.140625}{{U}^{2}}\right) - 0.25}{U} \]
      4. metadata-eval18.8%

        \[\leadsto \frac{\left(\frac{\color{blue}{0.1875}}{U} - \frac{0.140625}{{U}^{2}}\right) - 0.25}{U} \]
      5. unpow218.8%

        \[\leadsto \frac{\left(\frac{0.1875}{U} - \frac{0.140625}{\color{blue}{U \cdot U}}\right) - 0.25}{U} \]
      6. associate-/r*18.8%

        \[\leadsto \frac{\left(\frac{0.1875}{U} - \color{blue}{\frac{\frac{0.140625}{U}}{U}}\right) - 0.25}{U} \]
      7. metadata-eval18.8%

        \[\leadsto \frac{\left(\frac{0.1875}{U} - \frac{\frac{\color{blue}{0.140625 \cdot 1}}{U}}{U}\right) - 0.25}{U} \]
      8. associate-*r/18.8%

        \[\leadsto \frac{\left(\frac{0.1875}{U} - \frac{\color{blue}{0.140625 \cdot \frac{1}{U}}}{U}\right) - 0.25}{U} \]
      9. div-sub18.8%

        \[\leadsto \frac{\color{blue}{\frac{0.1875 - 0.140625 \cdot \frac{1}{U}}{U}} - 0.25}{U} \]
      10. sub-neg18.8%

        \[\leadsto \frac{\frac{\color{blue}{0.1875 + \left(-0.140625 \cdot \frac{1}{U}\right)}}{U} - 0.25}{U} \]
      11. associate-*r/18.8%

        \[\leadsto \frac{\frac{0.1875 + \left(-\color{blue}{\frac{0.140625 \cdot 1}{U}}\right)}{U} - 0.25}{U} \]
      12. metadata-eval18.8%

        \[\leadsto \frac{\frac{0.1875 + \left(-\frac{\color{blue}{0.140625}}{U}\right)}{U} - 0.25}{U} \]
      13. distribute-neg-frac18.8%

        \[\leadsto \frac{\frac{0.1875 + \color{blue}{\frac{-0.140625}{U}}}{U} - 0.25}{U} \]
      14. metadata-eval18.8%

        \[\leadsto \frac{\frac{0.1875 + \frac{\color{blue}{-0.140625}}{U}}{U} - 0.25}{U} \]
    8. Simplified18.8%

      \[\leadsto \color{blue}{\frac{\frac{0.1875 + \frac{-0.140625}{U}}{U} - 0.25}{U}} \]

    if -600 < l < 28500

    1. Initial program 72.2%

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

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

    if 28500 < l < 4.00000000000000007e141

    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-rr31.3%

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

    if 4.00000000000000007e141 < 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-rr1.7%

      \[\leadsto \color{blue}{\frac{U}{U + \left(-4 \cdot U + U \cdot \left(-4 \cdot U\right)\right)}} \]
    4. Step-by-step derivation
      1. associate-+r+1.7%

        \[\leadsto \frac{U}{\color{blue}{\left(U + -4 \cdot U\right) + U \cdot \left(-4 \cdot U\right)}} \]
      2. distribute-rgt1-in1.7%

        \[\leadsto \frac{U}{\color{blue}{\left(-4 + 1\right) \cdot U} + U \cdot \left(-4 \cdot U\right)} \]
      3. metadata-eval1.7%

        \[\leadsto \frac{U}{\color{blue}{-3} \cdot U + U \cdot \left(-4 \cdot U\right)} \]
      4. *-commutative1.7%

        \[\leadsto \frac{U}{\color{blue}{U \cdot -3} + U \cdot \left(-4 \cdot U\right)} \]
      5. distribute-lft-out1.7%

        \[\leadsto \frac{U}{\color{blue}{U \cdot \left(-3 + -4 \cdot U\right)}} \]
      6. associate-/r*1.6%

        \[\leadsto \color{blue}{\frac{\frac{U}{U}}{-3 + -4 \cdot U}} \]
      7. *-inverses1.6%

        \[\leadsto \frac{\color{blue}{1}}{-3 + -4 \cdot U} \]
      8. +-commutative1.6%

        \[\leadsto \frac{1}{\color{blue}{-4 \cdot U + -3}} \]
      9. *-commutative1.6%

        \[\leadsto \frac{1}{\color{blue}{U \cdot -4} + -3} \]
    5. Simplified1.6%

      \[\leadsto \color{blue}{\frac{1}{U \cdot -4 + -3}} \]
    6. Taylor expanded in U around 0 33.1%

      \[\leadsto \color{blue}{U \cdot \left(0.4444444444444444 + U \cdot \left(0.7901234567901234 \cdot U - 0.5925925925925926\right)\right) - 0.3333333333333333} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification49.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -600:\\ \;\;\;\;\frac{\frac{0.1875 + \frac{-0.140625}{U}}{U} - 0.25}{U}\\ \mathbf{elif}\;\ell \leq 28500:\\ \;\;\;\;U\\ \mathbf{elif}\;\ell \leq 4 \cdot 10^{+141}:\\ \;\;\;\;U \cdot U\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(0.4444444444444444 + U \cdot \left(U \cdot 0.7901234567901234 - 0.5925925925925926\right)\right) - 0.3333333333333333\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 44.0% accurate, 19.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -740:\\ \;\;\;\;\frac{\frac{0.1875 + \frac{-0.140625}{U}}{U} - 0.25}{U}\\ \mathbf{elif}\;\ell \leq 485:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -740.0)
   (/ (- (/ (+ 0.1875 (/ -0.140625 U)) U) 0.25) U)
   (if (<= l 485.0) U (* U (- U -4.0)))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -740.0) {
		tmp = (((0.1875 + (-0.140625 / U)) / U) - 0.25) / U;
	} else if (l <= 485.0) {
		tmp = 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 <= (-740.0d0)) then
        tmp = (((0.1875d0 + ((-0.140625d0) / u)) / u) - 0.25d0) / u
    else if (l <= 485.0d0) then
        tmp = 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 <= -740.0) {
		tmp = (((0.1875 + (-0.140625 / U)) / U) - 0.25) / U;
	} else if (l <= 485.0) {
		tmp = U;
	} else {
		tmp = U * (U - -4.0);
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -740.0:
		tmp = (((0.1875 + (-0.140625 / U)) / U) - 0.25) / U
	elif l <= 485.0:
		tmp = U
	else:
		tmp = U * (U - -4.0)
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -740.0)
		tmp = Float64(Float64(Float64(Float64(0.1875 + Float64(-0.140625 / U)) / U) - 0.25) / U);
	elseif (l <= 485.0)
		tmp = 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 <= -740.0)
		tmp = (((0.1875 + (-0.140625 / U)) / U) - 0.25) / U;
	elseif (l <= 485.0)
		tmp = U;
	else
		tmp = U * (U - -4.0);
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -740.0], N[(N[(N[(N[(0.1875 + N[(-0.140625 / U), $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision] - 0.25), $MachinePrecision] / U), $MachinePrecision], If[LessEqual[l, 485.0], U, N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -740:\\
\;\;\;\;\frac{\frac{0.1875 + \frac{-0.140625}{U}}{U} - 0.25}{U}\\

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

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


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

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

      \[\leadsto \color{blue}{\frac{U}{U + \left(-4 \cdot U + U \cdot \left(-4 \cdot U\right)\right)}} \]
    4. Step-by-step derivation
      1. associate-+r+1.6%

        \[\leadsto \frac{U}{\color{blue}{\left(U + -4 \cdot U\right) + U \cdot \left(-4 \cdot U\right)}} \]
      2. distribute-rgt1-in1.6%

        \[\leadsto \frac{U}{\color{blue}{\left(-4 + 1\right) \cdot U} + U \cdot \left(-4 \cdot U\right)} \]
      3. metadata-eval1.6%

        \[\leadsto \frac{U}{\color{blue}{-3} \cdot U + U \cdot \left(-4 \cdot U\right)} \]
      4. *-commutative1.6%

        \[\leadsto \frac{U}{\color{blue}{U \cdot -3} + U \cdot \left(-4 \cdot U\right)} \]
      5. distribute-lft-out1.6%

        \[\leadsto \frac{U}{\color{blue}{U \cdot \left(-3 + -4 \cdot U\right)}} \]
      6. associate-/r*1.5%

        \[\leadsto \color{blue}{\frac{\frac{U}{U}}{-3 + -4 \cdot U}} \]
      7. *-inverses1.5%

        \[\leadsto \frac{\color{blue}{1}}{-3 + -4 \cdot U} \]
      8. +-commutative1.5%

        \[\leadsto \frac{1}{\color{blue}{-4 \cdot U + -3}} \]
      9. *-commutative1.5%

        \[\leadsto \frac{1}{\color{blue}{U \cdot -4} + -3} \]
    5. Simplified1.5%

      \[\leadsto \color{blue}{\frac{1}{U \cdot -4 + -3}} \]
    6. Taylor expanded in U around inf 18.8%

      \[\leadsto \color{blue}{\frac{0.1875 \cdot \frac{1}{U} - \left(0.25 + \frac{0.140625}{{U}^{2}}\right)}{U}} \]
    7. Step-by-step derivation
      1. +-commutative18.8%

        \[\leadsto \frac{0.1875 \cdot \frac{1}{U} - \color{blue}{\left(\frac{0.140625}{{U}^{2}} + 0.25\right)}}{U} \]
      2. associate--r+18.8%

        \[\leadsto \frac{\color{blue}{\left(0.1875 \cdot \frac{1}{U} - \frac{0.140625}{{U}^{2}}\right) - 0.25}}{U} \]
      3. associate-*r/18.8%

        \[\leadsto \frac{\left(\color{blue}{\frac{0.1875 \cdot 1}{U}} - \frac{0.140625}{{U}^{2}}\right) - 0.25}{U} \]
      4. metadata-eval18.8%

        \[\leadsto \frac{\left(\frac{\color{blue}{0.1875}}{U} - \frac{0.140625}{{U}^{2}}\right) - 0.25}{U} \]
      5. unpow218.8%

        \[\leadsto \frac{\left(\frac{0.1875}{U} - \frac{0.140625}{\color{blue}{U \cdot U}}\right) - 0.25}{U} \]
      6. associate-/r*18.8%

        \[\leadsto \frac{\left(\frac{0.1875}{U} - \color{blue}{\frac{\frac{0.140625}{U}}{U}}\right) - 0.25}{U} \]
      7. metadata-eval18.8%

        \[\leadsto \frac{\left(\frac{0.1875}{U} - \frac{\frac{\color{blue}{0.140625 \cdot 1}}{U}}{U}\right) - 0.25}{U} \]
      8. associate-*r/18.8%

        \[\leadsto \frac{\left(\frac{0.1875}{U} - \frac{\color{blue}{0.140625 \cdot \frac{1}{U}}}{U}\right) - 0.25}{U} \]
      9. div-sub18.8%

        \[\leadsto \frac{\color{blue}{\frac{0.1875 - 0.140625 \cdot \frac{1}{U}}{U}} - 0.25}{U} \]
      10. sub-neg18.8%

        \[\leadsto \frac{\frac{\color{blue}{0.1875 + \left(-0.140625 \cdot \frac{1}{U}\right)}}{U} - 0.25}{U} \]
      11. associate-*r/18.8%

        \[\leadsto \frac{\frac{0.1875 + \left(-\color{blue}{\frac{0.140625 \cdot 1}{U}}\right)}{U} - 0.25}{U} \]
      12. metadata-eval18.8%

        \[\leadsto \frac{\frac{0.1875 + \left(-\frac{\color{blue}{0.140625}}{U}\right)}{U} - 0.25}{U} \]
      13. distribute-neg-frac18.8%

        \[\leadsto \frac{\frac{0.1875 + \color{blue}{\frac{-0.140625}{U}}}{U} - 0.25}{U} \]
      14. metadata-eval18.8%

        \[\leadsto \frac{\frac{0.1875 + \frac{\color{blue}{-0.140625}}{U}}{U} - 0.25}{U} \]
    8. Simplified18.8%

      \[\leadsto \color{blue}{\frac{\frac{0.1875 + \frac{-0.140625}{U}}{U} - 0.25}{U}} \]

    if -740 < l < 485

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

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

    if 485 < 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-rr21.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -740:\\ \;\;\;\;\frac{\frac{0.1875 + \frac{-0.140625}{U}}{U} - 0.25}{U}\\ \mathbf{elif}\;\ell \leq 485:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 42.1% accurate, 20.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.3 \cdot 10^{+65}:\\
\;\;\;\;-4 - U \cdot U\\

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

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


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

    1. Initial program 100.0%

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

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

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

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

      \[\leadsto \color{blue}{-4 + \left(-U\right) \cdot U} \]
    6. Step-by-step derivation
      1. cancel-sign-sub-inv14.2%

        \[\leadsto \color{blue}{-4 - U \cdot U} \]
    7. Simplified14.2%

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

    if -2.3e65 < l < 950

    1. Initial program 73.8%

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

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

    if 950 < 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-rr21.6%

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

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

Alternative 15: 42.7% accurate, 20.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -580000000000:\\ \;\;\;\;\frac{\frac{0.1875}{U} + -0.25}{U}\\ \mathbf{elif}\;\ell \leq 620:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -580000000000.0)
   (/ (+ (/ 0.1875 U) -0.25) U)
   (if (<= l 620.0) U (* U (- U -4.0)))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -580000000000.0) {
		tmp = ((0.1875 / U) + -0.25) / U;
	} else if (l <= 620.0) {
		tmp = 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 <= (-580000000000.0d0)) then
        tmp = ((0.1875d0 / u) + (-0.25d0)) / u
    else if (l <= 620.0d0) then
        tmp = 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 <= -580000000000.0) {
		tmp = ((0.1875 / U) + -0.25) / U;
	} else if (l <= 620.0) {
		tmp = U;
	} else {
		tmp = U * (U - -4.0);
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -580000000000.0:
		tmp = ((0.1875 / U) + -0.25) / U
	elif l <= 620.0:
		tmp = U
	else:
		tmp = U * (U - -4.0)
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -580000000000.0)
		tmp = Float64(Float64(Float64(0.1875 / U) + -0.25) / U);
	elseif (l <= 620.0)
		tmp = 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 <= -580000000000.0)
		tmp = ((0.1875 / U) + -0.25) / U;
	elseif (l <= 620.0)
		tmp = U;
	else
		tmp = U * (U - -4.0);
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -580000000000.0], N[(N[(N[(0.1875 / U), $MachinePrecision] + -0.25), $MachinePrecision] / U), $MachinePrecision], If[LessEqual[l, 620.0], U, N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -580000000000:\\
\;\;\;\;\frac{\frac{0.1875}{U} + -0.25}{U}\\

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

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


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

    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-rr1.5%

      \[\leadsto \color{blue}{\frac{U}{U + \left(-4 \cdot U + U \cdot \left(-4 \cdot U\right)\right)}} \]
    4. Step-by-step derivation
      1. associate-+r+1.5%

        \[\leadsto \frac{U}{\color{blue}{\left(U + -4 \cdot U\right) + U \cdot \left(-4 \cdot U\right)}} \]
      2. distribute-rgt1-in1.5%

        \[\leadsto \frac{U}{\color{blue}{\left(-4 + 1\right) \cdot U} + U \cdot \left(-4 \cdot U\right)} \]
      3. metadata-eval1.5%

        \[\leadsto \frac{U}{\color{blue}{-3} \cdot U + U \cdot \left(-4 \cdot U\right)} \]
      4. *-commutative1.5%

        \[\leadsto \frac{U}{\color{blue}{U \cdot -3} + U \cdot \left(-4 \cdot U\right)} \]
      5. distribute-lft-out1.5%

        \[\leadsto \frac{U}{\color{blue}{U \cdot \left(-3 + -4 \cdot U\right)}} \]
      6. associate-/r*1.5%

        \[\leadsto \color{blue}{\frac{\frac{U}{U}}{-3 + -4 \cdot U}} \]
      7. *-inverses1.5%

        \[\leadsto \frac{\color{blue}{1}}{-3 + -4 \cdot U} \]
      8. +-commutative1.5%

        \[\leadsto \frac{1}{\color{blue}{-4 \cdot U + -3}} \]
      9. *-commutative1.5%

        \[\leadsto \frac{1}{\color{blue}{U \cdot -4} + -3} \]
    5. Simplified1.5%

      \[\leadsto \color{blue}{\frac{1}{U \cdot -4 + -3}} \]
    6. Taylor expanded in U around inf 15.4%

      \[\leadsto \color{blue}{\frac{0.1875 \cdot \frac{1}{U} - 0.25}{U}} \]
    7. Step-by-step derivation
      1. sub-neg15.4%

        \[\leadsto \frac{\color{blue}{0.1875 \cdot \frac{1}{U} + \left(-0.25\right)}}{U} \]
      2. associate-*r/15.4%

        \[\leadsto \frac{\color{blue}{\frac{0.1875 \cdot 1}{U}} + \left(-0.25\right)}{U} \]
      3. metadata-eval15.4%

        \[\leadsto \frac{\frac{\color{blue}{0.1875}}{U} + \left(-0.25\right)}{U} \]
      4. metadata-eval15.4%

        \[\leadsto \frac{\frac{0.1875}{U} + \color{blue}{-0.25}}{U} \]
    8. Simplified15.4%

      \[\leadsto \color{blue}{\frac{\frac{0.1875}{U} + -0.25}{U}} \]

    if -5.8e11 < l < 620

    1. Initial program 72.2%

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

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

    if 620 < 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-rr21.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -580000000000:\\ \;\;\;\;\frac{\frac{0.1875}{U} + -0.25}{U}\\ \mathbf{elif}\;\ell \leq 620:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 39.7% accurate, 31.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 950:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot \left(U - -4\right)\\ \end{array} \end{array} \]
(FPCore (J l K U) :precision binary64 (if (<= l 950.0) U (* U (- U -4.0))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= 950.0) {
		tmp = 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 <= 950.0d0) then
        tmp = 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 <= 950.0) {
		tmp = U;
	} else {
		tmp = U * (U - -4.0);
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= 950.0:
		tmp = U
	else:
		tmp = U * (U - -4.0)
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= 950.0)
		tmp = 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 <= 950.0)
		tmp = U;
	else
		tmp = U * (U - -4.0);
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, 950.0], U, N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 950:\\
\;\;\;\;U\\

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


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

    1. Initial program 80.5%

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

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

    if 950 < 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-rr21.6%

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

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

Alternative 17: 39.7% accurate, 38.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 19000:\\
\;\;\;\;U\\

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


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

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

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

    if 19000 < 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-rr21.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 19000:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot U\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 2.7% accurate, 312.0× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{U}{U + \left(-4 \cdot U + U \cdot \left(-4 \cdot U\right)\right)}} \]
  4. Step-by-step derivation
    1. associate-+r+2.1%

      \[\leadsto \frac{U}{\color{blue}{\left(U + -4 \cdot U\right) + U \cdot \left(-4 \cdot U\right)}} \]
    2. distribute-rgt1-in2.1%

      \[\leadsto \frac{U}{\color{blue}{\left(-4 + 1\right) \cdot U} + U \cdot \left(-4 \cdot U\right)} \]
    3. metadata-eval2.1%

      \[\leadsto \frac{U}{\color{blue}{-3} \cdot U + U \cdot \left(-4 \cdot U\right)} \]
    4. *-commutative2.1%

      \[\leadsto \frac{U}{\color{blue}{U \cdot -3} + U \cdot \left(-4 \cdot U\right)} \]
    5. distribute-lft-out2.1%

      \[\leadsto \frac{U}{\color{blue}{U \cdot \left(-3 + -4 \cdot U\right)}} \]
    6. associate-/r*2.0%

      \[\leadsto \color{blue}{\frac{\frac{U}{U}}{-3 + -4 \cdot U}} \]
    7. *-inverses2.0%

      \[\leadsto \frac{\color{blue}{1}}{-3 + -4 \cdot U} \]
    8. +-commutative2.0%

      \[\leadsto \frac{1}{\color{blue}{-4 \cdot U + -3}} \]
    9. *-commutative2.0%

      \[\leadsto \frac{1}{\color{blue}{U \cdot -4} + -3} \]
  5. Simplified2.0%

    \[\leadsto \color{blue}{\frac{1}{U \cdot -4 + -3}} \]
  6. Taylor expanded in U around 0 2.6%

    \[\leadsto \color{blue}{-0.3333333333333333} \]
  7. Final simplification2.6%

    \[\leadsto -0.3333333333333333 \]
  8. Add Preprocessing

Alternative 19: 2.7% accurate, 312.0× speedup?

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

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

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

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

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

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

    \[\leadsto 1 \]
  7. Add Preprocessing

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

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

    \[\leadsto \color{blue}{U} \]
  4. Final simplification37.9%

    \[\leadsto U \]
  5. Add Preprocessing

Reproduce

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