Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.6% → 100.0%
Time: 13.8s
Alternatives: 18
Speedup: 2.3×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 18 alternatives:

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

Initial Program: 86.6% 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: 100.0% accurate, 1.5× speedup?

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

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

    \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. associate-*l*N/A

      \[\leadsto \mathsf{+.f64}\left(\left(J \cdot \left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right)\right), U\right) \]
    2. *-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\left(\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J\right), U\right) \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right)\right), J\right), U\right) \]
    4. *-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(\cos \left(\frac{K}{2}\right) \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right), J\right), U\right) \]
    5. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\cos \left(\frac{K}{2}\right), \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right), J\right), U\right) \]
    6. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\left(\frac{K}{2}\right)\right), \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right), J\right), U\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right), \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right), J\right), U\right) \]
    8. sinh-undefN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right), \left(2 \cdot \sinh \ell\right)\right), J\right), U\right) \]
    9. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right), \mathsf{*.f64}\left(2, \sinh \ell\right)\right), J\right), U\right) \]
    10. sinh-lowering-sinh.f64100.0%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right), \mathsf{*.f64}\left(2, \mathsf{sinh.f64}\left(\ell\right)\right)\right), J\right), U\right) \]
  4. Applied egg-rr100.0%

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

Alternative 2: 86.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq -0.988:\\ \;\;\;\;U + t\_0 \cdot \left(\ell \cdot \left(2 \cdot J\right)\right)\\ \mathbf{elif}\;t\_0 \leq -0.62:\\ \;\;\;\;U + \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)\right) \cdot \left(1 + K \cdot \left(K \cdot \left(-0.125 + \left(K \cdot K\right) \cdot \left(0.0026041666666666665 + K \cdot \left(K \cdot -2.170138888888889 \cdot 10^{-5}\right)\right)\right)\right)\right)\\ \mathbf{elif}\;t\_0 \leq -0.04:\\ \;\;\;\;U + \ell \cdot \left(t\_0 \cdot \left(2 \cdot J\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + \left(2 \cdot \sinh \ell\right) \cdot J\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))))
   (if (<= t_0 -0.988)
     (+ U (* t_0 (* l (* 2.0 J))))
     (if (<= t_0 -0.62)
       (+
        U
        (*
         (* J (* l (+ 2.0 (* (* l l) 0.3333333333333333))))
         (+
          1.0
          (*
           K
           (*
            K
            (+
             -0.125
             (*
              (* K K)
              (+
               0.0026041666666666665
               (* K (* K -2.170138888888889e-5))))))))))
       (if (<= t_0 -0.04)
         (+ U (* l (* t_0 (* 2.0 J))))
         (+ U (* (* 2.0 (sinh 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.988) {
		tmp = U + (t_0 * (l * (2.0 * J)));
	} else if (t_0 <= -0.62) {
		tmp = U + ((J * (l * (2.0 + ((l * l) * 0.3333333333333333)))) * (1.0 + (K * (K * (-0.125 + ((K * K) * (0.0026041666666666665 + (K * (K * -2.170138888888889e-5)))))))));
	} else if (t_0 <= -0.04) {
		tmp = U + (l * (t_0 * (2.0 * J)));
	} else {
		tmp = U + ((2.0 * sinh(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.988d0)) then
        tmp = u + (t_0 * (l * (2.0d0 * j)))
    else if (t_0 <= (-0.62d0)) then
        tmp = u + ((j * (l * (2.0d0 + ((l * l) * 0.3333333333333333d0)))) * (1.0d0 + (k * (k * ((-0.125d0) + ((k * k) * (0.0026041666666666665d0 + (k * (k * (-2.170138888888889d-5))))))))))
    else if (t_0 <= (-0.04d0)) then
        tmp = u + (l * (t_0 * (2.0d0 * j)))
    else
        tmp = u + ((2.0d0 * sinh(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.988) {
		tmp = U + (t_0 * (l * (2.0 * J)));
	} else if (t_0 <= -0.62) {
		tmp = U + ((J * (l * (2.0 + ((l * l) * 0.3333333333333333)))) * (1.0 + (K * (K * (-0.125 + ((K * K) * (0.0026041666666666665 + (K * (K * -2.170138888888889e-5)))))))));
	} else if (t_0 <= -0.04) {
		tmp = U + (l * (t_0 * (2.0 * J)));
	} else {
		tmp = U + ((2.0 * Math.sinh(l)) * J);
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K / 2.0))
	tmp = 0
	if t_0 <= -0.988:
		tmp = U + (t_0 * (l * (2.0 * J)))
	elif t_0 <= -0.62:
		tmp = U + ((J * (l * (2.0 + ((l * l) * 0.3333333333333333)))) * (1.0 + (K * (K * (-0.125 + ((K * K) * (0.0026041666666666665 + (K * (K * -2.170138888888889e-5)))))))))
	elif t_0 <= -0.04:
		tmp = U + (l * (t_0 * (2.0 * J)))
	else:
		tmp = U + ((2.0 * math.sinh(l)) * J)
	return tmp
function code(J, l, K, U)
	t_0 = cos(Float64(K / 2.0))
	tmp = 0.0
	if (t_0 <= -0.988)
		tmp = Float64(U + Float64(t_0 * Float64(l * Float64(2.0 * J))));
	elseif (t_0 <= -0.62)
		tmp = Float64(U + Float64(Float64(J * Float64(l * Float64(2.0 + Float64(Float64(l * l) * 0.3333333333333333)))) * Float64(1.0 + Float64(K * Float64(K * Float64(-0.125 + Float64(Float64(K * K) * Float64(0.0026041666666666665 + Float64(K * Float64(K * -2.170138888888889e-5))))))))));
	elseif (t_0 <= -0.04)
		tmp = Float64(U + Float64(l * Float64(t_0 * Float64(2.0 * J))));
	else
		tmp = Float64(U + Float64(Float64(2.0 * sinh(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.988)
		tmp = U + (t_0 * (l * (2.0 * J)));
	elseif (t_0 <= -0.62)
		tmp = U + ((J * (l * (2.0 + ((l * l) * 0.3333333333333333)))) * (1.0 + (K * (K * (-0.125 + ((K * K) * (0.0026041666666666665 + (K * (K * -2.170138888888889e-5)))))))));
	elseif (t_0 <= -0.04)
		tmp = U + (l * (t_0 * (2.0 * J)));
	else
		tmp = U + ((2.0 * sinh(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.988], N[(U + N[(t$95$0 * N[(l * N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.62], N[(U + N[(N[(J * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(K * N[(K * N[(-0.125 + N[(N[(K * K), $MachinePrecision] * N[(0.0026041666666666665 + N[(K * N[(K * -2.170138888888889e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.04], N[(U + N[(l * N[(t$95$0 * N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t\_0 \leq -0.62:\\
\;\;\;\;U + \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)\right) \cdot \left(1 + K \cdot \left(K \cdot \left(-0.125 + \left(K \cdot K\right) \cdot \left(0.0026041666666666665 + K \cdot \left(K \cdot -2.170138888888889 \cdot 10^{-5}\right)\right)\right)\right)\right)\\

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

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


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

    1. Initial program 52.2%

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\color{blue}{\left(2 \cdot \left(J \cdot \ell\right)\right)}, \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    4. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(\left(2 \cdot J\right) \cdot \ell\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(\ell \cdot \left(2 \cdot J\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \left(2 \cdot J\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      4. *-lowering-*.f6489.8%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(2, J\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    5. Simplified89.8%

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

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

    1. Initial program 97.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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \color{blue}{\left(\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)}\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left(\frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \left({\ell}^{2}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \left(\ell \cdot \ell\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      5. *-lowering-*.f6479.5%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    5. Simplified79.5%

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \color{blue}{\left(1 + {K}^{2} \cdot \left({K}^{2} \cdot \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right) - \frac{1}{8}\right)\right)}\right), U\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left({K}^{2} \cdot \left({K}^{2} \cdot \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right) - \frac{1}{8}\right)\right)\right)\right), U\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left(\left(K \cdot K\right) \cdot \left({K}^{2} \cdot \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right) - \frac{1}{8}\right)\right)\right)\right), U\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left(K \cdot \left(K \cdot \left({K}^{2} \cdot \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right) - \frac{1}{8}\right)\right)\right)\right)\right), U\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \left(K \cdot \left({K}^{2} \cdot \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right) - \frac{1}{8}\right)\right)\right)\right)\right), U\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \left({K}^{2} \cdot \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right) - \frac{1}{8}\right)\right)\right)\right)\right), U\right) \]
      6. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \left({K}^{2} \cdot \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right) + \left(\mathsf{neg}\left(\frac{1}{8}\right)\right)\right)\right)\right)\right)\right), U\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \left({K}^{2} \cdot \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right) + \frac{-1}{8}\right)\right)\right)\right)\right), U\right) \]
      8. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \left(\frac{-1}{8} + {K}^{2} \cdot \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right)\right)\right)\right)\right)\right), U\right) \]
      9. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \left({K}^{2} \cdot \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right)\right)\right)\right)\right)\right)\right), U\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\left({K}^{2}\right), \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right)\right)\right)\right)\right)\right)\right), U\right) \]
      11. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\left(K \cdot K\right), \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right)\right)\right)\right)\right)\right)\right), U\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right)\right)\right)\right)\right)\right)\right), U\right) \]
      13. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \mathsf{+.f64}\left(\frac{1}{384}, \left(\frac{-1}{46080} \cdot {K}^{2}\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \mathsf{+.f64}\left(\frac{1}{384}, \left({K}^{2} \cdot \frac{-1}{46080}\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \mathsf{+.f64}\left(\frac{1}{384}, \mathsf{*.f64}\left(\left({K}^{2}\right), \frac{-1}{46080}\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      16. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \mathsf{+.f64}\left(\frac{1}{384}, \mathsf{*.f64}\left(\left(K \cdot K\right), \frac{-1}{46080}\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      17. *-lowering-*.f6485.0%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \mathsf{+.f64}\left(\frac{1}{384}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \frac{-1}{46080}\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
    8. Simplified85.0%

      \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right) \cdot \color{blue}{\left(1 + K \cdot \left(K \cdot \left(-0.125 + \left(K \cdot K\right) \cdot \left(0.0026041666666666665 + \left(K \cdot K\right) \cdot -2.170138888888889 \cdot 10^{-5}\right)\right)\right)\right)} + U \]
    9. Step-by-step derivation
      1. associate-*l*N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \mathsf{+.f64}\left(\frac{1}{384}, \left(K \cdot \left(K \cdot \frac{-1}{46080}\right)\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \mathsf{+.f64}\left(\frac{1}{384}, \left(\left(K \cdot \frac{-1}{46080}\right) \cdot K\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \mathsf{+.f64}\left(\frac{1}{384}, \mathsf{*.f64}\left(\left(K \cdot \frac{-1}{46080}\right), K\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      4. *-lowering-*.f6485.0%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \mathsf{+.f64}\left(\frac{1}{384}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, \frac{-1}{46080}\right), K\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
    10. Applied egg-rr85.0%

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\color{blue}{\left(\ell \cdot \left(2 \cdot J + {\ell}^{2} \cdot \left(\frac{1}{60} \cdot \left(J \cdot {\ell}^{2}\right) + \frac{1}{3} \cdot J\right)\right)\right)}, \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \left(2 \cdot J + {\ell}^{2} \cdot \left(\frac{1}{60} \cdot \left(J \cdot {\ell}^{2}\right) + \frac{1}{3} \cdot J\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\left(2 \cdot J\right), \left({\ell}^{2} \cdot \left(\frac{1}{60} \cdot \left(J \cdot {\ell}^{2}\right) + \frac{1}{3} \cdot J\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\mathsf{*.f64}\left(2, J\right), \left({\ell}^{2} \cdot \left(\frac{1}{60} \cdot \left(J \cdot {\ell}^{2}\right) + \frac{1}{3} \cdot J\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\mathsf{*.f64}\left(2, J\right), \left({\ell}^{2} \cdot \left(\frac{1}{3} \cdot J + \frac{1}{60} \cdot \left(J \cdot {\ell}^{2}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      5. distribute-rgt-inN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\mathsf{*.f64}\left(2, J\right), \left(\left(\frac{1}{3} \cdot J\right) \cdot {\ell}^{2} + \left(\frac{1}{60} \cdot \left(J \cdot {\ell}^{2}\right)\right) \cdot {\ell}^{2}\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\mathsf{*.f64}\left(2, J\right), \left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right) + \left(\frac{1}{60} \cdot \left(J \cdot {\ell}^{2}\right)\right) \cdot {\ell}^{2}\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\mathsf{*.f64}\left(2, J\right), \left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right) + {\ell}^{2} \cdot \left(\frac{1}{60} \cdot \left(J \cdot {\ell}^{2}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      8. associate-*r*N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\mathsf{*.f64}\left(2, J\right), \left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right) + \left({\ell}^{2} \cdot \frac{1}{60}\right) \cdot \left(J \cdot {\ell}^{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\mathsf{*.f64}\left(2, J\right), \left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right) + \left(\frac{1}{60} \cdot {\ell}^{2}\right) \cdot \left(J \cdot {\ell}^{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      10. distribute-rgt-outN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\mathsf{*.f64}\left(2, J\right), \left(\left(J \cdot {\ell}^{2}\right) \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\mathsf{*.f64}\left(2, J\right), \mathsf{*.f64}\left(\left(J \cdot {\ell}^{2}\right), \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\mathsf{*.f64}\left(2, J\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \left({\ell}^{2}\right)\right), \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\mathsf{*.f64}\left(2, J\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \left(\ell \cdot \ell\right)\right), \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\mathsf{*.f64}\left(2, J\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \ell\right)\right), \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      15. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\mathsf{*.f64}\left(2, J\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{+.f64}\left(\frac{1}{3}, \left(\frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      16. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\mathsf{*.f64}\left(2, J\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{+.f64}\left(\frac{1}{3}, \left({\ell}^{2} \cdot \frac{1}{60}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      17. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\mathsf{*.f64}\left(2, J\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\left({\ell}^{2}\right), \frac{1}{60}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      18. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\mathsf{*.f64}\left(2, J\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\left(\ell \cdot \ell\right), \frac{1}{60}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      19. *-lowering-*.f6492.4%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\mathsf{*.f64}\left(2, J\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \frac{1}{60}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    5. Simplified92.4%

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \color{blue}{\left(2 \cdot J\right)}\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \left(J \cdot 2\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      2. *-lowering-*.f6465.2%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(J, 2\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    8. Simplified65.2%

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

        \[\leadsto \mathsf{+.f64}\left(\left(\ell \cdot \left(\left(J \cdot 2\right) \cdot \cos \left(\frac{K}{2}\right)\right)\right), U\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\left(\left(J \cdot 2\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \ell\right), U\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(\left(J \cdot 2\right) \cdot \cos \left(\frac{K}{2}\right)\right), \ell\right), U\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot 2\right)\right), \ell\right), U\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\cos \left(\frac{K}{2}\right), \left(J \cdot 2\right)\right), \ell\right), U\right) \]
      6. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\left(\frac{K}{2}\right)\right), \left(J \cdot 2\right)\right), \ell\right), U\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right), \left(J \cdot 2\right)\right), \ell\right), U\right) \]
      8. *-lowering-*.f6465.3%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right), \mathsf{*.f64}\left(J, 2\right)\right), \ell\right), U\right) \]
    10. Applied egg-rr65.3%

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

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

    1. Initial program 86.9%

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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)}, U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right), U\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} + \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\left(e^{\ell}\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      4. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      5. exp-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right)\right), U\right) \]
      6. distribute-neg-fracN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{\mathsf{neg}\left(1\right)}{e^{\ell}}\right)\right)\right), U\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{-1}{e^{\ell}}\right)\right)\right), U\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \left(e^{\ell}\right)\right)\right)\right), U\right) \]
      9. exp-lowering-exp.f6486.5%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \mathsf{exp.f64}\left(\ell\right)\right)\right)\right), U\right) \]
    5. Simplified86.5%

      \[\leadsto \color{blue}{J \cdot \left(e^{\ell} + \frac{-1}{e^{\ell}}\right)} + U \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\left(e^{\ell} + \frac{-1}{e^{\ell}}\right) \cdot J\right), U\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + \frac{-1}{e^{\ell}}\right), J\right), U\right) \]
      3. div-invN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + -1 \cdot \frac{1}{e^{\ell}}\right), J\right), U\right) \]
      4. mul-1-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right), J\right), U\right) \]
      5. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} - \frac{1}{e^{\ell}}\right), J\right), U\right) \]
      6. rec-expN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right), J\right), U\right) \]
      7. sinh-undefN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(2 \cdot \sinh \ell\right), J\right), U\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(2, \sinh \ell\right), J\right), U\right) \]
      9. sinh-lowering-sinh.f6495.8%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(2, \mathsf{sinh.f64}\left(\ell\right)\right), J\right), U\right) \]
    7. Applied egg-rr95.8%

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

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

