Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 85.6% → 99.9%
Time: 13.2s
Alternatives: 21
Speedup: 2.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 21 alternatives:

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

Initial Program: 85.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: 99.9% 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 87.1%

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

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

    \[\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: 94.4% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq 0.96:\\ \;\;\;\;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.96)
     (+ 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.96) {
		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.96d0) 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.96) {
		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.96:
		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.96)
		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.96)
		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.96], 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.96:\\
\;\;\;\;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.95999999999999996

    1. Initial program 84.3%

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

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

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

      \[\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.95999999999999996 < (cos.f64 (/.f64 K #s(literal 2 binary64)))

    1. Initial program 89.5%

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

      \[\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.f6489.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. Simplified89.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.f6499.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.96:\\ \;\;\;\;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 3: 93.1% accurate, 1.4× speedup?

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

    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 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. *-commutativeN/A

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

        \[\leadsto \mathsf{+.f64}\left(\left(\ell \cdot \left(\frac{1}{3} \cdot \left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot {\ell}^{2}\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)\right), U\right) \]
      3. associate-*l*N/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) \]
      4. *-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. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\ell, \left({\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \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) \]
      6. associate-*r*N/A

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

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

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

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

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

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

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

    1. Initial program 88.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.f6488.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. Simplified88.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.f6497.3%

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

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

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

Alternative 4: 87.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.04:\\ \;\;\;\;U + t\_0 \cdot \left(J \cdot \left(2 \cdot \ell\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.04)
     (+ U (* t_0 (* J (* 2.0 l))))
     (+ 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.04) {
		tmp = U + (t_0 * (J * (2.0 * l)));
	} 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.04d0)) then
        tmp = u + (t_0 * (j * (2.0d0 * l)))
    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.04) {
		tmp = U + (t_0 * (J * (2.0 * l)));
	} 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.04:
		tmp = U + (t_0 * (J * (2.0 * l)))
	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.04)
		tmp = Float64(U + Float64(t_0 * Float64(J * Float64(2.0 * l))));
	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.04)
		tmp = U + (t_0 * (J * (2.0 * l)));
	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.04], N[(U + N[(t$95$0 * N[(J * N[(2.0 * l), $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.04:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(2 \cdot \ell\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 82.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(\mathsf{*.f64}\left(J, \color{blue}{\left(2 \cdot \ell\right)}\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    4. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

    1. Initial program 88.5%

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

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

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

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

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

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

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

Alternative 5: 89.5% accurate, 2.3× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;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 + \ell \cdot \left(\ell \cdot \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right)\right)\right)\right)\right)\\


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

    1. Initial program 89.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.f6479.1%

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

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

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

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

    if 1.00000000000000005e-4 < (/.f64 K #s(literal 2 binary64))

    1. Initial program 81.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(\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. 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}, \left(\left(\ell \cdot \ell\right) \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) \]
      8. 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}, \left(\ell \cdot \left(\ell \cdot \left(\frac{1}{60} + \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) \]
      9. *-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}, \left(\ell \cdot \left(\left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right) \cdot \ell\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(\ell, \left(\left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right) \cdot \ell\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(\ell, \left(\ell \cdot \left(\frac{1}{60} + \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) \]
      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(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \left(\frac{1}{60} + \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) \]
      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(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{60}, \left(\frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\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(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{60}, \left({\ell}^{2} \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-*.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(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{60}, \mathsf{*.f64}\left(\left({\ell}^{2}\right), \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) \]
      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(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \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)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      17. *-lowering-*.f6498.5%

        \[\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(\ell, \mathsf{*.f64}\left(\ell, \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)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    5. Simplified98.5%

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

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

Alternative 6: 88.9% accurate, 2.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;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 0.016666666666666666\right)\right)\right)\right)\\


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

    1. Initial program 89.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.f6479.1%

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

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

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

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

    if 1.00000000000000005e-4 < (/.f64 K #s(literal 2 binary64))

    1. Initial program 81.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(\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. *-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} + \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. 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} + \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) \]
      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} + \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) \]
      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(\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) \]
      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(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \left({\ell}^{2} \cdot \frac{1}{60}\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(\mathsf{*.f64}\left(\ell, \ell\right), \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\left({\ell}^{2}\right), \frac{1}{60}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      9. 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), \frac{1}{60}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
      10. *-lowering-*.f6497.0%

        \[\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), \frac{1}{60}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    5. Simplified97.0%

      \[\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 0.016666666666666666\right)\right)\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.3%

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

Alternative 7: 83.8% accurate, 2.6× speedup?

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

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

\mathbf{elif}\;J \leq 5.5 \cdot 10^{+60}:\\
\;\;\;\;U + \left(2 \cdot \sinh \ell\right) \cdot J\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if J < -3.7000000000000001e116 or 5.5000000000000001e60 < J

    1. Initial program 74.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(\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. *-commutativeN/A

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

        \[\leadsto \mathsf{+.f64}\left(\left(\ell \cdot \left(\frac{1}{3} \cdot \left(\left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right) \cdot {\ell}^{2}\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right)\right), U\right) \]
      3. associate-*l*N/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) \]
      4. *-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. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\ell, \left({\ell}^{2} \cdot \left(\frac{1}{3} \cdot \left(J \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) \]
      6. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.7000000000000001e116 < J < 5.5000000000000001e60

    1. Initial program 93.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 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.f6485.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. Simplified85.3%

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

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

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

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

Alternative 8: 81.2% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;J \leq -5.2 \cdot 10^{+220}:\\ \;\;\;\;\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot \left(2 \cdot \ell\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 (<= J -5.2e+220)
   (* (cos (* K 0.5)) (* J (* 2.0 l)))
   (+ U (* (* 2.0 (sinh l)) J))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (J <= -5.2e+220) {
		tmp = cos((K * 0.5)) * (J * (2.0 * l));
	} 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 (j <= (-5.2d+220)) then
        tmp = cos((k * 0.5d0)) * (j * (2.0d0 * l))
    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 (J <= -5.2e+220) {
		tmp = Math.cos((K * 0.5)) * (J * (2.0 * l));
	} else {
		tmp = U + ((2.0 * Math.sinh(l)) * J);
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if J <= -5.2e+220:
		tmp = math.cos((K * 0.5)) * (J * (2.0 * l))
	else:
		tmp = U + ((2.0 * math.sinh(l)) * J)
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (J <= -5.2e+220)
		tmp = Float64(cos(Float64(K * 0.5)) * Float64(J * Float64(2.0 * l)));
	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 (J <= -5.2e+220)
		tmp = cos((K * 0.5)) * (J * (2.0 * l));
	else
		tmp = U + ((2.0 * sinh(l)) * J);
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[J, -5.2e+220], N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(J * N[(2.0 * l), $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}\;J \leq -5.2 \cdot 10^{+220}:\\
\;\;\;\;\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot \left(2 \cdot \ell\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 J < -5.19999999999999988e220

    1. Initial program 71.1%

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

      \[\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-*.f6499.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{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    5. Simplified99.9%

      \[\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. *-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(\frac{1}{3}, \color{blue}{\left({\ell}^{2}\right)}\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, \mathsf{*.f64}\left(\frac{1}{3}, \left(\ell \cdot \color{blue}{\ell}\right)\right)\right)\right) \]
      14. *-lowering-*.f6495.2%

        \[\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(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \color{blue}{\ell}\right)\right)\right)\right) \]
    8. Simplified95.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(2, \ell\right)\right), \mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot K\right)\right)\right) \]
      9. *-lowering-*.f6495.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \mathsf{*.f64}\left(2, \ell\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, K\right)\right)\right) \]
    11. Simplified95.2%

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

    if -5.19999999999999988e220 < J

    1. Initial program 88.4%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Add Preprocessing
    3. Taylor expanded in 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.f6476.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. Simplified76.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.f6481.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-rr81.8%

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

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

