Maksimov and Kolovsky, Equation (4)

Percentage Accurate: 85.9% → 99.9%
Time: 12.0s
Alternatives: 16
Speedup: 2.2×

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;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(j, l, k, u)
use fmin_fmax_functions
    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 16 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;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

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

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

Alternative 1: 99.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(J \cdot \left(\left(\cosh \ell \cdot 2\right) \cdot \tanh \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (+ (* (* J (* (* (cosh l) 2.0) (tanh l))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
	return ((J * ((cosh(l) * 2.0) * tanh(l))) * cos((K / 2.0))) + U;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(j, l, k, u)
use fmin_fmax_functions
    real(8), intent (in) :: j
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8), intent (in) :: u
    code = ((j * ((cosh(l) * 2.0d0) * tanh(l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
	return ((J * ((Math.cosh(l) * 2.0) * Math.tanh(l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U):
	return ((J * ((math.cosh(l) * 2.0) * math.tanh(l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U)
	return Float64(Float64(Float64(J * Float64(Float64(cosh(l) * 2.0) * tanh(l))) * cos(Float64(K / 2.0))) + U)
end
function tmp = code(J, l, K, U)
	tmp = ((J * ((cosh(l) * 2.0) * tanh(l))) * cos((K / 2.0))) + U;
end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[(N[Cosh[l], $MachinePrecision] * 2.0), $MachinePrecision] * N[Tanh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}

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

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

      \[\leadsto \left(J \cdot \color{blue}{\left(e^{\ell} - e^{-\ell}\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    2. flip--N/A

      \[\leadsto \left(J \cdot \color{blue}{\frac{e^{\ell} \cdot e^{\ell} - e^{-\ell} \cdot e^{-\ell}}{e^{\ell} + e^{-\ell}}}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    3. difference-of-squaresN/A

      \[\leadsto \left(J \cdot \frac{\color{blue}{\left(e^{\ell} + e^{-\ell}\right) \cdot \left(e^{\ell} - e^{-\ell}\right)}}{e^{\ell} + e^{-\ell}}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    4. lift--.f64N/A

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

      \[\leadsto \left(J \cdot \color{blue}{\left(\left(e^{\ell} + e^{-\ell}\right) \cdot \frac{e^{\ell} - e^{-\ell}}{e^{\ell} + e^{-\ell}}\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    6. lower-*.f64N/A

      \[\leadsto \left(J \cdot \color{blue}{\left(\left(e^{\ell} + e^{-\ell}\right) \cdot \frac{e^{\ell} - e^{-\ell}}{e^{\ell} + e^{-\ell}}\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    7. lift-exp.f64N/A

      \[\leadsto \left(J \cdot \left(\left(\color{blue}{e^{\ell}} + e^{-\ell}\right) \cdot \frac{e^{\ell} - e^{-\ell}}{e^{\ell} + e^{-\ell}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    8. lift-exp.f64N/A

      \[\leadsto \left(J \cdot \left(\left(e^{\ell} + \color{blue}{e^{-\ell}}\right) \cdot \frac{e^{\ell} - e^{-\ell}}{e^{\ell} + e^{-\ell}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    9. lift-neg.f64N/A

      \[\leadsto \left(J \cdot \left(\left(e^{\ell} + e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}\right) \cdot \frac{e^{\ell} - e^{-\ell}}{e^{\ell} + e^{-\ell}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    10. cosh-undefN/A

      \[\leadsto \left(J \cdot \left(\color{blue}{\left(2 \cdot \cosh \ell\right)} \cdot \frac{e^{\ell} - e^{-\ell}}{e^{\ell} + e^{-\ell}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    11. *-commutativeN/A

      \[\leadsto \left(J \cdot \left(\color{blue}{\left(\cosh \ell \cdot 2\right)} \cdot \frac{e^{\ell} - e^{-\ell}}{e^{\ell} + e^{-\ell}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    12. lower-*.f64N/A

      \[\leadsto \left(J \cdot \left(\color{blue}{\left(\cosh \ell \cdot 2\right)} \cdot \frac{e^{\ell} - e^{-\ell}}{e^{\ell} + e^{-\ell}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    13. lower-cosh.f64N/A

      \[\leadsto \left(J \cdot \left(\left(\color{blue}{\cosh \ell} \cdot 2\right) \cdot \frac{e^{\ell} - e^{-\ell}}{e^{\ell} + e^{-\ell}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    14. lift--.f64N/A

      \[\leadsto \left(J \cdot \left(\left(\cosh \ell \cdot 2\right) \cdot \frac{\color{blue}{e^{\ell} - e^{-\ell}}}{e^{\ell} + e^{-\ell}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    15. lift-exp.f64N/A

      \[\leadsto \left(J \cdot \left(\left(\cosh \ell \cdot 2\right) \cdot \frac{\color{blue}{e^{\ell}} - e^{-\ell}}{e^{\ell} + e^{-\ell}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    16. lift-exp.f64N/A

      \[\leadsto \left(J \cdot \left(\left(\cosh \ell \cdot 2\right) \cdot \frac{e^{\ell} - \color{blue}{e^{-\ell}}}{e^{\ell} + e^{-\ell}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    17. lift-neg.f64N/A

      \[\leadsto \left(J \cdot \left(\left(\cosh \ell \cdot 2\right) \cdot \frac{e^{\ell} - e^{\color{blue}{\mathsf{neg}\left(\ell\right)}}}{e^{\ell} + e^{-\ell}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  4. Applied rewrites100.0%

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

Alternative 2: 99.9% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\left(\sinh \ell \cdot \cos \left(\frac{K}{-2}\right)\right) \cdot 2, J, U\right) \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (fma (* (* (sinh l) (cos (/ K -2.0))) 2.0) J U))
double code(double J, double l, double K, double U) {
	return fma(((sinh(l) * cos((K / -2.0))) * 2.0), J, U);
}
function code(J, l, K, U)
	return fma(Float64(Float64(sinh(l) * cos(Float64(K / -2.0))) * 2.0), J, U)
end
code[J_, l_, K_, U_] := N[(N[(N[(N[Sinh[l], $MachinePrecision] * N[Cos[N[(K / -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] * J + U), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\left(\sinh \ell \cdot \cos \left(\frac{K}{-2}\right)\right) \cdot 2, J, U\right)
\end{array}
Derivation
  1. Initial program 85.1%

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

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

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

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

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

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

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

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

Alternative 3: 94.7% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (+
  (*
   (*
    J
    (*
     (fma
      (fma
       (fma 0.0003968253968253968 (* l l) 0.016666666666666666)
       (* l l)
       0.3333333333333333)
      (* l l)
      2.0)
     l))
   (cos (/ K 2.0)))
  U))
double code(double J, double l, double K, double U) {
	return ((J * (fma(fma(fma(0.0003968253968253968, (l * l), 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l)) * cos((K / 2.0))) + U;
}
function code(J, l, K, U)
	return Float64(Float64(Float64(J * Float64(fma(fma(fma(0.0003968253968253968, Float64(l * l), 0.016666666666666666), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)) * cos(Float64(K / 2.0))) + U)
end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[(N[(N[(0.0003968253968253968 * N[(l * l), $MachinePrecision] + 0.016666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}

\\
\left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
Derivation
  1. Initial program 85.1%

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

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

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

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

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

      \[\leadsto \left(J \cdot \left(\left(\color{blue}{\left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right) \cdot {\ell}^{2}} + 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    5. lower-fma.f64N/A

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

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

      \[\leadsto \left(J \cdot \left(\mathsf{fma}\left(\color{blue}{\left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right) \cdot {\ell}^{2}} + \frac{1}{3}, {\ell}^{2}, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    8. lower-fma.f64N/A

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

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

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

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

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

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

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

      \[\leadsto \left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, \ell \cdot \ell, \frac{1}{60}\right), \ell \cdot \ell, \frac{1}{3}\right), \color{blue}{\ell \cdot \ell}, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    16. lower-*.f6496.6

      \[\leadsto \left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \color{blue}{\ell \cdot \ell}, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  5. Applied rewrites96.6%

    \[\leadsto \left(J \cdot \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  6. Add Preprocessing

Alternative 4: 94.7% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\cos \left(\frac{K}{-2}\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right) \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (fma
  (*
   (cos (/ K -2.0))
   (*
    (fma
     (fma
      (fma (* l l) 0.0003968253968253968 0.016666666666666666)
      (* l l)
      0.3333333333333333)
     (* l l)
     2.0)
    l))
  J
  U))
double code(double J, double l, double K, double U) {
	return fma((cos((K / -2.0)) * (fma(fma(fma((l * l), 0.0003968253968253968, 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l)), J, U);
}
function code(J, l, K, U)
	return fma(Float64(cos(Float64(K / -2.0)) * Float64(fma(fma(fma(Float64(l * l), 0.0003968253968253968, 0.016666666666666666), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)), J, U)
end
code[J_, l_, K_, U_] := N[(N[(N[Cos[N[(K / -2.0), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968 + 0.016666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\cos \left(\frac{K}{-2}\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)
\end{array}
Derivation
  1. Initial program 85.1%

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

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

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

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

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

      \[\leadsto \left(J \cdot \left(\left(\color{blue}{\left(\frac{1}{3} + {\ell}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right)\right) \cdot {\ell}^{2}} + 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    5. lower-fma.f64N/A

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

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

      \[\leadsto \left(J \cdot \left(\mathsf{fma}\left(\color{blue}{\left(\frac{1}{60} + \frac{1}{2520} \cdot {\ell}^{2}\right) \cdot {\ell}^{2}} + \frac{1}{3}, {\ell}^{2}, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    8. lower-fma.f64N/A

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

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

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

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

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

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

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

      \[\leadsto \left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, \ell \cdot \ell, \frac{1}{60}\right), \ell \cdot \ell, \frac{1}{3}\right), \color{blue}{\ell \cdot \ell}, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
    16. lower-*.f6496.6

      \[\leadsto \left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \color{blue}{\ell \cdot \ell}, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
  5. Applied rewrites96.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, \ell \cdot \ell, \frac{1}{60}\right), \ell \cdot \ell, \frac{1}{3}\right), \ell \cdot \ell, 2\right) \cdot \ell\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot J} + U \]
    6. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, \ell \cdot \ell, \frac{1}{60}\right), \ell \cdot \ell, \frac{1}{3}\right), \ell \cdot \ell, 2\right) \cdot \ell\right) \cdot \cos \left(\frac{K}{2}\right), J, U\right)} \]
  7. Applied rewrites96.6%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{K}{-2}\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)} \]
  8. Add Preprocessing

Alternative 5: 90.4% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\ t_1 := \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\\ t_2 := \left(\left(t\_1 \cdot \ell\right) \cdot J\right) \cdot \cos \left(-0.5 \cdot K\right)\\ \mathbf{if}\;\ell \leq -9.8 \cdot 10^{+101}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq 400:\\ \;\;\;\;\left(\left(J \cdot t\_1\right) \cdot \ell\right) \cdot \cos \left(\frac{K}{2}\right) + U\\ \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+100}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (J l K U)
 :precision binary64
 (let* ((t_0 (fma (* (* (fma -0.125 l (/ l (* K K))) K) K) (* 2.0 J) U))
        (t_1 (fma (* l l) 0.3333333333333333 2.0))
        (t_2 (* (* (* t_1 l) J) (cos (* -0.5 K)))))
   (if (<= l -9.8e+101)
     t_2
     (if (<= l -7.8e+25)
       t_0
       (if (<= l 400.0)
         (+ (* (* (* J t_1) l) (cos (/ K 2.0))) U)
         (if (<= l 1.1e+100) t_0 t_2))))))
double code(double J, double l, double K, double U) {
	double t_0 = fma(((fma(-0.125, l, (l / (K * K))) * K) * K), (2.0 * J), U);
	double t_1 = fma((l * l), 0.3333333333333333, 2.0);
	double t_2 = ((t_1 * l) * J) * cos((-0.5 * K));
	double tmp;
	if (l <= -9.8e+101) {
		tmp = t_2;
	} else if (l <= -7.8e+25) {
		tmp = t_0;
	} else if (l <= 400.0) {
		tmp = (((J * t_1) * l) * cos((K / 2.0))) + U;
	} else if (l <= 1.1e+100) {
		tmp = t_0;
	} else {
		tmp = t_2;
	}
	return tmp;
}
function code(J, l, K, U)
	t_0 = fma(Float64(Float64(fma(-0.125, l, Float64(l / Float64(K * K))) * K) * K), Float64(2.0 * J), U)
	t_1 = fma(Float64(l * l), 0.3333333333333333, 2.0)
	t_2 = Float64(Float64(Float64(t_1 * l) * J) * cos(Float64(-0.5 * K)))
	tmp = 0.0
	if (l <= -9.8e+101)
		tmp = t_2;
	elseif (l <= -7.8e+25)
		tmp = t_0;
	elseif (l <= 400.0)
		tmp = Float64(Float64(Float64(Float64(J * t_1) * l) * cos(Float64(K / 2.0))) + U);
	elseif (l <= 1.1e+100)
		tmp = t_0;
	else
		tmp = t_2;
	end
	return tmp
end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[(N[(-0.125 * l + N[(l / N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * K), $MachinePrecision] * K), $MachinePrecision] * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision]}, Block[{t$95$1 = N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(t$95$1 * l), $MachinePrecision] * J), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -9.8e+101], t$95$2, If[LessEqual[l, -7.8e+25], t$95$0, If[LessEqual[l, 400.0], N[(N[(N[(N[(J * t$95$1), $MachinePrecision] * l), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 1.1e+100], t$95$0, t$95$2]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\
t_1 := \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\\
t_2 := \left(\left(t\_1 \cdot \ell\right) \cdot J\right) \cdot \cos \left(-0.5 \cdot K\right)\\
\mathbf{if}\;\ell \leq -9.8 \cdot 10^{+101}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+100}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -9.79999999999999965e101 or 1.1e100 < l

    1. Initial program 100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right), \ell, U\right)} \]
    6. Taylor expanded in J around inf

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

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

      if -9.79999999999999965e101 < l < -7.8000000000000004e25 or 400 < l < 1.1e100

      1. Initial program 100.0%

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\left(\ell \cdot \left(2 \cdot J\right)\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
        8. lower-fma.f64N/A

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

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

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

          \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot J\right)} \cdot \ell, \cos \left(\frac{1}{2} \cdot K\right), U\right) \]
        12. cos-neg-revN/A

          \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)}, U\right) \]
        13. lower-cos.f64N/A

          \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)}, U\right) \]
        14. distribute-lft-neg-inN/A

          \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)}, U\right) \]
        15. lower-*.f64N/A

          \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)}, U\right) \]
        16. metadata-eval19.0

          \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \left(\color{blue}{-0.5} \cdot K\right), U\right) \]
      5. Applied rewrites19.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \left(-0.5 \cdot K\right), U\right)} \]
      6. Step-by-step derivation
        1. Applied rewrites19.0%

          \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right) \cdot \ell, \color{blue}{2 \cdot J}, U\right) \]
        2. Taylor expanded in K around 0

          \[\leadsto \mathsf{fma}\left(\ell + \frac{-1}{8} \cdot \left({K}^{2} \cdot \ell\right), \color{blue}{2} \cdot J, U\right) \]
        3. Step-by-step derivation
          1. Applied rewrites38.0%

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

            \[\leadsto \mathsf{fma}\left({K}^{2} \cdot \left(\frac{-1}{8} \cdot \ell + \frac{\ell}{{K}^{2}}\right), 2 \cdot J, U\right) \]
          3. Step-by-step derivation
            1. Applied rewrites77.5%

              \[\leadsto \mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right) \]

            if -7.8000000000000004e25 < l < 400

            1. Initial program 72.0%

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

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

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

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

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

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

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

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

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

                \[\leadsto \left(\left(J \cdot \left(\frac{1}{3} \cdot {\ell}^{2}\right) + \color{blue}{J \cdot 2}\right) \cdot \ell\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              9. distribute-lft-outN/A

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

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

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

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

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

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

                \[\leadsto \left(\left(J \cdot \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, \frac{1}{3}, 2\right)\right) \cdot \ell\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
              16. lower-*.f6497.5

                \[\leadsto \left(\left(J \cdot \mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, 0.3333333333333333, 2\right)\right) \cdot \ell\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
            5. Applied rewrites97.5%

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -9.8 \cdot 10^{+101}:\\ \;\;\;\;\left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot \cos \left(-0.5 \cdot K\right)\\ \mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25}:\\ \;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\ \mathbf{elif}\;\ell \leq 400:\\ \;\;\;\;\left(\left(J \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right) \cdot \ell\right) \cdot \cos \left(\frac{K}{2}\right) + U\\ \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot \cos \left(-0.5 \cdot K\right)\\ \end{array} \]
          6. Add Preprocessing

          Alternative 6: 90.4% accurate, 2.1× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(-0.5 \cdot K\right)\\ t_1 := \mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\ t_2 := \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\\ t_3 := \left(\left(t\_2 \cdot \ell\right) \cdot J\right) \cdot t\_0\\ \mathbf{if}\;\ell \leq -9.8 \cdot 10^{+101}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\ell \leq 400:\\ \;\;\;\;\left(t\_0 \cdot \left(J \cdot t\_2\right)\right) \cdot \ell + U\\ \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+100}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_3\\ \end{array} \end{array} \]
          (FPCore (J l K U)
           :precision binary64
           (let* ((t_0 (cos (* -0.5 K)))
                  (t_1 (fma (* (* (fma -0.125 l (/ l (* K K))) K) K) (* 2.0 J) U))
                  (t_2 (fma (* l l) 0.3333333333333333 2.0))
                  (t_3 (* (* (* t_2 l) J) t_0)))
             (if (<= l -9.8e+101)
               t_3
               (if (<= l -7.8e+25)
                 t_1
                 (if (<= l 400.0)
                   (+ (* (* t_0 (* J t_2)) l) U)
                   (if (<= l 1.1e+100) t_1 t_3))))))
          double code(double J, double l, double K, double U) {
          	double t_0 = cos((-0.5 * K));
          	double t_1 = fma(((fma(-0.125, l, (l / (K * K))) * K) * K), (2.0 * J), U);
          	double t_2 = fma((l * l), 0.3333333333333333, 2.0);
          	double t_3 = ((t_2 * l) * J) * t_0;
          	double tmp;
          	if (l <= -9.8e+101) {
          		tmp = t_3;
          	} else if (l <= -7.8e+25) {
          		tmp = t_1;
          	} else if (l <= 400.0) {
          		tmp = ((t_0 * (J * t_2)) * l) + U;
          	} else if (l <= 1.1e+100) {
          		tmp = t_1;
          	} else {
          		tmp = t_3;
          	}
          	return tmp;
          }
          
          function code(J, l, K, U)
          	t_0 = cos(Float64(-0.5 * K))
          	t_1 = fma(Float64(Float64(fma(-0.125, l, Float64(l / Float64(K * K))) * K) * K), Float64(2.0 * J), U)
          	t_2 = fma(Float64(l * l), 0.3333333333333333, 2.0)
          	t_3 = Float64(Float64(Float64(t_2 * l) * J) * t_0)
          	tmp = 0.0
          	if (l <= -9.8e+101)
          		tmp = t_3;
          	elseif (l <= -7.8e+25)
          		tmp = t_1;
          	elseif (l <= 400.0)
          		tmp = Float64(Float64(Float64(t_0 * Float64(J * t_2)) * l) + U);
          	elseif (l <= 1.1e+100)
          		tmp = t_1;
          	else
          		tmp = t_3;
          	end
          	return tmp
          end
          
          code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(-0.125 * l + N[(l / N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * K), $MachinePrecision] * K), $MachinePrecision] * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision]}, Block[{t$95$2 = N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(t$95$2 * l), $MachinePrecision] * J), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[l, -9.8e+101], t$95$3, If[LessEqual[l, -7.8e+25], t$95$1, If[LessEqual[l, 400.0], N[(N[(N[(t$95$0 * N[(J * t$95$2), $MachinePrecision]), $MachinePrecision] * l), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 1.1e+100], t$95$1, t$95$3]]]]]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \cos \left(-0.5 \cdot K\right)\\
          t_1 := \mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\
          t_2 := \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\\
          t_3 := \left(\left(t\_2 \cdot \ell\right) \cdot J\right) \cdot t\_0\\
          \mathbf{if}\;\ell \leq -9.8 \cdot 10^{+101}:\\
          \;\;\;\;t\_3\\
          
          \mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25}:\\
          \;\;\;\;t\_1\\
          
          \mathbf{elif}\;\ell \leq 400:\\
          \;\;\;\;\left(t\_0 \cdot \left(J \cdot t\_2\right)\right) \cdot \ell + U\\
          
          \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+100}:\\
          \;\;\;\;t\_1\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_3\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if l < -9.79999999999999965e101 or 1.1e100 < l

            1. Initial program 100.0%

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

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

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

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

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right), \ell, U\right)} \]
            6. Taylor expanded in J around inf

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

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

              if -9.79999999999999965e101 < l < -7.8000000000000004e25 or 400 < l < 1.1e100

              1. Initial program 100.0%

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

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

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

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

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

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

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

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

                  \[\leadsto \color{blue}{\left(\ell \cdot \left(2 \cdot J\right)\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                8. lower-fma.f64N/A

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

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

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

                  \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot J\right)} \cdot \ell, \cos \left(\frac{1}{2} \cdot K\right), U\right) \]
                12. cos-neg-revN/A

                  \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)}, U\right) \]
                13. lower-cos.f64N/A

                  \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)}, U\right) \]
                14. distribute-lft-neg-inN/A

                  \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)}, U\right) \]
                15. lower-*.f64N/A

                  \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)}, U\right) \]
                16. metadata-eval19.0

                  \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \left(\color{blue}{-0.5} \cdot K\right), U\right) \]
              5. Applied rewrites19.0%

                \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \left(-0.5 \cdot K\right), U\right)} \]
              6. Step-by-step derivation
                1. Applied rewrites19.0%

                  \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right) \cdot \ell, \color{blue}{2 \cdot J}, U\right) \]
                2. Taylor expanded in K around 0

                  \[\leadsto \mathsf{fma}\left(\ell + \frac{-1}{8} \cdot \left({K}^{2} \cdot \ell\right), \color{blue}{2} \cdot J, U\right) \]
                3. Step-by-step derivation
                  1. Applied rewrites38.0%

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

                    \[\leadsto \mathsf{fma}\left({K}^{2} \cdot \left(\frac{-1}{8} \cdot \ell + \frac{\ell}{{K}^{2}}\right), 2 \cdot J, U\right) \]
                  3. Step-by-step derivation
                    1. Applied rewrites77.5%

                      \[\leadsto \mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right) \]

                    if -7.8000000000000004e25 < l < 400

                    1. Initial program 72.0%

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

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

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

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

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

                    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -9.8 \cdot 10^{+101}:\\ \;\;\;\;\left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot \cos \left(-0.5 \cdot K\right)\\ \mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25}:\\ \;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\ \mathbf{elif}\;\ell \leq 400:\\ \;\;\;\;\left(\cos \left(-0.5 \cdot K\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right)\right) \cdot \ell + U\\ \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot \cos \left(-0.5 \cdot K\right)\\ \end{array} \]
                  6. Add Preprocessing

                  Alternative 7: 90.4% accurate, 2.1× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\ t_1 := \left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot \cos \left(-0.5 \cdot K\right)\\ \mathbf{if}\;\ell \leq -9.8 \cdot 10^{+101}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq 400:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot \left(\cos \left(0.5 \cdot K\right) \cdot J\right), \mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right), U\right)\\ \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+100}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
                  (FPCore (J l K U)
                   :precision binary64
                   (let* ((t_0 (fma (* (* (fma -0.125 l (/ l (* K K))) K) K) (* 2.0 J) U))
                          (t_1
                           (*
                            (* (* (fma (* l l) 0.3333333333333333 2.0) l) J)
                            (cos (* -0.5 K)))))
                     (if (<= l -9.8e+101)
                       t_1
                       (if (<= l -7.8e+25)
                         t_0
                         (if (<= l 400.0)
                           (fma
                            (* l (* (cos (* 0.5 K)) J))
                            (fma 0.3333333333333333 (* l l) 2.0)
                            U)
                           (if (<= l 1.1e+100) t_0 t_1))))))
                  double code(double J, double l, double K, double U) {
                  	double t_0 = fma(((fma(-0.125, l, (l / (K * K))) * K) * K), (2.0 * J), U);
                  	double t_1 = ((fma((l * l), 0.3333333333333333, 2.0) * l) * J) * cos((-0.5 * K));
                  	double tmp;
                  	if (l <= -9.8e+101) {
                  		tmp = t_1;
                  	} else if (l <= -7.8e+25) {
                  		tmp = t_0;
                  	} else if (l <= 400.0) {
                  		tmp = fma((l * (cos((0.5 * K)) * J)), fma(0.3333333333333333, (l * l), 2.0), U);
                  	} else if (l <= 1.1e+100) {
                  		tmp = t_0;
                  	} else {
                  		tmp = t_1;
                  	}
                  	return tmp;
                  }
                  
                  function code(J, l, K, U)
                  	t_0 = fma(Float64(Float64(fma(-0.125, l, Float64(l / Float64(K * K))) * K) * K), Float64(2.0 * J), U)
                  	t_1 = Float64(Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) * J) * cos(Float64(-0.5 * K)))
                  	tmp = 0.0
                  	if (l <= -9.8e+101)
                  		tmp = t_1;
                  	elseif (l <= -7.8e+25)
                  		tmp = t_0;
                  	elseif (l <= 400.0)
                  		tmp = fma(Float64(l * Float64(cos(Float64(0.5 * K)) * J)), fma(0.3333333333333333, Float64(l * l), 2.0), U);
                  	elseif (l <= 1.1e+100)
                  		tmp = t_0;
                  	else
                  		tmp = t_1;
                  	end
                  	return tmp
                  end
                  
                  code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[(N[(-0.125 * l + N[(l / N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * K), $MachinePrecision] * K), $MachinePrecision] * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -9.8e+101], t$95$1, If[LessEqual[l, -7.8e+25], t$95$0, If[LessEqual[l, 400.0], N[(N[(l * N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision] * N[(0.3333333333333333 * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 1.1e+100], t$95$0, t$95$1]]]]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_0 := \mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\
                  t_1 := \left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot \cos \left(-0.5 \cdot K\right)\\
                  \mathbf{if}\;\ell \leq -9.8 \cdot 10^{+101}:\\
                  \;\;\;\;t\_1\\
                  
                  \mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25}:\\
                  \;\;\;\;t\_0\\
                  
                  \mathbf{elif}\;\ell \leq 400:\\
                  \;\;\;\;\mathsf{fma}\left(\ell \cdot \left(\cos \left(0.5 \cdot K\right) \cdot J\right), \mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right), U\right)\\
                  
                  \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+100}:\\
                  \;\;\;\;t\_0\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;t\_1\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 3 regimes
                  2. if l < -9.79999999999999965e101 or 1.1e100 < l

                    1. Initial program 100.0%

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

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

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

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

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

                      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right), \ell, U\right)} \]
                    6. Taylor expanded in J around inf

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

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

                      if -9.79999999999999965e101 < l < -7.8000000000000004e25 or 400 < l < 1.1e100

                      1. Initial program 100.0%

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

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

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

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

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

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

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

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

                          \[\leadsto \color{blue}{\left(\ell \cdot \left(2 \cdot J\right)\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                        8. lower-fma.f64N/A

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

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

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

                          \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot J\right)} \cdot \ell, \cos \left(\frac{1}{2} \cdot K\right), U\right) \]
                        12. cos-neg-revN/A

                          \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)}, U\right) \]
                        13. lower-cos.f64N/A

                          \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)}, U\right) \]
                        14. distribute-lft-neg-inN/A

                          \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)}, U\right) \]
                        15. lower-*.f64N/A

                          \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)}, U\right) \]
                        16. metadata-eval19.0

                          \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \left(\color{blue}{-0.5} \cdot K\right), U\right) \]
                      5. Applied rewrites19.0%

                        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \left(-0.5 \cdot K\right), U\right)} \]
                      6. Step-by-step derivation
                        1. Applied rewrites19.0%

                          \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right) \cdot \ell, \color{blue}{2 \cdot J}, U\right) \]
                        2. Taylor expanded in K around 0

                          \[\leadsto \mathsf{fma}\left(\ell + \frac{-1}{8} \cdot \left({K}^{2} \cdot \ell\right), \color{blue}{2} \cdot J, U\right) \]
                        3. Step-by-step derivation
                          1. Applied rewrites38.0%

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

                            \[\leadsto \mathsf{fma}\left({K}^{2} \cdot \left(\frac{-1}{8} \cdot \ell + \frac{\ell}{{K}^{2}}\right), 2 \cdot J, U\right) \]
                          3. Step-by-step derivation
                            1. Applied rewrites77.5%

                              \[\leadsto \mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right) \]

                            if -7.8000000000000004e25 < l < 400

                            1. Initial program 72.0%

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

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

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

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

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

                              \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right), \ell, U\right)} \]
                            6. Step-by-step derivation
                              1. Applied rewrites97.5%

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

                              \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -9.8 \cdot 10^{+101}:\\ \;\;\;\;\left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot \cos \left(-0.5 \cdot K\right)\\ \mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25}:\\ \;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\ \mathbf{elif}\;\ell \leq 400:\\ \;\;\;\;\mathsf{fma}\left(\ell \cdot \left(\cos \left(0.5 \cdot K\right) \cdot J\right), \mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right), U\right)\\ \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot \cos \left(-0.5 \cdot K\right)\\ \end{array} \]
                            9. Add Preprocessing

                            Alternative 8: 90.2% accurate, 2.1× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(-0.5 \cdot K\right)\\ t_1 := \mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\ t_2 := \left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot t\_0\\ \mathbf{if}\;\ell \leq -9.8 \cdot 10^{+101}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\ell \leq 400:\\ \;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \ell, t\_0, U\right)\\ \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+100}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
                            (FPCore (J l K U)
                             :precision binary64
                             (let* ((t_0 (cos (* -0.5 K)))
                                    (t_1 (fma (* (* (fma -0.125 l (/ l (* K K))) K) K) (* 2.0 J) U))
                                    (t_2 (* (* (* (fma (* l l) 0.3333333333333333 2.0) l) J) t_0)))
                               (if (<= l -9.8e+101)
                                 t_2
                                 (if (<= l -7.8e+25)
                                   t_1
                                   (if (<= l 400.0)
                                     (fma (* (+ J J) l) t_0 U)
                                     (if (<= l 1.1e+100) t_1 t_2))))))
                            double code(double J, double l, double K, double U) {
                            	double t_0 = cos((-0.5 * K));
                            	double t_1 = fma(((fma(-0.125, l, (l / (K * K))) * K) * K), (2.0 * J), U);
                            	double t_2 = ((fma((l * l), 0.3333333333333333, 2.0) * l) * J) * t_0;
                            	double tmp;
                            	if (l <= -9.8e+101) {
                            		tmp = t_2;
                            	} else if (l <= -7.8e+25) {
                            		tmp = t_1;
                            	} else if (l <= 400.0) {
                            		tmp = fma(((J + J) * l), t_0, U);
                            	} else if (l <= 1.1e+100) {
                            		tmp = t_1;
                            	} else {
                            		tmp = t_2;
                            	}
                            	return tmp;
                            }
                            
                            function code(J, l, K, U)
                            	t_0 = cos(Float64(-0.5 * K))
                            	t_1 = fma(Float64(Float64(fma(-0.125, l, Float64(l / Float64(K * K))) * K) * K), Float64(2.0 * J), U)
                            	t_2 = Float64(Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) * J) * t_0)
                            	tmp = 0.0
                            	if (l <= -9.8e+101)
                            		tmp = t_2;
                            	elseif (l <= -7.8e+25)
                            		tmp = t_1;
                            	elseif (l <= 400.0)
                            		tmp = fma(Float64(Float64(J + J) * l), t_0, U);
                            	elseif (l <= 1.1e+100)
                            		tmp = t_1;
                            	else
                            		tmp = t_2;
                            	end
                            	return tmp
                            end
                            
                            code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(-0.125 * l + N[(l / N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * K), $MachinePrecision] * K), $MachinePrecision] * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[l, -9.8e+101], t$95$2, If[LessEqual[l, -7.8e+25], t$95$1, If[LessEqual[l, 400.0], N[(N[(N[(J + J), $MachinePrecision] * l), $MachinePrecision] * t$95$0 + U), $MachinePrecision], If[LessEqual[l, 1.1e+100], t$95$1, t$95$2]]]]]]]
                            
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            t_0 := \cos \left(-0.5 \cdot K\right)\\
                            t_1 := \mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\
                            t_2 := \left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot t\_0\\
                            \mathbf{if}\;\ell \leq -9.8 \cdot 10^{+101}:\\
                            \;\;\;\;t\_2\\
                            
                            \mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25}:\\
                            \;\;\;\;t\_1\\
                            
                            \mathbf{elif}\;\ell \leq 400:\\
                            \;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \ell, t\_0, U\right)\\
                            
                            \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+100}:\\
                            \;\;\;\;t\_1\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;t\_2\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 3 regimes
                            2. if l < -9.79999999999999965e101 or 1.1e100 < l

                              1. Initial program 100.0%

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

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

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

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

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

                                \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right), \ell, U\right)} \]
                              6. Taylor expanded in J around inf

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

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

                                if -9.79999999999999965e101 < l < -7.8000000000000004e25 or 400 < l < 1.1e100

                                1. Initial program 100.0%

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

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

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

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

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

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

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

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

                                    \[\leadsto \color{blue}{\left(\ell \cdot \left(2 \cdot J\right)\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                                  8. lower-fma.f64N/A

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

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

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

                                    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot J\right)} \cdot \ell, \cos \left(\frac{1}{2} \cdot K\right), U\right) \]
                                  12. cos-neg-revN/A

                                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)}, U\right) \]
                                  13. lower-cos.f64N/A

                                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)}, U\right) \]
                                  14. distribute-lft-neg-inN/A

                                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)}, U\right) \]
                                  15. lower-*.f64N/A

                                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)}, U\right) \]
                                  16. metadata-eval19.0

                                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \left(\color{blue}{-0.5} \cdot K\right), U\right) \]
                                5. Applied rewrites19.0%

                                  \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \left(-0.5 \cdot K\right), U\right)} \]
                                6. Step-by-step derivation
                                  1. Applied rewrites19.0%

                                    \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right) \cdot \ell, \color{blue}{2 \cdot J}, U\right) \]
                                  2. Taylor expanded in K around 0

                                    \[\leadsto \mathsf{fma}\left(\ell + \frac{-1}{8} \cdot \left({K}^{2} \cdot \ell\right), \color{blue}{2} \cdot J, U\right) \]
                                  3. Step-by-step derivation
                                    1. Applied rewrites38.0%

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

                                      \[\leadsto \mathsf{fma}\left({K}^{2} \cdot \left(\frac{-1}{8} \cdot \ell + \frac{\ell}{{K}^{2}}\right), 2 \cdot J, U\right) \]
                                    3. Step-by-step derivation
                                      1. Applied rewrites77.5%

                                        \[\leadsto \mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right) \]

                                      if -7.8000000000000004e25 < l < 400

                                      1. Initial program 72.0%

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

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

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

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

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

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

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

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

                                          \[\leadsto \color{blue}{\left(\ell \cdot \left(2 \cdot J\right)\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                                        8. lower-fma.f64N/A

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

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

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

                                          \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot J\right)} \cdot \ell, \cos \left(\frac{1}{2} \cdot K\right), U\right) \]
                                        12. cos-neg-revN/A

                                          \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)}, U\right) \]
                                        13. lower-cos.f64N/A

                                          \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)}, U\right) \]
                                        14. distribute-lft-neg-inN/A

                                          \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)}, U\right) \]
                                        15. lower-*.f64N/A

                                          \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)}, U\right) \]
                                        16. metadata-eval97.0

                                          \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \left(\color{blue}{-0.5} \cdot K\right), U\right) \]
                                      5. Applied rewrites97.0%

                                        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \left(-0.5 \cdot K\right), U\right)} \]
                                      6. Step-by-step derivation
                                        1. Applied rewrites97.0%

                                          \[\leadsto \mathsf{fma}\left(\left(J + J\right) \cdot \ell, \cos \left(\color{blue}{-0.5} \cdot K\right), U\right) \]
                                      7. Recombined 3 regimes into one program.
                                      8. Final simplification94.9%

                                        \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -9.8 \cdot 10^{+101}:\\ \;\;\;\;\left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot \cos \left(-0.5 \cdot K\right)\\ \mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25}:\\ \;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\ \mathbf{elif}\;\ell \leq 400:\\ \;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \ell, \cos \left(-0.5 \cdot K\right), U\right)\\ \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot \cos \left(-0.5 \cdot K\right)\\ \end{array} \]
                                      9. Add Preprocessing

                                      Alternative 9: 92.7% accurate, 2.2× speedup?

                                      \[\begin{array}{l} \\ \left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \end{array} \]
                                      (FPCore (J l K U)
                                       :precision binary64
                                       (+
                                        (*
                                         (*
                                          J
                                          (*
                                           (fma (fma 0.016666666666666666 (* l l) 0.3333333333333333) (* l l) 2.0)
                                           l))
                                         (cos (/ K 2.0)))
                                        U))
                                      double code(double J, double l, double K, double U) {
                                      	return ((J * (fma(fma(0.016666666666666666, (l * l), 0.3333333333333333), (l * l), 2.0) * l)) * cos((K / 2.0))) + U;
                                      }
                                      
                                      function code(J, l, K, U)
                                      	return Float64(Float64(Float64(J * Float64(fma(fma(0.016666666666666666, Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)) * cos(Float64(K / 2.0))) + U)
                                      end
                                      
                                      code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[(N[(0.016666666666666666 * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
                                      
                                      \begin{array}{l}
                                      
                                      \\
                                      \left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
                                      \end{array}
                                      
                                      Derivation
                                      1. Initial program 85.1%

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

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

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

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

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

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

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

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

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

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

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

                                          \[\leadsto \left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{60}, \ell \cdot \ell, \frac{1}{3}\right), \color{blue}{\ell \cdot \ell}, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                        11. lower-*.f6495.1

                                          \[\leadsto \left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \color{blue}{\ell \cdot \ell}, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                      5. Applied rewrites95.1%

                                        \[\leadsto \left(J \cdot \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                      6. Add Preprocessing

                                      Alternative 10: 92.7% accurate, 2.2× speedup?

                                      \[\begin{array}{l} \\ \mathsf{fma}\left(\cos \left(\frac{K}{-2}\right) \cdot J, \mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell, U\right) \end{array} \]
                                      (FPCore (J l K U)
                                       :precision binary64
                                       (fma
                                        (* (cos (/ K -2.0)) J)
                                        (* (fma (fma 0.016666666666666666 (* l l) 0.3333333333333333) (* l l) 2.0) l)
                                        U))
                                      double code(double J, double l, double K, double U) {
                                      	return fma((cos((K / -2.0)) * J), (fma(fma(0.016666666666666666, (l * l), 0.3333333333333333), (l * l), 2.0) * l), U);
                                      }
                                      
                                      function code(J, l, K, U)
                                      	return fma(Float64(cos(Float64(K / -2.0)) * J), Float64(fma(fma(0.016666666666666666, Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l), U)
                                      end
                                      
                                      code[J_, l_, K_, U_] := N[(N[(N[Cos[N[(K / -2.0), $MachinePrecision]], $MachinePrecision] * J), $MachinePrecision] * N[(N[(N[(0.016666666666666666 * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision] + U), $MachinePrecision]
                                      
                                      \begin{array}{l}
                                      
                                      \\
                                      \mathsf{fma}\left(\cos \left(\frac{K}{-2}\right) \cdot J, \mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell, U\right)
                                      \end{array}
                                      
                                      Derivation
                                      1. Initial program 85.1%

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

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

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

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

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

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

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

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

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

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

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

                                          \[\leadsto \left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{60}, \ell \cdot \ell, \frac{1}{3}\right), \color{blue}{\ell \cdot \ell}, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                        11. lower-*.f6495.1

                                          \[\leadsto \left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \color{blue}{\ell \cdot \ell}, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                      5. Applied rewrites95.1%

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

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

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

                                          \[\leadsto \color{blue}{\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{60}, \ell \cdot \ell, \frac{1}{3}\right), \ell \cdot \ell, 2\right) \cdot \ell\right)\right)} + U \]
                                        4. lift-*.f64N/A

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

                                          \[\leadsto \color{blue}{\left(\cos \left(\frac{K}{2}\right) \cdot J\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{60}, \ell \cdot \ell, \frac{1}{3}\right), \ell \cdot \ell, 2\right) \cdot \ell\right)} + U \]
                                        6. lower-fma.f64N/A

                                          \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{K}{2}\right) \cdot J, \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{60}, \ell \cdot \ell, \frac{1}{3}\right), \ell \cdot \ell, 2\right) \cdot \ell, U\right)} \]
                                      7. Applied rewrites95.0%

                                        \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{K}{-2}\right) \cdot J, \mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell, U\right)} \]
                                      8. Add Preprocessing

                                      Alternative 11: 89.2% accurate, 2.2× speedup?

                                      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\\ \mathbf{if}\;\ell \leq 400:\\ \;\;\;\;\left(J \cdot t\_0\right) \cdot \cos \left(\frac{K}{2}\right) + U\\ \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t\_0 \cdot J\right) \cdot \cos \left(-0.5 \cdot K\right)\\ \end{array} \end{array} \]
                                      (FPCore (J l K U)
                                       :precision binary64
                                       (let* ((t_0 (* (fma (* l l) 0.3333333333333333 2.0) l)))
                                         (if (<= l 400.0)
                                           (+ (* (* J t_0) (cos (/ K 2.0))) U)
                                           (if (<= l 1.1e+100)
                                             (fma (* (* (fma -0.125 l (/ l (* K K))) K) K) (* 2.0 J) U)
                                             (* (* t_0 J) (cos (* -0.5 K)))))))
                                      double code(double J, double l, double K, double U) {
                                      	double t_0 = fma((l * l), 0.3333333333333333, 2.0) * l;
                                      	double tmp;
                                      	if (l <= 400.0) {
                                      		tmp = ((J * t_0) * cos((K / 2.0))) + U;
                                      	} else if (l <= 1.1e+100) {
                                      		tmp = fma(((fma(-0.125, l, (l / (K * K))) * K) * K), (2.0 * J), U);
                                      	} else {
                                      		tmp = (t_0 * J) * cos((-0.5 * K));
                                      	}
                                      	return tmp;
                                      }
                                      
                                      function code(J, l, K, U)
                                      	t_0 = Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l)
                                      	tmp = 0.0
                                      	if (l <= 400.0)
                                      		tmp = Float64(Float64(Float64(J * t_0) * cos(Float64(K / 2.0))) + U);
                                      	elseif (l <= 1.1e+100)
                                      		tmp = fma(Float64(Float64(fma(-0.125, l, Float64(l / Float64(K * K))) * K) * K), Float64(2.0 * J), U);
                                      	else
                                      		tmp = Float64(Float64(t_0 * J) * cos(Float64(-0.5 * K)));
                                      	end
                                      	return tmp
                                      end
                                      
                                      code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision]}, If[LessEqual[l, 400.0], N[(N[(N[(J * t$95$0), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 1.1e+100], N[(N[(N[(N[(-0.125 * l + N[(l / N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * K), $MachinePrecision] * K), $MachinePrecision] * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision], N[(N[(t$95$0 * J), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
                                      
                                      \begin{array}{l}
                                      
                                      \\
                                      \begin{array}{l}
                                      t_0 := \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\\
                                      \mathbf{if}\;\ell \leq 400:\\
                                      \;\;\;\;\left(J \cdot t\_0\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
                                      
                                      \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+100}:\\
                                      \;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;\left(t\_0 \cdot J\right) \cdot \cos \left(-0.5 \cdot K\right)\\
                                      
                                      
                                      \end{array}
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 3 regimes
                                      2. if l < 400

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

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

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

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

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

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

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

                                            \[\leadsto \left(J \cdot \left(\mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, \frac{1}{3}, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                          7. lower-*.f6493.4

                                            \[\leadsto \left(J \cdot \left(\mathsf{fma}\left(\color{blue}{\ell \cdot \ell}, 0.3333333333333333, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \]
                                        5. Applied rewrites93.4%

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

                                        if 400 < l < 1.1e100

                                        1. Initial program 100.0%

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

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

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

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

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

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

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

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

                                            \[\leadsto \color{blue}{\left(\ell \cdot \left(2 \cdot J\right)\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                                          8. lower-fma.f64N/A

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

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

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

                                            \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot J\right)} \cdot \ell, \cos \left(\frac{1}{2} \cdot K\right), U\right) \]
                                          12. cos-neg-revN/A

                                            \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)}, U\right) \]
                                          13. lower-cos.f64N/A

                                            \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)}, U\right) \]
                                          14. distribute-lft-neg-inN/A

                                            \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)}, U\right) \]
                                          15. lower-*.f64N/A

                                            \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)}, U\right) \]
                                          16. metadata-eval17.9

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

                                          \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \left(-0.5 \cdot K\right), U\right)} \]
                                        6. Step-by-step derivation
                                          1. Applied rewrites17.9%

                                            \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right) \cdot \ell, \color{blue}{2 \cdot J}, U\right) \]
                                          2. Taylor expanded in K around 0

                                            \[\leadsto \mathsf{fma}\left(\ell + \frac{-1}{8} \cdot \left({K}^{2} \cdot \ell\right), \color{blue}{2} \cdot J, U\right) \]
                                          3. Step-by-step derivation
                                            1. Applied rewrites36.4%

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

                                              \[\leadsto \mathsf{fma}\left({K}^{2} \cdot \left(\frac{-1}{8} \cdot \ell + \frac{\ell}{{K}^{2}}\right), 2 \cdot J, U\right) \]
                                            3. Step-by-step derivation
                                              1. Applied rewrites81.9%

                                                \[\leadsto \mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right) \]

                                              if 1.1e100 < l

                                              1. Initial program 100.0%

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

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

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

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

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

                                                \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right), \ell, U\right)} \]
                                              6. Taylor expanded in J around inf

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

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

                                                \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 400:\\ \;\;\;\;\left(J \cdot \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U\\ \mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot \cos \left(-0.5 \cdot K\right)\\ \end{array} \]
                                              10. Add Preprocessing

                                              Alternative 12: 81.0% accurate, 2.4× speedup?

                                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{+104}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell, J, U\right)\\ \mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25} \lor \neg \left(\ell \leq 400\right):\\ \;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \ell, \cos \left(-0.5 \cdot K\right), U\right)\\ \end{array} \end{array} \]
                                              (FPCore (J l K U)
                                               :precision binary64
                                               (if (<= l -5e+104)
                                                 (fma (* (fma (* l l) 0.3333333333333333 2.0) l) J U)
                                                 (if (or (<= l -7.8e+25) (not (<= l 400.0)))
                                                   (fma (* (* (fma -0.125 l (/ l (* K K))) K) K) (* 2.0 J) U)
                                                   (fma (* (+ J J) l) (cos (* -0.5 K)) U))))
                                              double code(double J, double l, double K, double U) {
                                              	double tmp;
                                              	if (l <= -5e+104) {
                                              		tmp = fma((fma((l * l), 0.3333333333333333, 2.0) * l), J, U);
                                              	} else if ((l <= -7.8e+25) || !(l <= 400.0)) {
                                              		tmp = fma(((fma(-0.125, l, (l / (K * K))) * K) * K), (2.0 * J), U);
                                              	} else {
                                              		tmp = fma(((J + J) * l), cos((-0.5 * K)), U);
                                              	}
                                              	return tmp;
                                              }
                                              
                                              function code(J, l, K, U)
                                              	tmp = 0.0
                                              	if (l <= -5e+104)
                                              		tmp = fma(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l), J, U);
                                              	elseif ((l <= -7.8e+25) || !(l <= 400.0))
                                              		tmp = fma(Float64(Float64(fma(-0.125, l, Float64(l / Float64(K * K))) * K) * K), Float64(2.0 * J), U);
                                              	else
                                              		tmp = fma(Float64(Float64(J + J) * l), cos(Float64(-0.5 * K)), U);
                                              	end
                                              	return tmp
                                              end
                                              
                                              code[J_, l_, K_, U_] := If[LessEqual[l, -5e+104], N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J + U), $MachinePrecision], If[Or[LessEqual[l, -7.8e+25], N[Not[LessEqual[l, 400.0]], $MachinePrecision]], N[(N[(N[(N[(-0.125 * l + N[(l / N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * K), $MachinePrecision] * K), $MachinePrecision] * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(J + J), $MachinePrecision] * l), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] + U), $MachinePrecision]]]
                                              
                                              \begin{array}{l}
                                              
                                              \\
                                              \begin{array}{l}
                                              \mathbf{if}\;\ell \leq -5 \cdot 10^{+104}:\\
                                              \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell, J, U\right)\\
                                              
                                              \mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25} \lor \neg \left(\ell \leq 400\right):\\
                                              \;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\
                                              
                                              \mathbf{else}:\\
                                              \;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \ell, \cos \left(-0.5 \cdot K\right), U\right)\\
                                              
                                              
                                              \end{array}
                                              \end{array}
                                              
                                              Derivation
                                              1. Split input into 3 regimes
                                              2. if l < -4.9999999999999997e104

                                                1. Initial program 100.0%

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

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

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

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

                                                    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right), \ell, U\right)} \]
                                                5. Applied rewrites90.9%

                                                  \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right), \ell, U\right)} \]
                                                6. Step-by-step derivation
                                                  1. Applied rewrites90.9%

                                                    \[\leadsto \mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \mathsf{fma}\left(J, 2, \left(0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right) \cdot J\right), \ell, U\right) \]
                                                  2. Taylor expanded in K around 0

                                                    \[\leadsto U + \color{blue}{\ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right) + 2 \cdot J\right)} \]
                                                  3. Step-by-step derivation
                                                    1. Applied rewrites87.8%

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

                                                    if -4.9999999999999997e104 < l < -7.8000000000000004e25 or 400 < l

                                                    1. Initial program 100.0%

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

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

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

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

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

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

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

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

                                                        \[\leadsto \color{blue}{\left(\ell \cdot \left(2 \cdot J\right)\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                                                      8. lower-fma.f64N/A

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

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

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

                                                        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot J\right)} \cdot \ell, \cos \left(\frac{1}{2} \cdot K\right), U\right) \]
                                                      12. cos-neg-revN/A

                                                        \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)}, U\right) \]
                                                      13. lower-cos.f64N/A

                                                        \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)}, U\right) \]
                                                      14. distribute-lft-neg-inN/A

                                                        \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)}, U\right) \]
                                                      15. lower-*.f64N/A

                                                        \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)}, U\right) \]
                                                      16. metadata-eval22.5

                                                        \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \left(\color{blue}{-0.5} \cdot K\right), U\right) \]
                                                    5. Applied rewrites22.5%

                                                      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \left(-0.5 \cdot K\right), U\right)} \]
                                                    6. Step-by-step derivation
                                                      1. Applied rewrites22.5%

                                                        \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right) \cdot \ell, \color{blue}{2 \cdot J}, U\right) \]
                                                      2. Taylor expanded in K around 0

                                                        \[\leadsto \mathsf{fma}\left(\ell + \frac{-1}{8} \cdot \left({K}^{2} \cdot \ell\right), \color{blue}{2} \cdot J, U\right) \]
                                                      3. Step-by-step derivation
                                                        1. Applied rewrites35.1%

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

                                                          \[\leadsto \mathsf{fma}\left({K}^{2} \cdot \left(\frac{-1}{8} \cdot \ell + \frac{\ell}{{K}^{2}}\right), 2 \cdot J, U\right) \]
                                                        3. Step-by-step derivation
                                                          1. Applied rewrites76.3%

                                                            \[\leadsto \mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right) \]

                                                          if -7.8000000000000004e25 < l < 400

                                                          1. Initial program 72.0%

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

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

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

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

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

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

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

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

                                                              \[\leadsto \color{blue}{\left(\ell \cdot \left(2 \cdot J\right)\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                                                            8. lower-fma.f64N/A

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

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

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

                                                              \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot J\right)} \cdot \ell, \cos \left(\frac{1}{2} \cdot K\right), U\right) \]
                                                            12. cos-neg-revN/A

                                                              \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)}, U\right) \]
                                                            13. lower-cos.f64N/A

                                                              \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)}, U\right) \]
                                                            14. distribute-lft-neg-inN/A

                                                              \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)}, U\right) \]
                                                            15. lower-*.f64N/A

                                                              \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)}, U\right) \]
                                                            16. metadata-eval97.0

                                                              \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \left(\color{blue}{-0.5} \cdot K\right), U\right) \]
                                                          5. Applied rewrites97.0%

                                                            \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \left(-0.5 \cdot K\right), U\right)} \]
                                                          6. Step-by-step derivation
                                                            1. Applied rewrites97.0%

                                                              \[\leadsto \mathsf{fma}\left(\left(J + J\right) \cdot \ell, \cos \left(\color{blue}{-0.5} \cdot K\right), U\right) \]
                                                          7. Recombined 3 regimes into one program.
                                                          8. Final simplification89.1%

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

                                                          Alternative 13: 74.1% accurate, 5.3× speedup?

                                                          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\\ \mathbf{if}\;\ell \leq -5 \cdot 10^{+104}:\\ \;\;\;\;\mathsf{fma}\left(t\_0 \cdot \ell, J, U\right)\\ \mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25} \lor \neg \left(\ell \leq 400\right):\\ \;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t\_0 \cdot J, \ell, U\right)\\ \end{array} \end{array} \]
                                                          (FPCore (J l K U)
                                                           :precision binary64
                                                           (let* ((t_0 (fma (* l l) 0.3333333333333333 2.0)))
                                                             (if (<= l -5e+104)
                                                               (fma (* t_0 l) J U)
                                                               (if (or (<= l -7.8e+25) (not (<= l 400.0)))
                                                                 (fma (* (* (fma -0.125 l (/ l (* K K))) K) K) (* 2.0 J) U)
                                                                 (fma (* t_0 J) l U)))))
                                                          double code(double J, double l, double K, double U) {
                                                          	double t_0 = fma((l * l), 0.3333333333333333, 2.0);
                                                          	double tmp;
                                                          	if (l <= -5e+104) {
                                                          		tmp = fma((t_0 * l), J, U);
                                                          	} else if ((l <= -7.8e+25) || !(l <= 400.0)) {
                                                          		tmp = fma(((fma(-0.125, l, (l / (K * K))) * K) * K), (2.0 * J), U);
                                                          	} else {
                                                          		tmp = fma((t_0 * J), l, U);
                                                          	}
                                                          	return tmp;
                                                          }
                                                          
                                                          function code(J, l, K, U)
                                                          	t_0 = fma(Float64(l * l), 0.3333333333333333, 2.0)
                                                          	tmp = 0.0
                                                          	if (l <= -5e+104)
                                                          		tmp = fma(Float64(t_0 * l), J, U);
                                                          	elseif ((l <= -7.8e+25) || !(l <= 400.0))
                                                          		tmp = fma(Float64(Float64(fma(-0.125, l, Float64(l / Float64(K * K))) * K) * K), Float64(2.0 * J), U);
                                                          	else
                                                          		tmp = fma(Float64(t_0 * J), l, U);
                                                          	end
                                                          	return tmp
                                                          end
                                                          
                                                          code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision]}, If[LessEqual[l, -5e+104], N[(N[(t$95$0 * l), $MachinePrecision] * J + U), $MachinePrecision], If[Or[LessEqual[l, -7.8e+25], N[Not[LessEqual[l, 400.0]], $MachinePrecision]], N[(N[(N[(N[(-0.125 * l + N[(l / N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * K), $MachinePrecision] * K), $MachinePrecision] * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision], N[(N[(t$95$0 * J), $MachinePrecision] * l + U), $MachinePrecision]]]]
                                                          
                                                          \begin{array}{l}
                                                          
                                                          \\
                                                          \begin{array}{l}
                                                          t_0 := \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\\
                                                          \mathbf{if}\;\ell \leq -5 \cdot 10^{+104}:\\
                                                          \;\;\;\;\mathsf{fma}\left(t\_0 \cdot \ell, J, U\right)\\
                                                          
                                                          \mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25} \lor \neg \left(\ell \leq 400\right):\\
                                                          \;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\
                                                          
                                                          \mathbf{else}:\\
                                                          \;\;\;\;\mathsf{fma}\left(t\_0 \cdot J, \ell, U\right)\\
                                                          
                                                          
                                                          \end{array}
                                                          \end{array}
                                                          
                                                          Derivation
                                                          1. Split input into 3 regimes
                                                          2. if l < -4.9999999999999997e104

                                                            1. Initial program 100.0%

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

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

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

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

                                                                \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right), \ell, U\right)} \]
                                                            5. Applied rewrites90.9%

                                                              \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right), \ell, U\right)} \]
                                                            6. Step-by-step derivation
                                                              1. Applied rewrites90.9%

                                                                \[\leadsto \mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \mathsf{fma}\left(J, 2, \left(0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right) \cdot J\right), \ell, U\right) \]
                                                              2. Taylor expanded in K around 0

                                                                \[\leadsto U + \color{blue}{\ell \cdot \left(\frac{1}{3} \cdot \left(J \cdot {\ell}^{2}\right) + 2 \cdot J\right)} \]
                                                              3. Step-by-step derivation
                                                                1. Applied rewrites87.8%

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

                                                                if -4.9999999999999997e104 < l < -7.8000000000000004e25 or 400 < l

                                                                1. Initial program 100.0%

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

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

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

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

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

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

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

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

                                                                    \[\leadsto \color{blue}{\left(\ell \cdot \left(2 \cdot J\right)\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                                                                  8. lower-fma.f64N/A

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

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

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

                                                                    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot J\right)} \cdot \ell, \cos \left(\frac{1}{2} \cdot K\right), U\right) \]
                                                                  12. cos-neg-revN/A

                                                                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)}, U\right) \]
                                                                  13. lower-cos.f64N/A

                                                                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)}, U\right) \]
                                                                  14. distribute-lft-neg-inN/A

                                                                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)}, U\right) \]
                                                                  15. lower-*.f64N/A

                                                                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)}, U\right) \]
                                                                  16. metadata-eval22.5

                                                                    \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \left(\color{blue}{-0.5} \cdot K\right), U\right) \]
                                                                5. Applied rewrites22.5%

                                                                  \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \left(-0.5 \cdot K\right), U\right)} \]
                                                                6. Step-by-step derivation
                                                                  1. Applied rewrites22.5%

                                                                    \[\leadsto \mathsf{fma}\left(\cos \left(0.5 \cdot K\right) \cdot \ell, \color{blue}{2 \cdot J}, U\right) \]
                                                                  2. Taylor expanded in K around 0

                                                                    \[\leadsto \mathsf{fma}\left(\ell + \frac{-1}{8} \cdot \left({K}^{2} \cdot \ell\right), \color{blue}{2} \cdot J, U\right) \]
                                                                  3. Step-by-step derivation
                                                                    1. Applied rewrites35.1%

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

                                                                      \[\leadsto \mathsf{fma}\left({K}^{2} \cdot \left(\frac{-1}{8} \cdot \ell + \frac{\ell}{{K}^{2}}\right), 2 \cdot J, U\right) \]
                                                                    3. Step-by-step derivation
                                                                      1. Applied rewrites76.3%

                                                                        \[\leadsto \mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right) \]

                                                                      if -7.8000000000000004e25 < l < 400

                                                                      1. Initial program 72.0%

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

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

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

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

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

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

                                                                        \[\leadsto U + \color{blue}{J \cdot \left(\ell \cdot \left(2 + \frac{1}{3} \cdot {\ell}^{2}\right)\right)} \]
                                                                      7. Step-by-step derivation
                                                                        1. Applied rewrites81.9%

                                                                          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot J, \color{blue}{\ell}, U\right) \]
                                                                      8. Recombined 3 regimes into one program.
                                                                      9. Final simplification81.1%

                                                                        \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{+104}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell, J, U\right)\\ \mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25} \lor \neg \left(\ell \leq 400\right):\\ \;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot J, \ell, U\right)\\ \end{array} \]
                                                                      10. Add Preprocessing

                                                                      Alternative 14: 71.6% accurate, 14.3× speedup?

                                                                      \[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell, J, U\right) \end{array} \]
                                                                      (FPCore (J l K U)
                                                                       :precision binary64
                                                                       (fma (* (fma (* l l) 0.3333333333333333 2.0) l) J U))
                                                                      double code(double J, double l, double K, double U) {
                                                                      	return fma((fma((l * l), 0.3333333333333333, 2.0) * l), J, U);
                                                                      }
                                                                      
                                                                      function code(J, l, K, U)
                                                                      	return fma(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l), J, U)
                                                                      end
                                                                      
                                                                      code[J_, l_, K_, U_] := N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J + U), $MachinePrecision]
                                                                      
                                                                      \begin{array}{l}
                                                                      
                                                                      \\
                                                                      \mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell, J, U\right)
                                                                      \end{array}
                                                                      
                                                                      Derivation
                                                                      1. Initial program 85.1%

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

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

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

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

                                                                          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right), \ell, U\right)} \]
                                                                      5. Applied rewrites85.7%

                                                                        \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right), \ell, U\right)} \]
                                                                      6. Step-by-step derivation
                                                                        1. Applied rewrites85.7%

                                                                          \[\leadsto \mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \mathsf{fma}\left(J, 2, \left(0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right) \cdot J\right), \ell, U\right) \]
                                                                        2. Taylor expanded in K around 0

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

                                                                            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell, \color{blue}{J}, U\right) \]
                                                                          2. Add Preprocessing

                                                                          Alternative 15: 69.2% accurate, 14.3× speedup?

                                                                          \[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot J, \ell, U\right) \end{array} \]
                                                                          (FPCore (J l K U)
                                                                           :precision binary64
                                                                           (fma (* (fma (* l l) 0.3333333333333333 2.0) J) l U))
                                                                          double code(double J, double l, double K, double U) {
                                                                          	return fma((fma((l * l), 0.3333333333333333, 2.0) * J), l, U);
                                                                          }
                                                                          
                                                                          function code(J, l, K, U)
                                                                          	return fma(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * J), l, U)
                                                                          end
                                                                          
                                                                          code[J_, l_, K_, U_] := N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * J), $MachinePrecision] * l + U), $MachinePrecision]
                                                                          
                                                                          \begin{array}{l}
                                                                          
                                                                          \\
                                                                          \mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot J, \ell, U\right)
                                                                          \end{array}
                                                                          
                                                                          Derivation
                                                                          1. Initial program 85.1%

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

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

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

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

                                                                              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{3} \cdot \left(J \cdot \left({\ell}^{2} \cdot \cos \left(\frac{1}{2} \cdot K\right)\right)\right) + 2 \cdot \left(J \cdot \cos \left(\frac{1}{2} \cdot K\right)\right), \ell, U\right)} \]
                                                                          5. Applied rewrites85.7%

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

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

                                                                              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot J, \color{blue}{\ell}, U\right) \]
                                                                            2. Final simplification71.1%

                                                                              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot J, \ell, U\right) \]
                                                                            3. Add Preprocessing

                                                                            Alternative 16: 54.4% accurate, 33.0× speedup?

                                                                            \[\begin{array}{l} \\ \mathsf{fma}\left(\ell + \ell, J, U\right) \end{array} \]
                                                                            (FPCore (J l K U) :precision binary64 (fma (+ l l) J U))
                                                                            double code(double J, double l, double K, double U) {
                                                                            	return fma((l + l), J, U);
                                                                            }
                                                                            
                                                                            function code(J, l, K, U)
                                                                            	return fma(Float64(l + l), J, U)
                                                                            end
                                                                            
                                                                            code[J_, l_, K_, U_] := N[(N[(l + l), $MachinePrecision] * J + U), $MachinePrecision]
                                                                            
                                                                            \begin{array}{l}
                                                                            
                                                                            \\
                                                                            \mathsf{fma}\left(\ell + \ell, J, U\right)
                                                                            \end{array}
                                                                            
                                                                            Derivation
                                                                            1. Initial program 85.1%

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

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

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

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

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

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

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

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

                                                                                \[\leadsto \color{blue}{\left(\ell \cdot \left(2 \cdot J\right)\right) \cdot \cos \left(\frac{1}{2} \cdot K\right)} + U \]
                                                                              8. lower-fma.f64N/A

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

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

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

                                                                                \[\leadsto \mathsf{fma}\left(\color{blue}{\left(2 \cdot J\right)} \cdot \ell, \cos \left(\frac{1}{2} \cdot K\right), U\right) \]
                                                                              12. cos-neg-revN/A

                                                                                \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)}, U\right) \]
                                                                              13. lower-cos.f64N/A

                                                                                \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \color{blue}{\cos \left(\mathsf{neg}\left(\frac{1}{2} \cdot K\right)\right)}, U\right) \]
                                                                              14. distribute-lft-neg-inN/A

                                                                                \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)}, U\right) \]
                                                                              15. lower-*.f64N/A

                                                                                \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot K\right)}, U\right) \]
                                                                              16. metadata-eval63.1

                                                                                \[\leadsto \mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \left(\color{blue}{-0.5} \cdot K\right), U\right) \]
                                                                            5. Applied rewrites63.1%

                                                                              \[\leadsto \color{blue}{\mathsf{fma}\left(\left(2 \cdot J\right) \cdot \ell, \cos \left(-0.5 \cdot K\right), U\right)} \]
                                                                            6. Taylor expanded in K around 0

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

                                                                                \[\leadsto \mathsf{fma}\left(2 \cdot \ell, \color{blue}{J}, U\right) \]
                                                                              2. Step-by-step derivation
                                                                                1. Applied rewrites53.6%

                                                                                  \[\leadsto \mathsf{fma}\left(\ell + \ell, J, U\right) \]
                                                                                2. Add Preprocessing

                                                                                Reproduce

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