Alternative 3: 86.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ t_1 := U + t\_0 \cdot \left(\ell \cdot \left(2 \cdot J\right)\right)\\ \mathbf{if}\;t\_0 \leq -0.988:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq -0.62:\\ \;\;\;\;U + \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)\right) \cdot \left(1 + K \cdot \left(K \cdot \left(-0.125 + \left(K \cdot K\right) \cdot \left(0.0026041666666666665 + K \cdot \left(K \cdot -2.170138888888889 \cdot 10^{-5}\right)\right)\right)\right)\right)\\ \mathbf{elif}\;t\_0 \leq -0.04:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;U + \left(2 \cdot \sinh \ell\right) \cdot J\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))) (t_1 (+ U (* t_0 (* l (* 2.0 J))))))
   (if (<= t_0 -0.988)
     t_1
     (if (<= t_0 -0.62)
       (+
        U
        (*
         (* J (* l (+ 2.0 (* (* l l) 0.3333333333333333))))
         (+
          1.0
          (*
           K
           (*
            K
            (+
             -0.125
             (*
              (* K K)
              (+
               0.0026041666666666665
               (* K (* K -2.170138888888889e-5))))))))))
       (if (<= t_0 -0.04) t_1 (+ U (* (* 2.0 (sinh l)) J)))))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K / 2.0));
	double t_1 = U + (t_0 * (l * (2.0 * J)));
	double tmp;
	if (t_0 <= -0.988) {
		tmp = t_1;
	} else if (t_0 <= -0.62) {
		tmp = U + ((J * (l * (2.0 + ((l * l) * 0.3333333333333333)))) * (1.0 + (K * (K * (-0.125 + ((K * K) * (0.0026041666666666665 + (K * (K * -2.170138888888889e-5)))))))));
	} else if (t_0 <= -0.04) {
		tmp = t_1;
	} else {
		tmp = U + ((2.0 * sinh(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) :: t_1
    real(8) :: tmp
    t_0 = cos((k / 2.0d0))
    t_1 = u + (t_0 * (l * (2.0d0 * j)))
    if (t_0 <= (-0.988d0)) then
        tmp = t_1
    else if (t_0 <= (-0.62d0)) then
        tmp = u + ((j * (l * (2.0d0 + ((l * l) * 0.3333333333333333d0)))) * (1.0d0 + (k * (k * ((-0.125d0) + ((k * k) * (0.0026041666666666665d0 + (k * (k * (-2.170138888888889d-5))))))))))
    else if (t_0 <= (-0.04d0)) then
        tmp = t_1
    else
        tmp = u + ((2.0d0 * sinh(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 t_1 = U + (t_0 * (l * (2.0 * J)));
	double tmp;
	if (t_0 <= -0.988) {
		tmp = t_1;
	} else if (t_0 <= -0.62) {
		tmp = U + ((J * (l * (2.0 + ((l * l) * 0.3333333333333333)))) * (1.0 + (K * (K * (-0.125 + ((K * K) * (0.0026041666666666665 + (K * (K * -2.170138888888889e-5)))))))));
	} else if (t_0 <= -0.04) {
		tmp = t_1;
	} else {
		tmp = U + ((2.0 * Math.sinh(l)) * J);
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K / 2.0))
	t_1 = U + (t_0 * (l * (2.0 * J)))
	tmp = 0
	if t_0 <= -0.988:
		tmp = t_1
	elif t_0 <= -0.62:
		tmp = U + ((J * (l * (2.0 + ((l * l) * 0.3333333333333333)))) * (1.0 + (K * (K * (-0.125 + ((K * K) * (0.0026041666666666665 + (K * (K * -2.170138888888889e-5)))))))))
	elif t_0 <= -0.04:
		tmp = t_1
	else:
		tmp = U + ((2.0 * math.sinh(l)) * J)
	return tmp
function code(J, l, K, U)
	t_0 = cos(Float64(K / 2.0))
	t_1 = Float64(U + Float64(t_0 * Float64(l * Float64(2.0 * J))))
	tmp = 0.0
	if (t_0 <= -0.988)
		tmp = t_1;
	elseif (t_0 <= -0.62)
		tmp = Float64(U + Float64(Float64(J * Float64(l * Float64(2.0 + Float64(Float64(l * l) * 0.3333333333333333)))) * Float64(1.0 + Float64(K * Float64(K * Float64(-0.125 + Float64(Float64(K * K) * Float64(0.0026041666666666665 + Float64(K * Float64(K * -2.170138888888889e-5))))))))));
	elseif (t_0 <= -0.04)
		tmp = t_1;
	else
		tmp = Float64(U + Float64(Float64(2.0 * sinh(l)) * J));
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = cos((K / 2.0));
	t_1 = U + (t_0 * (l * (2.0 * J)));
	tmp = 0.0;
	if (t_0 <= -0.988)
		tmp = t_1;
	elseif (t_0 <= -0.62)
		tmp = U + ((J * (l * (2.0 + ((l * l) * 0.3333333333333333)))) * (1.0 + (K * (K * (-0.125 + ((K * K) * (0.0026041666666666665 + (K * (K * -2.170138888888889e-5)))))))));
	elseif (t_0 <= -0.04)
		tmp = t_1;
	else
		tmp = U + ((2.0 * sinh(l)) * J);
	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[(U + N[(t$95$0 * N[(l * N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.988], t$95$1, If[LessEqual[t$95$0, -0.62], N[(U + N[(N[(J * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(K * N[(K * N[(-0.125 + N[(N[(K * K), $MachinePrecision] * N[(0.0026041666666666665 + N[(K * N[(K * -2.170138888888889e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.04], t$95$1, N[(U + N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t\_0 \leq -0.62:\\
\;\;\;\;U + \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)\right) \cdot \left(1 + K \cdot \left(K \cdot \left(-0.125 + \left(K \cdot K\right) \cdot \left(0.0026041666666666665 + K \cdot \left(K \cdot -2.170138888888889 \cdot 10^{-5}\right)\right)\right)\right)\right)\\

\mathbf{elif}\;t\_0 \leq -0.04:\\
\;\;\;\;t\_1\\

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


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

    1. Initial program 75.7%

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\color{blue}{\left(2 \cdot \left(J \cdot \ell\right)\right)}, \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    4. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(\left(2 \cdot J\right) \cdot \ell\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(\ell \cdot \left(2 \cdot J\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \left(2 \cdot J\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      4. *-lowering-*.f6472.2%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(2, J\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    5. Simplified72.2%

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

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

    1. Initial program 97.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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \color{blue}{\left(\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)}\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left(\frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \left({\ell}^{2}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \left(\ell \cdot \ell\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      5. *-lowering-*.f6479.5%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    5. Simplified79.5%

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \color{blue}{\left(1 + {K}^{2} \cdot \left({K}^{2} \cdot \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right) - \frac{1}{8}\right)\right)}\right), U\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left({K}^{2} \cdot \left({K}^{2} \cdot \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right) - \frac{1}{8}\right)\right)\right)\right), U\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left(\left(K \cdot K\right) \cdot \left({K}^{2} \cdot \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right) - \frac{1}{8}\right)\right)\right)\right), U\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left(K \cdot \left(K \cdot \left({K}^{2} \cdot \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right) - \frac{1}{8}\right)\right)\right)\right)\right), U\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \left(K \cdot \left({K}^{2} \cdot \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right) - \frac{1}{8}\right)\right)\right)\right)\right), U\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \left({K}^{2} \cdot \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right) - \frac{1}{8}\right)\right)\right)\right)\right), U\right) \]
      6. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \left({K}^{2} \cdot \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right) + \left(\mathsf{neg}\left(\frac{1}{8}\right)\right)\right)\right)\right)\right)\right), U\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \left({K}^{2} \cdot \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right) + \frac{-1}{8}\right)\right)\right)\right)\right), U\right) \]
      8. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \left(\frac{-1}{8} + {K}^{2} \cdot \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right)\right)\right)\right)\right)\right), U\right) \]
      9. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \left({K}^{2} \cdot \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right)\right)\right)\right)\right)\right)\right), U\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\left({K}^{2}\right), \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right)\right)\right)\right)\right)\right)\right), U\right) \]
      11. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\left(K \cdot K\right), \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right)\right)\right)\right)\right)\right)\right), U\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \left(\frac{1}{384} + \frac{-1}{46080} \cdot {K}^{2}\right)\right)\right)\right)\right)\right)\right), U\right) \]
      13. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \mathsf{+.f64}\left(\frac{1}{384}, \left(\frac{-1}{46080} \cdot {K}^{2}\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \mathsf{+.f64}\left(\frac{1}{384}, \left({K}^{2} \cdot \frac{-1}{46080}\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \mathsf{+.f64}\left(\frac{1}{384}, \mathsf{*.f64}\left(\left({K}^{2}\right), \frac{-1}{46080}\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      16. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \mathsf{+.f64}\left(\frac{1}{384}, \mathsf{*.f64}\left(\left(K \cdot K\right), \frac{-1}{46080}\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      17. *-lowering-*.f6485.0%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \mathsf{+.f64}\left(\frac{1}{384}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \frac{-1}{46080}\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
    8. Simplified85.0%

      \[\leadsto \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right) \cdot \color{blue}{\left(1 + K \cdot \left(K \cdot \left(-0.125 + \left(K \cdot K\right) \cdot \left(0.0026041666666666665 + \left(K \cdot K\right) \cdot -2.170138888888889 \cdot 10^{-5}\right)\right)\right)\right)} + U \]
    9. Step-by-step derivation
      1. associate-*l*N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \mathsf{+.f64}\left(\frac{1}{384}, \left(K \cdot \left(K \cdot \frac{-1}{46080}\right)\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \mathsf{+.f64}\left(\frac{1}{384}, \left(\left(K \cdot \frac{-1}{46080}\right) \cdot K\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \mathsf{+.f64}\left(\frac{1}{384}, \mathsf{*.f64}\left(\left(K \cdot \frac{-1}{46080}\right), K\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      4. *-lowering-*.f6485.0%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(K, \mathsf{*.f64}\left(K, \mathsf{+.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, K\right), \mathsf{+.f64}\left(\frac{1}{384}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(K, \frac{-1}{46080}\right), K\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
    10. Applied egg-rr85.0%

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

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

    1. Initial program 86.9%

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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)}, U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right), U\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} + \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\left(e^{\ell}\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      4. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      5. exp-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right)\right), U\right) \]
      6. distribute-neg-fracN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{\mathsf{neg}\left(1\right)}{e^{\ell}}\right)\right)\right), U\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{-1}{e^{\ell}}\right)\right)\right), U\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \left(e^{\ell}\right)\right)\right)\right), U\right) \]
      9. exp-lowering-exp.f6486.5%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \mathsf{exp.f64}\left(\ell\right)\right)\right)\right), U\right) \]
    5. Simplified86.5%

      \[\leadsto \color{blue}{J \cdot \left(e^{\ell} + \frac{-1}{e^{\ell}}\right)} + U \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\left(e^{\ell} + \frac{-1}{e^{\ell}}\right) \cdot J\right), U\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + \frac{-1}{e^{\ell}}\right), J\right), U\right) \]
      3. div-invN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + -1 \cdot \frac{1}{e^{\ell}}\right), J\right), U\right) \]
      4. mul-1-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right), J\right), U\right) \]
      5. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} - \frac{1}{e^{\ell}}\right), J\right), U\right) \]
      6. rec-expN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right), J\right), U\right) \]
      7. sinh-undefN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(2 \cdot \sinh \ell\right), J\right), U\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(2, \sinh \ell\right), J\right), U\right) \]
      9. sinh-lowering-sinh.f6495.8%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(2, \mathsf{sinh.f64}\left(\ell\right)\right), J\right), U\right) \]
    7. Applied egg-rr95.8%

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

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