Alternative 9: 80.8% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 1.4 \cdot 10^{+247}:\\ \;\;\;\;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 1.4e+247)
   (+ 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 <= 1.4e+247) {
		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 <= 1.4d+247) 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 <= 1.4e+247) {
		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 <= 1.4e+247:
		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 <= 1.4e+247)
		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 <= 1.4e+247)
		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, 1.4e+247], 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 1.4 \cdot 10^{+247}:\\
\;\;\;\;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 < 1.3999999999999999e247

    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 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.f6476.0%

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

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

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

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

    if 1.3999999999999999e247 < 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-*.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(\frac{-1}{8}, \mathsf{*.f64}\left(K, K\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 + -0.125 \cdot \left(K \cdot K\right)\right)} + U \]
  3. Recombined 2 regimes into one program.
  4. Final simplification82.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 1.4 \cdot 10^{+247}:\\ \;\;\;\;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 10: 77.3% accurate, 10.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 10^{+247}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \ell \cdot \left(\ell \cdot \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right)\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 1e+247)
   (+
    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 <= 1e+247) {
		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 <= 1d+247) 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 <= 1e+247) {
		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 <= 1e+247:
		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 <= 1e+247)
		tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(l * Float64(l * Float64(0.3333333333333333 + Float64(l * Float64(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 <= 1e+247)
		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, 1e+247], N[(U + N[(J * N[(l * N[(2.0 + N[(l * N[(l * N[(0.3333333333333333 + N[(l * N[(l * N[(0.016666666666666666 + N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $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 10^{+247}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \ell \cdot \left(\ell \cdot \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right)\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 < 9.99999999999999952e246

    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 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.f6476.0%

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

      \[\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. 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} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\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} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\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} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\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} + {\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(\ell, \mathsf{*.f64}\left(\ell, \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)\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(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{3}, \left(\left(\ell \cdot \ell\right) \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      9. associate-*l*N/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 \cdot \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\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(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \left(\ell \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      11. *-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(\ell, \mathsf{*.f64}\left(\ell, \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\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(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{60}, \left(\frac{1}{2520} \cdot {\ell}^{2}\right)\right)\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      13. *-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}, \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{60}, \left({\ell}^{2} \cdot \frac{1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      14. *-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(\ell, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{60}, \mathsf{*.f64}\left(\left({\ell}^{2}\right), \frac{1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right)\right), U\right) \]
      15. 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(\ell, \mathsf{*.f64}\left(\ell, \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)\right)\right), U\right) \]
      16. *-lowering-*.f6477.9%

        \[\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(\ell, \mathsf{*.f64}\left(\ell, \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)\right)\right), U\right) \]
    8. Simplified77.9%

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

    if 9.99999999999999952e246 < 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-*.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(\frac{-1}{8}, \mathsf{*.f64}\left(K, K\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 + -0.125 \cdot \left(K \cdot K\right)\right)} + U \]
  3. Recombined 2 regimes into one program.
  4. Final simplification78.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 10^{+247}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + \ell \cdot \left(\ell \cdot \left(0.3333333333333333 + \ell \cdot \left(\ell \cdot \left(0.016666666666666666 + \left(\ell \cdot \ell\right) \cdot 0.0003968253968253968\right)\right)\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 11: 69.5% accurate, 12.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \ell \cdot \left(J \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)\\ \mathbf{if}\;\ell \leq -29:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq 8.8 \cdot 10^{+17}:\\ \;\;\;\;U + J \cdot \left(2 \cdot \ell\right)\\ \mathbf{elif}\;\ell \leq 3 \cdot 10^{+89}:\\ \;\;\;\;\left(\ell \cdot J\right) \cdot \left(\left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (* l (* J (+ 2.0 (* (* l l) 0.3333333333333333))))))
   (if (<= l -29.0)
     t_0
     (if (<= l 8.8e+17)
       (+ U (* J (* 2.0 l)))
       (if (<= l 3e+89) (* (* l J) (* (* K K) -0.25)) t_0)))))
double code(double J, double l, double K, double U) {
	double t_0 = l * (J * (2.0 + ((l * l) * 0.3333333333333333)));
	double tmp;
	if (l <= -29.0) {
		tmp = t_0;
	} else if (l <= 8.8e+17) {
		tmp = U + (J * (2.0 * l));
	} else if (l <= 3e+89) {
		tmp = (l * J) * ((K * K) * -0.25);
	} 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 * (2.0d0 + ((l * l) * 0.3333333333333333d0)))
    if (l <= (-29.0d0)) then
        tmp = t_0
    else if (l <= 8.8d+17) then
        tmp = u + (j * (2.0d0 * l))
    else if (l <= 3d+89) then
        tmp = (l * j) * ((k * k) * (-0.25d0))
    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 * (2.0 + ((l * l) * 0.3333333333333333)));
	double tmp;
	if (l <= -29.0) {
		tmp = t_0;
	} else if (l <= 8.8e+17) {
		tmp = U + (J * (2.0 * l));
	} else if (l <= 3e+89) {
		tmp = (l * J) * ((K * K) * -0.25);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = l * (J * (2.0 + ((l * l) * 0.3333333333333333)))
	tmp = 0
	if l <= -29.0:
		tmp = t_0
	elif l <= 8.8e+17:
		tmp = U + (J * (2.0 * l))
	elif l <= 3e+89:
		tmp = (l * J) * ((K * K) * -0.25)
	else:
		tmp = t_0
	return tmp
function code(J, l, K, U)
	t_0 = Float64(l * Float64(J * Float64(2.0 + Float64(Float64(l * l) * 0.3333333333333333))))
	tmp = 0.0
	if (l <= -29.0)
		tmp = t_0;
	elseif (l <= 8.8e+17)
		tmp = Float64(U + Float64(J * Float64(2.0 * l)));
	elseif (l <= 3e+89)
		tmp = Float64(Float64(l * J) * Float64(Float64(K * K) * -0.25));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	t_0 = l * (J * (2.0 + ((l * l) * 0.3333333333333333)));
	tmp = 0.0;
	if (l <= -29.0)
		tmp = t_0;
	elseif (l <= 8.8e+17)
		tmp = U + (J * (2.0 * l));
	elseif (l <= 3e+89)
		tmp = (l * J) * ((K * K) * -0.25);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(l * N[(J * N[(2.0 + N[(N[(l * l), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -29.0], t$95$0, If[LessEqual[l, 8.8e+17], N[(U + N[(J * N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3e+89], N[(N[(l * J), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \ell \cdot \left(J \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)\\
\mathbf{if}\;\ell \leq -29:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;\ell \leq 8.8 \cdot 10^{+17}:\\
\;\;\;\;U + J \cdot \left(2 \cdot \ell\right)\\

\mathbf{elif}\;\ell \leq 3 \cdot 10^{+89}:\\
\;\;\;\;\left(\ell \cdot J\right) \cdot \left(\left(K \cdot K\right) \cdot -0.25\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -29 or 3.00000000000000013e89 < 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-*.f6489.4%

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

      \[\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. *-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(\frac{1}{3}, \color{blue}{\left({\ell}^{2}\right)}\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, \mathsf{*.f64}\left(\frac{1}{3}, \left(\ell \cdot \color{blue}{\ell}\right)\right)\right)\right) \]
      14. *-lowering-*.f6482.7%

        \[\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(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \color{blue}{\ell}\right)\right)\right)\right) \]
    8. Simplified82.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(J, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \left(\ell \cdot \color{blue}{\ell}\right)\right)\right)\right)\right) \]
      9. *-lowering-*.f6461.6%

        \[\leadsto \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(J, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(\ell, \color{blue}{\ell}\right)\right)\right)\right)\right) \]
    11. Simplified61.6%

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

    if -29 < l < 8.8e17

    1. Initial program 75.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.f6473.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. Simplified73.7%

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

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

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

    if 8.8e17 < l < 3.00000000000000013e89

    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-*.f6424.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{cos.f64}\left(\mathsf{/.f64}\left(K, 2\right)\right)\right), U\right) \]
    5. Simplified24.9%

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

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

      \[\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 \]
    9. 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{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(K, K\right)\right)\right)\right), U\right) \]
    10. 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{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(K, K\right)\right)\right)\right), U\right) \]
      2. *-commutativeN/A

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{-1}{4} \cdot \left(J \cdot \ell\right)\right) \cdot \color{blue}{{K}^{2}} \]
      4. *-commutativeN/A

        \[\leadsto \left(\left(J \cdot \ell\right) \cdot \frac{-1}{4}\right) \cdot {\color{blue}{K}}^{2} \]
      5. associate-*l*N/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \ell\right), \mathsf{*.f64}\left(\frac{-1}{4}, \color{blue}{\left({K}^{2}\right)}\right)\right) \]
      9. unpow2N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \ell\right), \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(K, \color{blue}{K}\right)\right)\right) \]
    14. Simplified34.3%

      \[\leadsto \color{blue}{\left(J \cdot \ell\right) \cdot \left(-0.25 \cdot \left(K \cdot K\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification71.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -29:\\ \;\;\;\;\ell \cdot \left(J \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)\\ \mathbf{elif}\;\ell \leq 8.8 \cdot 10^{+17}:\\ \;\;\;\;U + J \cdot \left(2 \cdot \ell\right)\\ \mathbf{elif}\;\ell \leq 3 \cdot 10^{+89}:\\ \;\;\;\;\left(\ell \cdot J\right) \cdot \left(\left(K \cdot K\right) \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \left(J \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 75.7% accurate, 12.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 1.25 \cdot 10^{+247}:\\ \;\;\;\;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.25e+247)
   (+
    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.25e+247) {
		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.25d+247) 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.25e+247) {
		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.25e+247:
		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.25e+247)
		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.25e+247)
		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.25e+247], 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.25 \cdot 10^{+247}:\\
\;\;\;\;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.25000000000000006e247

    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 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.f6476.0%

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

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

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

      \[\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.25000000000000006e247 < 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-*.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(\frac{-1}{8}, \mathsf{*.f64}\left(K, K\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 + -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.25 \cdot 10^{+247}:\\ \;\;\;\;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.7% accurate, 13.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 10^{+247}:\\
\;\;\;\;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}:\\
\;\;\;\;\ell \cdot \left(\left(1 + -0.125 \cdot \left(K \cdot K\right)\right) \cdot \left(J \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)\right)\\


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

    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 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.f6476.0%

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

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

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

      \[\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 9.99999999999999952e246 < 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-*.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(\frac{-1}{8}, \mathsf{*.f64}\left(K, K\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 + -0.125 \cdot \left(K \cdot K\right)\right)} + U \]
    9. Taylor expanded in l around inf

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

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

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

        \[\leadsto \left(\frac{1}{3} \cdot J\right) \cdot \left(\left(1 + \frac{-1}{8} \cdot {K}^{2}\right) \cdot \left(\left(\ell \cdot \ell\right) \cdot \color{blue}{\ell}\right)\right) \]
      4. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\left(\left(\frac{1}{3} \cdot {\ell}^{2}\right) \cdot J\right), \color{blue}{\left(1 + \frac{-1}{8} \cdot {K}^{2}\right)}\right)\right) \]
    11. Simplified85.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 10^{+247}:\\ \;\;\;\;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}:\\ \;\;\;\;\ell \cdot \left(\left(1 + -0.125 \cdot \left(K \cdot K\right)\right) \cdot \left(J \cdot \left(\left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 73.0% accurate, 14.2× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\left(\ell \cdot \left(\ell \cdot \ell\right)\right) \cdot \left(J \cdot 0.3333333333333333 + \left(J \cdot \left(K \cdot K\right)\right) \cdot -0.041666666666666664\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 6.6000000000000005e-5

    1. Initial program 83.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.f6476.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. Simplified76.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 + \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. *-lowering-*.f64N/A

        \[\leadsto \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), U\right) \]
      4. unpow2N/A

        \[\leadsto \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), U\right) \]
      5. *-lowering-*.f6478.6%

        \[\leadsto \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), U\right) \]
    8. Simplified78.6%

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

    if 6.6000000000000005e-5 < l

    1. Initial program 99.7%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Add Preprocessing
    3. Taylor expanded in 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-*.f6477.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. Simplified77.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(\color{blue}{\left(\frac{-1}{8} \cdot \left(J \cdot \left({K}^{2} \cdot \left(\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)\right) + J \cdot \left(\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)\right)}, U\right) \]
    7. Step-by-step derivation
      1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\ell, \ell\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(J, \frac{1}{3}\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(J, \left(K \cdot K\right)\right), \frac{-1}{24}\right)\right)\right) \]
      15. *-lowering-*.f6461.2%

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

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

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

