Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 85.9% → 99.4%
Time: 14.3s
Alternatives: 13
Speedup: 1.3×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 13 alternatives:

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

Initial Program: 85.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\right) + U \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (+ (* J (log1p (expm1 (* l (* 2.0 (cos (* K 0.5))))))) U))
double code(double J, double l, double K, double U) {
	return (J * log1p(expm1((l * (2.0 * cos((K * 0.5))))))) + U;
}
public static double code(double J, double l, double K, double U) {
	return (J * Math.log1p(Math.expm1((l * (2.0 * Math.cos((K * 0.5))))))) + U;
}
def code(J, l, K, U):
	return (J * math.log1p(math.expm1((l * (2.0 * math.cos((K * 0.5))))))) + U
function code(J, l, K, U)
	return Float64(Float64(J * log1p(expm1(Float64(l * Float64(2.0 * cos(Float64(K * 0.5))))))) + U)
end
code[J_, l_, K_, U_] := N[(N[(J * N[Log[1 + N[(Exp[N[(l * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}

\\
J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\right) + U
\end{array}
Derivation
  1. Initial program 85.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\ell \cdot 2\right) \cdot \cos \color{blue}{\left(K \cdot 0.5\right)}\right)\right) + U \]
    4. metadata-eval99.3%

      \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\ell \cdot 2\right) \cdot \cos \left(K \cdot \color{blue}{\frac{1}{2}}\right)\right)\right) + U \]
    5. div-inv99.3%

      \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\ell \cdot 2\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)}\right)\right) + U \]
    6. associate-*l*99.3%

      \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\ell \cdot \left(2 \cdot \cos \left(\frac{K}{2}\right)\right)}\right)\right) + U \]
    7. div-inv99.3%

      \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \color{blue}{\left(K \cdot \frac{1}{2}\right)}\right)\right)\right) + U \]
    8. metadata-eval99.3%

      \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \left(K \cdot \color{blue}{0.5}\right)\right)\right)\right) + U \]
  10. Applied egg-rr99.3%

    \[\leadsto J \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\right)} + U \]
  11. Final simplification99.3%

    \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\right) + U \]
  12. Add Preprocessing

Alternative 2: 95.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.999999999999999:\\ \;\;\;\;U + J \cdot \left(\ell \cdot \left(\left(2 + 0.016666666666666666 \cdot {\ell}^{4}\right) \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot 2\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= (cos (/ K 2.0)) 0.999999999999999)
   (+
    U
    (*
     J
     (* l (* (+ 2.0 (* 0.016666666666666666 (pow l 4.0))) (cos (* K 0.5))))))
   (+ U (* J (log1p (expm1 (* l 2.0)))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (cos((K / 2.0)) <= 0.999999999999999) {
		tmp = U + (J * (l * ((2.0 + (0.016666666666666666 * pow(l, 4.0))) * cos((K * 0.5)))));
	} else {
		tmp = U + (J * log1p(expm1((l * 2.0))));
	}
	return tmp;
}
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (Math.cos((K / 2.0)) <= 0.999999999999999) {
		tmp = U + (J * (l * ((2.0 + (0.016666666666666666 * Math.pow(l, 4.0))) * Math.cos((K * 0.5)))));
	} else {
		tmp = U + (J * Math.log1p(Math.expm1((l * 2.0))));
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if math.cos((K / 2.0)) <= 0.999999999999999:
		tmp = U + (J * (l * ((2.0 + (0.016666666666666666 * math.pow(l, 4.0))) * math.cos((K * 0.5)))))
	else:
		tmp = U + (J * math.log1p(math.expm1((l * 2.0))))
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (cos(Float64(K / 2.0)) <= 0.999999999999999)
		tmp = Float64(U + Float64(J * Float64(l * Float64(Float64(2.0 + Float64(0.016666666666666666 * (l ^ 4.0))) * cos(Float64(K * 0.5))))));
	else
		tmp = Float64(U + Float64(J * log1p(expm1(Float64(l * 2.0)))));
	end
	return tmp
end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.999999999999999], N[(U + N[(J * N[(l * N[(N[(2.0 + N[(0.016666666666666666 * N[Power[l, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[Log[1 + N[(Exp[N[(l * 2.0), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.999999999999999:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(\left(2 + 0.016666666666666666 \cdot {\ell}^{4}\right) \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\

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


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

    1. Initial program 86.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\ell \cdot 2\right) \cdot \cos \color{blue}{\left(K \cdot 0.5\right)}\right)\right) + U \]
      4. metadata-eval99.4%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\ell \cdot 2\right) \cdot \cos \left(K \cdot \color{blue}{\frac{1}{2}}\right)\right)\right) + U \]
      5. div-inv99.4%

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

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\ell \cdot \left(2 \cdot \cos \left(\frac{K}{2}\right)\right)}\right)\right) + U \]
      7. div-inv99.4%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \color{blue}{\left(K \cdot \frac{1}{2}\right)}\right)\right)\right) + U \]
      8. metadata-eval99.4%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \left(K \cdot \color{blue}{0.5}\right)\right)\right)\right) + U \]
    10. Applied egg-rr99.4%

      \[\leadsto J \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\right)} + U \]
    11. Taylor expanded in K around 0 84.8%

      \[\leadsto J \cdot \mathsf{log1p}\left(\color{blue}{e^{2 \cdot \ell} - 1}\right) + U \]
    12. Step-by-step derivation
      1. expm1-define99.4%

        \[\leadsto J \cdot \mathsf{log1p}\left(\color{blue}{\mathsf{expm1}\left(2 \cdot \ell\right)}\right) + U \]
    13. Simplified99.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.999999999999999:\\ \;\;\;\;U + J \cdot \left(\ell \cdot \left(\left(2 + 0.016666666666666666 \cdot {\ell}^{4}\right) \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot 2\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 96.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K}{2}\right)\\ \mathbf{if}\;t\_0 \leq 0.999999999999999:\\ \;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.016666666666666666 \cdot {\ell}^{4}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot 2\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (cos (/ K 2.0))))
   (if (<= t_0 0.999999999999999)
     (+ U (* t_0 (* J (* l (+ 2.0 (* 0.016666666666666666 (pow l 4.0)))))))
     (+ U (* J (log1p (expm1 (* l 2.0))))))))