Alternative 4: 96.8% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq 0.9825:\\ \;\;\;\;U + t\_0 \cdot \left(\left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \ell \cdot \left(\ell \cdot \left(0.016666666666666666 + \ell \cdot \left(\ell \cdot 0.0003968253968253968\right)\right)\right)\right)\right) \cdot \left(\ell \cdot J\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + \left(2 \cdot \sinh \ell\right) \cdot J\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))))
   (if (<= t_0 0.9825)
     (+
      U
      (*
       t_0
       (*
        (+
         2.0
         (*
          (* l l)
          (+
           0.3333333333333333
           (*
            l
            (*
             l
             (+ 0.016666666666666666 (* l (* l 0.0003968253968253968))))))))
        (* l J))))
     (+ U (* (* 2.0 (sinh 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.9825) {
		tmp = U + (t_0 * ((2.0 + ((l * l) * (0.3333333333333333 + (l * (l * (0.016666666666666666 + (l * (l * 0.0003968253968253968)))))))) * (l * J)));
	} else {
		tmp = U + ((2.0 * sinh(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.9825d0) then
        tmp = u + (t_0 * ((2.0d0 + ((l * l) * (0.3333333333333333d0 + (l * (l * (0.016666666666666666d0 + (l * (l * 0.0003968253968253968d0)))))))) * (l * j)))
    else
        tmp = u + ((2.0d0 * sinh(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.9825) {
		tmp = U + (t_0 * ((2.0 + ((l * l) * (0.3333333333333333 + (l * (l * (0.016666666666666666 + (l * (l * 0.0003968253968253968)))))))) * (l * J)));
	} else {
		tmp = U + ((2.0 * Math.sinh(l)) * J);
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K / 2.0))
	tmp = 0
	if t_0 <= 0.9825:
		tmp = U + (t_0 * ((2.0 + ((l * l) * (0.3333333333333333 + (l * (l * (0.016666666666666666 + (l * (l * 0.0003968253968253968)))))))) * (l * J)))
	else:
		tmp = U + ((2.0 * math.sinh(l)) * J)
	return tmp
function code(J, l, K, U)
	t_0 = cos(Float64(K / 2.0))
	tmp = 0.0
	if (t_0 <= 0.9825)
		tmp = Float64(U + Float64(t_0 * Float64(Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(l * Float64(l * Float64(0.016666666666666666 + Float64(l * Float64(l * 0.0003968253968253968)))))))) * Float64(l * J))));
	else
		tmp = Float64(U + Float64(Float64(2.0 * sinh(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.9825)
		tmp = U + (t_0 * ((2.0 + ((l * l) * (0.3333333333333333 + (l * (l * (0.016666666666666666 + (l * (l * 0.0003968253968253968)))))))) * (l * J)));
	else
		tmp = U + ((2.0 * sinh(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.9825], N[(U + N[(t$95$0 * N[(N[(2.0 + N[(N[(l * l), $MachinePrecision] * N[(0.3333333333333333 + N[(l * N[(l * N[(0.016666666666666666 + N[(l * N[(l * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


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

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left({\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left({\ell}^{2}\right), \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left(\ell \cdot \ell\right), \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \left({\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\left({\ell}^{2}\right), \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\left(\ell \cdot \ell\right), \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      10. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{60}, \left(\frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{60}, \left({\ell}^{2} \cdot \frac{1}{2520}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{60}, \left(\left(\ell \cdot \ell\right) \cdot \frac{1}{2520}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      13. associate-*l*N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{60}, \left(\ell \cdot \left(\ell \cdot \frac{1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{60}, \mathsf{*.f64}\left(\ell, \left(\ell \cdot \frac{1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      15. *-lowering-*.f6496.6%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{60}, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \frac{1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    5. Simplified96.6%

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \left(\ell \cdot \ell\right) \cdot \left(\frac{1}{60} + \ell \cdot \left(\ell \cdot \frac{1}{2520}\right)\right)\right)\right)\right)\right), \cos \left(\frac{K}{2}\right)\right), U\right) \]
    7. Applied egg-rr96.6%

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)}, U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right), U\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} + \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\left(e^{\ell}\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      4. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      5. exp-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right)\right), U\right) \]
      6. distribute-neg-fracN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{\mathsf{neg}\left(1\right)}{e^{\ell}}\right)\right)\right), U\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{-1}{e^{\ell}}\right)\right)\right), U\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \left(e^{\ell}\right)\right)\right)\right), U\right) \]
      9. exp-lowering-exp.f6487.8%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \mathsf{exp.f64}\left(\ell\right)\right)\right)\right), U\right) \]
    5. Simplified87.8%

      \[\leadsto \color{blue}{J \cdot \left(e^{\ell} + \frac{-1}{e^{\ell}}\right)} + U \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\left(e^{\ell} + \frac{-1}{e^{\ell}}\right) \cdot J\right), U\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + \frac{-1}{e^{\ell}}\right), J\right), U\right) \]
      3. div-invN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + -1 \cdot \frac{1}{e^{\ell}}\right), J\right), U\right) \]
      4. mul-1-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right), J\right), U\right) \]
      5. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} - \frac{1}{e^{\ell}}\right), J\right), U\right) \]
      6. rec-expN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right), J\right), U\right) \]
      7. sinh-undefN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(2 \cdot \sinh \ell\right), J\right), U\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(2, \sinh \ell\right), J\right), U\right) \]
      9. sinh-lowering-sinh.f64100.0%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(2, \mathsf{sinh.f64}\left(\ell\right)\right), J\right), U\right) \]
    7. Applied egg-rr100.0%

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

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