Alternative 15: 72.3% accurate, 14.2× speedup?

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

\\
\begin{array}{l}
t_0 := \left(\ell \cdot \ell\right) \cdot 0.3333333333333333\\
\mathbf{if}\;\ell \leq 1.5 \cdot 10^{+247}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + t\_0\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\ell \cdot \left(\left(1 + -0.125 \cdot \left(K \cdot K\right)\right) \cdot \left(J \cdot t\_0\right)\right)\\


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

    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 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.f6476.0%

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

      \[\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. *-lowering-*.f64N/A

        \[\leadsto \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), U\right) \]
      4. unpow2N/A

        \[\leadsto \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), U\right) \]
      5. *-lowering-*.f6473.0%

        \[\leadsto \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), U\right) \]
    8. Simplified73.0%

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

    if 1.5e247 < 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-*.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(\frac{-1}{8}, \mathsf{*.f64}\left(K, K\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 + -0.125 \cdot \left(K \cdot K\right)\right)} + U \]
    9. Taylor expanded in l around inf

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

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

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

        \[\leadsto \left(\frac{1}{3} \cdot J\right) \cdot \left(\left(1 + \frac{-1}{8} \cdot {K}^{2}\right) \cdot \left(\left(\ell \cdot \ell\right) \cdot \color{blue}{\ell}\right)\right) \]
      4. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\ell, \mathsf{*.f64}\left(\left(\left(\frac{1}{3} \cdot {\ell}^{2}\right) \cdot J\right), \color{blue}{\left(1 + \frac{-1}{8} \cdot {K}^{2}\right)}\right)\right) \]
    11. Simplified85.0%

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

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

