Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 86.2% → 99.7%
Time: 9.4s
Alternatives: 12
Speedup: 0.5×

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 12 alternatives:

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

Initial Program: 86.2% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 100.0%

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

    if -10 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0

    1. Initial program 69.9%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{\ell} - e^{-\ell} \leq -10 \lor \neg \left(e^{\ell} - e^{-\ell} \leq 0\right):\\ \;\;\;\;\cos \left(\frac{K}{2}\right) \cdot \left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right) + U\\ \mathbf{else}:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \end{array} \]

Alternative 2: 86.3% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
t_1 := t_0 \cdot J\\
\mathbf{if}\;t_0 \leq -10:\\
\;\;\;\;t_1\\

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

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


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

    1. Initial program 100.0%

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

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

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

    if -10 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0

    1. Initial program 69.9%

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

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

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

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

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

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

    if 0.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

    1. Initial program 100.0%

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

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

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

Alternative 3: 86.1% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_0 \leq -10 \lor \neg \left(t_0 \leq 2 \cdot 10^{-6}\right):\\
\;\;\;\;t_0 \cdot J\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -10 or 1.99999999999999991e-6 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))

    1. Initial program 100.0%

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

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

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

    if -10 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 1.99999999999999991e-6

    1. Initial program 70.6%

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

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

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

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

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

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

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

Alternative 4: 78.5% accurate, 1.4× speedup?

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

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

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


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

    1. Initial program 85.1%

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

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

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

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

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

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

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

    1. Initial program 84.5%

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

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

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

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

Alternative 5: 77.5% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.6 \lor \neg \left(\ell \leq 9 \cdot 10^{+41}\right):\\
\;\;\;\;J \cdot \left(\ell \cdot 2 + 0.3333333333333333 \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -2.60000000000000009 or 9.0000000000000002e41 < 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. Taylor expanded in K around 0 81.1%

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

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

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

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

        \[\leadsto \left(\left(2 \cdot \ell\right) \cdot J + \color{blue}{\left(0.3333333333333333 \cdot {\ell}^{3}\right) \cdot J}\right) + U \]
      4. distribute-rgt-out72.5%

        \[\leadsto \color{blue}{J \cdot \left(2 \cdot \ell + 0.3333333333333333 \cdot {\ell}^{3}\right)} + U \]
      5. fma-def72.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, 2 \cdot \ell + 0.3333333333333333 \cdot {\ell}^{3}, U\right)} \]
      6. +-commutative72.5%

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell}, U\right) \]
      7. fma-def72.5%

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{\mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 2 \cdot \ell\right)}, U\right) \]
    5. Simplified72.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 2 \cdot \ell\right), U\right)} \]
    6. Taylor expanded in J around inf 72.6%

      \[\leadsto \color{blue}{\left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right) \cdot J} \]
    7. Step-by-step derivation
      1. unpow372.6%

        \[\leadsto \left(0.3333333333333333 \cdot \color{blue}{\left(\left(\ell \cdot \ell\right) \cdot \ell\right)} + 2 \cdot \ell\right) \cdot J \]
    8. Applied egg-rr72.6%

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

    if -2.60000000000000009 < l < 9.0000000000000002e41

    1. Initial program 72.8%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.6 \lor \neg \left(\ell \leq 9 \cdot 10^{+41}\right):\\ \;\;\;\;J \cdot \left(\ell \cdot 2 + 0.3333333333333333 \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\ \end{array} \]

Alternative 6: 71.0% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2.6 \lor \neg \left(\ell \leq 60000000000\right):\\ \;\;\;\;J \cdot \left(\ell \cdot 2 + 0.3333333333333333 \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot 2, J, U\right)\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (or (<= l -2.6) (not (<= l 60000000000.0)))
   (* J (+ (* l 2.0) (* 0.3333333333333333 (* l (* l l)))))
   (fma (* l 2.0) J U)))
double code(double J, double l, double K, double U) {
	double tmp;
	if ((l <= -2.6) || !(l <= 60000000000.0)) {
		tmp = J * ((l * 2.0) + (0.3333333333333333 * (l * (l * l))));
	} else {
		tmp = fma((l * 2.0), J, U);
	}
	return tmp;
}
function code(J, l, K, U)
	tmp = 0.0
	if ((l <= -2.6) || !(l <= 60000000000.0))
		tmp = Float64(J * Float64(Float64(l * 2.0) + Float64(0.3333333333333333 * Float64(l * Float64(l * l)))));
	else
		tmp = fma(Float64(l * 2.0), J, U);
	end
	return tmp