Alternative 5: 97.1% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq 0.9825:\\ \;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot \left(0.016666666666666666 + \ell \cdot \left(\ell \cdot 0.0003968253968253968\right)\right)\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + \left(2 \cdot \sinh \ell\right) \cdot J\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))))
   (if (<= t_0 0.9825)
     (+
      U
      (*
       t_0
       (*
        J
        (*
         l
         (+
          2.0
          (*
           (* l l)
           (+
            0.3333333333333333
            (*
             (* l l)
             (+ 0.016666666666666666 (* l (* l 0.0003968253968253968)))))))))))
     (+ U (* (* 2.0 (sinh 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.9825) {
		tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * (0.016666666666666666 + (l * (l * 0.0003968253968253968))))))))));
	} else {
		tmp = U + ((2.0 * sinh(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.9825d0) then
        tmp = u + (t_0 * (j * (l * (2.0d0 + ((l * l) * (0.3333333333333333d0 + ((l * l) * (0.016666666666666666d0 + (l * (l * 0.0003968253968253968d0))))))))))
    else
        tmp = u + ((2.0d0 * sinh(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.9825) {
		tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * (0.016666666666666666 + (l * (l * 0.0003968253968253968))))))))));
	} else {
		tmp = U + ((2.0 * Math.sinh(l)) * J);
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K / 2.0))
	tmp = 0
	if t_0 <= 0.9825:
		tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * (0.016666666666666666 + (l * (l * 0.0003968253968253968))))))))))
	else:
		tmp = U + ((2.0 * math.sinh(l)) * J)
	return tmp
function code(J, l, K, U)
	t_0 = cos(Float64(K / 2.0))
	tmp = 0.0
	if (t_0 <= 0.9825)
		tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * Float64(2.0 + Float64(Float64(l * l) * Float64(0.3333333333333333 + Float64(Float64(l * l) * Float64(0.016666666666666666 + Float64(l * Float64(l * 0.0003968253968253968)))))))))));
	else
		tmp = Float64(U + Float64(Float64(2.0 * sinh(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.9825)
		tmp = U + (t_0 * (J * (l * (2.0 + ((l * l) * (0.3333333333333333 + ((l * l) * (0.016666666666666666 + (l * (l * 0.0003968253968253968))))))))));
	else
		tmp = U + ((2.0 * sinh(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.9825], N[(U + N[(t$95$0 * N[(J * N[(l * N[(2.0 + N[(N[(l * l), $MachinePrecision] * N[(0.3333333333333333 + N[(N[(l * l), $MachinePrecision] * N[(0.016666666666666666 + N[(l * N[(l * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


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

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left({\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left({\ell}^{2}\right), \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left(\ell \cdot \ell\right), \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \left({\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\left({\ell}^{2}\right), \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\left(\ell \cdot \ell\right), \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      10. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{60}, \left(\frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{60}, \left({\ell}^{2} \cdot \frac{1}{2520}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{60}, \left(\left(\ell \cdot \ell\right) \cdot \frac{1}{2520}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      13. associate-*l*N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{60}, \left(\ell \cdot \left(\ell \cdot \frac{1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{60}, \mathsf{*.f64}\left(\ell, \left(\ell \cdot \frac{1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      15. *-lowering-*.f6496.6%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{60}, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \frac{1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    5. Simplified96.6%

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)}, U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right), U\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} + \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\left(e^{\ell}\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      4. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      5. exp-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right)\right), U\right) \]
      6. distribute-neg-fracN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{\mathsf{neg}\left(1\right)}{e^{\ell}}\right)\right)\right), U\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{-1}{e^{\ell}}\right)\right)\right), U\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \left(e^{\ell}\right)\right)\right)\right), U\right) \]
      9. exp-lowering-exp.f6487.8%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \mathsf{exp.f64}\left(\ell\right)\right)\right)\right), U\right) \]
    5. Simplified87.8%

      \[\leadsto \color{blue}{J \cdot \left(e^{\ell} + \frac{-1}{e^{\ell}}\right)} + U \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\left(e^{\ell} + \frac{-1}{e^{\ell}}\right) \cdot J\right), U\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + \frac{-1}{e^{\ell}}\right), J\right), U\right) \]
      3. div-invN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + -1 \cdot \frac{1}{e^{\ell}}\right), J\right), U\right) \]
      4. mul-1-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right), J\right), U\right) \]
      5. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} - \frac{1}{e^{\ell}}\right), J\right), U\right) \]
      6. rec-expN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right), J\right), U\right) \]
      7. sinh-undefN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(2 \cdot \sinh \ell\right), J\right), U\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(2, \sinh \ell\right), J\right), U\right) \]
      9. sinh-lowering-sinh.f64100.0%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(2, \mathsf{sinh.f64}\left(\ell\right)\right), J\right), U\right) \]
    7. Applied egg-rr100.0%

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

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