double code(double J, double l, double K, double U) {
	double t_0 = cos((K / 2.0));
	double tmp;
	if (t_0 <= 0.999999999999999) {
		tmp = U + (t_0 * (J * (l * (2.0 + (0.016666666666666666 * pow(l, 4.0))))));
	} else {
		tmp = U + (J * log1p(expm1((l * 2.0))));
	}
	return tmp;
}
public static double code(double J, double l, double K, double U) {
	double t_0 = Math.cos((K / 2.0));
	double tmp;
	if (t_0 <= 0.999999999999999) {
		tmp = U + (t_0 * (J * (l * (2.0 + (0.016666666666666666 * Math.pow(l, 4.0))))));
	} else {
		tmp = U + (J * Math.log1p(Math.expm1((l * 2.0))));
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = math.cos((K / 2.0))
	tmp = 0
	if t_0 <= 0.999999999999999:
		tmp = U + (t_0 * (J * (l * (2.0 + (0.016666666666666666 * math.pow(l, 4.0))))))
	else:
		tmp = U + (J * math.log1p(math.expm1((l * 2.0))))
	return tmp
function code(J, l, K, U)
	t_0 = cos(Float64(K / 2.0))
	tmp = 0.0
	if (t_0 <= 0.999999999999999)
		tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * Float64(2.0 + Float64(0.016666666666666666 * (l ^ 4.0)))))));
	else
		tmp = Float64(U + Float64(J * log1p(expm1(Float64(l * 2.0)))));
	end
	return 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.999999999999999], N[(U + N[(t$95$0 * N[(J * N[(l * N[(2.0 + N[(0.016666666666666666 * N[Power[l, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[Log[1 + N[(Exp[N[(l * 2.0), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


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

    1. Initial program 86.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\ell \cdot 2\right) \cdot \cos \color{blue}{\left(K \cdot 0.5\right)}\right)\right) + U \]
      4. metadata-eval99.4%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\ell \cdot 2\right) \cdot \cos \left(K \cdot \color{blue}{\frac{1}{2}}\right)\right)\right) + U \]
      5. div-inv99.4%

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

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\ell \cdot \left(2 \cdot \cos \left(\frac{K}{2}\right)\right)}\right)\right) + U \]
      7. div-inv99.4%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \color{blue}{\left(K \cdot \frac{1}{2}\right)}\right)\right)\right) + U \]
      8. metadata-eval99.4%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \left(K \cdot \color{blue}{0.5}\right)\right)\right)\right) + U \]
    10. Applied egg-rr99.4%

      \[\leadsto J \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\right)} + U \]
    11. Taylor expanded in K around 0 84.8%

      \[\leadsto J \cdot \mathsf{log1p}\left(\color{blue}{e^{2 \cdot \ell} - 1}\right) + U \]
    12. Step-by-step derivation
      1. expm1-define99.4%

        \[\leadsto J \cdot \mathsf{log1p}\left(\color{blue}{\mathsf{expm1}\left(2 \cdot \ell\right)}\right) + U \]
    13. Simplified99.4%

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

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