end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -2.6], N[Not[LessEqual[l, 60000000000.0]], $MachinePrecision]], N[(J * N[(N[(l * 2.0), $MachinePrecision] + N[(0.3333333333333333 * N[(l * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(l * 2.0), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.6 \lor \neg \left(\ell \leq 60000000000\right):\\
\;\;\;\;J \cdot \left(\ell \cdot 2 + 0.3333333333333333 \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -2.60000000000000009 or 6e10 < 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. Taylor expanded in K around 0 80.3%

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

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

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

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

        \[\leadsto \left(\left(2 \cdot \ell\right) \cdot J + \color{blue}{\left(0.3333333333333333 \cdot {\ell}^{3}\right) \cdot J}\right) + U \]
      4. distribute-rgt-out68.9%

        \[\leadsto \color{blue}{J \cdot \left(2 \cdot \ell + 0.3333333333333333 \cdot {\ell}^{3}\right)} + U \]
      5. fma-def68.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, 2 \cdot \ell + 0.3333333333333333 \cdot {\ell}^{3}, U\right)} \]
      6. +-commutative68.9%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 2 \cdot \ell\right), U\right)} \]
    6. Taylor expanded in J around inf 69.0%

      \[\leadsto \color{blue}{\left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right) \cdot J} \]
    7. Step-by-step derivation
      1. unpow369.0%

        \[\leadsto \left(0.3333333333333333 \cdot \color{blue}{\left(\left(\ell \cdot \ell\right) \cdot \ell\right)} + 2 \cdot \ell\right) \cdot J \]
    8. Applied egg-rr69.0%

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

    if -2.60000000000000009 < l < 6e10

    1. Initial program 71.6%

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

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

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

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

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

        \[\leadsto \left(\left(2 \cdot \ell\right) \cdot J + \color{blue}{\left(0.3333333333333333 \cdot {\ell}^{3}\right) \cdot J}\right) + U \]
      4. distribute-rgt-out84.6%

        \[\leadsto \color{blue}{J \cdot \left(2 \cdot \ell + 0.3333333333333333 \cdot {\ell}^{3}\right)} + U \]
      5. fma-def84.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, 2 \cdot \ell + 0.3333333333333333 \cdot {\ell}^{3}, U\right)} \]
      6. +-commutative84.7%

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell}, U\right) \]
      7. fma-def84.7%

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{\mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 2 \cdot \ell\right)}, U\right) \]
    5. Simplified84.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 2 \cdot \ell\right), U\right)} \]
    6. Taylor expanded in l around 0 84.6%

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

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

        \[\leadsto \color{blue}{\left(\ell \cdot 2\right)} \cdot J + U \]
      3. fma-def84.6%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\ell \cdot 2, J, U\right)} \]
    8. Simplified84.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.6 \lor \neg \left(\ell \leq 60000000000\right):\\ \;\;\;\;J \cdot \left(\ell \cdot 2 + 0.3333333333333333 \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot 2, J, U\right)\\ \end{array} \]