Alternative 6: 96.1% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq 0.9825:\\ \;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + \left(2 \cdot \sinh \ell\right) \cdot J\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))))
   (if (<= t_0 0.9825)
     (+
      U
      (*
       t_0
       (*
        J
        (*
         l
         (+
          2.0
          (*
           l
           (* l (+ 0.3333333333333333 (* (* l l) 0.016666666666666666)))))))))
     (+ U (* (* 2.0 (sinh 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.9825) {
		tmp = U + (t_0 * (J * (l * (2.0 + (l * (l * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))));
	} else {
		tmp = U + ((2.0 * sinh(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.9825d0) then
        tmp = u + (t_0 * (j * (l * (2.0d0 + (l * (l * (0.3333333333333333d0 + ((l * l) * 0.016666666666666666d0))))))))
    else
        tmp = u + ((2.0d0 * sinh(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.9825) {
		tmp = U + (t_0 * (J * (l * (2.0 + (l * (l * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))));
	} else {
		tmp = U + ((2.0 * Math.sinh(l)) * J);
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K / 2.0))
	tmp = 0
	if t_0 <= 0.9825:
		tmp = U + (t_0 * (J * (l * (2.0 + (l * (l * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))))
	else:
		tmp = U + ((2.0 * math.sinh(l)) * J)
	return tmp
function code(J, l, K, U)
	t_0 = cos(Float64(K / 2.0))
	tmp = 0.0
	if (t_0 <= 0.9825)
		tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * Float64(2.0 + Float64(l * Float64(l * Float64(0.3333333333333333 + Float64(Float64(l * l) * 0.016666666666666666)))))))));
	else
		tmp = Float64(U + Float64(Float64(2.0 * sinh(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.9825)
		tmp = U + (t_0 * (J * (l * (2.0 + (l * (l * (0.3333333333333333 + ((l * l) * 0.016666666666666666))))))));
	else
		tmp = U + ((2.0 * sinh(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.9825], N[(U + N[(t$95$0 * N[(J * N[(l * N[(2.0 + N[(l * N[(l * N[(0.3333333333333333 + N[(N[(l * l), $MachinePrecision] * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


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

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left({\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left(\left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      4. associate-*l*N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left(\ell \cdot \left(\ell \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left(\ell \cdot \left(\left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right) \cdot \ell\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \left(\left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right) \cdot \ell\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \left(\ell \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      9. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{3}, \left(\frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{3}, \left({\ell}^{2} \cdot \frac{1}{60}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\left({\ell}^{2}\right), \frac{1}{60}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\left(\ell \cdot \ell\right), \frac{1}{60}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      13. *-lowering-*.f6495.7%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \frac{1}{60}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    5. Simplified95.7%

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)}, U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right), U\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} + \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\left(e^{\ell}\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      4. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      5. exp-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right)\right), U\right) \]
      6. distribute-neg-fracN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{\mathsf{neg}\left(1\right)}{e^{\ell}}\right)\right)\right), U\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{-1}{e^{\ell}}\right)\right)\right), U\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \left(e^{\ell}\right)\right)\right)\right), U\right) \]
      9. exp-lowering-exp.f6487.8%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \mathsf{exp.f64}\left(\ell\right)\right)\right)\right), U\right) \]
    5. Simplified87.8%

      \[\leadsto \color{blue}{J \cdot \left(e^{\ell} + \frac{-1}{e^{\ell}}\right)} + U \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\left(e^{\ell} + \frac{-1}{e^{\ell}}\right) \cdot J\right), U\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + \frac{-1}{e^{\ell}}\right), J\right), U\right) \]
      3. div-invN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + -1 \cdot \frac{1}{e^{\ell}}\right), J\right), U\right) \]
      4. mul-1-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right), J\right), U\right) \]
      5. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} - \frac{1}{e^{\ell}}\right), J\right), U\right) \]
      6. rec-expN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right), J\right), U\right) \]
      7. sinh-undefN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(2 \cdot \sinh \ell\right), J\right), U\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(2, \sinh \ell\right), J\right), U\right) \]
      9. sinh-lowering-sinh.f64100.0%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(2, \mathsf{sinh.f64}\left(\ell\right)\right), J\right), U\right) \]
    7. Applied egg-rr100.0%

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

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

Alternative 7: 93.7% accurate, 1.4× speedup?

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

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

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


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

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \color{blue}{\left(\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)}\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left(\frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \left({\ell}^{2}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \left(\ell \cdot \ell\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      5. *-lowering-*.f6485.7%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    5. Simplified85.7%

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)}, U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right), U\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} + \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\left(e^{\ell}\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      4. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      5. exp-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right)\right), U\right) \]
      6. distribute-neg-fracN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{\mathsf{neg}\left(1\right)}{e^{\ell}}\right)\right)\right), U\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{-1}{e^{\ell}}\right)\right)\right), U\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \left(e^{\ell}\right)\right)\right)\right), U\right) \]
      9. exp-lowering-exp.f6487.8%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \mathsf{exp.f64}\left(\ell\right)\right)\right)\right), U\right) \]
    5. Simplified87.8%

      \[\leadsto \color{blue}{J \cdot \left(e^{\ell} + \frac{-1}{e^{\ell}}\right)} + U \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\left(e^{\ell} + \frac{-1}{e^{\ell}}\right) \cdot J\right), U\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + \frac{-1}{e^{\ell}}\right), J\right), U\right) \]
      3. div-invN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + -1 \cdot \frac{1}{e^{\ell}}\right), J\right), U\right) \]
      4. mul-1-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right), J\right), U\right) \]
      5. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} - \frac{1}{e^{\ell}}\right), J\right), U\right) \]
      6. rec-expN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right), J\right), U\right) \]
      7. sinh-undefN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(2 \cdot \sinh \ell\right), J\right), U\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(2, \sinh \ell\right), J\right), U\right) \]
      9. sinh-lowering-sinh.f64100.0%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(2, \mathsf{sinh.f64}\left(\ell\right)\right), J\right), U\right) \]
    7. Applied egg-rr100.0%

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

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

Alternative 8: 92.7% accurate, 1.4× speedup?

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

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

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


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

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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(\ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)\right)}, U\right) \]
    4. Step-by-step derivation
      1. distribute-rgt-inN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\left(\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)\right) \cdot \ell + \left(2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \ell\right), U\right) \]
      2. fma-defineN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\mathsf{fma}\left(\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right), \ell, \left(2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \ell\right)\right), U\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\mathsf{fma}\left(\frac{1}{3} \cdot \left(J \cdot \left(\cos \left(\frac{1}{2} \cdot K\right) \cdot {\ell}^{2}\right)\right), \ell, \left(2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \ell\right)\right), U\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{+.f64}\left(\left(\mathsf{fma}\left(\frac{1}{3} \cdot \left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot {\ell}^{2}\right), \ell, \left(2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \ell\right)\right), U\right) \]
      5. associate-*l*N/A

        \[\leadsto \mathsf{+.f64}\left(\left(\mathsf{fma}\left(\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2}, \ell, \left(2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \ell\right)\right), U\right) \]
      6. fma-undefineN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\left(\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2}\right) \cdot \ell + \left(2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \ell\right), U\right) \]
      7. distribute-rgt-inN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\ell \cdot \left(\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)\right), U\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\ell, \left(\left(\frac{1}{3} \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot {\ell}^{2} + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)\right), U\right) \]
    5. Simplified80.1%

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

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

    1. Initial program 86.9%

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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)}, U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right), U\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} + \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\left(e^{\ell}\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      4. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      5. exp-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right)\right), U\right) \]
      6. distribute-neg-fracN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{\mathsf{neg}\left(1\right)}{e^{\ell}}\right)\right)\right), U\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{-1}{e^{\ell}}\right)\right)\right), U\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \left(e^{\ell}\right)\right)\right)\right), U\right) \]
      9. exp-lowering-exp.f6486.5%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \mathsf{exp.f64}\left(\ell\right)\right)\right)\right), U\right) \]
    5. Simplified86.5%

      \[\leadsto \color{blue}{J \cdot \left(e^{\ell} + \frac{-1}{e^{\ell}}\right)} + U \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\left(e^{\ell} + \frac{-1}{e^{\ell}}\right) \cdot J\right), U\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + \frac{-1}{e^{\ell}}\right), J\right), U\right) \]
      3. div-invN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + -1 \cdot \frac{1}{e^{\ell}}\right), J\right), U\right) \]
      4. mul-1-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right), J\right), U\right) \]
      5. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} - \frac{1}{e^{\ell}}\right), J\right), U\right) \]
      6. rec-expN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right), J\right), U\right) \]
      7. sinh-undefN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(2 \cdot \sinh \ell\right), J\right), U\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(2, \sinh \ell\right), J\right), U\right) \]
      9. sinh-lowering-sinh.f6495.8%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(2, \mathsf{sinh.f64}\left(\ell\right)\right), J\right), U\right) \]
    7. Applied egg-rr95.8%

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

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

