Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.2% → 99.7%
Time: 10.8s
Alternatives: 16
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 16 alternatives:

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

Initial Program: 86.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.7% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -0.14000000000000001 or 880 < 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 -0.14000000000000001 < l < 880

    1. Initial program 75.7%

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

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

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

Alternative 2: 94.8% accurate, 0.5× speedup?

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

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


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

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

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(0.3333333333333333 + {\ell}^{2} \cdot \left(0.016666666666666666 + 0.0003968253968253968 \cdot {\ell}^{2}\right)\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. *-commutative93.8%

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

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

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

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

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

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

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

    if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.10000000000000001

    1. Initial program 76.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 99.4%

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

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

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

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

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

Alternative 3: 97.3% accurate, 0.7× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right)\\


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

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

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

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

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

    if 880 < 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. Recombined 2 regimes into one program.
  4. Final simplification98.5%

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

Alternative 4: 94.9% accurate, 1.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -5.5999999999999996 or 2.2000000000000002 < l

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

      \[\leadsto \left(J \cdot \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(0.3333333333333333 + {\ell}^{2} \cdot \left(0.016666666666666666 + 0.0003968253968253968 \cdot {\ell}^{2}\right)\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. Step-by-step derivation
      1. *-commutative93.8%

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

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

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

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

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

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

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

    if -5.5999999999999996 < l < 2.2000000000000002

    1. Initial program 76.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 99.6%

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

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

Alternative 5: 75.3% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.345:\\
\;\;\;\;U + \left(J \cdot \left(\ell \cdot 2\right)\right) \cdot \left({K}^{2} \cdot -8 + 5\right)\\

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


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

    1. Initial program 93.7%

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

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

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

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

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

      \[\leadsto \left(\left(2 \cdot \ell\right) \cdot J\right) \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\cos \left(-4 \cdot K\right)\right)} - -3\right)} + U \]
    7. Step-by-step derivation
      1. log1p-undefine33.5%

        \[\leadsto \left(\left(2 \cdot \ell\right) \cdot J\right) \cdot \left(e^{\color{blue}{\log \left(1 + \cos \left(-4 \cdot K\right)\right)}} - -3\right) + U \]
      2. rem-exp-log33.5%

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

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

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

        \[\leadsto \left(\left(2 \cdot \ell\right) \cdot J\right) \cdot \left(\cos \color{blue}{\left(K \cdot -4\right)} + \left(1 - -3\right)\right) + U \]
      6. metadata-eval33.5%

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

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

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

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

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

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

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

    1. Initial program 87.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 96.6%

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

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

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

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

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

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

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

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

Alternative 6: 75.3% accurate, 1.4× speedup?

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

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

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


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

    1. Initial program 93.7%

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

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

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

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

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

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

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

    1. Initial program 87.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 96.6%

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

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

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

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

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

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

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

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

Alternative 7: 78.1% accurate, 1.4× speedup?

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

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

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


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

    1. Initial program 92.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 69.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. *-commutative69.0%

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

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

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

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

    1. Initial program 87.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.2%

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

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

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

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

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

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

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

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

Alternative 8: 85.9% accurate, 1.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -4.9e20 or 880 < 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 72.4%

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

    if -4.9e20 < l < 880

    1. Initial program 76.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 97.9%

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

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

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

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

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

Alternative 9: 73.0% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 94.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 86.3%

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

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

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

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

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

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

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