Alternative 4: 86.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.07:\\ \;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot 2\right)\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= (cos (/ K 2.0)) -0.07)
   (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))
   (+ U (* J (log1p (expm1 (* l 2.0)))))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (cos((K / 2.0)) <= -0.07) {
		tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
	} else {
		tmp = U + (J * log1p(expm1((l * 2.0))));
	}
	return tmp;
}
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (Math.cos((K / 2.0)) <= -0.07) {
		tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
	} else {
		tmp = U + (J * Math.log1p(Math.expm1((l * 2.0))));
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if math.cos((K / 2.0)) <= -0.07:
		tmp = U + (2.0 * (J * (l * math.cos((K * 0.5)))))
	else:
		tmp = U + (J * math.log1p(math.expm1((l * 2.0))))
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (cos(Float64(K / 2.0)) <= -0.07)
		tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5))))));
	else
		tmp = Float64(U + Float64(J * log1p(expm1(Float64(l * 2.0)))));
	end
	return tmp
end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.07], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[Log[1 + N[(Exp[N[(l * 2.0), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 90.2%

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

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

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

    1. Initial program 84.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\ell \cdot 2\right) \cdot \cos \color{blue}{\left(K \cdot 0.5\right)}\right)\right) + U \]
      4. metadata-eval99.5%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\ell \cdot 2\right) \cdot \cos \left(K \cdot \color{blue}{\frac{1}{2}}\right)\right)\right) + U \]
      5. div-inv99.5%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\ell \cdot 2\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)}\right)\right) + U \]
      6. associate-*l*99.5%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\ell \cdot \left(2 \cdot \cos \left(\frac{K}{2}\right)\right)}\right)\right) + U \]
      7. div-inv99.5%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \color{blue}{\left(K \cdot \frac{1}{2}\right)}\right)\right)\right) + U \]
      8. metadata-eval99.5%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \left(K \cdot \color{blue}{0.5}\right)\right)\right)\right) + U \]
    10. Applied egg-rr99.5%

      \[\leadsto J \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\right)} + U \]
    11. Taylor expanded in K around 0 84.0%

      \[\leadsto J \cdot \mathsf{log1p}\left(\color{blue}{e^{2 \cdot \ell} - 1}\right) + U \]
    12. Step-by-step derivation
      1. expm1-define95.1%

        \[\leadsto J \cdot \mathsf{log1p}\left(\color{blue}{\mathsf{expm1}\left(2 \cdot \ell\right)}\right) + U \]
    13. Simplified95.1%

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

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

Alternative 5: 97.1% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := U + {\ell}^{5} \cdot \left(J \cdot \left(0.016666666666666666 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{if}\;\ell \leq -3.7 \cdot 10^{+58}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq -460:\\ \;\;\;\;U + J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 0.000155:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 1.95 \cdot 10^{+60}:\\ \;\;\;\;U + J \cdot \left(e^{\ell} - e^{-\ell}\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0
         (+ U (* (pow l 5.0) (* J (* 0.016666666666666666 (cos (* K 0.5))))))))
   (if (<= l -3.7e+58)
     t_0
     (if (<= l -460.0)
       (+ U (* J (log1p (expm1 (* l 2.0)))))
       (if (<= l 0.000155)
         (+ U (* (cos (/ K 2.0)) (* J (* l 2.0))))
         (if (<= l 1.95e+60) (+ U (* J (- (exp l) (exp (- l))))) t_0))))))