Alternative 9: 92.6% accurate, 2.3× speedup?

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

\\
\begin{array}{l}
t_0 := \left(\left(\ell \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right)\\
\mathbf{if}\;\ell \leq -1.18 \cdot 10^{+113}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;\ell \leq -0.0155:\\
\;\;\;\;U + \left(2 \cdot \sinh \ell\right) \cdot J\\

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

\mathbf{elif}\;\ell \leq 1.4 \cdot 10^{+144}:\\
\;\;\;\;U + J \cdot \left(e^{\ell} + \frac{-1}{\ell + 1}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -1.18000000000000008e113 or 1.40000000000000003e144 < 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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \color{blue}{\left(\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)}\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left(\frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \left({\ell}^{2}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \left(\ell \cdot \ell\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      5. *-lowering-*.f64100.0%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    5. Simplified100.0%

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

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

        \[\leadsto J \cdot \left(\left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot \color{blue}{\left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}\right) \]
      2. associate-*r*N/A

        \[\leadsto \left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) \cdot \color{blue}{\left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(J \cdot \left(\ell \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right), \color{blue}{\left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)}\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(J \cdot \ell\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)\right), \left(\color{blue}{2} + \frac{1}{3} \cdot {\ell}^{2}\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\cos \left(\frac{1}{2} \cdot K\right) \cdot \left(J \cdot \ell\right)\right), \left(\color{blue}{2} + \frac{1}{3} \cdot {\ell}^{2}\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\cos \left(\frac{1}{2} \cdot K\right), \left(J \cdot \ell\right)\right), \left(\color{blue}{2} + \frac{1}{3} \cdot {\ell}^{2}\right)\right) \]
      7. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot K\right)\right), \left(J \cdot \ell\right)\right), \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\left(K \cdot \frac{1}{2}\right)\right), \left(J \cdot \ell\right)\right), \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(K, \frac{1}{2}\right)\right), \left(J \cdot \ell\right)\right), \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(K, \frac{1}{2}\right)\right), \mathsf{*.f64}\left(J, \ell\right)\right), \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(K, \frac{1}{2}\right)\right), \mathsf{*.f64}\left(J, \ell\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left(\frac{1}{3} \cdot {\ell}^{2}\right)}\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(K, \frac{1}{2}\right)\right), \mathsf{*.f64}\left(J, \ell\right)\right), \mathsf{+.f64}\left(2, \left({\ell}^{2} \cdot \color{blue}{\frac{1}{3}}\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(K, \frac{1}{2}\right)\right), \mathsf{*.f64}\left(J, \ell\right)\right), \mathsf{+.f64}\left(2, \left(\left(\ell \cdot \ell\right) \cdot \frac{1}{3}\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(K, \frac{1}{2}\right)\right), \mathsf{*.f64}\left(J, \ell\right)\right), \mathsf{+.f64}\left(2, \left(\ell \cdot \color{blue}{\left(\ell \cdot \frac{1}{3}\right)}\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(K, \frac{1}{2}\right)\right), \mathsf{*.f64}\left(J, \ell\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \color{blue}{\left(\ell \cdot \frac{1}{3}\right)}\right)\right)\right) \]
      16. *-lowering-*.f6495.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(K, \frac{1}{2}\right)\right), \mathsf{*.f64}\left(J, \ell\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \color{blue}{\frac{1}{3}}\right)\right)\right)\right) \]
    8. Simplified95.4%

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

    if -1.18000000000000008e113 < l < -0.0155

    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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)}, U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right), U\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} + \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\left(e^{\ell}\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      4. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      5. exp-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right)\right), U\right) \]
      6. distribute-neg-fracN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{\mathsf{neg}\left(1\right)}{e^{\ell}}\right)\right)\right), U\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{-1}{e^{\ell}}\right)\right)\right), U\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \left(e^{\ell}\right)\right)\right)\right), U\right) \]
      9. exp-lowering-exp.f6477.8%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \mathsf{exp.f64}\left(\ell\right)\right)\right)\right), U\right) \]
    5. Simplified77.8%

      \[\leadsto \color{blue}{J \cdot \left(e^{\ell} + \frac{-1}{e^{\ell}}\right)} + U \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\left(e^{\ell} + \frac{-1}{e^{\ell}}\right) \cdot J\right), U\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + \frac{-1}{e^{\ell}}\right), J\right), U\right) \]
      3. div-invN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + -1 \cdot \frac{1}{e^{\ell}}\right), J\right), U\right) \]
      4. mul-1-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right), J\right), U\right) \]
      5. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} - \frac{1}{e^{\ell}}\right), J\right), U\right) \]
      6. rec-expN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right), J\right), U\right) \]
      7. sinh-undefN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(2 \cdot \sinh \ell\right), J\right), U\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(2, \sinh \ell\right), J\right), U\right) \]
      9. sinh-lowering-sinh.f6477.8%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(2, \mathsf{sinh.f64}\left(\ell\right)\right), J\right), U\right) \]
    7. Applied egg-rr77.8%

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

    if -0.0155 < l < 1.62000000000000003e-21

    1. Initial program 70.9%

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\color{blue}{\left(2 \cdot \left(J \cdot \ell\right)\right)}, \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    4. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(\left(2 \cdot J\right) \cdot \ell\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(\ell \cdot \left(2 \cdot J\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \left(2 \cdot J\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      4. *-lowering-*.f6499.9%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(2, J\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    5. Simplified99.9%

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

    if 1.62000000000000003e-21 < l < 1.40000000000000003e144

    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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)}, U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right), U\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} + \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\left(e^{\ell}\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      4. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      5. exp-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right)\right), U\right) \]
      6. distribute-neg-fracN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{\mathsf{neg}\left(1\right)}{e^{\ell}}\right)\right)\right), U\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{-1}{e^{\ell}}\right)\right)\right), U\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \left(e^{\ell}\right)\right)\right)\right), U\right) \]
      9. exp-lowering-exp.f6475.6%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \mathsf{exp.f64}\left(\ell\right)\right)\right)\right), U\right) \]
    5. Simplified75.6%

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \color{blue}{\left(1 + \ell\right)}\right)\right)\right), U\right) \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \left(\ell + 1\right)\right)\right)\right), U\right) \]
      2. +-lowering-+.f6475.8%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \mathsf{+.f64}\left(\ell, 1\right)\right)\right)\right), U\right) \]
    8. Simplified75.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.18 \cdot 10^{+113}:\\ \;\;\;\;\left(\left(\ell \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right)\\ \mathbf{elif}\;\ell \leq -0.0155:\\ \;\;\;\;U + \left(2 \cdot \sinh \ell\right) \cdot J\\ \mathbf{elif}\;\ell \leq 1.62 \cdot 10^{-21}:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(2 \cdot J\right)\right)\\ \mathbf{elif}\;\ell \leq 1.4 \cdot 10^{+144}:\\ \;\;\;\;U + J \cdot \left(e^{\ell} + \frac{-1}{\ell + 1}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\ell \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 80.3% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 4 \cdot 10^{+198}:\\
\;\;\;\;U + \left(2 \cdot \sinh \ell\right) \cdot J\\

\mathbf{else}:\\
\;\;\;\;U + \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)\right) \cdot \left(1 + -0.125 \cdot \left(K \cdot K\right)\right)\\


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

    1. Initial program 84.9%

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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)}, U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right), U\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} + \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\left(e^{\ell}\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      4. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      5. exp-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right)\right), U\right) \]
      6. distribute-neg-fracN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{\mathsf{neg}\left(1\right)}{e^{\ell}}\right)\right)\right), U\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{-1}{e^{\ell}}\right)\right)\right), U\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \left(e^{\ell}\right)\right)\right)\right), U\right) \]
      9. exp-lowering-exp.f6471.7%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \mathsf{exp.f64}\left(\ell\right)\right)\right)\right), U\right) \]
    5. Simplified71.7%

      \[\leadsto \color{blue}{J \cdot \left(e^{\ell} + \frac{-1}{e^{\ell}}\right)} + U \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\left(e^{\ell} + \frac{-1}{e^{\ell}}\right) \cdot J\right), U\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + \frac{-1}{e^{\ell}}\right), J\right), U\right) \]
      3. div-invN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + -1 \cdot \frac{1}{e^{\ell}}\right), J\right), U\right) \]
      4. mul-1-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} + \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right), J\right), U\right) \]
      5. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} - \frac{1}{e^{\ell}}\right), J\right), U\right) \]
      6. rec-expN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right), J\right), U\right) \]
      7. sinh-undefN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(2 \cdot \sinh \ell\right), J\right), U\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(2, \sinh \ell\right), J\right), U\right) \]
      9. sinh-lowering-sinh.f6479.2%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(2, \mathsf{sinh.f64}\left(\ell\right)\right), J\right), U\right) \]
    7. Applied egg-rr79.2%

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

    if 4.00000000000000007e198 < 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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \color{blue}{\left(\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)}\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left(\frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \left({\ell}^{2}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \left(\ell \cdot \ell\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      5. *-lowering-*.f64100.0%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    5. Simplified100.0%

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \color{blue}{\left(1 + \frac{-1}{8} \cdot {K}^{2}\right)}\right), U\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left(\frac{-1}{8} \cdot {K}^{2}\right)\right)\right), U\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \left({K}^{2}\right)\right)\right)\right), U\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \left(K \cdot K\right)\right)\right)\right), U\right) \]
      4. *-lowering-*.f6483.9%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(K, K\right)\right)\right)\right), U\right) \]
    8. Simplified83.9%

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

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

