Toniolo and Linder, Equation (10+)

Percentage Accurate: 54.9% → 90.6%
Time: 8.8s
Alternatives: 6
Speedup: N/A×

Specification

?
\[\begin{array}{l} \\ \frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) + 1\right)} \end{array} \]
(FPCore (t l k)
 :precision binary64
 (/
  2.0
  (*
   (* (* (/ (pow t 3.0) (* l l)) (sin k)) (tan k))
   (+ (+ 1.0 (pow (/ k t) 2.0)) 1.0))))
double code(double t, double l, double k) {
	return 2.0 / ((((pow(t, 3.0) / (l * l)) * sin(k)) * tan(k)) * ((1.0 + pow((k / t), 2.0)) + 1.0));
}
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(t, l, k)
use fmin_fmax_functions
    real(8), intent (in) :: t
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    code = 2.0d0 / (((((t ** 3.0d0) / (l * l)) * sin(k)) * tan(k)) * ((1.0d0 + ((k / t) ** 2.0d0)) + 1.0d0))
end function
public static double code(double t, double l, double k) {
	return 2.0 / ((((Math.pow(t, 3.0) / (l * l)) * Math.sin(k)) * Math.tan(k)) * ((1.0 + Math.pow((k / t), 2.0)) + 1.0));
}
def code(t, l, k):
	return 2.0 / ((((math.pow(t, 3.0) / (l * l)) * math.sin(k)) * math.tan(k)) * ((1.0 + math.pow((k / t), 2.0)) + 1.0))
function code(t, l, k)
	return Float64(2.0 / Float64(Float64(Float64(Float64((t ^ 3.0) / Float64(l * l)) * sin(k)) * tan(k)) * Float64(Float64(1.0 + (Float64(k / t) ^ 2.0)) + 1.0)))
end
function tmp = code(t, l, k)
	tmp = 2.0 / (((((t ^ 3.0) / (l * l)) * sin(k)) * tan(k)) * ((1.0 + ((k / t) ^ 2.0)) + 1.0));