Alternative 10: 83.1% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4.9 \cdot 10^{+20} \lor \neg \left(\ell \leq 1.12 \cdot 10^{+31}\right):\\
\;\;\;\;U + 0.0003968253968253968 \cdot \left(J \cdot {\ell}^{7}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -4.9e20 or 1.11999999999999993e31 < 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 97.1%

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

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

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

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

      \[\leadsto \color{blue}{\left(0.0003968253968253968 \cdot \left(J \cdot {\ell}^{7}\right)\right)} \cdot 1 + U \]

    if -4.9e20 < l < 1.11999999999999993e31

    1. Initial program 77.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 94.9%

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

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

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

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

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

Alternative 11: 83.2% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -4.9 \cdot 10^{+20} \lor \neg \left(\ell \leq 1.6 \cdot 10^{+30}\right):\\ \;\;\;\;U + 0.0003968253968253968 \cdot \left(J \cdot {\ell}^{7}\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 -4.9e+20) (not (<= l 1.6e+30)))
   (+ U (* 0.0003968253968253968 (* J (pow l 7.0))))
   (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if ((l <= -4.9e+20) || !(l <= 1.6e+30)) {
		tmp = U + (0.0003968253968253968 * (J * pow(l, 7.0)));
	} 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 <= (-4.9d+20)) .or. (.not. (l <= 1.6d+30))) then
        tmp = u + (0.0003968253968253968d0 * (j * (l ** 7.0d0)))
    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 <= -4.9e+20) || !(l <= 1.6e+30)) {
		tmp = U + (0.0003968253968253968 * (J * Math.pow(l, 7.0)));
	} else {
		tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if (l <= -4.9e+20) or not (l <= 1.6e+30):
		tmp = U + (0.0003968253968253968 * (J * math.pow(l, 7.0)))
	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 <= -4.9e+20) || !(l <= 1.6e+30))
		tmp = Float64(U + Float64(0.0003968253968253968 * Float64(J * (l ^ 7.0))));
	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 <= -4.9e+20) || ~((l <= 1.6e+30)))
		tmp = U + (0.0003968253968253968 * (J * (l ^ 7.0)));
	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, -4.9e+20], N[Not[LessEqual[l, 1.6e+30]], $MachinePrecision]], N[(U + N[(0.0003968253968253968 * N[(J * N[Power[l, 7.0], $MachinePrecision]), $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 -4.9 \cdot 10^{+20} \lor \neg \left(\ell \leq 1.6 \cdot 10^{+30}\right):\\
\;\;\;\;U + 0.0003968253968253968 \cdot \left(J \cdot {\ell}^{7}\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 < -4.9e20 or 1.59999999999999986e30 < 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 97.1%

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

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

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

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

      \[\leadsto \color{blue}{\left(0.0003968253968253968 \cdot \left(J \cdot {\ell}^{7}\right)\right)} \cdot 1 + U \]

    if -4.9e20 < l < 1.59999999999999986e30

    1. Initial program 77.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 94.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.9 \cdot 10^{+20} \lor \neg \left(\ell \leq 1.6 \cdot 10^{+30}\right):\\ \;\;\;\;U + 0.0003968253968253968 \cdot \left(J \cdot {\ell}^{7}\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 12: 58.4% accurate, 2.6× speedup?

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

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

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


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

    1. Initial program 94.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\left(2 \cdot \ell\right) \cdot J\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
    6. Applied egg-rr50.7%

      \[\leadsto \left(\left(2 \cdot \ell\right) \cdot J\right) \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\cos \left(-4 \cdot K\right)\right)} - -3\right)} + U \]
    7. Step-by-step derivation
      1. log1p-undefine50.7%

        \[\leadsto \left(\left(2 \cdot \ell\right) \cdot J\right) \cdot \left(e^{\color{blue}{\log \left(1 + \cos \left(-4 \cdot K\right)\right)}} - -3\right) + U \]
      2. rem-exp-log50.7%

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

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

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

        \[\leadsto \left(\left(2 \cdot \ell\right) \cdot J\right) \cdot \left(\cos \color{blue}{\left(K \cdot -4\right)} + \left(1 - -3\right)\right) + U \]
      6. metadata-eval50.7%

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

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

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

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

      \[\leadsto \color{blue}{\left(10 \cdot J\right) \cdot \ell} + U \]
    12. Taylor expanded in U around inf 58.6%

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

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

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

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

Alternative 13: 53.7% accurate, 26.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if K < 2.0499999999999999e34

    1. Initial program 87.7%

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

      \[\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. *-commutative61.1%

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

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

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

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

    if 2.0499999999999999e34 < K

    1. Initial program 91.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 71.2%

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

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

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

      \[\leadsto \color{blue}{\left(\left(2 \cdot \ell\right) \cdot J\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
    6. Applied egg-rr54.8%

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

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

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

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

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

        \[\leadsto \color{blue}{J \cdot \left(\ell \cdot -6\right)} + U \]
    11. Simplified55.8%

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

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

Alternative 14: 47.5% accurate, 26.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;K \leq 2.05 \cdot 10^{+34}:\\
\;\;\;\;U + 10 \cdot \left(\ell \cdot J\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if K < 2.0499999999999999e34

    1. Initial program 87.7%

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

      \[\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. *-commutative61.1%

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

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

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

      \[\leadsto \left(\left(2 \cdot \ell\right) \cdot J\right) \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\cos \left(-4 \cdot K\right)\right)} - -3\right)} + U \]
    7. Step-by-step derivation
      1. log1p-undefine46.6%

        \[\leadsto \left(\left(2 \cdot \ell\right) \cdot J\right) \cdot \left(e^{\color{blue}{\log \left(1 + \cos \left(-4 \cdot K\right)\right)}} - -3\right) + U \]
      2. rem-exp-log46.6%

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

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

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

        \[\leadsto \left(\left(2 \cdot \ell\right) \cdot J\right) \cdot \left(\cos \color{blue}{\left(K \cdot -4\right)} + \left(1 - -3\right)\right) + U \]
      6. metadata-eval46.6%

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

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

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

    if 2.0499999999999999e34 < K

    1. Initial program 91.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 71.2%

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

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

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

      \[\leadsto \color{blue}{\left(\left(2 \cdot \ell\right) \cdot J\right)} \cdot \cos \left(\frac{K}{2}\right) + U \]
    6. Applied egg-rr54.8%

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

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

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

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

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

        \[\leadsto \color{blue}{J \cdot \left(\ell \cdot -6\right)} + U \]
    11. Simplified55.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;K \leq 2.05 \cdot 10^{+34}:\\ \;\;\;\;U + 10 \cdot \left(\ell \cdot J\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot -6\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 47.6% accurate, 44.6× speedup?

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

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

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

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

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

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

    \[\leadsto \left(\left(2 \cdot \ell\right) \cdot J\right) \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\cos \left(-4 \cdot K\right)\right)} - -3\right)} + U \]
  7. Step-by-step derivation
    1. log1p-undefine47.4%

      \[\leadsto \left(\left(2 \cdot \ell\right) \cdot J\right) \cdot \left(e^{\color{blue}{\log \left(1 + \cos \left(-4 \cdot K\right)\right)}} - -3\right) + U \]
    2. rem-exp-log47.4%

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

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

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

      \[\leadsto \left(\left(2 \cdot \ell\right) \cdot J\right) \cdot \left(\cos \color{blue}{\left(K \cdot -4\right)} + \left(1 - -3\right)\right) + U \]
    6. metadata-eval47.4%

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

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

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

    \[\leadsto U + 10 \cdot \left(\ell \cdot J\right) \]
  11. Add Preprocessing

Alternative 16: 36.5% 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 88.6%

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

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

    \[\leadsto \color{blue}{U} \]
  5. Add Preprocessing

Reproduce

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