double code(double J, double l, double K, double U) {
	double t_0 = U + (pow(l, 5.0) * (J * (0.016666666666666666 * cos((K * 0.5)))));
	double tmp;
	if (l <= -3.7e+58) {
		tmp = t_0;
	} else if (l <= -460.0) {
		tmp = U + (J * log1p(expm1((l * 2.0))));
	} else if (l <= 0.000155) {
		tmp = U + (cos((K / 2.0)) * (J * (l * 2.0)));
	} else if (l <= 1.95e+60) {
		tmp = U + (J * (exp(l) - exp(-l)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
public static double code(double J, double l, double K, double U) {
	double t_0 = U + (Math.pow(l, 5.0) * (J * (0.016666666666666666 * Math.cos((K * 0.5)))));
	double tmp;
	if (l <= -3.7e+58) {
		tmp = t_0;
	} else if (l <= -460.0) {
		tmp = U + (J * Math.log1p(Math.expm1((l * 2.0))));
	} else if (l <= 0.000155) {
		tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
	} else if (l <= 1.95e+60) {
		tmp = U + (J * (Math.exp(l) - Math.exp(-l)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(J, l, K, U):
	t_0 = U + (math.pow(l, 5.0) * (J * (0.016666666666666666 * math.cos((K * 0.5)))))
	tmp = 0
	if l <= -3.7e+58:
		tmp = t_0
	elif l <= -460.0:
		tmp = U + (J * math.log1p(math.expm1((l * 2.0))))
	elif l <= 0.000155:
		tmp = U + (math.cos((K / 2.0)) * (J * (l * 2.0)))
	elif l <= 1.95e+60:
		tmp = U + (J * (math.exp(l) - math.exp(-l)))
	else:
		tmp = t_0
	return tmp
function code(J, l, K, U)
	t_0 = Float64(U + Float64((l ^ 5.0) * Float64(J * Float64(0.016666666666666666 * cos(Float64(K * 0.5))))))
	tmp = 0.0
	if (l <= -3.7e+58)
		tmp = t_0;
	elseif (l <= -460.0)
		tmp = Float64(U + Float64(J * log1p(expm1(Float64(l * 2.0)))));
	elseif (l <= 0.000155)
		tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0))));
	elseif (l <= 1.95e+60)
		tmp = Float64(U + Float64(J * Float64(exp(l) - exp(Float64(-l)))));
	else
		tmp = t_0;
	end
	return tmp
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(N[Power[l, 5.0], $MachinePrecision] * N[(J * N[(0.016666666666666666 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.7e+58], t$95$0, If[LessEqual[l, -460.0], N[(U + N[(J * N[Log[1 + N[(Exp[N[(l * 2.0), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 0.000155], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.95e+60], N[(U + N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

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

\mathbf{elif}\;\ell \leq -460:\\
\;\;\;\;U + J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot 2\right)\right)\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -3.7000000000000002e58 or 1.95000000000000015e60 < 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 99.0%

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

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

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

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

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

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

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

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

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

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

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

    if -3.7000000000000002e58 < l < -460

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot 2\right)\right)} + U \]
    9. Step-by-step derivation
      1. log1p-expm1-u100.0%

        \[\leadsto J \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot 2\right)\right)\right)} + U \]
      2. *-commutative100.0%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\left(\ell \cdot 2\right) \cdot \cos \left(0.5 \cdot K\right)}\right)\right) + U \]
      3. *-commutative100.0%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\ell \cdot 2\right) \cdot \cos \color{blue}{\left(K \cdot 0.5\right)}\right)\right) + U \]
      4. metadata-eval100.0%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\ell \cdot 2\right) \cdot \cos \left(K \cdot \color{blue}{\frac{1}{2}}\right)\right)\right) + U \]
      5. div-inv100.0%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\ell \cdot 2\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)}\right)\right) + U \]
      6. associate-*l*100.0%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\ell \cdot \left(2 \cdot \cos \left(\frac{K}{2}\right)\right)}\right)\right) + U \]
      7. div-inv100.0%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \color{blue}{\left(K \cdot \frac{1}{2}\right)}\right)\right)\right) + U \]
      8. metadata-eval100.0%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \left(K \cdot \color{blue}{0.5}\right)\right)\right)\right) + U \]
    10. Applied egg-rr100.0%

      \[\leadsto J \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\right)} + U \]
    11. Taylor expanded in K around 0 93.3%

      \[\leadsto J \cdot \mathsf{log1p}\left(\color{blue}{e^{2 \cdot \ell} - 1}\right) + U \]
    12. Step-by-step derivation
      1. expm1-define93.3%

        \[\leadsto J \cdot \mathsf{log1p}\left(\color{blue}{\mathsf{expm1}\left(2 \cdot \ell\right)}\right) + U \]
    13. Simplified93.3%

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

    if -460 < l < 1.55e-4

    1. Initial program 70.8%

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

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

    if 1.55e-4 < l < 1.95000000000000015e60

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.7 \cdot 10^{+58}:\\ \;\;\;\;U + {\ell}^{5} \cdot \left(J \cdot \left(0.016666666666666666 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \mathbf{elif}\;\ell \leq -460:\\ \;\;\;\;U + J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 0.000155:\\ \;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\ \mathbf{elif}\;\ell \leq 1.95 \cdot 10^{+60}:\\ \;\;\;\;U + J \cdot \left(e^{\ell} - e^{-\ell}\right)\\ \mathbf{else}:\\ \;\;\;\;U + {\ell}^{5} \cdot \left(J \cdot \left(0.016666666666666666 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 81.7% accurate, 1.4× speedup?

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

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

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


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

    1. Initial program 90.2%

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

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

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

    1. Initial program 84.5%

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

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

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

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

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

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

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

Alternative 7: 81.7% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1950000000000 \lor \neg \left(\ell \leq 15500\right):\\
\;\;\;\;U + {\ell}^{5} \cdot \left(J \cdot 0.016666666666666666\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -1.95e12 or 15500 < 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 84.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\ell}^{5} \cdot \left(J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot 0.016666666666666666\right)\right)} + U \]
    9. Taylor expanded in K around 0 65.6%

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

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

        \[\leadsto \color{blue}{\left({\ell}^{5} \cdot J\right)} \cdot 0.016666666666666666 + U \]
      3. associate-*l*65.6%

        \[\leadsto \color{blue}{{\ell}^{5} \cdot \left(J \cdot 0.016666666666666666\right)} + U \]
    11. Simplified65.6%

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

    if -1.95e12 < l < 15500

    1. Initial program 71.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 96.4%

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

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

Alternative 8: 81.7% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -8400000000000 \lor \neg \left(\ell \leq 460\right):\\
\;\;\;\;U + {\ell}^{5} \cdot \left(J \cdot 0.016666666666666666\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -8.4e12 or 460 < 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 84.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\ell}^{5} \cdot \left(J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot 0.016666666666666666\right)\right)} + U \]
    9. Taylor expanded in K around 0 65.6%

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

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

        \[\leadsto \color{blue}{\left({\ell}^{5} \cdot J\right)} \cdot 0.016666666666666666 + U \]
      3. associate-*l*65.6%

        \[\leadsto \color{blue}{{\ell}^{5} \cdot \left(J \cdot 0.016666666666666666\right)} + U \]
    11. Simplified65.6%

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

    if -8.4e12 < l < 460

    1. Initial program 71.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 96.4%

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

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