end
code[t_, l_, k_] := N[(2.0 / N[(N[(N[(N[(N[Power[t, 3.0], $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision] * N[Sin[k], $MachinePrecision]), $MachinePrecision] * N[Tan[k], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 + N[Power[N[(k / t), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) + 1\right)}
\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 6 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: 54.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) + 1\right)} \end{array} \]
(FPCore (t l k)
 :precision binary64
 (/
  2.0
  (*
   (* (* (/ (pow t 3.0) (* l l)) (sin k)) (tan k))
   (+ (+ 1.0 (pow (/ k t) 2.0)) 1.0))))
double code(double t, double l, double k) {
	return 2.0 / ((((pow(t, 3.0) / (l * l)) * sin(k)) * tan(k)) * ((1.0 + pow((k / t), 2.0)) + 1.0));
}
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(t, l, k)
use fmin_fmax_functions
    real(8), intent (in) :: t
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    code = 2.0d0 / (((((t ** 3.0d0) / (l * l)) * sin(k)) * tan(k)) * ((1.0d0 + ((k / t) ** 2.0d0)) + 1.0d0))
end function
public static double code(double t, double l, double k) {
	return 2.0 / ((((Math.pow(t, 3.0) / (l * l)) * Math.sin(k)) * Math.tan(k)) * ((1.0 + Math.pow((k / t), 2.0)) + 1.0));
}
def code(t, l, k):
	return 2.0 / ((((math.pow(t, 3.0) / (l * l)) * math.sin(k)) * math.tan(k)) * ((1.0 + math.pow((k / t), 2.0)) + 1.0))
function code(t, l, k)
	return Float64(2.0 / Float64(Float64(Float64(Float64((t ^ 3.0) / Float64(l * l)) * sin(k)) * tan(k)) * Float64(Float64(1.0 + (Float64(k / t) ^ 2.0)) + 1.0)))
end
function tmp = code(t, l, k)
	tmp = 2.0 / (((((t ^ 3.0) / (l * l)) * sin(k)) * tan(k)) * ((1.0 + ((k / t) ^ 2.0)) + 1.0));
end
code[t_, l_, k_] := N[(2.0 / N[(N[(N[(N[(N[Power[t, 3.0], $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision] * N[Sin[k], $MachinePrecision]), $MachinePrecision] * N[Tan[k], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 + N[Power[N[(k / t), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) + 1\right)}
\end{array}

Alternative 1: 90.6% accurate, N/A× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ \begin{array}{l} t_1 := \frac{{\sin k\_m}^{2}}{\cos k\_m}\\ \mathbf{if}\;k\_m \leq 1.45 \cdot 10^{+142}:\\ \;\;\;\;\frac{2}{\frac{\mathsf{fma}\left(k\_m \cdot k\_m, t\_1, {\left(\sin k\_m \cdot t\right)}^{2} \cdot \frac{2}{\cos k\_m}\right)}{\ell} \cdot \frac{t}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{\left(t\_1 \cdot \left(\frac{k\_m}{\ell} \cdot \frac{k\_m}{\ell}\right)\right) \cdot t}\\ \end{array} \end{array} \]
k_m = (fabs.f64 k)
(FPCore (t l k_m)
 :precision binary64
 (let* ((t_1 (/ (pow (sin k_m) 2.0) (cos k_m))))
   (if (<= k_m 1.45e+142)
     (/
      2.0
      (*
       (/
        (fma (* k_m k_m) t_1 (* (pow (* (sin k_m) t) 2.0) (/ 2.0 (cos k_m))))
        l)
       (/ t l)))
     (/ 2.0 (* (* t_1 (* (/ k_m l) (/ k_m l))) t)))))
k_m = fabs(k);
double code(double t, double l, double k_m) {
	double t_1 = pow(sin(k_m), 2.0) / cos(k_m);
	double tmp;
	if (k_m <= 1.45e+142) {
		tmp = 2.0 / ((fma((k_m * k_m), t_1, (pow((sin(k_m) * t), 2.0) * (2.0 / cos(k_m)))) / l) * (t / l));
	} else {
		tmp = 2.0 / ((t_1 * ((k_m / l) * (k_m / l))) * t);
	}
	return tmp;
}
k_m = abs(k)
function code(t, l, k_m)
	t_1 = Float64((sin(k_m) ^ 2.0) / cos(k_m))
	tmp = 0.0
	if (k_m <= 1.45e+142)
		tmp = Float64(2.0 / Float64(Float64(fma(Float64(k_m * k_m), t_1, Float64((Float64(sin(k_m) * t) ^ 2.0) * Float64(2.0 / cos(k_m)))) / l) * Float64(t / l)));
	else
		tmp = Float64(2.0 / Float64(Float64(t_1 * Float64(Float64(k_m / l) * Float64(k_m / l))) * t));
	end
	return tmp
end
k_m = N[Abs[k], $MachinePrecision]
code[t_, l_, k$95$m_] := Block[{t$95$1 = N[(N[Power[N[Sin[k$95$m], $MachinePrecision], 2.0], $MachinePrecision] / N[Cos[k$95$m], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[k$95$m, 1.45e+142], N[(2.0 / N[(N[(N[(N[(k$95$m * k$95$m), $MachinePrecision] * t$95$1 + N[(N[Power[N[(N[Sin[k$95$m], $MachinePrecision] * t), $MachinePrecision], 2.0], $MachinePrecision] * N[(2.0 / N[Cos[k$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(t / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(t$95$1 * N[(N[(k$95$m / l), $MachinePrecision] * N[(k$95$m / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
k_m = \left|k\right|

\\
\begin{array}{l}
t_1 := \frac{{\sin k\_m}^{2}}{\cos k\_m}\\
\mathbf{if}\;k\_m \leq 1.45 \cdot 10^{+142}:\\
\;\;\;\;\frac{2}{\frac{\mathsf{fma}\left(k\_m \cdot k\_m, t\_1, {\left(\sin k\_m \cdot t\right)}^{2} \cdot \frac{2}{\cos k\_m}\right)}{\ell} \cdot \frac{t}{\ell}}\\

\mathbf{else}:\\
\;\;\;\;\frac{2}{\left(t\_1 \cdot \left(\frac{k\_m}{\ell} \cdot \frac{k\_m}{\ell}\right)\right) \cdot t}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 1.45000000000000007e142

    1. Initial program 56.1%

      \[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) + 1\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in t around 0

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

        \[\leadsto \frac{2}{\left(2 \cdot \frac{{t}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k} + \frac{{k}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k}\right) \cdot \color{blue}{t}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{2}{\left(2 \cdot \frac{{t}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k} + \frac{{k}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k}\right) \cdot \color{blue}{t}} \]
    5. Applied rewrites77.5%

      \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(\frac{k \cdot k}{\ell \cdot \ell}, \frac{{\sin k}^{2}}{\cos k}, \frac{\mathsf{fma}\left({\left(t \cdot \sin k\right)}^{1}, {\left(t \cdot \sin k\right)}^{1}, {\left(t \cdot \sin k\right)}^{1} \cdot {\left(t \cdot \sin k\right)}^{1}\right)}{\cos k \cdot \left(\ell \cdot \ell\right)}\right) \cdot t}} \]
    6. Applied rewrites78.0%

      \[\leadsto \frac{2}{\frac{\mathsf{fma}\left(k \cdot k, \frac{{\sin k}^{2}}{\cos k}, \frac{{\left(\sin k \cdot t\right)}^{2} \cdot 2}{\cos k}\right) \cdot t}{\color{blue}{\ell \cdot \ell}}} \]
    7. Applied rewrites88.6%

      \[\leadsto \frac{2}{\frac{\mathsf{fma}\left(k \cdot k, \frac{{\sin k}^{2}}{\cos k}, {\left(\sin k \cdot t\right)}^{2} \cdot \frac{2}{\cos k}\right)}{\ell} \cdot \color{blue}{\frac{t}{\ell}}} \]

    if 1.45000000000000007e142 < k

    1. Initial program 52.6%

      \[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) + 1\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in t around 0

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

        \[\leadsto \frac{2}{\left(2 \cdot \frac{{t}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k} + \frac{{k}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k}\right) \cdot \color{blue}{t}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{2}{\left(2 \cdot \frac{{t}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k} + \frac{{k}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k}\right) \cdot \color{blue}{t}} \]
    5. Applied rewrites63.4%

      \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(\frac{k \cdot k}{\ell \cdot \ell}, \frac{{\sin k}^{2}}{\cos k}, \frac{\mathsf{fma}\left({\left(t \cdot \sin k\right)}^{1}, {\left(t \cdot \sin k\right)}^{1}, {\left(t \cdot \sin k\right)}^{1} \cdot {\left(t \cdot \sin k\right)}^{1}\right)}{\cos k \cdot \left(\ell \cdot \ell\right)}\right) \cdot t}} \]
    6. Taylor expanded in t around 0

      \[\leadsto \frac{2}{\frac{{k}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k} \cdot t} \]
    7. Step-by-step derivation
      1. frac-timesN/A

        \[\leadsto \frac{2}{\left(\frac{{k}^{2}}{{\ell}^{2}} \cdot \frac{{\sin k}^{2}}{\cos k}\right) \cdot t} \]
      2. pow2N/A

        \[\leadsto \frac{2}{\left(\frac{k \cdot k}{{\ell}^{2}} \cdot \frac{{\sin k}^{2}}{\cos k}\right) \cdot t} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{2}{\left(\frac{k \cdot k}{{\ell}^{2}} \cdot \frac{{\sin k}^{2}}{\cos k}\right) \cdot t} \]
      4. pow2N/A

        \[\leadsto \frac{2}{\left(\frac{k \cdot k}{\ell \cdot \ell} \cdot \frac{{\sin k}^{2}}{\cos k}\right) \cdot t} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{2}{\left(\frac{k \cdot k}{\ell \cdot \ell} \cdot \frac{{\sin k}^{2}}{\cos k}\right) \cdot t} \]
      6. lift-/.f64N/A

        \[\leadsto \frac{2}{\left(\frac{k \cdot k}{\ell \cdot \ell} \cdot \frac{{\sin k}^{2}}{\cos k}\right) \cdot t} \]
      7. *-commutativeN/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      10. lift-pow.f64N/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      11. lift-cos.f64N/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      12. lift-/.f6471.3

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      13. lift-/.f64N/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      15. lift-*.f64N/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      16. times-fracN/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \left(\frac{k}{\ell} \cdot \frac{k}{\ell}\right)\right) \cdot t} \]
    8. Applied rewrites92.2%

      \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \left(\frac{k}{\ell} \cdot \frac{k}{\ell}\right)\right) \cdot t} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 83.7% accurate, N/A× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ \begin{array}{l} t_1 := {\sin k\_m}^{2}\\ t_2 := \frac{t\_1}{\cos k\_m}\\ \mathbf{if}\;k\_m \leq 1.45 \cdot 10^{+142}:\\ \;\;\;\;\frac{2}{\frac{\mathsf{fma}\left(k\_m \cdot k\_m, t\_2, \left(t \cdot \left(t \cdot t\_1\right)\right) \cdot \frac{2}{\cos k\_m}\right)}{\ell} \cdot \frac{t}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{\left(t\_2 \cdot \left(\frac{k\_m}{\ell} \cdot \frac{k\_m}{\ell}\right)\right) \cdot t}\\ \end{array} \end{array} \]
k_m = (fabs.f64 k)
(FPCore (t l k_m)
 :precision binary64
 (let* ((t_1 (pow (sin k_m) 2.0)) (t_2 (/ t_1 (cos k_m))))
   (if (<= k_m 1.45e+142)
     (/
      2.0
      (*
       (/ (fma (* k_m k_m) t_2 (* (* t (* t t_1)) (/ 2.0 (cos k_m)))) l)
       (/ t l)))
     (/ 2.0 (* (* t_2 (* (/ k_m l) (/ k_m l))) t)))))
k_m = fabs(k);
double code(double t, double l, double k_m) {
	double t_1 = pow(sin(k_m), 2.0);
	double t_2 = t_1 / cos(k_m);
	double tmp;
	if (k_m <= 1.45e+142) {
		tmp = 2.0 / ((fma((k_m * k_m), t_2, ((t * (t * t_1)) * (2.0 / cos(k_m)))) / l) * (t / l));
	} else {
		tmp = 2.0 / ((t_2 * ((k_m / l) * (k_m / l))) * t);
	}
	return tmp;
}
k_m = abs(k)
function code(t, l, k_m)
	t_1 = sin(k_m) ^ 2.0
	t_2 = Float64(t_1 / cos(k_m))
	tmp = 0.0
	if (k_m <= 1.45e+142)
		tmp = Float64(2.0 / Float64(Float64(fma(Float64(k_m * k_m), t_2, Float64(Float64(t * Float64(t * t_1)) * Float64(2.0 / cos(k_m)))) / l) * Float64(t / l)));
	else
		tmp = Float64(2.0 / Float64(Float64(t_2 * Float64(Float64(k_m / l) * Float64(k_m / l))) * t));
	end
	return tmp
end
k_m = N[Abs[k], $MachinePrecision]
code[t_, l_, k$95$m_] := Block[{t$95$1 = N[Power[N[Sin[k$95$m], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[Cos[k$95$m], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[k$95$m, 1.45e+142], N[(2.0 / N[(N[(N[(N[(k$95$m * k$95$m), $MachinePrecision] * t$95$2 + N[(N[(t * N[(t * t$95$1), $MachinePrecision]), $MachinePrecision] * N[(2.0 / N[Cos[k$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(t / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(t$95$2 * N[(N[(k$95$m / l), $MachinePrecision] * N[(k$95$m / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
k_m = \left|k\right|

\\
\begin{array}{l}
t_1 := {\sin k\_m}^{2}\\
t_2 := \frac{t\_1}{\cos k\_m}\\
\mathbf{if}\;k\_m \leq 1.45 \cdot 10^{+142}:\\
\;\;\;\;\frac{2}{\frac{\mathsf{fma}\left(k\_m \cdot k\_m, t\_2, \left(t \cdot \left(t \cdot t\_1\right)\right) \cdot \frac{2}{\cos k\_m}\right)}{\ell} \cdot \frac{t}{\ell}}\\

\mathbf{else}:\\
\;\;\;\;\frac{2}{\left(t\_2 \cdot \left(\frac{k\_m}{\ell} \cdot \frac{k\_m}{\ell}\right)\right) \cdot t}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 1.45000000000000007e142

    1. Initial program 56.1%

      \[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) + 1\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in t around 0

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

        \[\leadsto \frac{2}{\left(2 \cdot \frac{{t}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k} + \frac{{k}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k}\right) \cdot \color{blue}{t}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{2}{\left(2 \cdot \frac{{t}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k} + \frac{{k}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k}\right) \cdot \color{blue}{t}} \]
    5. Applied rewrites77.5%

      \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(\frac{k \cdot k}{\ell \cdot \ell}, \frac{{\sin k}^{2}}{\cos k}, \frac{\mathsf{fma}\left({\left(t \cdot \sin k\right)}^{1}, {\left(t \cdot \sin k\right)}^{1}, {\left(t \cdot \sin k\right)}^{1} \cdot {\left(t \cdot \sin k\right)}^{1}\right)}{\cos k \cdot \left(\ell \cdot \ell\right)}\right) \cdot t}} \]
    6. Applied rewrites78.0%

      \[\leadsto \frac{2}{\frac{\mathsf{fma}\left(k \cdot k, \frac{{\sin k}^{2}}{\cos k}, \frac{{\left(\sin k \cdot t\right)}^{2} \cdot 2}{\cos k}\right) \cdot t}{\color{blue}{\ell \cdot \ell}}} \]
    7. Applied rewrites88.6%

      \[\leadsto \frac{2}{\frac{\mathsf{fma}\left(k \cdot k, \frac{{\sin k}^{2}}{\cos k}, {\left(\sin k \cdot t\right)}^{2} \cdot \frac{2}{\cos k}\right)}{\ell} \cdot \color{blue}{\frac{t}{\ell}}} \]
    8. Taylor expanded in t around 0

      \[\leadsto \frac{2}{\frac{\mathsf{fma}\left(k \cdot k, \frac{{\sin k}^{2}}{\cos k}, \left({t}^{2} \cdot {\sin k}^{2}\right) \cdot \frac{2}{\cos k}\right)}{\ell} \cdot \frac{t}{\ell}} \]
    9. Step-by-step derivation
      1. pow2N/A

        \[\leadsto \frac{2}{\frac{\mathsf{fma}\left(k \cdot k, \frac{{\sin k}^{2}}{\cos k}, \left(\left(t \cdot t\right) \cdot {\sin k}^{2}\right) \cdot \frac{2}{\cos k}\right)}{\ell} \cdot \frac{t}{\ell}} \]
      2. associate-*l*N/A

        \[\leadsto \frac{2}{\frac{\mathsf{fma}\left(k \cdot k, \frac{{\sin k}^{2}}{\cos k}, \left(t \cdot \left(t \cdot {\sin k}^{2}\right)\right) \cdot \frac{2}{\cos k}\right)}{\ell} \cdot \frac{t}{\ell}} \]
      3. lower-*.f64N/A

        \[\leadsto \frac{2}{\frac{\mathsf{fma}\left(k \cdot k, \frac{{\sin k}^{2}}{\cos k}, \left(t \cdot \left(t \cdot {\sin k}^{2}\right)\right) \cdot \frac{2}{\cos k}\right)}{\ell} \cdot \frac{t}{\ell}} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{2}{\frac{\mathsf{fma}\left(k \cdot k, \frac{{\sin k}^{2}}{\cos k}, \left(t \cdot \left(t \cdot {\sin k}^{2}\right)\right) \cdot \frac{2}{\cos k}\right)}{\ell} \cdot \frac{t}{\ell}} \]
      5. lift-sin.f64N/A

        \[\leadsto \frac{2}{\frac{\mathsf{fma}\left(k \cdot k, \frac{{\sin k}^{2}}{\cos k}, \left(t \cdot \left(t \cdot {\sin k}^{2}\right)\right) \cdot \frac{2}{\cos k}\right)}{\ell} \cdot \frac{t}{\ell}} \]
      6. lift-pow.f6483.0

        \[\leadsto \frac{2}{\frac{\mathsf{fma}\left(k \cdot k, \frac{{\sin k}^{2}}{\cos k}, \left(t \cdot \left(t \cdot {\sin k}^{2}\right)\right) \cdot \frac{2}{\cos k}\right)}{\ell} \cdot \frac{t}{\ell}} \]
    10. Applied rewrites83.0%

      \[\leadsto \frac{2}{\frac{\mathsf{fma}\left(k \cdot k, \frac{{\sin k}^{2}}{\cos k}, \left(t \cdot \left(t \cdot {\sin k}^{2}\right)\right) \cdot \frac{2}{\cos k}\right)}{\ell} \cdot \frac{t}{\ell}} \]

    if 1.45000000000000007e142 < k

    1. Initial program 52.6%

      \[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) + 1\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in t around 0

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

        \[\leadsto \frac{2}{\left(2 \cdot \frac{{t}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k} + \frac{{k}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k}\right) \cdot \color{blue}{t}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{2}{\left(2 \cdot \frac{{t}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k} + \frac{{k}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k}\right) \cdot \color{blue}{t}} \]
    5. Applied rewrites63.4%

      \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(\frac{k \cdot k}{\ell \cdot \ell}, \frac{{\sin k}^{2}}{\cos k}, \frac{\mathsf{fma}\left({\left(t \cdot \sin k\right)}^{1}, {\left(t \cdot \sin k\right)}^{1}, {\left(t \cdot \sin k\right)}^{1} \cdot {\left(t \cdot \sin k\right)}^{1}\right)}{\cos k \cdot \left(\ell \cdot \ell\right)}\right) \cdot t}} \]
    6. Taylor expanded in t around 0

      \[\leadsto \frac{2}{\frac{{k}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k} \cdot t} \]
    7. Step-by-step derivation
      1. frac-timesN/A

        \[\leadsto \frac{2}{\left(\frac{{k}^{2}}{{\ell}^{2}} \cdot \frac{{\sin k}^{2}}{\cos k}\right) \cdot t} \]
      2. pow2N/A

        \[\leadsto \frac{2}{\left(\frac{k \cdot k}{{\ell}^{2}} \cdot \frac{{\sin k}^{2}}{\cos k}\right) \cdot t} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{2}{\left(\frac{k \cdot k}{{\ell}^{2}} \cdot \frac{{\sin k}^{2}}{\cos k}\right) \cdot t} \]
      4. pow2N/A

        \[\leadsto \frac{2}{\left(\frac{k \cdot k}{\ell \cdot \ell} \cdot \frac{{\sin k}^{2}}{\cos k}\right) \cdot t} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{2}{\left(\frac{k \cdot k}{\ell \cdot \ell} \cdot \frac{{\sin k}^{2}}{\cos k}\right) \cdot t} \]
      6. lift-/.f64N/A

        \[\leadsto \frac{2}{\left(\frac{k \cdot k}{\ell \cdot \ell} \cdot \frac{{\sin k}^{2}}{\cos k}\right) \cdot t} \]
      7. *-commutativeN/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      10. lift-pow.f64N/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      11. lift-cos.f64N/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      12. lift-/.f6471.3

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      13. lift-/.f64N/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      15. lift-*.f64N/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      16. times-fracN/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \left(\frac{k}{\ell} \cdot \frac{k}{\ell}\right)\right) \cdot t} \]
    8. Applied rewrites92.2%

      \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \left(\frac{k}{\ell} \cdot \frac{k}{\ell}\right)\right) \cdot t} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 71.1% accurate, N/A× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ \begin{array}{l} t_1 := {\sin k\_m}^{2}\\ \mathbf{if}\;t \leq 6.8 \cdot 10^{+240}:\\ \;\;\;\;\frac{2}{\left(\frac{t\_1}{\cos k\_m} \cdot \left(\frac{k\_m}{\ell} \cdot \frac{k\_m}{\ell}\right)\right) \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k\_m}{t\_1}\\ \end{array} \end{array} \]
k_m = (fabs.f64 k)
(FPCore (t l k_m)
 :precision binary64
 (let* ((t_1 (pow (sin k_m) 2.0)))
   (if (<= t 6.8e+240)
     (/ 2.0 (* (* (/ t_1 (cos k_m)) (* (/ k_m l) (/ k_m l))) t))
     (* (/ (* l l) (pow t 3.0)) (/ (cos k_m) t_1)))))
k_m = fabs(k);
double code(double t, double l, double k_m) {
	double t_1 = pow(sin(k_m), 2.0);
	double tmp;
	if (t <= 6.8e+240) {
		tmp = 2.0 / (((t_1 / cos(k_m)) * ((k_m / l) * (k_m / l))) * t);
	} else {
		tmp = ((l * l) / pow(t, 3.0)) * (cos(k_m) / t_1);
	}
	return tmp;
}
k_m =     private
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(t, l, k_m)
use fmin_fmax_functions
    real(8), intent (in) :: t
    real(8), intent (in) :: l
    real(8), intent (in) :: k_m
    real(8) :: t_1
    real(8) :: tmp
    t_1 = sin(k_m) ** 2.0d0
    if (t <= 6.8d+240) then
        tmp = 2.0d0 / (((t_1 / cos(k_m)) * ((k_m / l) * (k_m / l))) * t)
    else
        tmp = ((l * l) / (t ** 3.0d0)) * (cos(k_m) / t_1)
    end if
    code = tmp
end function
k_m = Math.abs(k);
public static double code(double t, double l, double k_m) {
	double t_1 = Math.pow(Math.sin(k_m), 2.0);
	double tmp;
	if (t <= 6.8e+240) {
		tmp = 2.0 / (((t_1 / Math.cos(k_m)) * ((k_m / l) * (k_m / l))) * t);
	} else {
		tmp = ((l * l) / Math.pow(t, 3.0)) * (Math.cos(k_m) / t_1);
	}
	return tmp;
}
k_m = math.fabs(k)
def code(t, l, k_m):
	t_1 = math.pow(math.sin(k_m), 2.0)
	tmp = 0
	if t <= 6.8e+240:
		tmp = 2.0 / (((t_1 / math.cos(k_m)) * ((k_m / l) * (k_m / l))) * t)
	else:
		tmp = ((l * l) / math.pow(t, 3.0)) * (math.cos(k_m) / t_1)
	return tmp
k_m = abs(k)
function code(t, l, k_m)
	t_1 = sin(k_m) ^ 2.0
	tmp = 0.0
	if (t <= 6.8e+240)
		tmp = Float64(2.0 / Float64(Float64(Float64(t_1 / cos(k_m)) * Float64(Float64(k_m / l) * Float64(k_m / l))) * t));
	else
		tmp = Float64(Float64(Float64(l * l) / (t ^ 3.0)) * Float64(cos(k_m) / t_1));
	end
	return tmp
end
k_m = abs(k);
function tmp_2 = code(t, l, k_m)
	t_1 = sin(k_m) ^ 2.0;
	tmp = 0.0;
	if (t <= 6.8e+240)
		tmp = 2.0 / (((t_1 / cos(k_m)) * ((k_m / l) * (k_m / l))) * t);
	else
		tmp = ((l * l) / (t ^ 3.0)) * (cos(k_m) / t_1);
	end
	tmp_2 = tmp;
end
k_m = N[Abs[k], $MachinePrecision]
code[t_, l_, k$95$m_] := Block[{t$95$1 = N[Power[N[Sin[k$95$m], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t, 6.8e+240], N[(2.0 / N[(N[(N[(t$95$1 / N[Cos[k$95$m], $MachinePrecision]), $MachinePrecision] * N[(N[(k$95$m / l), $MachinePrecision] * N[(k$95$m / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], N[(N[(N[(l * l), $MachinePrecision] / N[Power[t, 3.0], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[k$95$m], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
k_m = \left|k\right|

\\
\begin{array}{l}
t_1 := {\sin k\_m}^{2}\\
\mathbf{if}\;t \leq 6.8 \cdot 10^{+240}:\\
\;\;\;\;\frac{2}{\left(\frac{t\_1}{\cos k\_m} \cdot \left(\frac{k\_m}{\ell} \cdot \frac{k\_m}{\ell}\right)\right) \cdot t}\\

\mathbf{else}:\\
\;\;\;\;\frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k\_m}{t\_1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 6.80000000000000017e240

    1. Initial program 54.5%

      \[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) + 1\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in t around 0

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

        \[\leadsto \frac{2}{\left(2 \cdot \frac{{t}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k} + \frac{{k}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k}\right) \cdot \color{blue}{t}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{2}{\left(2 \cdot \frac{{t}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k} + \frac{{k}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k}\right) \cdot \color{blue}{t}} \]
    5. Applied rewrites74.6%

      \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(\frac{k \cdot k}{\ell \cdot \ell}, \frac{{\sin k}^{2}}{\cos k}, \frac{\mathsf{fma}\left({\left(t \cdot \sin k\right)}^{1}, {\left(t \cdot \sin k\right)}^{1}, {\left(t \cdot \sin k\right)}^{1} \cdot {\left(t \cdot \sin k\right)}^{1}\right)}{\cos k \cdot \left(\ell \cdot \ell\right)}\right) \cdot t}} \]
    6. Taylor expanded in t around 0

      \[\leadsto \frac{2}{\frac{{k}^{2} \cdot {\sin k}^{2}}{{\ell}^{2} \cdot \cos k} \cdot t} \]
    7. Step-by-step derivation
      1. frac-timesN/A

        \[\leadsto \frac{2}{\left(\frac{{k}^{2}}{{\ell}^{2}} \cdot \frac{{\sin k}^{2}}{\cos k}\right) \cdot t} \]
      2. pow2N/A

        \[\leadsto \frac{2}{\left(\frac{k \cdot k}{{\ell}^{2}} \cdot \frac{{\sin k}^{2}}{\cos k}\right) \cdot t} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{2}{\left(\frac{k \cdot k}{{\ell}^{2}} \cdot \frac{{\sin k}^{2}}{\cos k}\right) \cdot t} \]
      4. pow2N/A

        \[\leadsto \frac{2}{\left(\frac{k \cdot k}{\ell \cdot \ell} \cdot \frac{{\sin k}^{2}}{\cos k}\right) \cdot t} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{2}{\left(\frac{k \cdot k}{\ell \cdot \ell} \cdot \frac{{\sin k}^{2}}{\cos k}\right) \cdot t} \]
      6. lift-/.f64N/A

        \[\leadsto \frac{2}{\left(\frac{k \cdot k}{\ell \cdot \ell} \cdot \frac{{\sin k}^{2}}{\cos k}\right) \cdot t} \]
      7. *-commutativeN/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      10. lift-pow.f64N/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      11. lift-cos.f64N/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      12. lift-/.f6465.2

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      13. lift-/.f64N/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      15. lift-*.f64N/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \frac{k \cdot k}{\ell \cdot \ell}\right) \cdot t} \]
      16. times-fracN/A

        \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \left(\frac{k}{\ell} \cdot \frac{k}{\ell}\right)\right) \cdot t} \]
    8. Applied rewrites74.8%

      \[\leadsto \frac{2}{\left(\frac{{\sin k}^{2}}{\cos k} \cdot \left(\frac{k}{\ell} \cdot \frac{k}{\ell}\right)\right) \cdot t} \]

    if 6.80000000000000017e240 < t

    1. Initial program 88.8%

      \[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) + 1\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in t around inf

      \[\leadsto \color{blue}{\frac{{\ell}^{2} \cdot \cos k}{{t}^{3} \cdot {\sin k}^{2}}} \]
    4. Step-by-step derivation
      1. times-fracN/A

        \[\leadsto \frac{{\ell}^{2}}{{t}^{3}} \cdot \color{blue}{\frac{\cos k}{{\sin k}^{2}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{{\ell}^{2}}{{t}^{3}} \cdot \color{blue}{\frac{\cos k}{{\sin k}^{2}}} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{{\ell}^{2}}{{t}^{3}} \cdot \frac{\color{blue}{\cos k}}{{\sin k}^{2}} \]
      4. pow2N/A

        \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos \color{blue}{k}}{{\sin k}^{2}} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos \color{blue}{k}}{{\sin k}^{2}} \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{{\sin k}^{2}} \]
      7. lower-/.f64N/A

        \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{\color{blue}{{\sin k}^{2}}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{{\color{blue}{\sin k}}^{2}} \]
      9. lower-pow.f64N/A

        \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{{\sin k}^{\color{blue}{2}}} \]
      10. lift-sin.f6487.5

        \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{{\sin k}^{2}} \]
    5. Applied rewrites87.5%

      \[\leadsto \color{blue}{\frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{{\sin k}^{2}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 64.4% accurate, N/A× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ \begin{array}{l} t_1 := {\sin k\_m}^{2}\\ \mathbf{if}\;t \leq 4.8 \cdot 10^{+43}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\cos k\_m, \ell \cdot \ell, \left(\cos k\_m \cdot \ell\right) \cdot \ell\right)}{\left(k\_m \cdot \left(k\_m \cdot t\right)\right) \cdot t\_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k\_m}{t\_1}\\ \end{array} \end{array} \]
k_m = (fabs.f64 k)
(FPCore (t l k_m)
 :precision binary64
 (let* ((t_1 (pow (sin k_m) 2.0)))
   (if (<= t 4.8e+43)
     (/
      (fma (cos k_m) (* l l) (* (* (cos k_m) l) l))
      (* (* k_m (* k_m t)) t_1))
     (* (/ (* l l) (pow t 3.0)) (/ (cos k_m) t_1)))))
k_m = fabs(k);
double code(double t, double l, double k_m) {
	double t_1 = pow(sin(k_m), 2.0);
	double tmp;
	if (t <= 4.8e+43) {
		tmp = fma(cos(k_m), (l * l), ((cos(k_m) * l) * l)) / ((k_m * (k_m * t)) * t_1);
	} else {
		tmp = ((l * l) / pow(t, 3.0)) * (cos(k_m) / t_1);
	}
	return tmp;
}
k_m = abs(k)
function code(t, l, k_m)
	t_1 = sin(k_m) ^ 2.0
	tmp = 0.0
	if (t <= 4.8e+43)
		tmp = Float64(fma(cos(k_m), Float64(l * l), Float64(Float64(cos(k_m) * l) * l)) / Float64(Float64(k_m * Float64(k_m * t)) * t_1));
	else
		tmp = Float64(Float64(Float64(l * l) / (t ^ 3.0)) * Float64(cos(k_m) / t_1));
	end
	return tmp
end
k_m = N[Abs[k], $MachinePrecision]
code[t_, l_, k$95$m_] := Block[{t$95$1 = N[Power[N[Sin[k$95$m], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t, 4.8e+43], N[(N[(N[Cos[k$95$m], $MachinePrecision] * N[(l * l), $MachinePrecision] + N[(N[(N[Cos[k$95$m], $MachinePrecision] * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] / N[(N[(k$95$m * N[(k$95$m * t), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(l * l), $MachinePrecision] / N[Power[t, 3.0], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[k$95$m], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
k_m = \left|k\right|

\\
\begin{array}{l}
t_1 := {\sin k\_m}^{2}\\
\mathbf{if}\;t \leq 4.8 \cdot 10^{+43}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\cos k\_m, \ell \cdot \ell, \left(\cos k\_m \cdot \ell\right) \cdot \ell\right)}{\left(k\_m \cdot \left(k\_m \cdot t\right)\right) \cdot t\_1}\\

\mathbf{else}:\\
\;\;\;\;\frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k\_m}{t\_1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 4.80000000000000046e43

    1. Initial program 53.1%

      \[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) + 1\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in t around 0

      \[\leadsto \color{blue}{2 \cdot \frac{{\ell}^{2} \cdot \cos k}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}} \]
    4. Step-by-step derivation
      1. count-2-revN/A

        \[\leadsto \frac{{\ell}^{2} \cdot \cos k}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)} + \color{blue}{\frac{{\ell}^{2} \cdot \cos k}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}} \]
      2. div-add-revN/A

        \[\leadsto \frac{{\ell}^{2} \cdot \cos k + {\ell}^{2} \cdot \cos k}{\color{blue}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{{\ell}^{2} \cdot \cos k + {\ell}^{2} \cdot \cos k}{\color{blue}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}} \]
      4. *-commutativeN/A

        \[\leadsto \frac{\cos k \cdot {\ell}^{2} + {\ell}^{2} \cdot \cos k}{{\color{blue}{k}}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)} \]
      5. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, {\ell}^{2}, {\ell}^{2} \cdot \cos k\right)}{\color{blue}{{k}^{2}} \cdot \left(t \cdot {\sin k}^{2}\right)} \]
      6. lower-cos.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, {\ell}^{2}, {\ell}^{2} \cdot \cos k\right)}{{\color{blue}{k}}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)} \]
      7. pow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, {\ell}^{2} \cdot \cos k\right)}{{k}^{\color{blue}{2}} \cdot \left(t \cdot {\sin k}^{2}\right)} \]
      8. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, {\ell}^{2} \cdot \cos k\right)}{{k}^{\color{blue}{2}} \cdot \left(t \cdot {\sin k}^{2}\right)} \]
      9. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot {\ell}^{2}\right)}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot {\ell}^{2}\right)}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)} \]
      11. lower-cos.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot {\ell}^{2}\right)}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)} \]
      12. pow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)} \]
      13. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)} \]
      14. associate-*r*N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left({k}^{2} \cdot t\right) \cdot \color{blue}{{\sin k}^{2}}} \]
      15. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left({k}^{2} \cdot t\right) \cdot \color{blue}{{\sin k}^{2}}} \]
    5. Applied rewrites68.4%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left(\left(k \cdot k\right) \cdot t\right) \cdot {\sin k}^{2}}} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left(\left(k \cdot k\right) \cdot t\right) \cdot {\color{blue}{\sin k}}^{2}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left(\left(k \cdot k\right) \cdot t\right) \cdot {\sin \color{blue}{k}}^{2}} \]
      3. associate-*l*N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left(k \cdot \left(k \cdot t\right)\right) \cdot {\color{blue}{\sin k}}^{2}} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left(k \cdot \left(k \cdot t\right)\right) \cdot {\color{blue}{\sin k}}^{2}} \]
      5. lower-*.f6471.1

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left(k \cdot \left(k \cdot t\right)\right) \cdot {\sin k}^{2}} \]
    7. Applied rewrites71.1%

      \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left(k \cdot \left(k \cdot t\right)\right) \cdot {\color{blue}{\sin k}}^{2}} \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left(k \cdot \left(k \cdot t\right)\right) \cdot {\sin k}^{2}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left(k \cdot \left(k \cdot t\right)\right) \cdot {\sin k}^{2}} \]
      3. lift-cos.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left(k \cdot \left(k \cdot t\right)\right) \cdot {\sin k}^{2}} \]
      4. associate-*r*N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \left(\cos k \cdot \ell\right) \cdot \ell\right)}{\left(k \cdot \left(k \cdot t\right)\right) \cdot {\sin k}^{2}} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \left(\cos k \cdot \ell\right) \cdot \ell\right)}{\left(k \cdot \left(k \cdot t\right)\right) \cdot {\sin k}^{2}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \left(\cos k \cdot \ell\right) \cdot \ell\right)}{\left(k \cdot \left(k \cdot t\right)\right) \cdot {\sin k}^{2}} \]
      7. lift-cos.f6471.2

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \left(\cos k \cdot \ell\right) \cdot \ell\right)}{\left(k \cdot \left(k \cdot t\right)\right) \cdot {\sin k}^{2}} \]
    9. Applied rewrites71.2%

      \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \left(\cos k \cdot \ell\right) \cdot \ell\right)}{\left(k \cdot \left(k \cdot t\right)\right) \cdot {\sin k}^{2}} \]

    if 4.80000000000000046e43 < t

    1. Initial program 68.0%

      \[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) + 1\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in t around inf

      \[\leadsto \color{blue}{\frac{{\ell}^{2} \cdot \cos k}{{t}^{3} \cdot {\sin k}^{2}}} \]
    4. Step-by-step derivation
      1. times-fracN/A

        \[\leadsto \frac{{\ell}^{2}}{{t}^{3}} \cdot \color{blue}{\frac{\cos k}{{\sin k}^{2}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{{\ell}^{2}}{{t}^{3}} \cdot \color{blue}{\frac{\cos k}{{\sin k}^{2}}} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{{\ell}^{2}}{{t}^{3}} \cdot \frac{\color{blue}{\cos k}}{{\sin k}^{2}} \]
      4. pow2N/A

        \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos \color{blue}{k}}{{\sin k}^{2}} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos \color{blue}{k}}{{\sin k}^{2}} \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{{\sin k}^{2}} \]
      7. lower-/.f64N/A

        \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{\color{blue}{{\sin k}^{2}}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{{\color{blue}{\sin k}}^{2}} \]
      9. lower-pow.f64N/A

        \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{{\sin k}^{\color{blue}{2}}} \]
      10. lift-sin.f6460.8

        \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{{\sin k}^{2}} \]
    5. Applied rewrites60.8%

      \[\leadsto \color{blue}{\frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{{\sin k}^{2}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 64.4% accurate, N/A× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ \begin{array}{l} t_1 := {\sin k\_m}^{2}\\ \mathbf{if}\;t \leq 4.8 \cdot 10^{+43}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\cos k\_m, \ell \cdot \ell, \cos k\_m \cdot \left(\ell \cdot \ell\right)\right)}{\left(k\_m \cdot \left(k\_m \cdot t\right)\right) \cdot t\_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k\_m}{t\_1}\\ \end{array} \end{array} \]