Alternative 16: 46.6% accurate, 20.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := J \cdot \left(2 \cdot \ell\right)\\ \mathbf{if}\;\ell \leq -29:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq 1200:\\ \;\;\;\;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 -29.0) t_0 (if (<= l 1200.0) U t_0))))
double code(double J, double l, double K, double U) {
	double t_0 = J * (2.0 * l);
	double tmp;
	if (l <= -29.0) {
		tmp = t_0;
	} else if (l <= 1200.0) {
		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 <= (-29.0d0)) then
        tmp = t_0
    else if (l <= 1200.0d0) 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 <= -29.0) {
		tmp = t_0;
	} else if (l <= 1200.0) {
		tmp = U;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = J * (2.0 * l)
	tmp = 0
	if l <= -29.0:
		tmp = t_0
	elif l <= 1200.0:
		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 <= -29.0)
		tmp = t_0;
	elseif (l <= 1200.0)
		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 <= -29.0)
		tmp = t_0;
	elseif (l <= 1200.0)
		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, -29.0], t$95$0, If[LessEqual[l, 1200.0], U, t$95$0]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

      \[\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. associate-*r*N/A

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

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

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

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

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

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

    if -29 < l < 1200

    1. Initial program 74.6%

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

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

        \[\leadsto \color{blue}{U} \]
    5. Recombined 2 regimes into one program.
    6. Add Preprocessing

    Alternative 17: 56.2% accurate, 22.3× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 980:\\ \;\;\;\;U + J \cdot \left(2 \cdot \ell\right)\\ \mathbf{else}:\\ \;\;\;\;J \cdot \left(2 \cdot \ell + \frac{U}{J}\right)\\ \end{array} \end{array} \]
    (FPCore (J l K U)
     :precision binary64
     (if (<= l 980.0) (+ U (* J (* 2.0 l))) (* J (+ (* 2.0 l) (/ U J)))))
    double code(double J, double l, double K, double U) {
    	double tmp;
    	if (l <= 980.0) {
    		tmp = U + (J * (2.0 * l));
    	} else {
    		tmp = J * ((2.0 * l) + (U / 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 (l <= 980.0d0) then
            tmp = u + (j * (2.0d0 * l))
        else
            tmp = j * ((2.0d0 * l) + (u / j))
        end if
        code = tmp
    end function
    
    public static double code(double J, double l, double K, double U) {
    	double tmp;
    	if (l <= 980.0) {
    		tmp = U + (J * (2.0 * l));
    	} else {
    		tmp = J * ((2.0 * l) + (U / J));
    	}
    	return tmp;
    }
    
    def code(J, l, K, U):
    	tmp = 0
    	if l <= 980.0:
    		tmp = U + (J * (2.0 * l))
    	else:
    		tmp = J * ((2.0 * l) + (U / J))
    	return tmp
    
    function code(J, l, K, U)
    	tmp = 0.0
    	if (l <= 980.0)
    		tmp = Float64(U + Float64(J * Float64(2.0 * l)));
    	else
    		tmp = Float64(J * Float64(Float64(2.0 * l) + Float64(U / J)));
    	end
    	return tmp
    end
    
    function tmp_2 = code(J, l, K, U)
    	tmp = 0.0;
    	if (l <= 980.0)
    		tmp = U + (J * (2.0 * l));
    	else
    		tmp = J * ((2.0 * l) + (U / J));
    	end
    	tmp_2 = tmp;
    end
    
    code[J_, l_, K_, U_] := If[LessEqual[l, 980.0], N[(U + N[(J * N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(J * N[(N[(2.0 * l), $MachinePrecision] + N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;\ell \leq 980:\\
    \;\;\;\;U + J \cdot \left(2 \cdot \ell\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;J \cdot \left(2 \cdot \ell + \frac{U}{J}\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if l < 980

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

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

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

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

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

      if 980 < l

      1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{*.f64}\left(J, \mathsf{+.f64}\left(\mathsf{/.f64}\left(U, J\right), \mathsf{*.f64}\left(2, \color{blue}{\ell}\right)\right)\right) \]
      11. Simplified32.2%

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

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

    Alternative 18: 72.2% accurate, 24.0× speedup?

    \[\begin{array}{l} \\ U + J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot 0.3333333333333333\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(Float64(l * 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[(N[(l * l), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    U + J \cdot \left(\ell \cdot \left(2 + \left(\ell \cdot \ell\right) \cdot 0.3333333333333333\right)\right)
    \end{array}
    
    Derivation
    1. Initial program 87.1%

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

      \[\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. *-lowering-*.f64N/A

        \[\leadsto \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), U\right) \]
      4. unpow2N/A

        \[\leadsto \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), U\right) \]
      5. *-lowering-*.f6472.0%

        \[\leadsto \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), U\right) \]
    8. Simplified72.0%

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

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

    Alternative 19: 58.3% 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 87.1%

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 21: 36.8% 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 87.1%

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

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

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

      Reproduce

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