Alternative 7: 71.0% accurate, 18.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.6 \lor \neg \left(\ell \leq 10^{+15}\right):\\
\;\;\;\;J \cdot \left(\ell \cdot 2 + 0.3333333333333333 \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -2.60000000000000009 or 1e15 < 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. Taylor expanded in K around 0 80.3%

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

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

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

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

        \[\leadsto \left(\left(2 \cdot \ell\right) \cdot J + \color{blue}{\left(0.3333333333333333 \cdot {\ell}^{3}\right) \cdot J}\right) + U \]
      4. distribute-rgt-out68.9%

        \[\leadsto \color{blue}{J \cdot \left(2 \cdot \ell + 0.3333333333333333 \cdot {\ell}^{3}\right)} + U \]
      5. fma-def68.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, 2 \cdot \ell + 0.3333333333333333 \cdot {\ell}^{3}, U\right)} \]
      6. +-commutative68.9%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 2 \cdot \ell\right), U\right)} \]
    6. Taylor expanded in J around inf 69.0%

      \[\leadsto \color{blue}{\left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right) \cdot J} \]
    7. Step-by-step derivation
      1. unpow369.0%

        \[\leadsto \left(0.3333333333333333 \cdot \color{blue}{\left(\left(\ell \cdot \ell\right) \cdot \ell\right)} + 2 \cdot \ell\right) \cdot J \]
    8. Applied egg-rr69.0%

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

    if -2.60000000000000009 < l < 1e15

    1. Initial program 71.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.6 \lor \neg \left(\ell \leq 10^{+15}\right):\\ \;\;\;\;J \cdot \left(\ell \cdot 2 + 0.3333333333333333 \cdot \left(\ell \cdot \left(\ell \cdot \ell\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\ \end{array} \]

Alternative 8: 42.9% accurate, 34.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;J \leq -9.2 \cdot 10^{+191} \lor \neg \left(J \leq 5.5 \cdot 10^{+120}\right):\\ \;\;\;\;J \cdot \left(\ell \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (or (<= J -9.2e+191) (not (<= J 5.5e+120))) (* J (* l 2.0)) U))
double code(double J, double l, double K, double U) {
	double tmp;
	if ((J <= -9.2e+191) || !(J <= 5.5e+120)) {
		tmp = J * (l * 2.0);
	} 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 ((j <= (-9.2d+191)) .or. (.not. (j <= 5.5d+120))) then
        tmp = j * (l * 2.0d0)
    else
        tmp = u
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if ((J <= -9.2e+191) || !(J <= 5.5e+120)) {
		tmp = J * (l * 2.0);
	} else {
		tmp = U;
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if (J <= -9.2e+191) or not (J <= 5.5e+120):
		tmp = J * (l * 2.0)
	else:
		tmp = U
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if ((J <= -9.2e+191) || !(J <= 5.5e+120))
		tmp = Float64(J * Float64(l * 2.0));
	else
		tmp = U;
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if ((J <= -9.2e+191) || ~((J <= 5.5e+120)))
		tmp = J * (l * 2.0);
	else
		tmp = U;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[Or[LessEqual[J, -9.2e+191], N[Not[LessEqual[J, 5.5e+120]], $MachinePrecision]], N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision], U]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;J \leq -9.2 \cdot 10^{+191} \lor \neg \left(J \leq 5.5 \cdot 10^{+120}\right):\\
\;\;\;\;J \cdot \left(\ell \cdot 2\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if J < -9.1999999999999997e191 or 5.50000000000000003e120 < J

    1. Initial program 66.2%

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

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

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

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

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

        \[\leadsto \left(\left(2 \cdot \ell\right) \cdot J + \color{blue}{\left(0.3333333333333333 \cdot {\ell}^{3}\right) \cdot J}\right) + U \]
      4. distribute-rgt-out82.5%

        \[\leadsto \color{blue}{J \cdot \left(2 \cdot \ell + 0.3333333333333333 \cdot {\ell}^{3}\right)} + U \]
      5. fma-def82.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(J, 2 \cdot \ell + 0.3333333333333333 \cdot {\ell}^{3}, U\right)} \]
      6. +-commutative82.5%

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell}, U\right) \]
      7. fma-def82.5%

        \[\leadsto \mathsf{fma}\left(J, \color{blue}{\mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 2 \cdot \ell\right)}, U\right) \]
    5. Simplified82.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(J, \mathsf{fma}\left(0.3333333333333333, {\ell}^{3}, 2 \cdot \ell\right), U\right)} \]
    6. Taylor expanded in J around inf 68.9%

      \[\leadsto \color{blue}{\left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right) \cdot J} \]
    7. Taylor expanded in l around 0 56.9%

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

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

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

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

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

    if -9.1999999999999997e191 < J < 5.50000000000000003e120

    1. Initial program 91.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;J \leq -9.2 \cdot 10^{+191} \lor \neg \left(J \leq 5.5 \cdot 10^{+120}\right):\\ \;\;\;\;J \cdot \left(\ell \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;U\\ \end{array} \]