k_m = (fabs.f64 k)
(FPCore (t l k_m)
 :precision binary64
 (let* ((t_1 (pow (sin k_m) 2.0)))
   (if (<= t 4.8e+43)
     (/
      (fma (cos k_m) (* l l) (* (cos k_m) (* l l)))
      (* (* k_m (* k_m t)) t_1))
     (* (/ (* l l) (pow t 3.0)) (/ (cos k_m) t_1)))))
k_m = fabs(k);
double code(double t, double l, double k_m) {
	double t_1 = pow(sin(k_m), 2.0);
	double tmp;
	if (t <= 4.8e+43) {
		tmp = fma(cos(k_m), (l * l), (cos(k_m) * (l * l))) / ((k_m * (k_m * t)) * t_1);
	} else {
		tmp = ((l * l) / pow(t, 3.0)) * (cos(k_m) / t_1);
	}
	return tmp;
}
k_m = abs(k)
function code(t, l, k_m)
	t_1 = sin(k_m) ^ 2.0
	tmp = 0.0
	if (t <= 4.8e+43)
		tmp = Float64(fma(cos(k_m), Float64(l * l), Float64(cos(k_m) * Float64(l * l))) / Float64(Float64(k_m * Float64(k_m * t)) * t_1));
	else
		tmp = Float64(Float64(Float64(l * l) / (t ^ 3.0)) * Float64(cos(k_m) / t_1));
	end
	return tmp
