Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 87.2% → 99.7%
Time: 12.6s
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: 87.2% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 67.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.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.7% accurate, 0.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(\left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{2}, 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))) < -0.0200000000000000004 or 4.99999999999999999e-15 < (-.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 -0.0200000000000000004 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 4.99999999999999999e-15

    1. Initial program 67.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.9%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.7% accurate, 0.4× speedup?

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

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


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

    1. Initial program 67.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 \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. *-commutative99.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. Simplified99.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 0 99.8%

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

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

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

      \[\leadsto \color{blue}{J \cdot \left(\ell \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\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 -0.02 \lor \neg \left(e^{\ell} - e^{-\ell} \leq 5 \cdot 10^{-15}\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(\ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(2 + {\ell}^{2} \cdot 0.3333333333333333\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 97.4% 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 -0.1:\\ \;\;\;\;\left(t\_1 \cdot J\right) \cdot t\_0 + U\\ \mathbf{else}:\\ \;\;\;\;U + t\_0 \cdot \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)\\ \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 (<= t_1 -0.1)
     (+ (* (* t_1 J) t_0) U)
     (+
      U
      (*
       t_0
       (*
        J
        (*
         l
         (+
          2.0
          (*
           (pow l 2.0)
           (+
            0.3333333333333333
            (*
             (pow l 2.0)
             (+
              0.016666666666666666
              (* (pow l 2.0) 0.0003968253968253968)))))))))))))
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 <= -0.1) {
		tmp = ((t_1 * J) * t_0) + U;
	} else {
		tmp = U + (t_0 * (J * (l * (2.0 + (pow(l, 2.0) * (0.3333333333333333 + (pow(l, 2.0) * (0.016666666666666666 + (pow(l, 2.0) * 0.0003968253968253968)))))))));
	}
	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 / 2.0d0))
    t_1 = exp(l) - exp(-l)
    if (t_1 <= (-0.1d0)) then
        tmp = ((t_1 * j) * t_0) + u
    else
        tmp = u + (t_0 * (j * (l * (2.0d0 + ((l ** 2.0d0) * (0.3333333333333333d0 + ((l ** 2.0d0) * (0.016666666666666666d0 + ((l ** 2.0d0) * 0.0003968253968253968d0)))))))))
    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 t_1 = Math.exp(l) - Math.exp(-l);
	double tmp;
	if (t_1 <= -0.1) {
		tmp = ((t_1 * J) * t_0) + U;
	} else {
		tmp = U + (t_0 * (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)))))))));
	}
	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 <= -0.1:
		tmp = ((t_1 * J) * t_0) + U
	else:
		tmp = U + (t_0 * (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)))))))))
	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 <= -0.1)
		tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U);
	else
		tmp = Float64(U + Float64(t_0 * 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))))))))));
	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 <= -0.1)
		tmp = ((t_1 * J) * t_0) + U;
	else
		tmp = U + (t_0 * (J * (l * (2.0 + ((l ^ 2.0) * (0.3333333333333333 + ((l ^ 2.0) * (0.016666666666666666 + ((l ^ 2.0) * 0.0003968253968253968)))))))));
	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[LessEqual[t$95$1, -0.1], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * 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]), $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 -0.1:\\
\;\;\;\;\left(t\_1 \cdot J\right) \cdot t\_0 + U\\

\mathbf{else}:\\
\;\;\;\;U + t\_0 \cdot \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)\\


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

    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.10000000000000001 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

    1. Initial program 78.8%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Add Preprocessing
    3. Taylor expanded in l around 0 98.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. *-commutative98.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. Simplified98.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 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{\ell} - e^{-\ell} \leq -0.1:\\ \;\;\;\;\left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\ \mathbf{else}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \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)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 96.5% accurate, 1.4× speedup?

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

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

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

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

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


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

    1. Initial program 100.0%

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

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

    if -1.90000000000000002e40 < l < -0.0259999999999999988

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

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

    if -0.0259999999999999988 < l < 5.5999999999999996

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

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

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

      \[\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 0 98.9%

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

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

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

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

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

Alternative 6: 96.3% accurate, 1.4× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -1.3e40 or 4 < l

    1. Initial program 100.0%

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

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

    if -1.3e40 < l < -0.0189999999999999995

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

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

    if -0.0189999999999999995 < l < 4

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

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

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

Alternative 7: 79.8% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.05:\\ \;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\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
 (if (<= (cos (/ K 2.0)) -0.05)
   (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))
   (+ 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.05) {
		tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
	} 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.05d0)) then
        tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
    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.05) {
		tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
	} 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.05:
		tmp = U + (2.0 * (J * (l * math.cos((K * 0.5)))))
	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.05)
		tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5))))));
	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.05)
		tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
	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.05], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $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.05:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\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.050000000000000003

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

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

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

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

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

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

      \[\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 0 86.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.05:\\ \;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\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: 87.5% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -0.027 \lor \neg \left(\ell \leq 0.00132\right):\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \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 -0.027) (not (<= l 0.00132)))
   (+ (* (- (exp l) (exp (- l))) J) U)
   (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if ((l <= -0.027) || !(l <= 0.00132)) {
		tmp = ((exp(l) - exp(-l)) * J) + U;
	} 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 <= (-0.027d0)) .or. (.not. (l <= 0.00132d0))) then
        tmp = ((exp(l) - exp(-l)) * j) + u
    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 <= -0.027) || !(l <= 0.00132)) {
		tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
	} else {
		tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if (l <= -0.027) or not (l <= 0.00132):
		tmp = ((math.exp(l) - math.exp(-l)) * J) + U
	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 <= -0.027) || !(l <= 0.00132))
		tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U);
	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 <= -0.027) || ~((l <= 0.00132)))
		tmp = ((exp(l) - exp(-l)) * J) + U;
	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, -0.027], N[Not[LessEqual[l, 0.00132]], $MachinePrecision]], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $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 -0.027 \lor \neg \left(\ell \leq 0.00132\right):\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\