Alternative 9: 41.1% accurate, 43.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2.6:\\ \;\;\;\;U \cdot U\\ \mathbf{elif}\;\ell \leq 6.4 \cdot 10^{+40}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot U\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (if (<= l -2.6) (* U U) (if (<= l 6.4e+40) U (* U U))))
double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -2.6) {
		tmp = U * U;
	} else if (l <= 6.4e+40) {
		tmp = U;
	} else {
		tmp = U * U;
	}
	return tmp;
}
real(8) function code(j, l, k, u)
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    real(8) :: tmp
    if (l <= (-2.6d0)) then
        tmp = u * u
    else if (l <= 6.4d+40) then
        tmp = u
    else
        tmp = u * u
    end if
    code = tmp
end function
public static double code(double J, double l, double K, double U) {
	double tmp;
	if (l <= -2.6) {
		tmp = U * U;
	} else if (l <= 6.4e+40) {
		tmp = U;
	} else {
		tmp = U * U;
	}
	return tmp;
}
def code(J, l, K, U):
	tmp = 0
	if l <= -2.6:
		tmp = U * U
	elif l <= 6.4e+40:
		tmp = U
	else:
		tmp = U * U
	return tmp
function code(J, l, K, U)
	tmp = 0.0
	if (l <= -2.6)
		tmp = Float64(U * U);
	elseif (l <= 6.4e+40)
		tmp = U;
	else
		tmp = Float64(U * U);
	end
	return tmp
end
function tmp_2 = code(J, l, K, U)
	tmp = 0.0;
	if (l <= -2.6)
		tmp = U * U;
	elseif (l <= 6.4e+40)
		tmp = U;
	else
		tmp = U * U;
	end
	tmp_2 = tmp;
end
code[J_, l_, K_, U_] := If[LessEqual[l, -2.6], N[(U * U), $MachinePrecision], If[LessEqual[l, 6.4e+40], U, N[(U * U), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.6:\\
\;\;\;\;U \cdot U\\

\mathbf{elif}\;\ell \leq 6.4 \cdot 10^{+40}:\\
\;\;\;\;U\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -2.60000000000000009 or 6.39999999999999961e40 < 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. Applied egg-rr12.4%

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

    if -2.60000000000000009 < l < 6.39999999999999961e40

    1. Initial program 72.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.6:\\ \;\;\;\;U \cdot U\\ \mathbf{elif}\;\ell \leq 6.4 \cdot 10^{+40}:\\ \;\;\;\;U\\ \mathbf{else}:\\ \;\;\;\;U \cdot U\\ \end{array} \]

Alternative 10: 53.5% accurate, 44.6× speedup?

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

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

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

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

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

    \[\leadsto U + J \cdot \left(\ell \cdot 2\right) \]

Alternative 11: 2.7% accurate, 312.0× speedup?

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

\\
-0.14285714285714285
\end{array}
Derivation
  1. Initial program 84.6%

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

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

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

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

      \[\leadsto \frac{U}{\left(-8 + 1\right) \cdot U + \color{blue}{\left(-8 \cdot U\right) \cdot U}} \]
    4. distribute-rgt-out2.6%

      \[\leadsto \frac{U}{\color{blue}{U \cdot \left(\left(-8 + 1\right) + -8 \cdot U\right)}} \]
    5. associate-/r*2.6%

      \[\leadsto \color{blue}{\frac{\frac{U}{U}}{\left(-8 + 1\right) + -8 \cdot U}} \]
    6. *-inverses2.6%

      \[\leadsto \frac{\color{blue}{1}}{\left(-8 + 1\right) + -8 \cdot U} \]
    7. +-commutative2.6%

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

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

      \[\leadsto \frac{1}{U \cdot -8 + \color{blue}{-7}} \]
  4. Simplified2.6%

    \[\leadsto \color{blue}{\frac{1}{U \cdot -8 + -7}} \]
  5. Taylor expanded in U around 0 2.9%

    \[\leadsto \color{blue}{-0.14285714285714285} \]
  6. Final simplification2.9%

    \[\leadsto -0.14285714285714285 \]

Alternative 12: 35.8% accurate, 312.0× speedup?

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

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

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

    \[\leadsto \color{blue}{U} \]
  3. Final simplification38.1%

    \[\leadsto U \]

Reproduce

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