Alternative 11: 76.8% accurate, 10.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.5 \cdot 10^{+149}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;U + \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)\right) \cdot \left(1 + -0.125 \cdot \left(K \cdot K\right)\right)\\


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

    1. Initial program 83.9%

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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)}, U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right), U\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} + \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\left(e^{\ell}\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      4. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      5. exp-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right)\right), U\right) \]
      6. distribute-neg-fracN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{\mathsf{neg}\left(1\right)}{e^{\ell}}\right)\right)\right), U\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{-1}{e^{\ell}}\right)\right)\right), U\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \left(e^{\ell}\right)\right)\right)\right), U\right) \]
      9. exp-lowering-exp.f6472.3%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \mathsf{exp.f64}\left(\ell\right)\right)\right)\right), U\right) \]
    5. Simplified72.3%

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)}\right), U\right) \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right), U\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left({\ell}^{2} \cdot \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right), U\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left({\ell}^{2}\right), \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right), U\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left(\ell \cdot \ell\right), \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right), U\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right), U\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \left({\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right), U\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\left({\ell}^{2}\right), \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right), U\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\left(\ell \cdot \ell\right), \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right), U\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right), U\right) \]
      10. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{60}, \left(\frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{60}, \left({\ell}^{2} \cdot \frac{1}{2520}\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{60}, \mathsf{*.f64}\left(\left({\ell}^{2}\right), \frac{1}{2520}\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{60}, \mathsf{*.f64}\left(\left(\ell \cdot \ell\right), \frac{1}{2520}\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      14. *-lowering-*.f6477.6%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \frac{1}{2520}\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
    8. Simplified77.6%

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

    if 1.50000000000000002e149 < 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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \color{blue}{\left(\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)}\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left(\frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \left({\ell}^{2}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \left(\ell \cdot \ell\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      5. *-lowering-*.f64100.0%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    5. Simplified100.0%

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \color{blue}{\left(1 + \frac{-1}{8} \cdot {K}^{2}\right)}\right), U\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left(\frac{-1}{8} \cdot {K}^{2}\right)\right)\right), U\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \left({K}^{2}\right)\right)\right)\right), U\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \left(K \cdot K\right)\right)\right)\right), U\right) \]
      4. *-lowering-*.f6477.3%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(K, K\right)\right)\right)\right), U\right) \]
    8. Simplified77.3%

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

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

Alternative 12: 75.2% accurate, 12.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.6 \cdot 10^{+149}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;U + \left(J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)\right) \cdot \left(1 + -0.125 \cdot \left(K \cdot K\right)\right)\\


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

    1. Initial program 83.9%

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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)}, U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right), U\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} + \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\left(e^{\ell}\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      4. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      5. exp-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right)\right), U\right) \]
      6. distribute-neg-fracN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{\mathsf{neg}\left(1\right)}{e^{\ell}}\right)\right)\right), U\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{-1}{e^{\ell}}\right)\right)\right), U\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \left(e^{\ell}\right)\right)\right)\right), U\right) \]
      9. exp-lowering-exp.f6472.3%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \mathsf{exp.f64}\left(\ell\right)\right)\right)\right), U\right) \]
    5. Simplified72.3%

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right), U\right) \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right), U\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left({\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right), U\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left(\left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right), U\right) \]
      4. associate-*l*N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left(\ell \cdot \left(\ell \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right), U\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \left(\ell \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right), U\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right), U\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{3}, \left(\frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right), U\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{3}, \left({\ell}^{2} \cdot \frac{1}{60}\right)\right)\right)\right)\right)\right)\right), U\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\left({\ell}^{2}\right), \frac{1}{60}\right)\right)\right)\right)\right)\right)\right), U\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\left(\ell \cdot \ell\right), \frac{1}{60}\right)\right)\right)\right)\right)\right)\right), U\right) \]
      11. *-lowering-*.f6477.2%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \frac{1}{60}\right)\right)\right)\right)\right)\right)\right), U\right) \]
    8. Simplified77.2%

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

    if 1.6000000000000001e149 < 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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \color{blue}{\left(\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)}\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left(\frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \left({\ell}^{2}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \left(\ell \cdot \ell\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      5. *-lowering-*.f64100.0%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    5. Simplified100.0%

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \color{blue}{\left(1 + \frac{-1}{8} \cdot {K}^{2}\right)}\right), U\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left(\frac{-1}{8} \cdot {K}^{2}\right)\right)\right), U\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \left({K}^{2}\right)\right)\right)\right), U\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \left(K \cdot K\right)\right)\right)\right), U\right) \]
      4. *-lowering-*.f6477.3%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \ell\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(K, K\right)\right)\right)\right), U\right) \]
    8. Simplified77.3%

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

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

Alternative 13: 75.6% accurate, 16.4× speedup?

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

\\
U + J \cdot \left(\ell \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right)
\end{array}
Derivation
  1. Initial program 86.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

    \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)}, U\right) \]
  4. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right), U\right) \]
    2. sub-negN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} + \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
    3. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\left(e^{\ell}\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
    4. exp-lowering-exp.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
    5. exp-negN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right)\right), U\right) \]
    6. distribute-neg-fracN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{\mathsf{neg}\left(1\right)}{e^{\ell}}\right)\right)\right), U\right) \]
    7. metadata-evalN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{-1}{e^{\ell}}\right)\right)\right), U\right) \]
    8. /-lowering-/.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \left(e^{\ell}\right)\right)\right)\right), U\right) \]
    9. exp-lowering-exp.f6470.8%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \mathsf{exp.f64}\left(\ell\right)\right)\right)\right), U\right) \]
  5. Simplified70.8%

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

    \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \color{blue}{\left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)}\right), U\right) \]
  7. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \left(2 + {\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right), U\right) \]
    2. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left({\ell}^{2} \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right), U\right) \]
    3. unpow2N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left(\left(\ell \cdot \ell\right) \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right), U\right) \]
    4. associate-*l*N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left(\ell \cdot \left(\ell \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right), U\right) \]
    5. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \left(\ell \cdot \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right), U\right) \]
    6. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \left(\frac{1}{3} + \frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right), U\right) \]
    7. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{3}, \left(\frac{1}{60} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right), U\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{3}, \left({\ell}^{2} \cdot \frac{1}{60}\right)\right)\right)\right)\right)\right)\right), U\right) \]
    9. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\left({\ell}^{2}\right), \frac{1}{60}\right)\right)\right)\right)\right)\right)\right), U\right) \]
    10. unpow2N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\left(\ell \cdot \ell\right), \frac{1}{60}\right)\right)\right)\right)\right)\right)\right), U\right) \]
    11. *-lowering-*.f6474.8%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \ell\right), \frac{1}{60}\right)\right)\right)\right)\right)\right)\right), U\right) \]
  8. Simplified74.8%

    \[\leadsto J \cdot \color{blue}{\left(\ell \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \left(\ell \cdot \ell\right) \cdot 0.016666666666666666\right)\right)\right)\right)} + U \]
  9. Final simplification74.8%

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

Alternative 14: 46.5% accurate, 20.8× speedup?

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

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

\mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+17}:\\
\;\;\;\;U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -1.4500000000000001e-22 or 1.3e17 < l

    1. Initial program 98.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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)}, U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right), U\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} + \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\left(e^{\ell}\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      4. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      5. exp-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right)\right), U\right) \]
      6. distribute-neg-fracN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{\mathsf{neg}\left(1\right)}{e^{\ell}}\right)\right)\right), U\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{-1}{e^{\ell}}\right)\right)\right), U\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \left(e^{\ell}\right)\right)\right)\right), U\right) \]
      9. exp-lowering-exp.f6469.3%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \mathsf{exp.f64}\left(\ell\right)\right)\right)\right), U\right) \]
    5. Simplified69.3%

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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(2 \cdot \left(J \cdot \ell\right)\right)}, U\right) \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\left(J \cdot \ell\right) \cdot 2\right), U\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{+.f64}\left(\left(J \cdot \left(\ell \cdot 2\right)\right), U\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\left(J \cdot \left(2 \cdot \ell\right)\right), U\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(2 \cdot \ell\right)\right), U\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(\ell \cdot 2\right)\right), U\right) \]
      6. *-lowering-*.f6427.1%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, 2\right)\right), U\right) \]
    8. Simplified27.1%

      \[\leadsto \color{blue}{J \cdot \left(\ell \cdot 2\right)} + U \]
    9. Taylor expanded in J around inf

      \[\leadsto \color{blue}{2 \cdot \left(J \cdot \ell\right)} \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(J \cdot \ell\right) \cdot \color{blue}{2} \]
      2. associate-*r*N/A

        \[\leadsto J \cdot \color{blue}{\left(\ell \cdot 2\right)} \]
      3. *-commutativeN/A

        \[\leadsto J \cdot \left(2 \cdot \color{blue}{\ell}\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(J, \color{blue}{\left(2 \cdot \ell\right)}\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(J, \left(\ell \cdot \color{blue}{2}\right)\right) \]
      6. *-lowering-*.f6426.5%

        \[\leadsto \mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \color{blue}{2}\right)\right) \]
    11. Simplified26.5%

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

    if -1.4500000000000001e-22 < l < 1.3e17

    1. Initial program 73.9%

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

      \[\leadsto \color{blue}{U} \]
    4. Step-by-step derivation
      1. Simplified71.5%

        \[\leadsto \color{blue}{U} \]
    5. Recombined 2 regimes into one program.
    6. Final simplification47.6%

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

    Alternative 15: 72.1% accurate, 24.0× speedup?

    \[\begin{array}{l} \\ U + J \cdot \left(\ell \cdot \left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right)\right) \end{array} \]
    (FPCore (J l K U)
     :precision binary64
     (+ U (* J (* l (+ 2.0 (* l (* l 0.3333333333333333)))))))
    double code(double J, double l, double K, double U) {
    	return U + (J * (l * (2.0 + (l * (l * 0.3333333333333333)))));
    }
    
    real(8) function code(j, l, k, u)
        real(8), intent (in) :: j
        real(8), intent (in) :: l
        real(8), intent (in) :: k
        real(8), intent (in) :: u
        code = u + (j * (l * (2.0d0 + (l * (l * 0.3333333333333333d0)))))
    end function
    
    public static double code(double J, double l, double K, double U) {
    	return U + (J * (l * (2.0 + (l * (l * 0.3333333333333333)))));
    }
    
    def code(J, l, K, U):
    	return U + (J * (l * (2.0 + (l * (l * 0.3333333333333333)))))
    
    function code(J, l, K, U)
    	return Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(l * Float64(l * 0.3333333333333333))))))
    end
    
    function tmp = code(J, l, K, U)
    	tmp = U + (J * (l * (2.0 + (l * (l * 0.3333333333333333)))));
    end
    
    code[J_, l_, K_, U_] := N[(U + N[(J * N[(l * N[(2.0 + N[(l * N[(l * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    U + J \cdot \left(\ell \cdot \left(2 + \ell \cdot \left(\ell \cdot 0.3333333333333333\right)\right)\right)
    \end{array}
    
    Derivation
    1. Initial program 86.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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)}, U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right), U\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} + \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\left(e^{\ell}\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      4. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      5. exp-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right)\right), U\right) \]
      6. distribute-neg-fracN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{\mathsf{neg}\left(1\right)}{e^{\ell}}\right)\right)\right), U\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{-1}{e^{\ell}}\right)\right)\right), U\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \left(e^{\ell}\right)\right)\right)\right), U\right) \]
      9. exp-lowering-exp.f6470.8%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \mathsf{exp.f64}\left(\ell\right)\right)\right)\right), U\right) \]
    5. Simplified70.8%

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \color{blue}{\left(\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)}\right), U\right) \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right), U\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left(\frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)\right), U\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left({\ell}^{2} \cdot \frac{1}{3}\right)\right)\right)\right), U\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left(\left(\ell \cdot \ell\right) \cdot \frac{1}{3}\right)\right)\right)\right), U\right) \]
      5. associate-*l*N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \left(\ell \cdot \left(\ell \cdot \frac{1}{3}\right)\right)\right)\right)\right), U\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \left(\ell \cdot \frac{1}{3}\right)\right)\right)\right)\right), U\right) \]
      7. *-lowering-*.f6469.3%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \frac{1}{3}\right)\right)\right)\right)\right), U\right) \]
    8. Simplified69.3%

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

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

    Alternative 16: 57.8% accurate, 28.4× speedup?

    \[\begin{array}{l} \\ U \cdot \left(1 + \frac{J \cdot \left(2 \cdot \ell\right)}{U}\right) \end{array} \]
    (FPCore (J l K U) :precision binary64 (* U (+ 1.0 (/ (* J (* 2.0 l)) U))))
    double code(double J, double l, double K, double U) {
    	return U * (1.0 + ((J * (2.0 * l)) / 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 * (1.0d0 + ((j * (2.0d0 * l)) / u))
    end function
    
    public static double code(double J, double l, double K, double U) {
    	return U * (1.0 + ((J * (2.0 * l)) / U));
    }
    
    def code(J, l, K, U):
    	return U * (1.0 + ((J * (2.0 * l)) / U))
    
    function code(J, l, K, U)
    	return Float64(U * Float64(1.0 + Float64(Float64(J * Float64(2.0 * l)) / U)))
    end
    
    function tmp = code(J, l, K, U)
    	tmp = U * (1.0 + ((J * (2.0 * l)) / U));
    end
    
    code[J_, l_, K_, U_] := N[(U * N[(1.0 + N[(N[(J * N[(2.0 * l), $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    U \cdot \left(1 + \frac{J \cdot \left(2 \cdot \ell\right)}{U}\right)
    \end{array}
    
    Derivation
    1. Initial program 86.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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)}, U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right), U\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} + \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\left(e^{\ell}\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      4. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      5. exp-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right)\right), U\right) \]
      6. distribute-neg-fracN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{\mathsf{neg}\left(1\right)}{e^{\ell}}\right)\right)\right), U\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{-1}{e^{\ell}}\right)\right)\right), U\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \left(e^{\ell}\right)\right)\right)\right), U\right) \]
      9. exp-lowering-exp.f6470.8%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \mathsf{exp.f64}\left(\ell\right)\right)\right)\right), U\right) \]
    5. Simplified70.8%

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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(2 \cdot \left(J \cdot \ell\right)\right)}, U\right) \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\left(J \cdot \ell\right) \cdot 2\right), U\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{+.f64}\left(\left(J \cdot \left(\ell \cdot 2\right)\right), U\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\left(J \cdot \left(2 \cdot \ell\right)\right), U\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(2 \cdot \ell\right)\right), U\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(\ell \cdot 2\right)\right), U\right) \]
      6. *-lowering-*.f6453.6%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, 2\right)\right), U\right) \]
    8. Simplified53.6%

      \[\leadsto \color{blue}{J \cdot \left(\ell \cdot 2\right)} + U \]
    9. Taylor expanded in U around inf

      \[\leadsto \color{blue}{U \cdot \left(1 + 2 \cdot \frac{J \cdot \ell}{U}\right)} \]
    10. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(U, \color{blue}{\left(1 + 2 \cdot \frac{J \cdot \ell}{U}\right)}\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(U, \mathsf{+.f64}\left(1, \color{blue}{\left(2 \cdot \frac{J \cdot \ell}{U}\right)}\right)\right) \]
      3. associate-*r/N/A

        \[\leadsto \mathsf{*.f64}\left(U, \mathsf{+.f64}\left(1, \left(\frac{2 \cdot \left(J \cdot \ell\right)}{\color{blue}{U}}\right)\right)\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(U, \mathsf{+.f64}\left(1, \left(\frac{\left(2 \cdot J\right) \cdot \ell}{U}\right)\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(U, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\left(2 \cdot J\right) \cdot \ell\right), \color{blue}{U}\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(U, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\left(J \cdot 2\right) \cdot \ell\right), U\right)\right)\right) \]
      7. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(U, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(J \cdot \left(2 \cdot \ell\right)\right), U\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(U, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(J, \left(2 \cdot \ell\right)\right), U\right)\right)\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(U, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(J, \left(\ell \cdot 2\right)\right), U\right)\right)\right) \]
      10. *-lowering-*.f6457.8%

        \[\leadsto \mathsf{*.f64}\left(U, \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, 2\right)\right), U\right)\right)\right) \]
    11. Simplified57.8%

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

      \[\leadsto U \cdot \left(1 + \frac{J \cdot \left(2 \cdot \ell\right)}{U}\right) \]
    13. Add Preprocessing

    Alternative 17: 54.4% accurate, 44.6× speedup?

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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(J \cdot \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right)}, U\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} - e^{\mathsf{neg}\left(\ell\right)}\right)\right), U\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(e^{\ell} + \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\left(e^{\ell}\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      4. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(e^{\mathsf{neg}\left(\ell\right)}\right)\right)\right)\right), U\right) \]
      5. exp-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\mathsf{neg}\left(\frac{1}{e^{\ell}}\right)\right)\right)\right), U\right) \]
      6. distribute-neg-fracN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{\mathsf{neg}\left(1\right)}{e^{\ell}}\right)\right)\right), U\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \left(\frac{-1}{e^{\ell}}\right)\right)\right), U\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \left(e^{\ell}\right)\right)\right)\right), U\right) \]
      9. exp-lowering-exp.f6470.8%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{exp.f64}\left(\ell\right), \mathsf{/.f64}\left(-1, \mathsf{exp.f64}\left(\ell\right)\right)\right)\right), U\right) \]
    5. Simplified70.8%

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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(2 \cdot \left(J \cdot \ell\right)\right)}, U\right) \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\left(J \cdot \ell\right) \cdot 2\right), U\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{+.f64}\left(\left(J \cdot \left(\ell \cdot 2\right)\right), U\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\left(J \cdot \left(2 \cdot \ell\right)\right), U\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(2 \cdot \ell\right)\right), U\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \left(\ell \cdot 2\right)\right), U\right) \]
      6. *-lowering-*.f6453.6%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(\ell, 2\right)\right), U\right) \]
    8. Simplified53.6%

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

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

    Alternative 18: 37.3% 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 86.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

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

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

      Reproduce

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