Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 85.9% → 99.8%
Time: 12.3s
Alternatives: 14
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 14 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: 85.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \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 5.0000000000000001e-4 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

    1. Initial program 100.0%

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

    if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.0000000000000001e-4

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 87.2% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+201} \lor \neg \left(t\_0 \leq 5 \cdot 10^{+206}\right):\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < -1.00000000000000004e201 or 5.0000000000000002e206 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))))

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{J \cdot \left(e^{\ell} - e^{-\ell}\right)} + U \]
    4. Taylor expanded in J around inf 74.8%

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

    if -1.00000000000000004e201 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < 5.0000000000000002e206

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

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

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

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

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

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

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

Alternative 3: 94.9% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
t_1 := U + {\ell}^{5} \cdot \left(t\_0 \cdot \left(J \cdot 0.016666666666666666\right)\right)\\
\mathbf{if}\;\ell \leq -3.4:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;\ell \leq 7 \cdot 10^{+52}:\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -3.39999999999999991 or 7e52 < l

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

        \[\leadsto {\ell}^{5} \cdot \left(\color{blue}{\left(J \cdot 0.016666666666666666\right)} \cdot \cos \left(K \cdot 0.5\right)\right) + U \]
      7. *-commutative95.0%

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

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

    if -3.39999999999999991 < l < 3.3000000000000003e-5

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

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

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

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

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

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

    if 3.3000000000000003e-5 < l < 7e52

    1. Initial program 98.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.4:\\ \;\;\;\;U + {\ell}^{5} \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 0.016666666666666666\right)\right)\\ \mathbf{elif}\;\ell \leq 3.3 \cdot 10^{-5}:\\ \;\;\;\;U + \ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 7 \cdot 10^{+52}:\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \mathbf{else}:\\ \;\;\;\;U + {\ell}^{5} \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 0.016666666666666666\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 95.1% accurate, 1.4× speedup?

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

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

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

\mathbf{elif}\;\ell \leq 9.4 \cdot 10^{+52}:\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -5 or 9.3999999999999999e52 < l

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

        \[\leadsto {\ell}^{5} \cdot \left(\color{blue}{\left(J \cdot 0.016666666666666666\right)} \cdot \cos \left(K \cdot 0.5\right)\right) + U \]
      7. *-commutative95.0%

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

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

    if -5 < l < 0.00619999999999999978

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.00619999999999999978 < l < 9.3999999999999999e52

    1. Initial program 99.7%

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

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

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

Alternative 5: 79.2% accurate, 1.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 (/.f64 K 2)) < 0.045999999999999999

    1. Initial program 82.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 76.0%

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

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

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

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

    if 0.045999999999999999 < (cos.f64 (/.f64 K 2))

    1. Initial program 82.7%

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

      \[\leadsto \color{blue}{J \cdot \left(e^{\ell} - e^{-\ell}\right)} + U \]
    4. Taylor expanded in l around 0 85.6%

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

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

Alternative 6: 79.2% accurate, 1.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 (/.f64 K 2)) < 0.045999999999999999

    1. Initial program 82.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 76.0%

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

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

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

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

    if 0.045999999999999999 < (cos.f64 (/.f64 K 2))

    1. Initial program 82.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 94.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 87.4% accurate, 1.4× speedup?

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

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

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

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


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

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

      \[\leadsto \color{blue}{J \cdot \left(e^{\ell} - e^{-\ell}\right)} + U \]
    4. Taylor expanded in J around inf 71.2%

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

    if -380 < l < 3.3000000000000003e-5

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

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

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

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

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

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

    if 3.3000000000000003e-5 < l

    1. Initial program 99.7%

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

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

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

Alternative 8: 64.0% accurate, 2.8× speedup?

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

\\
U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)
\end{array}
Derivation
  1. Initial program 82.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 75.6%

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

    \[\leadsto U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right) \]
  5. Add Preprocessing

Alternative 9: 63.9% accurate, 2.8× speedup?

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

\\
U + \ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right)\right)
\end{array}
Derivation
  1. Initial program 82.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 75.6%

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

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

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

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

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

    \[\leadsto U + \ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right)\right) \]
  7. Add Preprocessing

Alternative 10: 41.4% accurate, 23.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -7.2 \cdot 10^{-18} \lor \neg \left(\ell \leq 520\right):\\
\;\;\;\;U \cdot U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -7.20000000000000021e-18 or 520 < l

    1. Initial program 99.0%

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

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

    if -7.20000000000000021e-18 < l < 520

    1. Initial program 71.4%

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

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

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

Alternative 11: 53.7% accurate, 44.6× speedup?

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

\\
U + \ell \cdot \left(J \cdot 2\right)
\end{array}
Derivation
  1. Initial program 82.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 K around 0 72.1%

    \[\leadsto \color{blue}{J \cdot \left(e^{\ell} - e^{-\ell}\right)} + U \]
  4. Taylor expanded in l around 0 63.9%

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

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

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

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

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

Alternative 12: 2.7% accurate, 312.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 2.8% accurate, 312.0× speedup?

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

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

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

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

      \[\leadsto \color{blue}{1} \]
  5. Simplified3.0%

    \[\leadsto \color{blue}{1} \]
  6. Final simplification3.0%

    \[\leadsto 1 \]
  7. Add Preprocessing

Alternative 14: 36.1% 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 82.5%

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

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

    \[\leadsto U \]
  5. Add Preprocessing

Reproduce

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