Alternative 9: 74.9% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1200000000000 \lor \neg \left(\ell \leq 15.8\right):\\
\;\;\;\;U + {\ell}^{5} \cdot \left(J \cdot 0.016666666666666666\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -1.2e12 or 15.800000000000001 < 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 84.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\ell}^{5} \cdot \left(J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot 0.016666666666666666\right)\right)} + U \]
    9. Taylor expanded in K around 0 65.6%

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

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

        \[\leadsto \color{blue}{\left({\ell}^{5} \cdot J\right)} \cdot 0.016666666666666666 + U \]
      3. associate-*l*65.6%

        \[\leadsto \color{blue}{{\ell}^{5} \cdot \left(J \cdot 0.016666666666666666\right)} + U \]
    11. Simplified65.6%

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

    if -1.2e12 < l < 15.800000000000001

    1. Initial program 71.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 97.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{J \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot 2\right)\right)} + U \]
    9. Step-by-step derivation
      1. log1p-expm1-u98.6%

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

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

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\ell \cdot 2\right) \cdot \cos \color{blue}{\left(K \cdot 0.5\right)}\right)\right) + U \]
      4. metadata-eval98.6%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\ell \cdot 2\right) \cdot \cos \left(K \cdot \color{blue}{\frac{1}{2}}\right)\right)\right) + U \]
      5. div-inv98.6%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\ell \cdot 2\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)}\right)\right) + U \]
      6. associate-*l*98.6%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\ell \cdot \left(2 \cdot \cos \left(\frac{K}{2}\right)\right)}\right)\right) + U \]
      7. div-inv98.6%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \color{blue}{\left(K \cdot \frac{1}{2}\right)}\right)\right)\right) + U \]
      8. metadata-eval98.6%

        \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \left(K \cdot \color{blue}{0.5}\right)\right)\right)\right) + U \]
    10. Applied egg-rr98.6%

      \[\leadsto J \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\right)} + U \]
    11. Taylor expanded in K around 0 85.4%

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

        \[\leadsto \color{blue}{\left(2 \cdot J\right) \cdot \ell} + U \]
    13. Simplified85.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1200000000000 \lor \neg \left(\ell \leq 15.8\right):\\ \;\;\;\;U + {\ell}^{5} \cdot \left(J \cdot 0.016666666666666666\right)\\ \mathbf{else}:\\ \;\;\;\;U + \ell \cdot \left(J \cdot 2\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 41.0% accurate, 23.9× speedup?

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

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

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


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

    1. Initial program 98.1%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*98.1%

        \[\leadsto \color{blue}{J \cdot \left(\left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right)\right)} + U \]
      2. fma-define98.1%

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, \left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), U\right)} \]
    3. Simplified98.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), U\right)} \]
    4. Add Preprocessing
    5. Applied egg-rr18.1%

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

    if -235000 < l < 3.10000000000000007e-18

    1. Initial program 72.1%

      \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. Step-by-step derivation
      1. associate-*l*72.1%

        \[\leadsto \color{blue}{J \cdot \left(\left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right)\right)} + U \]
      2. fma-define72.1%

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, \left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), U\right)} \]
    3. Simplified72.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), U\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in J around 0 70.8%

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

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