end
k_m = N[Abs[k], $MachinePrecision]
code[t_, l_, k$95$m_] := Block[{t$95$1 = N[Power[N[Sin[k$95$m], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t, 4.8e+43], N[(N[(N[Cos[k$95$m], $MachinePrecision] * N[(l * l), $MachinePrecision] + N[(N[Cos[k$95$m], $MachinePrecision] * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(k$95$m * N[(k$95$m * t), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(l * l), $MachinePrecision] / N[Power[t, 3.0], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[k$95$m], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
k_m = \left|k\right|

\\
\begin{array}{l}
t_1 := {\sin k\_m}^{2}\\
\mathbf{if}\;t \leq 4.8 \cdot 10^{+43}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\cos k\_m, \ell \cdot \ell, \cos k\_m \cdot \left(\ell \cdot \ell\right)\right)}{\left(k\_m \cdot \left(k\_m \cdot t\right)\right) \cdot t\_1}\\

\mathbf{else}:\\
\;\;\;\;\frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k\_m}{t\_1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 4.80000000000000046e43

    1. Initial program 53.1%

      \[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) + 1\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in t around 0

      \[\leadsto \color{blue}{2 \cdot \frac{{\ell}^{2} \cdot \cos k}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}} \]
    4. Step-by-step derivation
      1. count-2-revN/A

        \[\leadsto \frac{{\ell}^{2} \cdot \cos k}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)} + \color{blue}{\frac{{\ell}^{2} \cdot \cos k}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}} \]
      2. div-add-revN/A

        \[\leadsto \frac{{\ell}^{2} \cdot \cos k + {\ell}^{2} \cdot \cos k}{\color{blue}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{{\ell}^{2} \cdot \cos k + {\ell}^{2} \cdot \cos k}{\color{blue}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}} \]
      4. *-commutativeN/A

        \[\leadsto \frac{\cos k \cdot {\ell}^{2} + {\ell}^{2} \cdot \cos k}{{\color{blue}{k}}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)} \]
      5. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, {\ell}^{2}, {\ell}^{2} \cdot \cos k\right)}{\color{blue}{{k}^{2}} \cdot \left(t \cdot {\sin k}^{2}\right)} \]
      6. lower-cos.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, {\ell}^{2}, {\ell}^{2} \cdot \cos k\right)}{{\color{blue}{k}}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)} \]
      7. pow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, {\ell}^{2} \cdot \cos k\right)}{{k}^{\color{blue}{2}} \cdot \left(t \cdot {\sin k}^{2}\right)} \]
      8. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, {\ell}^{2} \cdot \cos k\right)}{{k}^{\color{blue}{2}} \cdot \left(t \cdot {\sin k}^{2}\right)} \]
      9. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot {\ell}^{2}\right)}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot {\ell}^{2}\right)}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)} \]
      11. lower-cos.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot {\ell}^{2}\right)}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)} \]
      12. pow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)} \]
      13. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)} \]
      14. associate-*r*N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left({k}^{2} \cdot t\right) \cdot \color{blue}{{\sin k}^{2}}} \]
      15. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left({k}^{2} \cdot t\right) \cdot \color{blue}{{\sin k}^{2}}} \]
    5. Applied rewrites68.4%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left(\left(k \cdot k\right) \cdot t\right) \cdot {\sin k}^{2}}} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left(\left(k \cdot k\right) \cdot t\right) \cdot {\color{blue}{\sin k}}^{2}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left(\left(k \cdot k\right) \cdot t\right) \cdot {\sin \color{blue}{k}}^{2}} \]
      3. associate-*l*N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left(k \cdot \left(k \cdot t\right)\right) \cdot {\color{blue}{\sin k}}^{2}} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left(k \cdot \left(k \cdot t\right)\right) \cdot {\color{blue}{\sin k}}^{2}} \]
      5. lower-*.f6471.1

        \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left(k \cdot \left(k \cdot t\right)\right) \cdot {\sin k}^{2}} \]
    7. Applied rewrites71.1%

      \[\leadsto \frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left(k \cdot \left(k \cdot t\right)\right) \cdot {\color{blue}{\sin k}}^{2}} \]

    if 4.80000000000000046e43 < t

    1. Initial program 68.0%

      \[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) + 1\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in t around inf

      \[\leadsto \color{blue}{\frac{{\ell}^{2} \cdot \cos k}{{t}^{3} \cdot {\sin k}^{2}}} \]
    4. Step-by-step derivation
      1. times-fracN/A

        \[\leadsto \frac{{\ell}^{2}}{{t}^{3}} \cdot \color{blue}{\frac{\cos k}{{\sin k}^{2}}} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{{\ell}^{2}}{{t}^{3}} \cdot \color{blue}{\frac{\cos k}{{\sin k}^{2}}} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{{\ell}^{2}}{{t}^{3}} \cdot \frac{\color{blue}{\cos k}}{{\sin k}^{2}} \]
      4. pow2N/A

        \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos \color{blue}{k}}{{\sin k}^{2}} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos \color{blue}{k}}{{\sin k}^{2}} \]
      6. lift-pow.f64N/A

        \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{{\sin k}^{2}} \]
      7. lower-/.f64N/A

        \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{\color{blue}{{\sin k}^{2}}} \]
      8. lower-cos.f64N/A

        \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{{\color{blue}{\sin k}}^{2}} \]
      9. lower-pow.f64N/A

        \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{{\sin k}^{\color{blue}{2}}} \]
      10. lift-sin.f6460.8

        \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{{\sin k}^{2}} \]
    5. Applied rewrites60.8%

      \[\leadsto \color{blue}{\frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{{\sin k}^{2}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 50.5% accurate, N/A× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k\_m}{{\sin k\_m}^{2}} \end{array} \]
k_m = (fabs.f64 k)
(FPCore (t l k_m)
 :precision binary64
 (* (/ (* l l) (pow t 3.0)) (/ (cos k_m) (pow (sin k_m) 2.0))))
k_m = fabs(k);
double code(double t, double l, double k_m) {
	return ((l * l) / pow(t, 3.0)) * (cos(k_m) / pow(sin(k_m), 2.0));
}
k_m =     private
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(t, l, k_m)
use fmin_fmax_functions
    real(8), intent (in) :: t
    real(8), intent (in) :: l
    real(8), intent (in) :: k_m
    code = ((l * l) / (t ** 3.0d0)) * (cos(k_m) / (sin(k_m) ** 2.0d0))
end function
k_m = Math.abs(k);
public static double code(double t, double l, double k_m) {
	return ((l * l) / Math.pow(t, 3.0)) * (Math.cos(k_m) / Math.pow(Math.sin(k_m), 2.0));
}
k_m = math.fabs(k)
def code(t, l, k_m):
	return ((l * l) / math.pow(t, 3.0)) * (math.cos(k_m) / math.pow(math.sin(k_m), 2.0))
k_m = abs(k)
function code(t, l, k_m)
	return Float64(Float64(Float64(l * l) / (t ^ 3.0)) * Float64(cos(k_m) / (sin(k_m) ^ 2.0)))
end
k_m = abs(k);
function tmp = code(t, l, k_m)
	tmp = ((l * l) / (t ^ 3.0)) * (cos(k_m) / (sin(k_m) ^ 2.0));
end
k_m = N[Abs[k], $MachinePrecision]
code[t_, l_, k$95$m_] := N[(N[(N[(l * l), $MachinePrecision] / N[Power[t, 3.0], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[k$95$m], $MachinePrecision] / N[Power[N[Sin[k$95$m], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
k_m = \left|k\right|

\\
\frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k\_m}{{\sin k\_m}^{2}}
\end{array}
Derivation
  1. Initial program 55.6%

    \[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) + 1\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in t around inf

    \[\leadsto \color{blue}{\frac{{\ell}^{2} \cdot \cos k}{{t}^{3} \cdot {\sin k}^{2}}} \]
  4. Step-by-step derivation
    1. times-fracN/A

      \[\leadsto \frac{{\ell}^{2}}{{t}^{3}} \cdot \color{blue}{\frac{\cos k}{{\sin k}^{2}}} \]
    2. lower-*.f64N/A

      \[\leadsto \frac{{\ell}^{2}}{{t}^{3}} \cdot \color{blue}{\frac{\cos k}{{\sin k}^{2}}} \]
    3. lower-/.f64N/A

      \[\leadsto \frac{{\ell}^{2}}{{t}^{3}} \cdot \frac{\color{blue}{\cos k}}{{\sin k}^{2}} \]
    4. pow2N/A

      \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos \color{blue}{k}}{{\sin k}^{2}} \]
    5. lift-*.f64N/A

      \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos \color{blue}{k}}{{\sin k}^{2}} \]
    6. lift-pow.f64N/A

      \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{{\sin k}^{2}} \]
    7. lower-/.f64N/A

      \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{\color{blue}{{\sin k}^{2}}} \]
    8. lower-cos.f64N/A

      \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{{\color{blue}{\sin k}}^{2}} \]
    9. lower-pow.f64N/A

      \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{{\sin k}^{\color{blue}{2}}} \]
    10. lift-sin.f6455.6

      \[\leadsto \frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{{\sin k}^{2}} \]
  5. Applied rewrites55.6%

    \[\leadsto \color{blue}{\frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k}{{\sin k}^{2}}} \]
  6. Add Preprocessing

Reproduce

?
herbie shell --seed 2025064 
(FPCore (t l k)
  :name "Toniolo and Linder, Equation (10+)"
  :precision binary64
  (/ 2.0 (* (* (* (/ (pow t 3.0) (* l l)) (sin k)) (tan k)) (+ (+ 1.0 (pow (/ k t) 2.0)) 1.0))))