\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 < -0.0269999999999999997 or 0.00132 < 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 78.2%

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

    if -0.0269999999999999997 < l < 0.00132

    1. Initial program 68.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -0.027 \lor \neg \left(\ell \leq 0.00132\right):\\ \;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\ \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 9: 45.4% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -5.5 \cdot 10^{+140}:\\ \;\;\;\;{U}^{-4}\\ \mathbf{elif}\;\ell \leq -9.5 \cdot 10^{+28}:\\ \;\;\;\;U \cdot U\\ \mathbf{elif}\;\ell \leq -0.95:\\ \;\;\;\;{U}^{-3}\\ \mathbf{elif}\;\ell \leq 2.1:\\ \;\;\;\;U\\ \mathbf{elif}\;\ell \leq 3.2 \cdot 10^{+61}:\\ \;\;\;\;U \cdot U\\ \mathbf{else}:\\ \;\;\;\;{U}^{-3}\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -5.5e+140)
   (pow U -4.0)
   (if (<= l -9.5e+28)
     (* U U)
     (if (<= l -0.95)
       (pow U -3.0)
       (if (<= l 2.1) U (if (<= l 3.2e+61) (* U U) (pow U -3.0)))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -5.5e+140) {
		tmp = pow(U, -4.0);
	} else if (l <= -9.5e+28) {
		tmp = U * U;
	} else if (l <= -0.95) {
		tmp = pow(U, -3.0);
	} else if (l <= 2.1) {
		tmp = U;
	} else if (l <= 3.2e+61) {
		tmp = U * U;
	} else {
		tmp = pow(U, -3.0);
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: tmp
    if (l <= (-5.5d+140)) then
        tmp = u ** (-4.0d0)
    else if (l <= (-9.5d+28)) then
        tmp = u * u
    else if (l <= (-0.95d0)) then
        tmp = u ** (-3.0d0)
    else if (l <= 2.1d0) then
        tmp = u
    else if (l <= 3.2d+61) then
        tmp = u * u
    else
        tmp = u ** (-3.0d0)
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -5.5e+140) {
		tmp = Math.pow(U, -4.0);
	} else if (l <= -9.5e+28) {
		tmp = U * U;
	} else if (l <= -0.95) {
		tmp = Math.pow(U, -3.0);
	} else if (l <= 2.1) {
		tmp = U;
	} else if (l <= 3.2e+61) {
		tmp = U * U;
	} else {
		tmp = Math.pow(U, -3.0);
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -5.5e+140:
		tmp = math.pow(U, -4.0)
	elif l <= -9.5e+28:
		tmp = U * U
	elif l <= -0.95:
		tmp = math.pow(U, -3.0)
	elif l <= 2.1:
		tmp = U
	elif l <= 3.2e+61:
		tmp = U * U
	else:
		tmp = math.pow(U, -3.0)
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -5.5e+140)
		tmp = U ^ -4.0;
	elseif (l <= -9.5e+28)
		tmp = Float64(U * U);
	elseif (l <= -0.95)
		tmp = U ^ -3.0;
	elseif (l <= 2.1)
		tmp = U;
	elseif (l <= 3.2e+61)
		tmp = Float64(U * U);
	else
		tmp = U ^ -3.0;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= -5.5e+140)
		tmp = U ^ -4.0;
	elseif (l <= -9.5e+28)
		tmp = U * U;
	elseif (l <= -0.95)
		tmp = U ^ -3.0;
	elseif (l <= 2.1)
		tmp = U;
	elseif (l <= 3.2e+61)
		tmp = U * U;
	else
		tmp = U ^ -3.0;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -5.5e+140], N[Power[U, -4.0], $MachinePrecision], If[LessEqual[l, -9.5e+28], N[(U * U), $MachinePrecision], If[LessEqual[l, -0.95], N[Power[U, -3.0], $MachinePrecision], If[LessEqual[l, 2.1], U, If[LessEqual[l, 3.2e+61], N[(U * U), $MachinePrecision], N[Power[U, -3.0], $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;\ell \leq -9.5 \cdot 10^{+28}:\\
\;\;\;\;U \cdot U\\

\mathbf{elif}\;\ell \leq -0.95:\\
\;\;\;\;{U}^{-3}\\

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

\mathbf{elif}\;\ell \leq 3.2 \cdot 10^{+61}:\\
\;\;\;\;U \cdot U\\

\mathbf{else}:\\
\;\;\;\;{U}^{-3}\\


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

    1. Initial program 100.0%

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

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

    if -5.5e140 < l < -9.49999999999999927e28 or 2.10000000000000009 < l < 3.1999999999999998e61

    1. Initial program 100.0%

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

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

    if -9.49999999999999927e28 < l < -0.94999999999999996 or 3.1999999999999998e61 < l

    1. Initial program 100.0%

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

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

    if -0.94999999999999996 < l < 2.10000000000000009

    1. Initial program 68.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5.5 \cdot 10^{+140}:\\ \;\;\;\;{U}^{-4}\\ \mathbf{elif}\;\ell \leq -9.5 \cdot 10^{+28}:\\ \;\;\;\;U \cdot U\\ \mathbf{elif}\;\ell \leq -0.95:\\ \;\;\;\;{U}^{-3}\\ \mathbf{elif}\;\ell \leq 2.1:\\ \;\;\;\;U\\ \mathbf{elif}\;\ell \leq 3.2 \cdot 10^{+61}:\\ \;\;\;\;U \cdot U\\ \mathbf{else}:\\ \;\;\;\;{U}^{-3}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 64.6% 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 84.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 61.7%

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

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

Alternative 11: 44.2% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2.1 \cdot 10^{+141}:\\ \;\;\;\;{U}^{-4}\\ \mathbf{elif}\;\ell \leq -0.95 \lor \neg \left(\ell \leq 2.1\right):\\ \;\;\;\;U \cdot U\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -2.1e+141)
   (pow U -4.0)
   (if (or (<= l -0.95) (not (<= l 2.1))) (* U U) U)))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -2.1e+141) {
		tmp = pow(U, -4.0);
	} else if ((l <= -0.95) || !(l <= 2.1)) {
		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 <= (-2.1d+141)) then
        tmp = u ** (-4.0d0)
    else if ((l <= (-0.95d0)) .or. (.not. (l <= 2.1d0))) 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 <= -2.1e+141) {
		tmp = Math.pow(U, -4.0);
	} else if ((l <= -0.95) || !(l <= 2.1)) {
		tmp = U * U;
	} else {
		tmp = U;
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -2.1e+141:
		tmp = math.pow(U, -4.0)
	elif (l <= -0.95) or not (l <= 2.1):
		tmp = U * U
	else:
		tmp = U
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -2.1e+141)
		tmp = U ^ -4.0;
	elseif ((l <= -0.95) || !(l <= 2.1))
		tmp = Float64(U * U);
	else
		tmp = U;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= -2.1e+141)
		tmp = U ^ -4.0;
	elseif ((l <= -0.95) || ~((l <= 2.1)))
		tmp = U * U;
	else
		tmp = U;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -2.1e+141], N[Power[U, -4.0], $MachinePrecision], If[Or[LessEqual[l, -0.95], N[Not[LessEqual[l, 2.1]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]]
\begin{array}{l}

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

\mathbf{elif}\;\ell \leq -0.95 \lor \neg \left(\ell \leq 2.1\right):\\
\;\;\;\;U \cdot U\\

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


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

    1. Initial program 100.0%

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

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

    if -2.0999999999999998e141 < l < -0.94999999999999996 or 2.10000000000000009 < l

    1. Initial program 100.0%

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

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

    if -0.94999999999999996 < l < 2.10000000000000009

    1. Initial program 68.7%

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

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

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

Alternative 12: 43.4% accurate, 23.9× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

    if -0.94999999999999996 < l < 2.10000000000000009

    1. Initial program 68.7%

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

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

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

Alternative 13: 2.7% accurate, 312.0× speedup?

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

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

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

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

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

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

    \[\leadsto 1 \]
  7. Add Preprocessing

Alternative 14: 37.7% accurate, 312.0× speedup?

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

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

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

    \[\leadsto U \]
  5. Add Preprocessing

Reproduce

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