Alternative 11: 53.0% accurate, 44.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\ell \cdot 2\right) \cdot \cos \color{blue}{\left(K \cdot 0.5\right)}\right)\right) + U \]
    4. metadata-eval99.3%

      \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\ell \cdot 2\right) \cdot \cos \left(K \cdot \color{blue}{\frac{1}{2}}\right)\right)\right) + U \]
    5. div-inv99.3%

      \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\ell \cdot 2\right) \cdot \cos \color{blue}{\left(\frac{K}{2}\right)}\right)\right) + U \]
    6. associate-*l*99.3%

      \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\ell \cdot \left(2 \cdot \cos \left(\frac{K}{2}\right)\right)}\right)\right) + U \]
    7. div-inv99.3%

      \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \color{blue}{\left(K \cdot \frac{1}{2}\right)}\right)\right)\right) + U \]
    8. metadata-eval99.3%

      \[\leadsto J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \left(K \cdot \color{blue}{0.5}\right)\right)\right)\right) + U \]
  10. Applied egg-rr99.3%

    \[\leadsto J \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\right)} + U \]
  11. Taylor expanded in K around 0 53.3%

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

      \[\leadsto \color{blue}{\left(2 \cdot J\right) \cdot \ell} + U \]
  13. Simplified53.3%

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

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

Alternative 12: 2.7% accurate, 312.0× speedup?

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

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

    \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  2. Step-by-step derivation
    1. associate-*l*85.6%

      \[\leadsto \color{blue}{J \cdot \left(\left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right)\right)} + U \]
    2. fma-define85.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), U\right)} \]
  3. Simplified85.6%

    \[\leadsto \color{blue}{\mathsf{fma}\left(J, \left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), U\right)} \]
  4. Add Preprocessing
  5. Applied egg-rr2.6%

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

      \[\leadsto \color{blue}{1} \]
  7. Simplified2.6%

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

    \[\leadsto 1 \]
  9. Add Preprocessing

Alternative 13: 36.1% accurate, 312.0× speedup?

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

\\
U
\end{array}
Derivation
  1. Initial program 85.6%

    \[\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  2. Step-by-step derivation
    1. associate-*l*85.6%

      \[\leadsto \color{blue}{J \cdot \left(\left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right)\right)} + U \]
    2. fma-define85.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), U\right)} \]
  3. Simplified85.6%

    \[\leadsto \color{blue}{\mathsf{fma}\left(J, \left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), U\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in J around 0 35.3%

    \[\leadsto \color{blue}{U} \]
  6. Final simplification35.3%

    \[\leadsto U \]
  7. Add Preprocessing

Reproduce

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