Toniolo and Linder, Equation (10-)

Percentage Accurate: 35.6% → 95.7%
Time: 24.5s
Alternatives: 16
Speedup: 3.8×

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));
}
real(8) function code(t, l, k)
    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 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: 35.6% 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));
}
real(8) function code(t, l, k)
    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: 95.7% accurate, 0.8× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ t\_s \cdot \begin{array}{l} \mathbf{if}\;k\_m \leq 9 \cdot 10^{-8}:\\ \;\;\;\;{\left(\left(\frac{\ell}{k\_m} \cdot \frac{1}{\frac{\sin k\_m}{\sqrt{2}}}\right) \cdot \sqrt{\frac{\cos k\_m}{t\_m}}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left({\left(\frac{\ell}{k\_m}\right)}^{2} \cdot \frac{\frac{\cos k\_m}{{\sin k\_m}^{2}}}{t\_m}\right)\\ \end{array} \end{array} \]
k_m = (fabs.f64 k)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k_m)
 :precision binary64
 (*
  t_s
  (if (<= k_m 9e-8)
    (pow
     (*
      (* (/ l k_m) (/ 1.0 (/ (sin k_m) (sqrt 2.0))))
      (sqrt (/ (cos k_m) t_m)))
     2.0)
    (*
     2.0
     (* (pow (/ l k_m) 2.0) (/ (/ (cos k_m) (pow (sin k_m) 2.0)) t_m))))))
k_m = fabs(k);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k_m) {
	double tmp;
	if (k_m <= 9e-8) {
		tmp = pow((((l / k_m) * (1.0 / (sin(k_m) / sqrt(2.0)))) * sqrt((cos(k_m) / t_m))), 2.0);
	} else {
		tmp = 2.0 * (pow((l / k_m), 2.0) * ((cos(k_m) / pow(sin(k_m), 2.0)) / t_m));
	}
	return t_s * tmp;
}
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0d0, t)
real(8) function code(t_s, t_m, l, k_m)
    real(8), intent (in) :: t_s
    real(8), intent (in) :: t_m
    real(8), intent (in) :: l
    real(8), intent (in) :: k_m
    real(8) :: tmp
    if (k_m <= 9d-8) then
        tmp = (((l / k_m) * (1.0d0 / (sin(k_m) / sqrt(2.0d0)))) * sqrt((cos(k_m) / t_m))) ** 2.0d0
    else
        tmp = 2.0d0 * (((l / k_m) ** 2.0d0) * ((cos(k_m) / (sin(k_m) ** 2.0d0)) / t_m))
    end if
    code = t_s * tmp
end function
k_m = Math.abs(k);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k_m) {
	double tmp;
	if (k_m <= 9e-8) {
		tmp = Math.pow((((l / k_m) * (1.0 / (Math.sin(k_m) / Math.sqrt(2.0)))) * Math.sqrt((Math.cos(k_m) / t_m))), 2.0);
	} else {
		tmp = 2.0 * (Math.pow((l / k_m), 2.0) * ((Math.cos(k_m) / Math.pow(Math.sin(k_m), 2.0)) / t_m));
	}
	return t_s * tmp;
}
k_m = math.fabs(k)
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
def code(t_s, t_m, l, k_m):
	tmp = 0
	if k_m <= 9e-8:
		tmp = math.pow((((l / k_m) * (1.0 / (math.sin(k_m) / math.sqrt(2.0)))) * math.sqrt((math.cos(k_m) / t_m))), 2.0)
	else:
		tmp = 2.0 * (math.pow((l / k_m), 2.0) * ((math.cos(k_m) / math.pow(math.sin(k_m), 2.0)) / t_m))
	return t_s * tmp
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, t_m, l, k_m)
	tmp = 0.0
	if (k_m <= 9e-8)
		tmp = Float64(Float64(Float64(l / k_m) * Float64(1.0 / Float64(sin(k_m) / sqrt(2.0)))) * sqrt(Float64(cos(k_m) / t_m))) ^ 2.0;
	else
		tmp = Float64(2.0 * Float64((Float64(l / k_m) ^ 2.0) * Float64(Float64(cos(k_m) / (sin(k_m) ^ 2.0)) / t_m)));
	end
	return Float64(t_s * tmp)
end
k_m = abs(k);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
function tmp_2 = code(t_s, t_m, l, k_m)
	tmp = 0.0;
	if (k_m <= 9e-8)
		tmp = (((l / k_m) * (1.0 / (sin(k_m) / sqrt(2.0)))) * sqrt((cos(k_m) / t_m))) ^ 2.0;
	else
		tmp = 2.0 * (((l / k_m) ^ 2.0) * ((cos(k_m) / (sin(k_m) ^ 2.0)) / t_m));
	end
	tmp_2 = t_s * tmp;
end
k_m = N[Abs[k], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k$95$m_] := N[(t$95$s * If[LessEqual[k$95$m, 9e-8], N[Power[N[(N[(N[(l / k$95$m), $MachinePrecision] * N[(1.0 / N[(N[Sin[k$95$m], $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[Cos[k$95$m], $MachinePrecision] / t$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(2.0 * N[(N[Power[N[(l / k$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(N[Cos[k$95$m], $MachinePrecision] / N[Power[N[Sin[k$95$m], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / t$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
k_m = \left|k\right|
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
t\_s \cdot \begin{array}{l}
\mathbf{if}\;k\_m \leq 9 \cdot 10^{-8}:\\
\;\;\;\;{\left(\left(\frac{\ell}{k\_m} \cdot \frac{1}{\frac{\sin k\_m}{\sqrt{2}}}\right) \cdot \sqrt{\frac{\cos k\_m}{t\_m}}\right)}^{2}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 8.99999999999999986e-8

    1. Initial program 35.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. Simplified43.3%

      \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt23.6%

        \[\leadsto \color{blue}{\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \cdot \sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}} \]
      2. pow223.6%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}\right)}^{2}} \]
    5. Applied egg-rr27.3%

      \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\left(\sqrt{\sin k \cdot \tan k} \cdot \frac{k}{t}\right) \cdot {t}^{1.5}}\right)}^{2}} \]
    6. Step-by-step derivation
      1. associate-*l*27.8%

        \[\leadsto {\left(\ell \cdot \frac{\sqrt{2}}{\color{blue}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}}\right)}^{2} \]
    7. Simplified27.8%

      \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}\right)}^{2}} \]
    8. Taylor expanded in l around 0 38.2%

      \[\leadsto {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k} \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
    9. Step-by-step derivation
      1. times-frac39.1%

        \[\leadsto {\left(\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)} \cdot \sqrt{\frac{\cos k}{t}}\right)}^{2} \]
    10. Simplified39.1%

      \[\leadsto {\color{blue}{\left(\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right) \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
    11. Step-by-step derivation
      1. clear-num39.1%

        \[\leadsto {\left(\left(\frac{\ell}{k} \cdot \color{blue}{\frac{1}{\frac{\sin k}{\sqrt{2}}}}\right) \cdot \sqrt{\frac{\cos k}{t}}\right)}^{2} \]
      2. inv-pow39.1%

        \[\leadsto {\left(\left(\frac{\ell}{k} \cdot \color{blue}{{\left(\frac{\sin k}{\sqrt{2}}\right)}^{-1}}\right) \cdot \sqrt{\frac{\cos k}{t}}\right)}^{2} \]
    12. Applied egg-rr39.1%

      \[\leadsto {\left(\left(\frac{\ell}{k} \cdot \color{blue}{{\left(\frac{\sin k}{\sqrt{2}}\right)}^{-1}}\right) \cdot \sqrt{\frac{\cos k}{t}}\right)}^{2} \]
    13. Step-by-step derivation
      1. unpow-139.1%

        \[\leadsto {\left(\left(\frac{\ell}{k} \cdot \color{blue}{\frac{1}{\frac{\sin k}{\sqrt{2}}}}\right) \cdot \sqrt{\frac{\cos k}{t}}\right)}^{2} \]
    14. Simplified39.1%

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

    if 8.99999999999999986e-8 < k

    1. Initial program 25.3%

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

      \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in t around 0 71.3%

      \[\leadsto \color{blue}{\left(2 \cdot \frac{\cos k}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}\right)} \cdot \left(\ell \cdot \ell\right) \]
    5. Taylor expanded in k around inf 71.3%

      \[\leadsto \color{blue}{2 \cdot \frac{{\ell}^{2} \cdot \cos k}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-*r*71.3%

        \[\leadsto 2 \cdot \frac{{\ell}^{2} \cdot \cos k}{\color{blue}{\left({k}^{2} \cdot t\right) \cdot {\sin k}^{2}}} \]
      2. associate-*r/71.3%

        \[\leadsto \color{blue}{\frac{2 \cdot \left({\ell}^{2} \cdot \cos k\right)}{\left({k}^{2} \cdot t\right) \cdot {\sin k}^{2}}} \]
      3. *-commutative71.3%

        \[\leadsto \frac{2 \cdot \color{blue}{\left(\cos k \cdot {\ell}^{2}\right)}}{\left({k}^{2} \cdot t\right) \cdot {\sin k}^{2}} \]
      4. times-frac71.3%

        \[\leadsto \color{blue}{\frac{2}{{k}^{2} \cdot t} \cdot \frac{\cos k \cdot {\ell}^{2}}{{\sin k}^{2}}} \]
      5. *-commutative71.3%

        \[\leadsto \frac{2}{\color{blue}{t \cdot {k}^{2}}} \cdot \frac{\cos k \cdot {\ell}^{2}}{{\sin k}^{2}} \]
      6. *-commutative71.3%

        \[\leadsto \frac{2}{t \cdot {k}^{2}} \cdot \frac{\color{blue}{{\ell}^{2} \cdot \cos k}}{{\sin k}^{2}} \]
    7. Simplified71.3%

      \[\leadsto \color{blue}{\frac{2}{t \cdot {k}^{2}} \cdot \frac{{\ell}^{2} \cdot \cos k}{{\sin k}^{2}}} \]
    8. Step-by-step derivation
      1. associate-*l/71.3%

        \[\leadsto \color{blue}{\frac{2 \cdot \frac{{\ell}^{2} \cdot \cos k}{{\sin k}^{2}}}{t \cdot {k}^{2}}} \]
      2. pow271.3%

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

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

        \[\leadsto \frac{2 \cdot \left(\color{blue}{{\ell}^{2}} \cdot \frac{\cos k}{{\sin k}^{2}}\right)}{t \cdot {k}^{2}} \]
    9. Applied egg-rr71.2%

      \[\leadsto \color{blue}{\frac{2 \cdot \left({\ell}^{2} \cdot \frac{\cos k}{{\sin k}^{2}}\right)}{t \cdot {k}^{2}}} \]
    10. Step-by-step derivation
      1. associate-/l*71.2%

        \[\leadsto \color{blue}{2 \cdot \frac{{\ell}^{2} \cdot \frac{\cos k}{{\sin k}^{2}}}{t \cdot {k}^{2}}} \]
      2. *-commutative71.2%

        \[\leadsto 2 \cdot \frac{{\ell}^{2} \cdot \frac{\cos k}{{\sin k}^{2}}}{\color{blue}{{k}^{2} \cdot t}} \]
      3. times-frac74.2%

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

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

        \[\leadsto 2 \cdot \left(\frac{\ell \cdot \ell}{\color{blue}{k \cdot k}} \cdot \frac{\frac{\cos k}{{\sin k}^{2}}}{t}\right) \]
      6. times-frac96.7%

        \[\leadsto 2 \cdot \left(\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\ell}{k}\right)} \cdot \frac{\frac{\cos k}{{\sin k}^{2}}}{t}\right) \]
      7. unpow296.7%

        \[\leadsto 2 \cdot \left(\color{blue}{{\left(\frac{\ell}{k}\right)}^{2}} \cdot \frac{\frac{\cos k}{{\sin k}^{2}}}{t}\right) \]
    11. Simplified96.7%

      \[\leadsto \color{blue}{2 \cdot \left({\left(\frac{\ell}{k}\right)}^{2} \cdot \frac{\frac{\cos k}{{\sin k}^{2}}}{t}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification54.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 9 \cdot 10^{-8}:\\ \;\;\;\;{\left(\left(\frac{\ell}{k} \cdot \frac{1}{\frac{\sin k}{\sqrt{2}}}\right) \cdot \sqrt{\frac{\cos k}{t}}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left({\left(\frac{\ell}{k}\right)}^{2} \cdot \frac{\frac{\cos k}{{\sin k}^{2}}}{t}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 95.7% accurate, 0.8× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ t\_s \cdot \begin{array}{l} \mathbf{if}\;k\_m \leq 4.1 \cdot 10^{-7}:\\ \;\;\;\;{\left(\sqrt{\frac{\cos k\_m}{t\_m}} \cdot \frac{\ell \cdot \frac{\sqrt{2}}{\sin k\_m}}{k\_m}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left({\left(\frac{\ell}{k\_m}\right)}^{2} \cdot \frac{\frac{\cos k\_m}{{\sin k\_m}^{2}}}{t\_m}\right)\\ \end{array} \end{array} \]
k_m = (fabs.f64 k)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k_m)
 :precision binary64
 (*
  t_s
  (if (<= k_m 4.1e-7)
    (pow
     (* (sqrt (/ (cos k_m) t_m)) (/ (* l (/ (sqrt 2.0) (sin k_m))) k_m))
     2.0)
    (*
     2.0
     (* (pow (/ l k_m) 2.0) (/ (/ (cos k_m) (pow (sin k_m) 2.0)) t_m))))))
k_m = fabs(k);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k_m) {
	double tmp;
	if (k_m <= 4.1e-7) {
		tmp = pow((sqrt((cos(k_m) / t_m)) * ((l * (sqrt(2.0) / sin(k_m))) / k_m)), 2.0);
	} else {
		tmp = 2.0 * (pow((l / k_m), 2.0) * ((cos(k_m) / pow(sin(k_m), 2.0)) / t_m));
	}
	return t_s * tmp;
}
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0d0, t)
real(8) function code(t_s, t_m, l, k_m)
    real(8), intent (in) :: t_s
    real(8), intent (in) :: t_m
    real(8), intent (in) :: l
    real(8), intent (in) :: k_m
    real(8) :: tmp
    if (k_m <= 4.1d-7) then
        tmp = (sqrt((cos(k_m) / t_m)) * ((l * (sqrt(2.0d0) / sin(k_m))) / k_m)) ** 2.0d0
    else
        tmp = 2.0d0 * (((l / k_m) ** 2.0d0) * ((cos(k_m) / (sin(k_m) ** 2.0d0)) / t_m))
    end if
    code = t_s * tmp
end function
k_m = Math.abs(k);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k_m) {
	double tmp;
	if (k_m <= 4.1e-7) {
		tmp = Math.pow((Math.sqrt((Math.cos(k_m) / t_m)) * ((l * (Math.sqrt(2.0) / Math.sin(k_m))) / k_m)), 2.0);
	} else {
		tmp = 2.0 * (Math.pow((l / k_m), 2.0) * ((Math.cos(k_m) / Math.pow(Math.sin(k_m), 2.0)) / t_m));
	}
	return t_s * tmp;
}
k_m = math.fabs(k)
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
def code(t_s, t_m, l, k_m):
	tmp = 0
	if k_m <= 4.1e-7:
		tmp = math.pow((math.sqrt((math.cos(k_m) / t_m)) * ((l * (math.sqrt(2.0) / math.sin(k_m))) / k_m)), 2.0)
	else:
		tmp = 2.0 * (math.pow((l / k_m), 2.0) * ((math.cos(k_m) / math.pow(math.sin(k_m), 2.0)) / t_m))
	return t_s * tmp
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, t_m, l, k_m)
	tmp = 0.0
	if (k_m <= 4.1e-7)
		tmp = Float64(sqrt(Float64(cos(k_m) / t_m)) * Float64(Float64(l * Float64(sqrt(2.0) / sin(k_m))) / k_m)) ^ 2.0;
	else
		tmp = Float64(2.0 * Float64((Float64(l / k_m) ^ 2.0) * Float64(Float64(cos(k_m) / (sin(k_m) ^ 2.0)) / t_m)));
	end
	return Float64(t_s * tmp)
end
k_m = abs(k);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
function tmp_2 = code(t_s, t_m, l, k_m)
	tmp = 0.0;
	if (k_m <= 4.1e-7)
		tmp = (sqrt((cos(k_m) / t_m)) * ((l * (sqrt(2.0) / sin(k_m))) / k_m)) ^ 2.0;
	else
		tmp = 2.0 * (((l / k_m) ^ 2.0) * ((cos(k_m) / (sin(k_m) ^ 2.0)) / t_m));
	end
	tmp_2 = t_s * tmp;
end
k_m = N[Abs[k], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k$95$m_] := N[(t$95$s * If[LessEqual[k$95$m, 4.1e-7], N[Power[N[(N[Sqrt[N[(N[Cos[k$95$m], $MachinePrecision] / t$95$m), $MachinePrecision]], $MachinePrecision] * N[(N[(l * N[(N[Sqrt[2.0], $MachinePrecision] / N[Sin[k$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / k$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(2.0 * N[(N[Power[N[(l / k$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(N[Cos[k$95$m], $MachinePrecision] / N[Power[N[Sin[k$95$m], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / t$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
k_m = \left|k\right|
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
t\_s \cdot \begin{array}{l}
\mathbf{if}\;k\_m \leq 4.1 \cdot 10^{-7}:\\
\;\;\;\;{\left(\sqrt{\frac{\cos k\_m}{t\_m}} \cdot \frac{\ell \cdot \frac{\sqrt{2}}{\sin k\_m}}{k\_m}\right)}^{2}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 4.0999999999999999e-7

    1. Initial program 35.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. Simplified43.3%

      \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt23.6%

        \[\leadsto \color{blue}{\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \cdot \sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}} \]
      2. pow223.6%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}\right)}^{2}} \]
    5. Applied egg-rr27.3%

      \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\left(\sqrt{\sin k \cdot \tan k} \cdot \frac{k}{t}\right) \cdot {t}^{1.5}}\right)}^{2}} \]
    6. Step-by-step derivation
      1. associate-*l*27.8%

        \[\leadsto {\left(\ell \cdot \frac{\sqrt{2}}{\color{blue}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}}\right)}^{2} \]
    7. Simplified27.8%

      \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}\right)}^{2}} \]
    8. Taylor expanded in l around 0 38.2%

      \[\leadsto {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k} \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
    9. Step-by-step derivation
      1. times-frac39.1%

        \[\leadsto {\left(\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)} \cdot \sqrt{\frac{\cos k}{t}}\right)}^{2} \]
    10. Simplified39.1%

      \[\leadsto {\color{blue}{\left(\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right) \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
    11. Step-by-step derivation
      1. associate-*l/39.1%

        \[\leadsto {\left(\color{blue}{\frac{\ell \cdot \frac{\sqrt{2}}{\sin k}}{k}} \cdot \sqrt{\frac{\cos k}{t}}\right)}^{2} \]
    12. Applied egg-rr39.1%

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

    if 4.0999999999999999e-7 < k

    1. Initial program 25.3%

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

      \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in t around 0 71.3%

      \[\leadsto \color{blue}{\left(2 \cdot \frac{\cos k}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}\right)} \cdot \left(\ell \cdot \ell\right) \]
    5. Taylor expanded in k around inf 71.3%

      \[\leadsto \color{blue}{2 \cdot \frac{{\ell}^{2} \cdot \cos k}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-*r*71.3%

        \[\leadsto 2 \cdot \frac{{\ell}^{2} \cdot \cos k}{\color{blue}{\left({k}^{2} \cdot t\right) \cdot {\sin k}^{2}}} \]
      2. associate-*r/71.3%

        \[\leadsto \color{blue}{\frac{2 \cdot \left({\ell}^{2} \cdot \cos k\right)}{\left({k}^{2} \cdot t\right) \cdot {\sin k}^{2}}} \]
      3. *-commutative71.3%

        \[\leadsto \frac{2 \cdot \color{blue}{\left(\cos k \cdot {\ell}^{2}\right)}}{\left({k}^{2} \cdot t\right) \cdot {\sin k}^{2}} \]
      4. times-frac71.3%

        \[\leadsto \color{blue}{\frac{2}{{k}^{2} \cdot t} \cdot \frac{\cos k \cdot {\ell}^{2}}{{\sin k}^{2}}} \]
      5. *-commutative71.3%

        \[\leadsto \frac{2}{\color{blue}{t \cdot {k}^{2}}} \cdot \frac{\cos k \cdot {\ell}^{2}}{{\sin k}^{2}} \]
      6. *-commutative71.3%

        \[\leadsto \frac{2}{t \cdot {k}^{2}} \cdot \frac{\color{blue}{{\ell}^{2} \cdot \cos k}}{{\sin k}^{2}} \]
    7. Simplified71.3%

      \[\leadsto \color{blue}{\frac{2}{t \cdot {k}^{2}} \cdot \frac{{\ell}^{2} \cdot \cos k}{{\sin k}^{2}}} \]
    8. Step-by-step derivation
      1. associate-*l/71.3%

        \[\leadsto \color{blue}{\frac{2 \cdot \frac{{\ell}^{2} \cdot \cos k}{{\sin k}^{2}}}{t \cdot {k}^{2}}} \]
      2. pow271.3%

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

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

        \[\leadsto \frac{2 \cdot \left(\color{blue}{{\ell}^{2}} \cdot \frac{\cos k}{{\sin k}^{2}}\right)}{t \cdot {k}^{2}} \]
    9. Applied egg-rr71.2%

      \[\leadsto \color{blue}{\frac{2 \cdot \left({\ell}^{2} \cdot \frac{\cos k}{{\sin k}^{2}}\right)}{t \cdot {k}^{2}}} \]
    10. Step-by-step derivation
      1. associate-/l*71.2%

        \[\leadsto \color{blue}{2 \cdot \frac{{\ell}^{2} \cdot \frac{\cos k}{{\sin k}^{2}}}{t \cdot {k}^{2}}} \]
      2. *-commutative71.2%

        \[\leadsto 2 \cdot \frac{{\ell}^{2} \cdot \frac{\cos k}{{\sin k}^{2}}}{\color{blue}{{k}^{2} \cdot t}} \]
      3. times-frac74.2%

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

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

        \[\leadsto 2 \cdot \left(\frac{\ell \cdot \ell}{\color{blue}{k \cdot k}} \cdot \frac{\frac{\cos k}{{\sin k}^{2}}}{t}\right) \]
      6. times-frac96.7%

        \[\leadsto 2 \cdot \left(\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\ell}{k}\right)} \cdot \frac{\frac{\cos k}{{\sin k}^{2}}}{t}\right) \]
      7. unpow296.7%

        \[\leadsto 2 \cdot \left(\color{blue}{{\left(\frac{\ell}{k}\right)}^{2}} \cdot \frac{\frac{\cos k}{{\sin k}^{2}}}{t}\right) \]
    11. Simplified96.7%

      \[\leadsto \color{blue}{2 \cdot \left({\left(\frac{\ell}{k}\right)}^{2} \cdot \frac{\frac{\cos k}{{\sin k}^{2}}}{t}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification54.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 4.1 \cdot 10^{-7}:\\ \;\;\;\;{\left(\sqrt{\frac{\cos k}{t}} \cdot \frac{\ell \cdot \frac{\sqrt{2}}{\sin k}}{k}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left({\left(\frac{\ell}{k}\right)}^{2} \cdot \frac{\frac{\cos k}{{\sin k}^{2}}}{t}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 95.7% accurate, 1.0× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ t\_s \cdot \begin{array}{l} \mathbf{if}\;k\_m \leq 4.3 \cdot 10^{-7}:\\ \;\;\;\;{\left(\sqrt{\frac{\cos k\_m}{t\_m}} \cdot \left(\frac{\ell}{k\_m} \cdot \frac{\sqrt{2}}{k\_m}\right)\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left({\left(\frac{\ell}{k\_m}\right)}^{2} \cdot \frac{\frac{\cos k\_m}{{\sin k\_m}^{2}}}{t\_m}\right)\\ \end{array} \end{array} \]
k_m = (fabs.f64 k)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k_m)
 :precision binary64
 (*
  t_s
  (if (<= k_m 4.3e-7)
    (pow (* (sqrt (/ (cos k_m) t_m)) (* (/ l k_m) (/ (sqrt 2.0) k_m))) 2.0)
    (*
     2.0
     (* (pow (/ l k_m) 2.0) (/ (/ (cos k_m) (pow (sin k_m) 2.0)) t_m))))))
k_m = fabs(k);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k_m) {
	double tmp;
	if (k_m <= 4.3e-7) {
		tmp = pow((sqrt((cos(k_m) / t_m)) * ((l / k_m) * (sqrt(2.0) / k_m))), 2.0);
	} else {
		tmp = 2.0 * (pow((l / k_m), 2.0) * ((cos(k_m) / pow(sin(k_m), 2.0)) / t_m));
	}
	return t_s * tmp;
}
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0d0, t)
real(8) function code(t_s, t_m, l, k_m)
    real(8), intent (in) :: t_s
    real(8), intent (in) :: t_m
    real(8), intent (in) :: l
    real(8), intent (in) :: k_m
    real(8) :: tmp
    if (k_m <= 4.3d-7) then
        tmp = (sqrt((cos(k_m) / t_m)) * ((l / k_m) * (sqrt(2.0d0) / k_m))) ** 2.0d0
    else
        tmp = 2.0d0 * (((l / k_m) ** 2.0d0) * ((cos(k_m) / (sin(k_m) ** 2.0d0)) / t_m))
    end if
    code = t_s * tmp
end function
k_m = Math.abs(k);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k_m) {
	double tmp;
	if (k_m <= 4.3e-7) {
		tmp = Math.pow((Math.sqrt((Math.cos(k_m) / t_m)) * ((l / k_m) * (Math.sqrt(2.0) / k_m))), 2.0);
	} else {
		tmp = 2.0 * (Math.pow((l / k_m), 2.0) * ((Math.cos(k_m) / Math.pow(Math.sin(k_m), 2.0)) / t_m));
	}
	return t_s * tmp;
}
k_m = math.fabs(k)
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
def code(t_s, t_m, l, k_m):
	tmp = 0
	if k_m <= 4.3e-7:
		tmp = math.pow((math.sqrt((math.cos(k_m) / t_m)) * ((l / k_m) * (math.sqrt(2.0) / k_m))), 2.0)
	else:
		tmp = 2.0 * (math.pow((l / k_m), 2.0) * ((math.cos(k_m) / math.pow(math.sin(k_m), 2.0)) / t_m))
	return t_s * tmp
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, t_m, l, k_m)
	tmp = 0.0
	if (k_m <= 4.3e-7)
		tmp = Float64(sqrt(Float64(cos(k_m) / t_m)) * Float64(Float64(l / k_m) * Float64(sqrt(2.0) / k_m))) ^ 2.0;
	else
		tmp = Float64(2.0 * Float64((Float64(l / k_m) ^ 2.0) * Float64(Float64(cos(k_m) / (sin(k_m) ^ 2.0)) / t_m)));
	end
	return Float64(t_s * tmp)
end
k_m = abs(k);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
function tmp_2 = code(t_s, t_m, l, k_m)
	tmp = 0.0;
	if (k_m <= 4.3e-7)
		tmp = (sqrt((cos(k_m) / t_m)) * ((l / k_m) * (sqrt(2.0) / k_m))) ^ 2.0;
	else
		tmp = 2.0 * (((l / k_m) ^ 2.0) * ((cos(k_m) / (sin(k_m) ^ 2.0)) / t_m));
	end
	tmp_2 = t_s * tmp;
end
k_m = N[Abs[k], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k$95$m_] := N[(t$95$s * If[LessEqual[k$95$m, 4.3e-7], N[Power[N[(N[Sqrt[N[(N[Cos[k$95$m], $MachinePrecision] / t$95$m), $MachinePrecision]], $MachinePrecision] * N[(N[(l / k$95$m), $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / k$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(2.0 * N[(N[Power[N[(l / k$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(N[Cos[k$95$m], $MachinePrecision] / N[Power[N[Sin[k$95$m], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / t$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
k_m = \left|k\right|
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
t\_s \cdot \begin{array}{l}
\mathbf{if}\;k\_m \leq 4.3 \cdot 10^{-7}:\\
\;\;\;\;{\left(\sqrt{\frac{\cos k\_m}{t\_m}} \cdot \left(\frac{\ell}{k\_m} \cdot \frac{\sqrt{2}}{k\_m}\right)\right)}^{2}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 4.3000000000000001e-7

    1. Initial program 35.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. Simplified43.3%

      \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt23.6%

        \[\leadsto \color{blue}{\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \cdot \sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}} \]
      2. pow223.6%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}\right)}^{2}} \]
    5. Applied egg-rr27.3%

      \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\left(\sqrt{\sin k \cdot \tan k} \cdot \frac{k}{t}\right) \cdot {t}^{1.5}}\right)}^{2}} \]
    6. Step-by-step derivation
      1. associate-*l*27.8%

        \[\leadsto {\left(\ell \cdot \frac{\sqrt{2}}{\color{blue}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}}\right)}^{2} \]
    7. Simplified27.8%

      \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}\right)}^{2}} \]
    8. Taylor expanded in l around 0 38.2%

      \[\leadsto {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k} \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
    9. Step-by-step derivation
      1. times-frac39.1%

        \[\leadsto {\left(\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)} \cdot \sqrt{\frac{\cos k}{t}}\right)}^{2} \]
    10. Simplified39.1%

      \[\leadsto {\color{blue}{\left(\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right) \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
    11. Taylor expanded in k around 0 35.7%

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

    if 4.3000000000000001e-7 < k

    1. Initial program 25.3%

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

      \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in t around 0 71.3%

      \[\leadsto \color{blue}{\left(2 \cdot \frac{\cos k}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}\right)} \cdot \left(\ell \cdot \ell\right) \]
    5. Taylor expanded in k around inf 71.3%

      \[\leadsto \color{blue}{2 \cdot \frac{{\ell}^{2} \cdot \cos k}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-*r*71.3%

        \[\leadsto 2 \cdot \frac{{\ell}^{2} \cdot \cos k}{\color{blue}{\left({k}^{2} \cdot t\right) \cdot {\sin k}^{2}}} \]
      2. associate-*r/71.3%

        \[\leadsto \color{blue}{\frac{2 \cdot \left({\ell}^{2} \cdot \cos k\right)}{\left({k}^{2} \cdot t\right) \cdot {\sin k}^{2}}} \]
      3. *-commutative71.3%

        \[\leadsto \frac{2 \cdot \color{blue}{\left(\cos k \cdot {\ell}^{2}\right)}}{\left({k}^{2} \cdot t\right) \cdot {\sin k}^{2}} \]
      4. times-frac71.3%

        \[\leadsto \color{blue}{\frac{2}{{k}^{2} \cdot t} \cdot \frac{\cos k \cdot {\ell}^{2}}{{\sin k}^{2}}} \]
      5. *-commutative71.3%

        \[\leadsto \frac{2}{\color{blue}{t \cdot {k}^{2}}} \cdot \frac{\cos k \cdot {\ell}^{2}}{{\sin k}^{2}} \]
      6. *-commutative71.3%

        \[\leadsto \frac{2}{t \cdot {k}^{2}} \cdot \frac{\color{blue}{{\ell}^{2} \cdot \cos k}}{{\sin k}^{2}} \]
    7. Simplified71.3%

      \[\leadsto \color{blue}{\frac{2}{t \cdot {k}^{2}} \cdot \frac{{\ell}^{2} \cdot \cos k}{{\sin k}^{2}}} \]
    8. Step-by-step derivation
      1. associate-*l/71.3%

        \[\leadsto \color{blue}{\frac{2 \cdot \frac{{\ell}^{2} \cdot \cos k}{{\sin k}^{2}}}{t \cdot {k}^{2}}} \]
      2. pow271.3%

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

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

        \[\leadsto \frac{2 \cdot \left(\color{blue}{{\ell}^{2}} \cdot \frac{\cos k}{{\sin k}^{2}}\right)}{t \cdot {k}^{2}} \]
    9. Applied egg-rr71.2%

      \[\leadsto \color{blue}{\frac{2 \cdot \left({\ell}^{2} \cdot \frac{\cos k}{{\sin k}^{2}}\right)}{t \cdot {k}^{2}}} \]
    10. Step-by-step derivation
      1. associate-/l*71.2%

        \[\leadsto \color{blue}{2 \cdot \frac{{\ell}^{2} \cdot \frac{\cos k}{{\sin k}^{2}}}{t \cdot {k}^{2}}} \]
      2. *-commutative71.2%

        \[\leadsto 2 \cdot \frac{{\ell}^{2} \cdot \frac{\cos k}{{\sin k}^{2}}}{\color{blue}{{k}^{2} \cdot t}} \]
      3. times-frac74.2%

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

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

        \[\leadsto 2 \cdot \left(\frac{\ell \cdot \ell}{\color{blue}{k \cdot k}} \cdot \frac{\frac{\cos k}{{\sin k}^{2}}}{t}\right) \]
      6. times-frac96.7%

        \[\leadsto 2 \cdot \left(\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\ell}{k}\right)} \cdot \frac{\frac{\cos k}{{\sin k}^{2}}}{t}\right) \]
      7. unpow296.7%

        \[\leadsto 2 \cdot \left(\color{blue}{{\left(\frac{\ell}{k}\right)}^{2}} \cdot \frac{\frac{\cos k}{{\sin k}^{2}}}{t}\right) \]
    11. Simplified96.7%

      \[\leadsto \color{blue}{2 \cdot \left({\left(\frac{\ell}{k}\right)}^{2} \cdot \frac{\frac{\cos k}{{\sin k}^{2}}}{t}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification51.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 4.3 \cdot 10^{-7}:\\ \;\;\;\;{\left(\sqrt{\frac{\cos k}{t}} \cdot \left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{k}\right)\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left({\left(\frac{\ell}{k}\right)}^{2} \cdot \frac{\frac{\cos k}{{\sin k}^{2}}}{t}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 95.7% accurate, 1.0× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ t\_s \cdot \begin{array}{l} \mathbf{if}\;k\_m \leq 2.15 \cdot 10^{-7}:\\ \;\;\;\;{\left(\sqrt{\frac{\cos k\_m}{t\_m}} \cdot \left(\frac{\ell}{k\_m} \cdot \frac{\sqrt{2}}{k\_m}\right)\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;\cos k\_m \cdot \frac{{\left(\frac{\ell \cdot \sqrt{2}}{k\_m \cdot \sin k\_m}\right)}^{2}}{t\_m}\\ \end{array} \end{array} \]
k_m = (fabs.f64 k)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k_m)
 :precision binary64
 (*
  t_s
  (if (<= k_m 2.15e-7)
    (pow (* (sqrt (/ (cos k_m) t_m)) (* (/ l k_m) (/ (sqrt 2.0) k_m))) 2.0)
    (* (cos k_m) (/ (pow (/ (* l (sqrt 2.0)) (* k_m (sin k_m))) 2.0) t_m)))))
k_m = fabs(k);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k_m) {
	double tmp;
	if (k_m <= 2.15e-7) {
		tmp = pow((sqrt((cos(k_m) / t_m)) * ((l / k_m) * (sqrt(2.0) / k_m))), 2.0);
	} else {
		tmp = cos(k_m) * (pow(((l * sqrt(2.0)) / (k_m * sin(k_m))), 2.0) / t_m);
	}
	return t_s * tmp;
}
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0d0, t)
real(8) function code(t_s, t_m, l, k_m)
    real(8), intent (in) :: t_s
    real(8), intent (in) :: t_m
    real(8), intent (in) :: l
    real(8), intent (in) :: k_m
    real(8) :: tmp
    if (k_m <= 2.15d-7) then
        tmp = (sqrt((cos(k_m) / t_m)) * ((l / k_m) * (sqrt(2.0d0) / k_m))) ** 2.0d0
    else
        tmp = cos(k_m) * ((((l * sqrt(2.0d0)) / (k_m * sin(k_m))) ** 2.0d0) / t_m)
    end if
    code = t_s * tmp
end function
k_m = Math.abs(k);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k_m) {
	double tmp;
	if (k_m <= 2.15e-7) {
		tmp = Math.pow((Math.sqrt((Math.cos(k_m) / t_m)) * ((l / k_m) * (Math.sqrt(2.0) / k_m))), 2.0);
	} else {
		tmp = Math.cos(k_m) * (Math.pow(((l * Math.sqrt(2.0)) / (k_m * Math.sin(k_m))), 2.0) / t_m);
	}
	return t_s * tmp;
}
k_m = math.fabs(k)
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
def code(t_s, t_m, l, k_m):
	tmp = 0
	if k_m <= 2.15e-7:
		tmp = math.pow((math.sqrt((math.cos(k_m) / t_m)) * ((l / k_m) * (math.sqrt(2.0) / k_m))), 2.0)
	else:
		tmp = math.cos(k_m) * (math.pow(((l * math.sqrt(2.0)) / (k_m * math.sin(k_m))), 2.0) / t_m)
	return t_s * tmp
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, t_m, l, k_m)
	tmp = 0.0
	if (k_m <= 2.15e-7)
		tmp = Float64(sqrt(Float64(cos(k_m) / t_m)) * Float64(Float64(l / k_m) * Float64(sqrt(2.0) / k_m))) ^ 2.0;
	else
		tmp = Float64(cos(k_m) * Float64((Float64(Float64(l * sqrt(2.0)) / Float64(k_m * sin(k_m))) ^ 2.0) / t_m));
	end
	return Float64(t_s * tmp)
end
k_m = abs(k);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
function tmp_2 = code(t_s, t_m, l, k_m)
	tmp = 0.0;
	if (k_m <= 2.15e-7)
		tmp = (sqrt((cos(k_m) / t_m)) * ((l / k_m) * (sqrt(2.0) / k_m))) ^ 2.0;
	else
		tmp = cos(k_m) * ((((l * sqrt(2.0)) / (k_m * sin(k_m))) ^ 2.0) / t_m);
	end
	tmp_2 = t_s * tmp;
end
k_m = N[Abs[k], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k$95$m_] := N[(t$95$s * If[LessEqual[k$95$m, 2.15e-7], N[Power[N[(N[Sqrt[N[(N[Cos[k$95$m], $MachinePrecision] / t$95$m), $MachinePrecision]], $MachinePrecision] * N[(N[(l / k$95$m), $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / k$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(N[Cos[k$95$m], $MachinePrecision] * N[(N[Power[N[(N[(l * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] / N[(k$95$m * N[Sin[k$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / t$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
k_m = \left|k\right|
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
t\_s \cdot \begin{array}{l}
\mathbf{if}\;k\_m \leq 2.15 \cdot 10^{-7}:\\
\;\;\;\;{\left(\sqrt{\frac{\cos k\_m}{t\_m}} \cdot \left(\frac{\ell}{k\_m} \cdot \frac{\sqrt{2}}{k\_m}\right)\right)}^{2}\\

\mathbf{else}:\\
\;\;\;\;\cos k\_m \cdot \frac{{\left(\frac{\ell \cdot \sqrt{2}}{k\_m \cdot \sin k\_m}\right)}^{2}}{t\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 2.1500000000000001e-7

    1. Initial program 35.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. Simplified43.3%

      \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt23.6%

        \[\leadsto \color{blue}{\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \cdot \sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}} \]
      2. pow223.6%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}\right)}^{2}} \]
    5. Applied egg-rr27.3%

      \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\left(\sqrt{\sin k \cdot \tan k} \cdot \frac{k}{t}\right) \cdot {t}^{1.5}}\right)}^{2}} \]
    6. Step-by-step derivation
      1. associate-*l*27.8%

        \[\leadsto {\left(\ell \cdot \frac{\sqrt{2}}{\color{blue}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}}\right)}^{2} \]
    7. Simplified27.8%

      \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}\right)}^{2}} \]
    8. Taylor expanded in l around 0 38.2%

      \[\leadsto {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k} \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
    9. Step-by-step derivation
      1. times-frac39.1%

        \[\leadsto {\left(\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)} \cdot \sqrt{\frac{\cos k}{t}}\right)}^{2} \]
    10. Simplified39.1%

      \[\leadsto {\color{blue}{\left(\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right) \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
    11. Taylor expanded in k around 0 35.7%

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

    if 2.1500000000000001e-7 < k

    1. Initial program 25.3%

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

      \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt33.0%

        \[\leadsto \color{blue}{\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \cdot \sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}} \]
      2. pow233.0%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}\right)}^{2}} \]
    5. Applied egg-rr17.7%

      \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\left(\sqrt{\sin k \cdot \tan k} \cdot \frac{k}{t}\right) \cdot {t}^{1.5}}\right)}^{2}} \]
    6. Step-by-step derivation
      1. associate-*l*17.7%

        \[\leadsto {\left(\ell \cdot \frac{\sqrt{2}}{\color{blue}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}}\right)}^{2} \]
    7. Simplified17.7%

      \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}\right)}^{2}} \]
    8. Taylor expanded in l around 0 50.9%

      \[\leadsto {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k} \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
    9. Step-by-step derivation
      1. times-frac51.1%

        \[\leadsto {\left(\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)} \cdot \sqrt{\frac{\cos k}{t}}\right)}^{2} \]
    10. Simplified51.1%

      \[\leadsto {\color{blue}{\left(\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right) \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
    11. Step-by-step derivation
      1. *-commutative51.1%

        \[\leadsto {\color{blue}{\left(\sqrt{\frac{\cos k}{t}} \cdot \left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)\right)}}^{2} \]
      2. unpow-prod-down48.4%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{\cos k}{t}}\right)}^{2} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2}} \]
      3. pow248.4%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{\cos k}{t}} \cdot \sqrt{\frac{\cos k}{t}}\right)} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2} \]
      4. add-sqr-sqrt96.5%

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

        \[\leadsto \frac{\cos k}{t} \cdot {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}}^{2} \]
    12. Applied egg-rr96.6%

      \[\leadsto \color{blue}{\frac{\cos k}{t} \cdot {\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}^{2}} \]
    13. Step-by-step derivation
      1. times-frac96.5%

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

      \[\leadsto \color{blue}{\frac{\cos k}{t} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2}} \]
    15. Step-by-step derivation
      1. associate-*l/96.4%

        \[\leadsto \color{blue}{\frac{\cos k \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2}}{t}} \]
      2. frac-times96.6%

        \[\leadsto \frac{\cos k \cdot {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}}^{2}}{t} \]
      3. associate-*r/96.5%

        \[\leadsto \frac{\cos k \cdot {\color{blue}{\left(\ell \cdot \frac{\sqrt{2}}{k \cdot \sin k}\right)}}^{2}}{t} \]
      4. associate-/r*96.6%

        \[\leadsto \frac{\cos k \cdot {\left(\ell \cdot \color{blue}{\frac{\frac{\sqrt{2}}{k}}{\sin k}}\right)}^{2}}{t} \]
    16. Applied egg-rr96.6%

      \[\leadsto \color{blue}{\frac{\cos k \cdot {\left(\ell \cdot \frac{\frac{\sqrt{2}}{k}}{\sin k}\right)}^{2}}{t}} \]
    17. Step-by-step derivation
      1. associate-/l*96.6%

        \[\leadsto \color{blue}{\cos k \cdot \frac{{\left(\ell \cdot \frac{\frac{\sqrt{2}}{k}}{\sin k}\right)}^{2}}{t}} \]
      2. associate-/r*96.6%

        \[\leadsto \cos k \cdot \frac{{\left(\ell \cdot \color{blue}{\frac{\sqrt{2}}{k \cdot \sin k}}\right)}^{2}}{t} \]
      3. associate-/l*96.6%

        \[\leadsto \cos k \cdot \frac{{\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}}^{2}}{t} \]
    18. Simplified96.6%

      \[\leadsto \color{blue}{\cos k \cdot \frac{{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}^{2}}{t}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification51.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 2.15 \cdot 10^{-7}:\\ \;\;\;\;{\left(\sqrt{\frac{\cos k}{t}} \cdot \left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{k}\right)\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;\cos k \cdot \frac{{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}^{2}}{t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 93.6% accurate, 1.0× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ t\_s \cdot \begin{array}{l} \mathbf{if}\;k\_m \leq 9.2 \cdot 10^{-6}:\\ \;\;\;\;{\left(\left(\ell \cdot \frac{\sqrt{2}}{{k\_m}^{2}}\right) \cdot \sqrt{\frac{1}{t\_m}}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \frac{\cos k\_m \cdot {\left(\frac{\ell}{k\_m}\right)}^{2}}{t\_m \cdot \left(1 - \cos \left(k\_m \cdot 2\right)\right)}\\ \end{array} \end{array} \]
k_m = (fabs.f64 k)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k_m)
 :precision binary64
 (*
  t_s
  (if (<= k_m 9.2e-6)
    (pow (* (* l (/ (sqrt 2.0) (pow k_m 2.0))) (sqrt (/ 1.0 t_m))) 2.0)
    (*
     4.0
     (/
      (* (cos k_m) (pow (/ l k_m) 2.0))
      (* t_m (- 1.0 (cos (* k_m 2.0)))))))))
k_m = fabs(k);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k_m) {
	double tmp;
	if (k_m <= 9.2e-6) {
		tmp = pow(((l * (sqrt(2.0) / pow(k_m, 2.0))) * sqrt((1.0 / t_m))), 2.0);
	} else {
		tmp = 4.0 * ((cos(k_m) * pow((l / k_m), 2.0)) / (t_m * (1.0 - cos((k_m * 2.0)))));
	}
	return t_s * tmp;
}
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0d0, t)
real(8) function code(t_s, t_m, l, k_m)
    real(8), intent (in) :: t_s
    real(8), intent (in) :: t_m
    real(8), intent (in) :: l
    real(8), intent (in) :: k_m
    real(8) :: tmp
    if (k_m <= 9.2d-6) then
        tmp = ((l * (sqrt(2.0d0) / (k_m ** 2.0d0))) * sqrt((1.0d0 / t_m))) ** 2.0d0
    else
        tmp = 4.0d0 * ((cos(k_m) * ((l / k_m) ** 2.0d0)) / (t_m * (1.0d0 - cos((k_m * 2.0d0)))))
    end if
    code = t_s * tmp
end function
k_m = Math.abs(k);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k_m) {
	double tmp;
	if (k_m <= 9.2e-6) {
		tmp = Math.pow(((l * (Math.sqrt(2.0) / Math.pow(k_m, 2.0))) * Math.sqrt((1.0 / t_m))), 2.0);
	} else {
		tmp = 4.0 * ((Math.cos(k_m) * Math.pow((l / k_m), 2.0)) / (t_m * (1.0 - Math.cos((k_m * 2.0)))));
	}
	return t_s * tmp;
}
k_m = math.fabs(k)
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
def code(t_s, t_m, l, k_m):
	tmp = 0
	if k_m <= 9.2e-6:
		tmp = math.pow(((l * (math.sqrt(2.0) / math.pow(k_m, 2.0))) * math.sqrt((1.0 / t_m))), 2.0)
	else:
		tmp = 4.0 * ((math.cos(k_m) * math.pow((l / k_m), 2.0)) / (t_m * (1.0 - math.cos((k_m * 2.0)))))
	return t_s * tmp
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, t_m, l, k_m)
	tmp = 0.0
	if (k_m <= 9.2e-6)
		tmp = Float64(Float64(l * Float64(sqrt(2.0) / (k_m ^ 2.0))) * sqrt(Float64(1.0 / t_m))) ^ 2.0;
	else
		tmp = Float64(4.0 * Float64(Float64(cos(k_m) * (Float64(l / k_m) ^ 2.0)) / Float64(t_m * Float64(1.0 - cos(Float64(k_m * 2.0))))));
	end
	return Float64(t_s * tmp)
end
k_m = abs(k);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
function tmp_2 = code(t_s, t_m, l, k_m)
	tmp = 0.0;
	if (k_m <= 9.2e-6)
		tmp = ((l * (sqrt(2.0) / (k_m ^ 2.0))) * sqrt((1.0 / t_m))) ^ 2.0;
	else
		tmp = 4.0 * ((cos(k_m) * ((l / k_m) ^ 2.0)) / (t_m * (1.0 - cos((k_m * 2.0)))));
	end
	tmp_2 = t_s * tmp;
end
k_m = N[Abs[k], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k$95$m_] := N[(t$95$s * If[LessEqual[k$95$m, 9.2e-6], N[Power[N[(N[(l * N[(N[Sqrt[2.0], $MachinePrecision] / N[Power[k$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 / t$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(4.0 * N[(N[(N[Cos[k$95$m], $MachinePrecision] * N[Power[N[(l / k$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(t$95$m * N[(1.0 - N[Cos[N[(k$95$m * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
k_m = \left|k\right|
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
t\_s \cdot \begin{array}{l}
\mathbf{if}\;k\_m \leq 9.2 \cdot 10^{-6}:\\
\;\;\;\;{\left(\left(\ell \cdot \frac{\sqrt{2}}{{k\_m}^{2}}\right) \cdot \sqrt{\frac{1}{t\_m}}\right)}^{2}\\

\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{\cos k\_m \cdot {\left(\frac{\ell}{k\_m}\right)}^{2}}{t\_m \cdot \left(1 - \cos \left(k\_m \cdot 2\right)\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 9.2e-6

    1. Initial program 35.3%

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

      \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt23.5%

        \[\leadsto \color{blue}{\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \cdot \sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}} \]
      2. pow223.5%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}\right)}^{2}} \]
    5. Applied egg-rr27.1%

      \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\left(\sqrt{\sin k \cdot \tan k} \cdot \frac{k}{t}\right) \cdot {t}^{1.5}}\right)}^{2}} \]
    6. Step-by-step derivation
      1. associate-*l*27.6%

        \[\leadsto {\left(\ell \cdot \frac{\sqrt{2}}{\color{blue}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}}\right)}^{2} \]
    7. Simplified27.6%

      \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}\right)}^{2}} \]
    8. Taylor expanded in k around 0 36.7%

      \[\leadsto {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{{k}^{2}} \cdot \sqrt{\frac{1}{t}}\right)}}^{2} \]
    9. Step-by-step derivation
      1. associate-/l*36.7%

        \[\leadsto {\left(\color{blue}{\left(\ell \cdot \frac{\sqrt{2}}{{k}^{2}}\right)} \cdot \sqrt{\frac{1}{t}}\right)}^{2} \]
    10. Simplified36.7%

      \[\leadsto {\color{blue}{\left(\left(\ell \cdot \frac{\sqrt{2}}{{k}^{2}}\right) \cdot \sqrt{\frac{1}{t}}\right)}}^{2} \]

    if 9.2e-6 < k

    1. Initial program 25.7%

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

      \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in t around 0 70.9%

      \[\leadsto \color{blue}{\left(2 \cdot \frac{\cos k}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}\right)} \cdot \left(\ell \cdot \ell\right) \]
    5. Step-by-step derivation
      1. unpow270.9%

        \[\leadsto \left(2 \cdot \frac{\frac{\cos k}{{k}^{2} \cdot t}}{\color{blue}{\sin k \cdot \sin k}}\right) \cdot \left(\ell \cdot \ell\right) \]
      2. sin-mult70.7%

        \[\leadsto \left(2 \cdot \frac{\frac{\cos k}{{k}^{2} \cdot t}}{\color{blue}{\frac{\cos \left(k - k\right) - \cos \left(k + k\right)}{2}}}\right) \cdot \left(\ell \cdot \ell\right) \]
    6. Applied egg-rr70.7%

      \[\leadsto \left(2 \cdot \frac{\cos k}{{k}^{2} \cdot \left(t \cdot \color{blue}{\frac{\cos \left(k - k\right) - \cos \left(k + k\right)}{2}}\right)}\right) \cdot \left(\ell \cdot \ell\right) \]
    7. Step-by-step derivation
      1. +-inverses70.7%

        \[\leadsto \left(2 \cdot \frac{\frac{\cos k}{{k}^{2} \cdot t}}{\frac{\cos \color{blue}{0} - \cos \left(k + k\right)}{2}}\right) \cdot \left(\ell \cdot \ell\right) \]
      2. cos-070.7%

        \[\leadsto \left(2 \cdot \frac{\frac{\cos k}{{k}^{2} \cdot t}}{\frac{\color{blue}{1} - \cos \left(k + k\right)}{2}}\right) \cdot \left(\ell \cdot \ell\right) \]
      3. count-270.7%

        \[\leadsto \left(2 \cdot \frac{\frac{\cos k}{{k}^{2} \cdot t}}{\frac{1 - \cos \color{blue}{\left(2 \cdot k\right)}}{2}}\right) \cdot \left(\ell \cdot \ell\right) \]
      4. *-commutative70.7%

        \[\leadsto \left(2 \cdot \frac{\frac{\cos k}{{k}^{2} \cdot t}}{\frac{1 - \cos \color{blue}{\left(k \cdot 2\right)}}{2}}\right) \cdot \left(\ell \cdot \ell\right) \]
    8. Simplified70.7%

      \[\leadsto \left(2 \cdot \frac{\cos k}{{k}^{2} \cdot \left(t \cdot \color{blue}{\frac{1 - \cos \left(k \cdot 2\right)}{2}}\right)}\right) \cdot \left(\ell \cdot \ell\right) \]
    9. Taylor expanded in k around inf 70.7%

      \[\leadsto \color{blue}{4 \cdot \frac{{\ell}^{2} \cdot \cos k}{{k}^{2} \cdot \left(t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)\right)}} \]
    10. Step-by-step derivation
      1. times-frac73.6%

        \[\leadsto 4 \cdot \color{blue}{\left(\frac{{\ell}^{2}}{{k}^{2}} \cdot \frac{\cos k}{t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)}\right)} \]
      2. associate-*r/73.6%

        \[\leadsto 4 \cdot \color{blue}{\frac{\frac{{\ell}^{2}}{{k}^{2}} \cdot \cos k}{t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)}} \]
      3. unpow273.6%

        \[\leadsto 4 \cdot \frac{\frac{\color{blue}{\ell \cdot \ell}}{{k}^{2}} \cdot \cos k}{t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)} \]
      4. unpow273.6%

        \[\leadsto 4 \cdot \frac{\frac{\ell \cdot \ell}{\color{blue}{k \cdot k}} \cdot \cos k}{t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)} \]
      5. times-frac96.3%

        \[\leadsto 4 \cdot \frac{\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\ell}{k}\right)} \cdot \cos k}{t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)} \]
      6. unpow296.3%

        \[\leadsto 4 \cdot \frac{\color{blue}{{\left(\frac{\ell}{k}\right)}^{2}} \cdot \cos k}{t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)} \]
    11. Simplified96.3%

      \[\leadsto \color{blue}{4 \cdot \frac{{\left(\frac{\ell}{k}\right)}^{2} \cdot \cos k}{t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification52.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 9.2 \cdot 10^{-6}:\\ \;\;\;\;{\left(\left(\ell \cdot \frac{\sqrt{2}}{{k}^{2}}\right) \cdot \sqrt{\frac{1}{t}}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \frac{\cos k \cdot {\left(\frac{\ell}{k}\right)}^{2}}{t \cdot \left(1 - \cos \left(k \cdot 2\right)\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 92.0% accurate, 1.0× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ t\_s \cdot \left(\cos k\_m \cdot \frac{{\left(\frac{\ell \cdot \sqrt{2}}{k\_m \cdot \sin k\_m}\right)}^{2}}{t\_m}\right) \end{array} \]
k_m = (fabs.f64 k)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k_m)
 :precision binary64
 (*
  t_s
  (* (cos k_m) (/ (pow (/ (* l (sqrt 2.0)) (* k_m (sin k_m))) 2.0) t_m))))
k_m = fabs(k);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k_m) {
	return t_s * (cos(k_m) * (pow(((l * sqrt(2.0)) / (k_m * sin(k_m))), 2.0) / t_m));
}
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0d0, t)
real(8) function code(t_s, t_m, l, k_m)
    real(8), intent (in) :: t_s
    real(8), intent (in) :: t_m
    real(8), intent (in) :: l
    real(8), intent (in) :: k_m
    code = t_s * (cos(k_m) * ((((l * sqrt(2.0d0)) / (k_m * sin(k_m))) ** 2.0d0) / t_m))
end function
k_m = Math.abs(k);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k_m) {
	return t_s * (Math.cos(k_m) * (Math.pow(((l * Math.sqrt(2.0)) / (k_m * Math.sin(k_m))), 2.0) / t_m));
}
k_m = math.fabs(k)
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
def code(t_s, t_m, l, k_m):
	return t_s * (math.cos(k_m) * (math.pow(((l * math.sqrt(2.0)) / (k_m * math.sin(k_m))), 2.0) / t_m))
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, t_m, l, k_m)
	return Float64(t_s * Float64(cos(k_m) * Float64((Float64(Float64(l * sqrt(2.0)) / Float64(k_m * sin(k_m))) ^ 2.0) / t_m)))
end
k_m = abs(k);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
function tmp = code(t_s, t_m, l, k_m)
	tmp = t_s * (cos(k_m) * ((((l * sqrt(2.0)) / (k_m * sin(k_m))) ^ 2.0) / t_m));
end
k_m = N[Abs[k], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k$95$m_] := N[(t$95$s * N[(N[Cos[k$95$m], $MachinePrecision] * N[(N[Power[N[(N[(l * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] / N[(k$95$m * N[Sin[k$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / t$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
k_m = \left|k\right|
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
t\_s \cdot \left(\cos k\_m \cdot \frac{{\left(\frac{\ell \cdot \sqrt{2}}{k\_m \cdot \sin k\_m}\right)}^{2}}{t\_m}\right)
\end{array}
Derivation
  1. Initial program 32.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. Simplified41.0%

    \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. add-sqr-sqrt26.1%

      \[\leadsto \color{blue}{\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \cdot \sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}} \]
    2. pow226.1%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}\right)}^{2}} \]
  5. Applied egg-rr24.7%

    \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\left(\sqrt{\sin k \cdot \tan k} \cdot \frac{k}{t}\right) \cdot {t}^{1.5}}\right)}^{2}} \]
  6. Step-by-step derivation
    1. associate-*l*25.1%

      \[\leadsto {\left(\ell \cdot \frac{\sqrt{2}}{\color{blue}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}}\right)}^{2} \]
  7. Simplified25.1%

    \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}\right)}^{2}} \]
  8. Taylor expanded in l around 0 41.6%

    \[\leadsto {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k} \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
  9. Step-by-step derivation
    1. times-frac42.3%

      \[\leadsto {\left(\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)} \cdot \sqrt{\frac{\cos k}{t}}\right)}^{2} \]
  10. Simplified42.3%

    \[\leadsto {\color{blue}{\left(\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right) \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
  11. Step-by-step derivation
    1. *-commutative42.3%

      \[\leadsto {\color{blue}{\left(\sqrt{\frac{\cos k}{t}} \cdot \left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)\right)}}^{2} \]
    2. unpow-prod-down40.2%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{\cos k}{t}}\right)}^{2} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2}} \]
    3. pow240.2%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{\cos k}{t}} \cdot \sqrt{\frac{\cos k}{t}}\right)} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2} \]
    4. add-sqr-sqrt95.5%

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

      \[\leadsto \frac{\cos k}{t} \cdot {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}}^{2} \]
  12. Applied egg-rr94.4%

    \[\leadsto \color{blue}{\frac{\cos k}{t} \cdot {\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}^{2}} \]
  13. Step-by-step derivation
    1. times-frac95.5%

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

    \[\leadsto \color{blue}{\frac{\cos k}{t} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2}} \]
  15. Step-by-step derivation
    1. associate-*l/95.4%

      \[\leadsto \color{blue}{\frac{\cos k \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2}}{t}} \]
    2. frac-times94.4%

      \[\leadsto \frac{\cos k \cdot {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}}^{2}}{t} \]
    3. associate-*r/94.4%

      \[\leadsto \frac{\cos k \cdot {\color{blue}{\left(\ell \cdot \frac{\sqrt{2}}{k \cdot \sin k}\right)}}^{2}}{t} \]
    4. associate-/r*94.4%

      \[\leadsto \frac{\cos k \cdot {\left(\ell \cdot \color{blue}{\frac{\frac{\sqrt{2}}{k}}{\sin k}}\right)}^{2}}{t} \]
  16. Applied egg-rr94.4%

    \[\leadsto \color{blue}{\frac{\cos k \cdot {\left(\ell \cdot \frac{\frac{\sqrt{2}}{k}}{\sin k}\right)}^{2}}{t}} \]
  17. Step-by-step derivation
    1. associate-/l*94.4%

      \[\leadsto \color{blue}{\cos k \cdot \frac{{\left(\ell \cdot \frac{\frac{\sqrt{2}}{k}}{\sin k}\right)}^{2}}{t}} \]
    2. associate-/r*94.4%

      \[\leadsto \cos k \cdot \frac{{\left(\ell \cdot \color{blue}{\frac{\sqrt{2}}{k \cdot \sin k}}\right)}^{2}}{t} \]
    3. associate-/l*94.4%

      \[\leadsto \cos k \cdot \frac{{\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}}^{2}}{t} \]
  18. Simplified94.4%

    \[\leadsto \color{blue}{\cos k \cdot \frac{{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}^{2}}{t}} \]
  19. Final simplification94.4%

    \[\leadsto \cos k \cdot \frac{{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}^{2}}{t} \]
  20. Add Preprocessing

Alternative 7: 92.9% accurate, 1.0× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ t\_s \cdot \left(\frac{\cos k\_m}{t\_m} \cdot {\left(\frac{\ell}{k\_m} \cdot \frac{\sqrt{2}}{\sin k\_m}\right)}^{2}\right) \end{array} \]
k_m = (fabs.f64 k)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k_m)
 :precision binary64
 (*
  t_s
  (* (/ (cos k_m) t_m) (pow (* (/ l k_m) (/ (sqrt 2.0) (sin k_m))) 2.0))))
k_m = fabs(k);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k_m) {
	return t_s * ((cos(k_m) / t_m) * pow(((l / k_m) * (sqrt(2.0) / sin(k_m))), 2.0));
}
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0d0, t)
real(8) function code(t_s, t_m, l, k_m)
    real(8), intent (in) :: t_s
    real(8), intent (in) :: t_m
    real(8), intent (in) :: l
    real(8), intent (in) :: k_m
    code = t_s * ((cos(k_m) / t_m) * (((l / k_m) * (sqrt(2.0d0) / sin(k_m))) ** 2.0d0))
end function
k_m = Math.abs(k);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k_m) {
	return t_s * ((Math.cos(k_m) / t_m) * Math.pow(((l / k_m) * (Math.sqrt(2.0) / Math.sin(k_m))), 2.0));
}
k_m = math.fabs(k)
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
def code(t_s, t_m, l, k_m):
	return t_s * ((math.cos(k_m) / t_m) * math.pow(((l / k_m) * (math.sqrt(2.0) / math.sin(k_m))), 2.0))
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, t_m, l, k_m)
	return Float64(t_s * Float64(Float64(cos(k_m) / t_m) * (Float64(Float64(l / k_m) * Float64(sqrt(2.0) / sin(k_m))) ^ 2.0)))
end
k_m = abs(k);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
function tmp = code(t_s, t_m, l, k_m)
	tmp = t_s * ((cos(k_m) / t_m) * (((l / k_m) * (sqrt(2.0) / sin(k_m))) ^ 2.0));
end
k_m = N[Abs[k], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k$95$m_] := N[(t$95$s * N[(N[(N[Cos[k$95$m], $MachinePrecision] / t$95$m), $MachinePrecision] * N[Power[N[(N[(l / k$95$m), $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / N[Sin[k$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
k_m = \left|k\right|
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
t\_s \cdot \left(\frac{\cos k\_m}{t\_m} \cdot {\left(\frac{\ell}{k\_m} \cdot \frac{\sqrt{2}}{\sin k\_m}\right)}^{2}\right)
\end{array}
Derivation
  1. Initial program 32.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. Simplified41.0%

    \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. add-sqr-sqrt26.1%

      \[\leadsto \color{blue}{\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \cdot \sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}} \]
    2. pow226.1%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}\right)}^{2}} \]
  5. Applied egg-rr24.7%

    \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\left(\sqrt{\sin k \cdot \tan k} \cdot \frac{k}{t}\right) \cdot {t}^{1.5}}\right)}^{2}} \]
  6. Step-by-step derivation
    1. associate-*l*25.1%

      \[\leadsto {\left(\ell \cdot \frac{\sqrt{2}}{\color{blue}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}}\right)}^{2} \]
  7. Simplified25.1%

    \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}\right)}^{2}} \]
  8. Taylor expanded in l around 0 41.6%

    \[\leadsto {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k} \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
  9. Step-by-step derivation
    1. times-frac42.3%

      \[\leadsto {\left(\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)} \cdot \sqrt{\frac{\cos k}{t}}\right)}^{2} \]
  10. Simplified42.3%

    \[\leadsto {\color{blue}{\left(\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right) \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
  11. Step-by-step derivation
    1. *-commutative42.3%

      \[\leadsto {\color{blue}{\left(\sqrt{\frac{\cos k}{t}} \cdot \left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)\right)}}^{2} \]
    2. unpow-prod-down40.2%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{\cos k}{t}}\right)}^{2} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2}} \]
    3. pow240.2%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{\cos k}{t}} \cdot \sqrt{\frac{\cos k}{t}}\right)} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2} \]
    4. add-sqr-sqrt95.5%

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

      \[\leadsto \frac{\cos k}{t} \cdot {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}}^{2} \]
  12. Applied egg-rr94.4%

    \[\leadsto \color{blue}{\frac{\cos k}{t} \cdot {\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}^{2}} \]
  13. Step-by-step derivation
    1. times-frac95.5%

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

    \[\leadsto \color{blue}{\frac{\cos k}{t} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2}} \]
  15. Final simplification95.5%

    \[\leadsto \frac{\cos k}{t} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2} \]
  16. Add Preprocessing

Alternative 8: 92.8% accurate, 1.0× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ t\_s \cdot \left(\frac{\cos k\_m}{t\_m} \cdot {\left(\frac{\ell \cdot \frac{\sqrt{2}}{\sin k\_m}}{k\_m}\right)}^{2}\right) \end{array} \]
k_m = (fabs.f64 k)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k_m)
 :precision binary64
 (*
  t_s
  (* (/ (cos k_m) t_m) (pow (/ (* l (/ (sqrt 2.0) (sin k_m))) k_m) 2.0))))
k_m = fabs(k);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k_m) {
	return t_s * ((cos(k_m) / t_m) * pow(((l * (sqrt(2.0) / sin(k_m))) / k_m), 2.0));
}
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0d0, t)
real(8) function code(t_s, t_m, l, k_m)
    real(8), intent (in) :: t_s
    real(8), intent (in) :: t_m
    real(8), intent (in) :: l
    real(8), intent (in) :: k_m
    code = t_s * ((cos(k_m) / t_m) * (((l * (sqrt(2.0d0) / sin(k_m))) / k_m) ** 2.0d0))
end function
k_m = Math.abs(k);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k_m) {
	return t_s * ((Math.cos(k_m) / t_m) * Math.pow(((l * (Math.sqrt(2.0) / Math.sin(k_m))) / k_m), 2.0));
}
k_m = math.fabs(k)
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
def code(t_s, t_m, l, k_m):
	return t_s * ((math.cos(k_m) / t_m) * math.pow(((l * (math.sqrt(2.0) / math.sin(k_m))) / k_m), 2.0))
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, t_m, l, k_m)
	return Float64(t_s * Float64(Float64(cos(k_m) / t_m) * (Float64(Float64(l * Float64(sqrt(2.0) / sin(k_m))) / k_m) ^ 2.0)))
end
k_m = abs(k);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
function tmp = code(t_s, t_m, l, k_m)
	tmp = t_s * ((cos(k_m) / t_m) * (((l * (sqrt(2.0) / sin(k_m))) / k_m) ^ 2.0));
end
k_m = N[Abs[k], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k$95$m_] := N[(t$95$s * N[(N[(N[Cos[k$95$m], $MachinePrecision] / t$95$m), $MachinePrecision] * N[Power[N[(N[(l * N[(N[Sqrt[2.0], $MachinePrecision] / N[Sin[k$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / k$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
k_m = \left|k\right|
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
t\_s \cdot \left(\frac{\cos k\_m}{t\_m} \cdot {\left(\frac{\ell \cdot \frac{\sqrt{2}}{\sin k\_m}}{k\_m}\right)}^{2}\right)
\end{array}
Derivation
  1. Initial program 32.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. Simplified41.0%

    \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. add-sqr-sqrt26.1%

      \[\leadsto \color{blue}{\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \cdot \sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}} \]
    2. pow226.1%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}\right)}^{2}} \]
  5. Applied egg-rr24.7%

    \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\left(\sqrt{\sin k \cdot \tan k} \cdot \frac{k}{t}\right) \cdot {t}^{1.5}}\right)}^{2}} \]
  6. Step-by-step derivation
    1. associate-*l*25.1%

      \[\leadsto {\left(\ell \cdot \frac{\sqrt{2}}{\color{blue}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}}\right)}^{2} \]
  7. Simplified25.1%

    \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}\right)}^{2}} \]
  8. Taylor expanded in l around 0 41.6%

    \[\leadsto {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k} \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
  9. Step-by-step derivation
    1. times-frac42.3%

      \[\leadsto {\left(\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)} \cdot \sqrt{\frac{\cos k}{t}}\right)}^{2} \]
  10. Simplified42.3%

    \[\leadsto {\color{blue}{\left(\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right) \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
  11. Step-by-step derivation
    1. *-commutative42.3%

      \[\leadsto {\color{blue}{\left(\sqrt{\frac{\cos k}{t}} \cdot \left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)\right)}}^{2} \]
    2. unpow-prod-down40.2%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{\cos k}{t}}\right)}^{2} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2}} \]
    3. pow240.2%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{\cos k}{t}} \cdot \sqrt{\frac{\cos k}{t}}\right)} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2} \]
    4. add-sqr-sqrt95.5%

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

      \[\leadsto \frac{\cos k}{t} \cdot {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}}^{2} \]
  12. Applied egg-rr94.4%

    \[\leadsto \color{blue}{\frac{\cos k}{t} \cdot {\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}^{2}} \]
  13. Step-by-step derivation
    1. associate-/l*94.4%

      \[\leadsto \frac{\cos k}{t} \cdot {\color{blue}{\left(\ell \cdot \frac{\sqrt{2}}{k \cdot \sin k}\right)}}^{2} \]
  14. Simplified94.4%

    \[\leadsto \color{blue}{\frac{\cos k}{t} \cdot {\left(\ell \cdot \frac{\sqrt{2}}{k \cdot \sin k}\right)}^{2}} \]
  15. Step-by-step derivation
    1. associate-*r/94.4%

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

      \[\leadsto \frac{\cos k}{t} \cdot {\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}}^{2} \]
    3. associate-*l/95.5%

      \[\leadsto \frac{\cos k}{t} \cdot {\color{blue}{\left(\frac{\ell \cdot \frac{\sqrt{2}}{\sin k}}{k}\right)}}^{2} \]
  16. Applied egg-rr95.5%

    \[\leadsto \frac{\cos k}{t} \cdot {\color{blue}{\left(\frac{\ell \cdot \frac{\sqrt{2}}{\sin k}}{k}\right)}}^{2} \]
  17. Final simplification95.5%

    \[\leadsto \frac{\cos k}{t} \cdot {\left(\frac{\ell \cdot \frac{\sqrt{2}}{\sin k}}{k}\right)}^{2} \]
  18. Add Preprocessing

Alternative 9: 92.9% accurate, 1.0× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ t\_s \cdot \left(\frac{\cos k\_m}{t\_m} \cdot {\left(\frac{\frac{\ell}{k\_m} \cdot \sqrt{2}}{\sin k\_m}\right)}^{2}\right) \end{array} \]
k_m = (fabs.f64 k)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k_m)
 :precision binary64
 (*
  t_s
  (* (/ (cos k_m) t_m) (pow (/ (* (/ l k_m) (sqrt 2.0)) (sin k_m)) 2.0))))
k_m = fabs(k);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k_m) {
	return t_s * ((cos(k_m) / t_m) * pow((((l / k_m) * sqrt(2.0)) / sin(k_m)), 2.0));
}
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0d0, t)
real(8) function code(t_s, t_m, l, k_m)
    real(8), intent (in) :: t_s
    real(8), intent (in) :: t_m
    real(8), intent (in) :: l
    real(8), intent (in) :: k_m
    code = t_s * ((cos(k_m) / t_m) * ((((l / k_m) * sqrt(2.0d0)) / sin(k_m)) ** 2.0d0))
end function
k_m = Math.abs(k);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k_m) {
	return t_s * ((Math.cos(k_m) / t_m) * Math.pow((((l / k_m) * Math.sqrt(2.0)) / Math.sin(k_m)), 2.0));
}
k_m = math.fabs(k)
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
def code(t_s, t_m, l, k_m):
	return t_s * ((math.cos(k_m) / t_m) * math.pow((((l / k_m) * math.sqrt(2.0)) / math.sin(k_m)), 2.0))
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, t_m, l, k_m)
	return Float64(t_s * Float64(Float64(cos(k_m) / t_m) * (Float64(Float64(Float64(l / k_m) * sqrt(2.0)) / sin(k_m)) ^ 2.0)))
end
k_m = abs(k);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
function tmp = code(t_s, t_m, l, k_m)
	tmp = t_s * ((cos(k_m) / t_m) * ((((l / k_m) * sqrt(2.0)) / sin(k_m)) ^ 2.0));
end
k_m = N[Abs[k], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k$95$m_] := N[(t$95$s * N[(N[(N[Cos[k$95$m], $MachinePrecision] / t$95$m), $MachinePrecision] * N[Power[N[(N[(N[(l / k$95$m), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] / N[Sin[k$95$m], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
k_m = \left|k\right|
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
t\_s \cdot \left(\frac{\cos k\_m}{t\_m} \cdot {\left(\frac{\frac{\ell}{k\_m} \cdot \sqrt{2}}{\sin k\_m}\right)}^{2}\right)
\end{array}
Derivation
  1. Initial program 32.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. Simplified41.0%

    \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. add-sqr-sqrt26.1%

      \[\leadsto \color{blue}{\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \cdot \sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}} \]
    2. pow226.1%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}\right)}^{2}} \]
  5. Applied egg-rr24.7%

    \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\left(\sqrt{\sin k \cdot \tan k} \cdot \frac{k}{t}\right) \cdot {t}^{1.5}}\right)}^{2}} \]
  6. Step-by-step derivation
    1. associate-*l*25.1%

      \[\leadsto {\left(\ell \cdot \frac{\sqrt{2}}{\color{blue}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}}\right)}^{2} \]
  7. Simplified25.1%

    \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}\right)}^{2}} \]
  8. Taylor expanded in l around 0 41.6%

    \[\leadsto {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k} \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
  9. Step-by-step derivation
    1. times-frac42.3%

      \[\leadsto {\left(\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)} \cdot \sqrt{\frac{\cos k}{t}}\right)}^{2} \]
  10. Simplified42.3%

    \[\leadsto {\color{blue}{\left(\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right) \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
  11. Step-by-step derivation
    1. *-commutative42.3%

      \[\leadsto {\color{blue}{\left(\sqrt{\frac{\cos k}{t}} \cdot \left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)\right)}}^{2} \]
    2. unpow-prod-down40.2%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{\cos k}{t}}\right)}^{2} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2}} \]
    3. pow240.2%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{\cos k}{t}} \cdot \sqrt{\frac{\cos k}{t}}\right)} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2} \]
    4. add-sqr-sqrt95.5%

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

      \[\leadsto \frac{\cos k}{t} \cdot {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}}^{2} \]
  12. Applied egg-rr94.4%

    \[\leadsto \color{blue}{\frac{\cos k}{t} \cdot {\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}^{2}} \]
  13. Step-by-step derivation
    1. associate-/l*94.4%

      \[\leadsto \frac{\cos k}{t} \cdot {\color{blue}{\left(\ell \cdot \frac{\sqrt{2}}{k \cdot \sin k}\right)}}^{2} \]
  14. Simplified94.4%

    \[\leadsto \color{blue}{\frac{\cos k}{t} \cdot {\left(\ell \cdot \frac{\sqrt{2}}{k \cdot \sin k}\right)}^{2}} \]
  15. Step-by-step derivation
    1. associate-*r/94.4%

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

      \[\leadsto \frac{\cos k}{t} \cdot {\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}}^{2} \]
    3. associate-*r/95.5%

      \[\leadsto \frac{\cos k}{t} \cdot {\color{blue}{\left(\frac{\frac{\ell}{k} \cdot \sqrt{2}}{\sin k}\right)}}^{2} \]
  16. Applied egg-rr95.5%

    \[\leadsto \frac{\cos k}{t} \cdot {\color{blue}{\left(\frac{\frac{\ell}{k} \cdot \sqrt{2}}{\sin k}\right)}}^{2} \]
  17. Final simplification95.5%

    \[\leadsto \frac{\cos k}{t} \cdot {\left(\frac{\frac{\ell}{k} \cdot \sqrt{2}}{\sin k}\right)}^{2} \]
  18. Add Preprocessing

Alternative 10: 92.7% accurate, 1.3× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ \begin{array}{l} t_2 := \frac{\cos k\_m}{t\_m}\\ t\_s \cdot \begin{array}{l} \mathbf{if}\;k\_m \leq 9.2 \cdot 10^{-6}:\\ \;\;\;\;t\_2 \cdot {\left(\frac{\ell}{k\_m} \cdot \frac{\sqrt{2}}{k\_m}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \left({\left(\frac{\ell}{k\_m}\right)}^{2} \cdot \frac{t\_2}{1 - \cos \left(k\_m \cdot 2\right)}\right)\\ \end{array} \end{array} \end{array} \]
k_m = (fabs.f64 k)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k_m)
 :precision binary64
 (let* ((t_2 (/ (cos k_m) t_m)))
   (*
    t_s
    (if (<= k_m 9.2e-6)
      (* t_2 (pow (* (/ l k_m) (/ (sqrt 2.0) k_m)) 2.0))
      (* 4.0 (* (pow (/ l k_m) 2.0) (/ t_2 (- 1.0 (cos (* k_m 2.0))))))))))
k_m = fabs(k);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k_m) {
	double t_2 = cos(k_m) / t_m;
	double tmp;
	if (k_m <= 9.2e-6) {
		tmp = t_2 * pow(((l / k_m) * (sqrt(2.0) / k_m)), 2.0);
	} else {
		tmp = 4.0 * (pow((l / k_m), 2.0) * (t_2 / (1.0 - cos((k_m * 2.0)))));
	}
	return t_s * tmp;
}
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0d0, t)
real(8) function code(t_s, t_m, l, k_m)
    real(8), intent (in) :: t_s
    real(8), intent (in) :: t_m
    real(8), intent (in) :: l
    real(8), intent (in) :: k_m
    real(8) :: t_2
    real(8) :: tmp
    t_2 = cos(k_m) / t_m
    if (k_m <= 9.2d-6) then
        tmp = t_2 * (((l / k_m) * (sqrt(2.0d0) / k_m)) ** 2.0d0)
    else
        tmp = 4.0d0 * (((l / k_m) ** 2.0d0) * (t_2 / (1.0d0 - cos((k_m * 2.0d0)))))
    end if
    code = t_s * tmp
end function
k_m = Math.abs(k);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k_m) {
	double t_2 = Math.cos(k_m) / t_m;
	double tmp;
	if (k_m <= 9.2e-6) {
		tmp = t_2 * Math.pow(((l / k_m) * (Math.sqrt(2.0) / k_m)), 2.0);
	} else {
		tmp = 4.0 * (Math.pow((l / k_m), 2.0) * (t_2 / (1.0 - Math.cos((k_m * 2.0)))));
	}
	return t_s * tmp;
}
k_m = math.fabs(k)
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
def code(t_s, t_m, l, k_m):
	t_2 = math.cos(k_m) / t_m
	tmp = 0
	if k_m <= 9.2e-6:
		tmp = t_2 * math.pow(((l / k_m) * (math.sqrt(2.0) / k_m)), 2.0)
	else:
		tmp = 4.0 * (math.pow((l / k_m), 2.0) * (t_2 / (1.0 - math.cos((k_m * 2.0)))))
	return t_s * tmp
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, t_m, l, k_m)
	t_2 = Float64(cos(k_m) / t_m)
	tmp = 0.0
	if (k_m <= 9.2e-6)
		tmp = Float64(t_2 * (Float64(Float64(l / k_m) * Float64(sqrt(2.0) / k_m)) ^ 2.0));
	else
		tmp = Float64(4.0 * Float64((Float64(l / k_m) ^ 2.0) * Float64(t_2 / Float64(1.0 - cos(Float64(k_m * 2.0))))));
	end
	return Float64(t_s * tmp)
end
k_m = abs(k);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
function tmp_2 = code(t_s, t_m, l, k_m)
	t_2 = cos(k_m) / t_m;
	tmp = 0.0;
	if (k_m <= 9.2e-6)
		tmp = t_2 * (((l / k_m) * (sqrt(2.0) / k_m)) ^ 2.0);
	else
		tmp = 4.0 * (((l / k_m) ^ 2.0) * (t_2 / (1.0 - cos((k_m * 2.0)))));
	end
	tmp_2 = t_s * tmp;
end
k_m = N[Abs[k], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k$95$m_] := Block[{t$95$2 = N[(N[Cos[k$95$m], $MachinePrecision] / t$95$m), $MachinePrecision]}, N[(t$95$s * If[LessEqual[k$95$m, 9.2e-6], N[(t$95$2 * N[Power[N[(N[(l / k$95$m), $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / k$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(N[Power[N[(l / k$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(t$95$2 / N[(1.0 - N[Cos[N[(k$95$m * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
k_m = \left|k\right|
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
\begin{array}{l}
t_2 := \frac{\cos k\_m}{t\_m}\\
t\_s \cdot \begin{array}{l}
\mathbf{if}\;k\_m \leq 9.2 \cdot 10^{-6}:\\
\;\;\;\;t\_2 \cdot {\left(\frac{\ell}{k\_m} \cdot \frac{\sqrt{2}}{k\_m}\right)}^{2}\\

\mathbf{else}:\\
\;\;\;\;4 \cdot \left({\left(\frac{\ell}{k\_m}\right)}^{2} \cdot \frac{t\_2}{1 - \cos \left(k\_m \cdot 2\right)}\right)\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 9.2e-6

    1. Initial program 35.3%

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

      \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt23.5%

        \[\leadsto \color{blue}{\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \cdot \sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}} \]
      2. pow223.5%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}\right)}^{2}} \]
    5. Applied egg-rr27.1%

      \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\left(\sqrt{\sin k \cdot \tan k} \cdot \frac{k}{t}\right) \cdot {t}^{1.5}}\right)}^{2}} \]
    6. Step-by-step derivation
      1. associate-*l*27.6%

        \[\leadsto {\left(\ell \cdot \frac{\sqrt{2}}{\color{blue}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}}\right)}^{2} \]
    7. Simplified27.6%

      \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}\right)}^{2}} \]
    8. Taylor expanded in l around 0 38.0%

      \[\leadsto {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k} \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
    9. Step-by-step derivation
      1. times-frac38.9%

        \[\leadsto {\left(\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)} \cdot \sqrt{\frac{\cos k}{t}}\right)}^{2} \]
    10. Simplified38.9%

      \[\leadsto {\color{blue}{\left(\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right) \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
    11. Step-by-step derivation
      1. *-commutative38.9%

        \[\leadsto {\color{blue}{\left(\sqrt{\frac{\cos k}{t}} \cdot \left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)\right)}}^{2} \]
      2. unpow-prod-down37.0%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{\cos k}{t}}\right)}^{2} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2}} \]
      3. pow237.0%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{\cos k}{t}} \cdot \sqrt{\frac{\cos k}{t}}\right)} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2} \]
      4. add-sqr-sqrt95.1%

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

        \[\leadsto \frac{\cos k}{t} \cdot {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}}^{2} \]
    12. Applied egg-rr93.6%

      \[\leadsto \color{blue}{\frac{\cos k}{t} \cdot {\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}^{2}} \]
    13. Step-by-step derivation
      1. times-frac95.1%

        \[\leadsto \frac{\cos k}{t} \cdot {\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}}^{2} \]
    14. Simplified95.1%

      \[\leadsto \color{blue}{\frac{\cos k}{t} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2}} \]
    15. Taylor expanded in k around 0 84.9%

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

    if 9.2e-6 < k

    1. Initial program 25.7%

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

      \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in t around 0 70.9%

      \[\leadsto \color{blue}{\left(2 \cdot \frac{\cos k}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}\right)} \cdot \left(\ell \cdot \ell\right) \]
    5. Step-by-step derivation
      1. associate-*r*70.9%

        \[\leadsto \left(2 \cdot \frac{\cos k}{\color{blue}{\left({k}^{2} \cdot t\right) \cdot {\sin k}^{2}}}\right) \cdot \left(\ell \cdot \ell\right) \]
      2. associate-/r*70.9%

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

      \[\leadsto \color{blue}{\left(2 \cdot \frac{\frac{\cos k}{{k}^{2} \cdot t}}{{\sin k}^{2}}\right)} \cdot \left(\ell \cdot \ell\right) \]
    7. Step-by-step derivation
      1. unpow270.9%

        \[\leadsto \left(2 \cdot \frac{\frac{\cos k}{{k}^{2} \cdot t}}{\color{blue}{\sin k \cdot \sin k}}\right) \cdot \left(\ell \cdot \ell\right) \]
      2. sin-mult70.7%

        \[\leadsto \left(2 \cdot \frac{\frac{\cos k}{{k}^{2} \cdot t}}{\color{blue}{\frac{\cos \left(k - k\right) - \cos \left(k + k\right)}{2}}}\right) \cdot \left(\ell \cdot \ell\right) \]
    8. Applied egg-rr70.7%

      \[\leadsto \left(2 \cdot \frac{\frac{\cos k}{{k}^{2} \cdot t}}{\color{blue}{\frac{\cos \left(k - k\right) - \cos \left(k + k\right)}{2}}}\right) \cdot \left(\ell \cdot \ell\right) \]
    9. Step-by-step derivation
      1. +-inverses70.7%

        \[\leadsto \left(2 \cdot \frac{\frac{\cos k}{{k}^{2} \cdot t}}{\frac{\cos \color{blue}{0} - \cos \left(k + k\right)}{2}}\right) \cdot \left(\ell \cdot \ell\right) \]
      2. cos-070.7%

        \[\leadsto \left(2 \cdot \frac{\frac{\cos k}{{k}^{2} \cdot t}}{\frac{\color{blue}{1} - \cos \left(k + k\right)}{2}}\right) \cdot \left(\ell \cdot \ell\right) \]
      3. count-270.7%

        \[\leadsto \left(2 \cdot \frac{\frac{\cos k}{{k}^{2} \cdot t}}{\frac{1 - \cos \color{blue}{\left(2 \cdot k\right)}}{2}}\right) \cdot \left(\ell \cdot \ell\right) \]
      4. *-commutative70.7%

        \[\leadsto \left(2 \cdot \frac{\frac{\cos k}{{k}^{2} \cdot t}}{\frac{1 - \cos \color{blue}{\left(k \cdot 2\right)}}{2}}\right) \cdot \left(\ell \cdot \ell\right) \]
    10. Simplified70.7%

      \[\leadsto \left(2 \cdot \frac{\frac{\cos k}{{k}^{2} \cdot t}}{\color{blue}{\frac{1 - \cos \left(k \cdot 2\right)}{2}}}\right) \cdot \left(\ell \cdot \ell\right) \]
    11. Taylor expanded in k around inf 70.7%

      \[\leadsto \color{blue}{4 \cdot \frac{{\ell}^{2} \cdot \cos k}{{k}^{2} \cdot \left(t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)\right)}} \]
    12. Step-by-step derivation
      1. times-frac73.6%

        \[\leadsto 4 \cdot \color{blue}{\left(\frac{{\ell}^{2}}{{k}^{2}} \cdot \frac{\cos k}{t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)}\right)} \]
      2. unpow273.6%

        \[\leadsto 4 \cdot \left(\frac{\color{blue}{\ell \cdot \ell}}{{k}^{2}} \cdot \frac{\cos k}{t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)}\right) \]
      3. unpow273.6%

        \[\leadsto 4 \cdot \left(\frac{\ell \cdot \ell}{\color{blue}{k \cdot k}} \cdot \frac{\cos k}{t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)}\right) \]
      4. times-frac96.4%

        \[\leadsto 4 \cdot \left(\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\ell}{k}\right)} \cdot \frac{\cos k}{t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)}\right) \]
      5. unpow296.4%

        \[\leadsto 4 \cdot \left(\color{blue}{{\left(\frac{\ell}{k}\right)}^{2}} \cdot \frac{\cos k}{t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)}\right) \]
      6. *-commutative96.4%

        \[\leadsto 4 \cdot \left({\left(\frac{\ell}{k}\right)}^{2} \cdot \frac{\cos k}{t \cdot \left(1 - \cos \color{blue}{\left(k \cdot 2\right)}\right)}\right) \]
      7. associate-/r*96.3%

        \[\leadsto 4 \cdot \left({\left(\frac{\ell}{k}\right)}^{2} \cdot \color{blue}{\frac{\frac{\cos k}{t}}{1 - \cos \left(k \cdot 2\right)}}\right) \]
      8. *-commutative96.3%

        \[\leadsto 4 \cdot \left({\left(\frac{\ell}{k}\right)}^{2} \cdot \frac{\frac{\cos k}{t}}{1 - \cos \color{blue}{\left(2 \cdot k\right)}}\right) \]
    13. Simplified96.3%

      \[\leadsto \color{blue}{4 \cdot \left({\left(\frac{\ell}{k}\right)}^{2} \cdot \frac{\frac{\cos k}{t}}{1 - \cos \left(2 \cdot k\right)}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification87.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 9.2 \cdot 10^{-6}:\\ \;\;\;\;\frac{\cos k}{t} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{k}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \left({\left(\frac{\ell}{k}\right)}^{2} \cdot \frac{\frac{\cos k}{t}}{1 - \cos \left(k \cdot 2\right)}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 92.7% accurate, 1.3× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ t\_s \cdot \begin{array}{l} \mathbf{if}\;k\_m \leq 9.2 \cdot 10^{-6}:\\ \;\;\;\;\frac{\cos k\_m}{t\_m} \cdot {\left(\frac{\ell}{k\_m} \cdot \frac{\sqrt{2}}{k\_m}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \frac{\cos k\_m \cdot {\left(\frac{\ell}{k\_m}\right)}^{2}}{t\_m \cdot \left(1 - \cos \left(k\_m \cdot 2\right)\right)}\\ \end{array} \end{array} \]
k_m = (fabs.f64 k)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k_m)
 :precision binary64
 (*
  t_s
  (if (<= k_m 9.2e-6)
    (* (/ (cos k_m) t_m) (pow (* (/ l k_m) (/ (sqrt 2.0) k_m)) 2.0))
    (*
     4.0
     (/
      (* (cos k_m) (pow (/ l k_m) 2.0))
      (* t_m (- 1.0 (cos (* k_m 2.0)))))))))
k_m = fabs(k);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k_m) {
	double tmp;
	if (k_m <= 9.2e-6) {
		tmp = (cos(k_m) / t_m) * pow(((l / k_m) * (sqrt(2.0) / k_m)), 2.0);
	} else {
		tmp = 4.0 * ((cos(k_m) * pow((l / k_m), 2.0)) / (t_m * (1.0 - cos((k_m * 2.0)))));
	}
	return t_s * tmp;
}
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0d0, t)
real(8) function code(t_s, t_m, l, k_m)
    real(8), intent (in) :: t_s
    real(8), intent (in) :: t_m
    real(8), intent (in) :: l
    real(8), intent (in) :: k_m
    real(8) :: tmp
    if (k_m <= 9.2d-6) then
        tmp = (cos(k_m) / t_m) * (((l / k_m) * (sqrt(2.0d0) / k_m)) ** 2.0d0)
    else
        tmp = 4.0d0 * ((cos(k_m) * ((l / k_m) ** 2.0d0)) / (t_m * (1.0d0 - cos((k_m * 2.0d0)))))
    end if
    code = t_s * tmp
end function
k_m = Math.abs(k);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k_m) {
	double tmp;
	if (k_m <= 9.2e-6) {
		tmp = (Math.cos(k_m) / t_m) * Math.pow(((l / k_m) * (Math.sqrt(2.0) / k_m)), 2.0);
	} else {
		tmp = 4.0 * ((Math.cos(k_m) * Math.pow((l / k_m), 2.0)) / (t_m * (1.0 - Math.cos((k_m * 2.0)))));
	}
	return t_s * tmp;
}
k_m = math.fabs(k)
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
def code(t_s, t_m, l, k_m):
	tmp = 0
	if k_m <= 9.2e-6:
		tmp = (math.cos(k_m) / t_m) * math.pow(((l / k_m) * (math.sqrt(2.0) / k_m)), 2.0)
	else:
		tmp = 4.0 * ((math.cos(k_m) * math.pow((l / k_m), 2.0)) / (t_m * (1.0 - math.cos((k_m * 2.0)))))
	return t_s * tmp
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, t_m, l, k_m)
	tmp = 0.0
	if (k_m <= 9.2e-6)
		tmp = Float64(Float64(cos(k_m) / t_m) * (Float64(Float64(l / k_m) * Float64(sqrt(2.0) / k_m)) ^ 2.0));
	else
		tmp = Float64(4.0 * Float64(Float64(cos(k_m) * (Float64(l / k_m) ^ 2.0)) / Float64(t_m * Float64(1.0 - cos(Float64(k_m * 2.0))))));
	end
	return Float64(t_s * tmp)
end
k_m = abs(k);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
function tmp_2 = code(t_s, t_m, l, k_m)
	tmp = 0.0;
	if (k_m <= 9.2e-6)
		tmp = (cos(k_m) / t_m) * (((l / k_m) * (sqrt(2.0) / k_m)) ^ 2.0);
	else
		tmp = 4.0 * ((cos(k_m) * ((l / k_m) ^ 2.0)) / (t_m * (1.0 - cos((k_m * 2.0)))));
	end
	tmp_2 = t_s * tmp;
end
k_m = N[Abs[k], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k$95$m_] := N[(t$95$s * If[LessEqual[k$95$m, 9.2e-6], N[(N[(N[Cos[k$95$m], $MachinePrecision] / t$95$m), $MachinePrecision] * N[Power[N[(N[(l / k$95$m), $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / k$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(N[(N[Cos[k$95$m], $MachinePrecision] * N[Power[N[(l / k$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(t$95$m * N[(1.0 - N[Cos[N[(k$95$m * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
k_m = \left|k\right|
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
t\_s \cdot \begin{array}{l}
\mathbf{if}\;k\_m \leq 9.2 \cdot 10^{-6}:\\
\;\;\;\;\frac{\cos k\_m}{t\_m} \cdot {\left(\frac{\ell}{k\_m} \cdot \frac{\sqrt{2}}{k\_m}\right)}^{2}\\

\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{\cos k\_m \cdot {\left(\frac{\ell}{k\_m}\right)}^{2}}{t\_m \cdot \left(1 - \cos \left(k\_m \cdot 2\right)\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if k < 9.2e-6

    1. Initial program 35.3%

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

      \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt23.5%

        \[\leadsto \color{blue}{\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \cdot \sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}} \]
      2. pow223.5%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}\right)}^{2}} \]
    5. Applied egg-rr27.1%

      \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\left(\sqrt{\sin k \cdot \tan k} \cdot \frac{k}{t}\right) \cdot {t}^{1.5}}\right)}^{2}} \]
    6. Step-by-step derivation
      1. associate-*l*27.6%

        \[\leadsto {\left(\ell \cdot \frac{\sqrt{2}}{\color{blue}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}}\right)}^{2} \]
    7. Simplified27.6%

      \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}\right)}^{2}} \]
    8. Taylor expanded in l around 0 38.0%

      \[\leadsto {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k} \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
    9. Step-by-step derivation
      1. times-frac38.9%

        \[\leadsto {\left(\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)} \cdot \sqrt{\frac{\cos k}{t}}\right)}^{2} \]
    10. Simplified38.9%

      \[\leadsto {\color{blue}{\left(\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right) \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
    11. Step-by-step derivation
      1. *-commutative38.9%

        \[\leadsto {\color{blue}{\left(\sqrt{\frac{\cos k}{t}} \cdot \left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)\right)}}^{2} \]
      2. unpow-prod-down37.0%

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{\cos k}{t}}\right)}^{2} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2}} \]
      3. pow237.0%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{\cos k}{t}} \cdot \sqrt{\frac{\cos k}{t}}\right)} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2} \]
      4. add-sqr-sqrt95.1%

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

        \[\leadsto \frac{\cos k}{t} \cdot {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}}^{2} \]
    12. Applied egg-rr93.6%

      \[\leadsto \color{blue}{\frac{\cos k}{t} \cdot {\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}^{2}} \]
    13. Step-by-step derivation
      1. times-frac95.1%

        \[\leadsto \frac{\cos k}{t} \cdot {\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}}^{2} \]
    14. Simplified95.1%

      \[\leadsto \color{blue}{\frac{\cos k}{t} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2}} \]
    15. Taylor expanded in k around 0 84.9%

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

    if 9.2e-6 < k

    1. Initial program 25.7%

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

      \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in t around 0 70.9%

      \[\leadsto \color{blue}{\left(2 \cdot \frac{\cos k}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}\right)} \cdot \left(\ell \cdot \ell\right) \]
    5. Step-by-step derivation
      1. unpow270.9%

        \[\leadsto \left(2 \cdot \frac{\frac{\cos k}{{k}^{2} \cdot t}}{\color{blue}{\sin k \cdot \sin k}}\right) \cdot \left(\ell \cdot \ell\right) \]
      2. sin-mult70.7%

        \[\leadsto \left(2 \cdot \frac{\frac{\cos k}{{k}^{2} \cdot t}}{\color{blue}{\frac{\cos \left(k - k\right) - \cos \left(k + k\right)}{2}}}\right) \cdot \left(\ell \cdot \ell\right) \]
    6. Applied egg-rr70.7%

      \[\leadsto \left(2 \cdot \frac{\cos k}{{k}^{2} \cdot \left(t \cdot \color{blue}{\frac{\cos \left(k - k\right) - \cos \left(k + k\right)}{2}}\right)}\right) \cdot \left(\ell \cdot \ell\right) \]
    7. Step-by-step derivation
      1. +-inverses70.7%

        \[\leadsto \left(2 \cdot \frac{\frac{\cos k}{{k}^{2} \cdot t}}{\frac{\cos \color{blue}{0} - \cos \left(k + k\right)}{2}}\right) \cdot \left(\ell \cdot \ell\right) \]
      2. cos-070.7%

        \[\leadsto \left(2 \cdot \frac{\frac{\cos k}{{k}^{2} \cdot t}}{\frac{\color{blue}{1} - \cos \left(k + k\right)}{2}}\right) \cdot \left(\ell \cdot \ell\right) \]
      3. count-270.7%

        \[\leadsto \left(2 \cdot \frac{\frac{\cos k}{{k}^{2} \cdot t}}{\frac{1 - \cos \color{blue}{\left(2 \cdot k\right)}}{2}}\right) \cdot \left(\ell \cdot \ell\right) \]
      4. *-commutative70.7%

        \[\leadsto \left(2 \cdot \frac{\frac{\cos k}{{k}^{2} \cdot t}}{\frac{1 - \cos \color{blue}{\left(k \cdot 2\right)}}{2}}\right) \cdot \left(\ell \cdot \ell\right) \]
    8. Simplified70.7%

      \[\leadsto \left(2 \cdot \frac{\cos k}{{k}^{2} \cdot \left(t \cdot \color{blue}{\frac{1 - \cos \left(k \cdot 2\right)}{2}}\right)}\right) \cdot \left(\ell \cdot \ell\right) \]
    9. Taylor expanded in k around inf 70.7%

      \[\leadsto \color{blue}{4 \cdot \frac{{\ell}^{2} \cdot \cos k}{{k}^{2} \cdot \left(t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)\right)}} \]
    10. Step-by-step derivation
      1. times-frac73.6%

        \[\leadsto 4 \cdot \color{blue}{\left(\frac{{\ell}^{2}}{{k}^{2}} \cdot \frac{\cos k}{t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)}\right)} \]
      2. associate-*r/73.6%

        \[\leadsto 4 \cdot \color{blue}{\frac{\frac{{\ell}^{2}}{{k}^{2}} \cdot \cos k}{t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)}} \]
      3. unpow273.6%

        \[\leadsto 4 \cdot \frac{\frac{\color{blue}{\ell \cdot \ell}}{{k}^{2}} \cdot \cos k}{t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)} \]
      4. unpow273.6%

        \[\leadsto 4 \cdot \frac{\frac{\ell \cdot \ell}{\color{blue}{k \cdot k}} \cdot \cos k}{t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)} \]
      5. times-frac96.3%

        \[\leadsto 4 \cdot \frac{\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\ell}{k}\right)} \cdot \cos k}{t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)} \]
      6. unpow296.3%

        \[\leadsto 4 \cdot \frac{\color{blue}{{\left(\frac{\ell}{k}\right)}^{2}} \cdot \cos k}{t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)} \]
    11. Simplified96.3%

      \[\leadsto \color{blue}{4 \cdot \frac{{\left(\frac{\ell}{k}\right)}^{2} \cdot \cos k}{t \cdot \left(1 - \cos \left(2 \cdot k\right)\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification87.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 9.2 \cdot 10^{-6}:\\ \;\;\;\;\frac{\cos k}{t} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{k}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \frac{\cos k \cdot {\left(\frac{\ell}{k}\right)}^{2}}{t \cdot \left(1 - \cos \left(k \cdot 2\right)\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 73.7% accurate, 1.3× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ t\_s \cdot \begin{array}{l} \mathbf{if}\;\ell \leq 7.2 \cdot 10^{+200}:\\ \;\;\;\;{\left(\ell \cdot \left(\sqrt{\frac{2}{t\_m}} \cdot {k\_m}^{-2}\right)\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \frac{\cos k\_m}{t\_m \cdot {k\_m}^{4}}\right) \cdot \left(\ell \cdot \ell\right)\\ \end{array} \end{array} \]
k_m = (fabs.f64 k)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k_m)
 :precision binary64
 (*
  t_s
  (if (<= l 7.2e+200)
    (pow (* l (* (sqrt (/ 2.0 t_m)) (pow k_m -2.0))) 2.0)
    (* (* 2.0 (/ (cos k_m) (* t_m (pow k_m 4.0)))) (* l l)))))
k_m = fabs(k);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k_m) {
	double tmp;
	if (l <= 7.2e+200) {
		tmp = pow((l * (sqrt((2.0 / t_m)) * pow(k_m, -2.0))), 2.0);
	} else {
		tmp = (2.0 * (cos(k_m) / (t_m * pow(k_m, 4.0)))) * (l * l);
	}
	return t_s * tmp;
}
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0d0, t)
real(8) function code(t_s, t_m, l, k_m)
    real(8), intent (in) :: t_s
    real(8), intent (in) :: t_m
    real(8), intent (in) :: l
    real(8), intent (in) :: k_m
    real(8) :: tmp
    if (l <= 7.2d+200) then
        tmp = (l * (sqrt((2.0d0 / t_m)) * (k_m ** (-2.0d0)))) ** 2.0d0
    else
        tmp = (2.0d0 * (cos(k_m) / (t_m * (k_m ** 4.0d0)))) * (l * l)
    end if
    code = t_s * tmp
end function
k_m = Math.abs(k);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k_m) {
	double tmp;
	if (l <= 7.2e+200) {
		tmp = Math.pow((l * (Math.sqrt((2.0 / t_m)) * Math.pow(k_m, -2.0))), 2.0);
	} else {
		tmp = (2.0 * (Math.cos(k_m) / (t_m * Math.pow(k_m, 4.0)))) * (l * l);
	}
	return t_s * tmp;
}
k_m = math.fabs(k)
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
def code(t_s, t_m, l, k_m):
	tmp = 0
	if l <= 7.2e+200:
		tmp = math.pow((l * (math.sqrt((2.0 / t_m)) * math.pow(k_m, -2.0))), 2.0)
	else:
		tmp = (2.0 * (math.cos(k_m) / (t_m * math.pow(k_m, 4.0)))) * (l * l)
	return t_s * tmp
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, t_m, l, k_m)
	tmp = 0.0
	if (l <= 7.2e+200)
		tmp = Float64(l * Float64(sqrt(Float64(2.0 / t_m)) * (k_m ^ -2.0))) ^ 2.0;
	else
		tmp = Float64(Float64(2.0 * Float64(cos(k_m) / Float64(t_m * (k_m ^ 4.0)))) * Float64(l * l));
	end
	return Float64(t_s * tmp)
end
k_m = abs(k);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
function tmp_2 = code(t_s, t_m, l, k_m)
	tmp = 0.0;
	if (l <= 7.2e+200)
		tmp = (l * (sqrt((2.0 / t_m)) * (k_m ^ -2.0))) ^ 2.0;
	else
		tmp = (2.0 * (cos(k_m) / (t_m * (k_m ^ 4.0)))) * (l * l);
	end
	tmp_2 = t_s * tmp;
end
k_m = N[Abs[k], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k$95$m_] := N[(t$95$s * If[LessEqual[l, 7.2e+200], N[Power[N[(l * N[(N[Sqrt[N[(2.0 / t$95$m), $MachinePrecision]], $MachinePrecision] * N[Power[k$95$m, -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(N[(2.0 * N[(N[Cos[k$95$m], $MachinePrecision] / N[(t$95$m * N[Power[k$95$m, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(l * l), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
k_m = \left|k\right|
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
t\_s \cdot \begin{array}{l}
\mathbf{if}\;\ell \leq 7.2 \cdot 10^{+200}:\\
\;\;\;\;{\left(\ell \cdot \left(\sqrt{\frac{2}{t\_m}} \cdot {k\_m}^{-2}\right)\right)}^{2}\\

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


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

    1. Initial program 32.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. Simplified41.4%

      \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in k around 0 60.3%

      \[\leadsto \color{blue}{\frac{2}{{k}^{4} \cdot t}} \cdot \left(\ell \cdot \ell\right) \]
    5. Step-by-step derivation
      1. *-commutative60.3%

        \[\leadsto \frac{2}{\color{blue}{t \cdot {k}^{4}}} \cdot \left(\ell \cdot \ell\right) \]
      2. associate-/r*60.2%

        \[\leadsto \color{blue}{\frac{\frac{2}{t}}{{k}^{4}}} \cdot \left(\ell \cdot \ell\right) \]
    6. Simplified60.2%

      \[\leadsto \color{blue}{\frac{\frac{2}{t}}{{k}^{4}}} \cdot \left(\ell \cdot \ell\right) \]
    7. Step-by-step derivation
      1. div-inv60.2%

        \[\leadsto \color{blue}{\left(\frac{2}{t} \cdot \frac{1}{{k}^{4}}\right)} \cdot \left(\ell \cdot \ell\right) \]
      2. pow-flip60.2%

        \[\leadsto \left(\frac{2}{t} \cdot \color{blue}{{k}^{\left(-4\right)}}\right) \cdot \left(\ell \cdot \ell\right) \]
      3. metadata-eval60.2%

        \[\leadsto \left(\frac{2}{t} \cdot {k}^{\color{blue}{-4}}\right) \cdot \left(\ell \cdot \ell\right) \]
    8. Applied egg-rr60.2%

      \[\leadsto \color{blue}{\left(\frac{2}{t} \cdot {k}^{-4}\right)} \cdot \left(\ell \cdot \ell\right) \]
    9. Step-by-step derivation
      1. add-sqr-sqrt39.6%

        \[\leadsto \color{blue}{\sqrt{\left(\frac{2}{t} \cdot {k}^{-4}\right) \cdot \left(\ell \cdot \ell\right)} \cdot \sqrt{\left(\frac{2}{t} \cdot {k}^{-4}\right) \cdot \left(\ell \cdot \ell\right)}} \]
      2. pow239.6%

        \[\leadsto \color{blue}{{\left(\sqrt{\left(\frac{2}{t} \cdot {k}^{-4}\right) \cdot \left(\ell \cdot \ell\right)}\right)}^{2}} \]
      3. *-commutative39.6%

        \[\leadsto {\left(\sqrt{\color{blue}{\left(\ell \cdot \ell\right) \cdot \left(\frac{2}{t} \cdot {k}^{-4}\right)}}\right)}^{2} \]
      4. sqrt-prod37.9%

        \[\leadsto {\color{blue}{\left(\sqrt{\ell \cdot \ell} \cdot \sqrt{\frac{2}{t} \cdot {k}^{-4}}\right)}}^{2} \]
      5. sqrt-prod15.0%

        \[\leadsto {\left(\color{blue}{\left(\sqrt{\ell} \cdot \sqrt{\ell}\right)} \cdot \sqrt{\frac{2}{t} \cdot {k}^{-4}}\right)}^{2} \]
      6. add-sqr-sqrt42.4%

        \[\leadsto {\left(\color{blue}{\ell} \cdot \sqrt{\frac{2}{t} \cdot {k}^{-4}}\right)}^{2} \]
      7. sqrt-prod31.6%

        \[\leadsto {\left(\ell \cdot \color{blue}{\left(\sqrt{\frac{2}{t}} \cdot \sqrt{{k}^{-4}}\right)}\right)}^{2} \]
      8. sqrt-pow132.8%

        \[\leadsto {\left(\ell \cdot \left(\sqrt{\frac{2}{t}} \cdot \color{blue}{{k}^{\left(\frac{-4}{2}\right)}}\right)\right)}^{2} \]
      9. metadata-eval32.8%

        \[\leadsto {\left(\ell \cdot \left(\sqrt{\frac{2}{t}} \cdot {k}^{\color{blue}{-2}}\right)\right)}^{2} \]
    10. Applied egg-rr32.8%

      \[\leadsto \color{blue}{{\left(\ell \cdot \left(\sqrt{\frac{2}{t}} \cdot {k}^{-2}\right)\right)}^{2}} \]

    if 7.1999999999999995e200 < l

    1. Initial program 36.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. Simplified36.4%

      \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in t around 0 68.2%

      \[\leadsto \color{blue}{\left(2 \cdot \frac{\cos k}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}\right)} \cdot \left(\ell \cdot \ell\right) \]
    5. Taylor expanded in k around 0 63.6%

      \[\leadsto \left(2 \cdot \frac{\cos k}{\color{blue}{{k}^{4} \cdot t}}\right) \cdot \left(\ell \cdot \ell\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification35.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 7.2 \cdot 10^{+200}:\\ \;\;\;\;{\left(\ell \cdot \left(\sqrt{\frac{2}{t}} \cdot {k}^{-2}\right)\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \frac{\cos k}{t \cdot {k}^{4}}\right) \cdot \left(\ell \cdot \ell\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 74.4% accurate, 1.3× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ t\_s \cdot \left(\frac{\cos k\_m}{t\_m} \cdot {\left(\frac{\ell}{k\_m} \cdot \frac{\sqrt{2}}{k\_m}\right)}^{2}\right) \end{array} \]
k_m = (fabs.f64 k)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k_m)
 :precision binary64
 (* t_s (* (/ (cos k_m) t_m) (pow (* (/ l k_m) (/ (sqrt 2.0) k_m)) 2.0))))
k_m = fabs(k);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k_m) {
	return t_s * ((cos(k_m) / t_m) * pow(((l / k_m) * (sqrt(2.0) / k_m)), 2.0));
}
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0d0, t)
real(8) function code(t_s, t_m, l, k_m)
    real(8), intent (in) :: t_s
    real(8), intent (in) :: t_m
    real(8), intent (in) :: l
    real(8), intent (in) :: k_m
    code = t_s * ((cos(k_m) / t_m) * (((l / k_m) * (sqrt(2.0d0) / k_m)) ** 2.0d0))
end function
k_m = Math.abs(k);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k_m) {
	return t_s * ((Math.cos(k_m) / t_m) * Math.pow(((l / k_m) * (Math.sqrt(2.0) / k_m)), 2.0));
}
k_m = math.fabs(k)
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
def code(t_s, t_m, l, k_m):
	return t_s * ((math.cos(k_m) / t_m) * math.pow(((l / k_m) * (math.sqrt(2.0) / k_m)), 2.0))
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, t_m, l, k_m)
	return Float64(t_s * Float64(Float64(cos(k_m) / t_m) * (Float64(Float64(l / k_m) * Float64(sqrt(2.0) / k_m)) ^ 2.0)))
end
k_m = abs(k);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
function tmp = code(t_s, t_m, l, k_m)
	tmp = t_s * ((cos(k_m) / t_m) * (((l / k_m) * (sqrt(2.0) / k_m)) ^ 2.0));
end
k_m = N[Abs[k], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k$95$m_] := N[(t$95$s * N[(N[(N[Cos[k$95$m], $MachinePrecision] / t$95$m), $MachinePrecision] * N[Power[N[(N[(l / k$95$m), $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / k$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
k_m = \left|k\right|
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
t\_s \cdot \left(\frac{\cos k\_m}{t\_m} \cdot {\left(\frac{\ell}{k\_m} \cdot \frac{\sqrt{2}}{k\_m}\right)}^{2}\right)
\end{array}
Derivation
  1. Initial program 32.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. Simplified41.0%

    \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. add-sqr-sqrt26.1%

      \[\leadsto \color{blue}{\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \cdot \sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}} \]
    2. pow226.1%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)}\right)}^{2}} \]
  5. Applied egg-rr24.7%

    \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\left(\sqrt{\sin k \cdot \tan k} \cdot \frac{k}{t}\right) \cdot {t}^{1.5}}\right)}^{2}} \]
  6. Step-by-step derivation
    1. associate-*l*25.1%

      \[\leadsto {\left(\ell \cdot \frac{\sqrt{2}}{\color{blue}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}}\right)}^{2} \]
  7. Simplified25.1%

    \[\leadsto \color{blue}{{\left(\ell \cdot \frac{\sqrt{2}}{\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot {t}^{1.5}\right)}\right)}^{2}} \]
  8. Taylor expanded in l around 0 41.6%

    \[\leadsto {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k} \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
  9. Step-by-step derivation
    1. times-frac42.3%

      \[\leadsto {\left(\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)} \cdot \sqrt{\frac{\cos k}{t}}\right)}^{2} \]
  10. Simplified42.3%

    \[\leadsto {\color{blue}{\left(\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right) \cdot \sqrt{\frac{\cos k}{t}}\right)}}^{2} \]
  11. Step-by-step derivation
    1. *-commutative42.3%

      \[\leadsto {\color{blue}{\left(\sqrt{\frac{\cos k}{t}} \cdot \left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)\right)}}^{2} \]
    2. unpow-prod-down40.2%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{\cos k}{t}}\right)}^{2} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2}} \]
    3. pow240.2%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{\cos k}{t}} \cdot \sqrt{\frac{\cos k}{t}}\right)} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2} \]
    4. add-sqr-sqrt95.5%

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

      \[\leadsto \frac{\cos k}{t} \cdot {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}}^{2} \]
  12. Applied egg-rr94.4%

    \[\leadsto \color{blue}{\frac{\cos k}{t} \cdot {\left(\frac{\ell \cdot \sqrt{2}}{k \cdot \sin k}\right)}^{2}} \]
  13. Step-by-step derivation
    1. times-frac95.5%

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

    \[\leadsto \color{blue}{\frac{\cos k}{t} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{\sin k}\right)}^{2}} \]
  15. Taylor expanded in k around 0 75.6%

    \[\leadsto \frac{\cos k}{t} \cdot {\left(\frac{\ell}{k} \cdot \color{blue}{\frac{\sqrt{2}}{k}}\right)}^{2} \]
  16. Final simplification75.6%

    \[\leadsto \frac{\cos k}{t} \cdot {\left(\frac{\ell}{k} \cdot \frac{\sqrt{2}}{k}\right)}^{2} \]
  17. Add Preprocessing

Alternative 14: 71.7% accurate, 2.0× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ t\_s \cdot \left({\left(\frac{\ell}{k\_m}\right)}^{2} \cdot \frac{2}{t\_m \cdot {k\_m}^{2}}\right) \end{array} \]
k_m = (fabs.f64 k)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k_m)
 :precision binary64
 (* t_s (* (pow (/ l k_m) 2.0) (/ 2.0 (* t_m (pow k_m 2.0))))))
k_m = fabs(k);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k_m) {
	return t_s * (pow((l / k_m), 2.0) * (2.0 / (t_m * pow(k_m, 2.0))));
}
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0d0, t)
real(8) function code(t_s, t_m, l, k_m)
    real(8), intent (in) :: t_s
    real(8), intent (in) :: t_m
    real(8), intent (in) :: l
    real(8), intent (in) :: k_m
    code = t_s * (((l / k_m) ** 2.0d0) * (2.0d0 / (t_m * (k_m ** 2.0d0))))
end function
k_m = Math.abs(k);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k_m) {
	return t_s * (Math.pow((l / k_m), 2.0) * (2.0 / (t_m * Math.pow(k_m, 2.0))));
}
k_m = math.fabs(k)
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
def code(t_s, t_m, l, k_m):
	return t_s * (math.pow((l / k_m), 2.0) * (2.0 / (t_m * math.pow(k_m, 2.0))))
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, t_m, l, k_m)
	return Float64(t_s * Float64((Float64(l / k_m) ^ 2.0) * Float64(2.0 / Float64(t_m * (k_m ^ 2.0)))))
end
k_m = abs(k);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
function tmp = code(t_s, t_m, l, k_m)
	tmp = t_s * (((l / k_m) ^ 2.0) * (2.0 / (t_m * (k_m ^ 2.0))));
end
k_m = N[Abs[k], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k$95$m_] := N[(t$95$s * N[(N[Power[N[(l / k$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(2.0 / N[(t$95$m * N[Power[k$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
k_m = \left|k\right|
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
t\_s \cdot \left({\left(\frac{\ell}{k\_m}\right)}^{2} \cdot \frac{2}{t\_m \cdot {k\_m}^{2}}\right)
\end{array}
Derivation
  1. Initial program 32.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. Simplified41.0%

    \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in t around 0 70.6%

    \[\leadsto \color{blue}{\left(2 \cdot \frac{\cos k}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}\right)} \cdot \left(\ell \cdot \ell\right) \]
  5. Taylor expanded in k around inf 71.0%

    \[\leadsto \color{blue}{2 \cdot \frac{{\ell}^{2} \cdot \cos k}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}} \]
  6. Step-by-step derivation
    1. associate-*r*71.0%

      \[\leadsto 2 \cdot \frac{{\ell}^{2} \cdot \cos k}{\color{blue}{\left({k}^{2} \cdot t\right) \cdot {\sin k}^{2}}} \]
    2. associate-*r/71.0%

      \[\leadsto \color{blue}{\frac{2 \cdot \left({\ell}^{2} \cdot \cos k\right)}{\left({k}^{2} \cdot t\right) \cdot {\sin k}^{2}}} \]
    3. *-commutative71.0%

      \[\leadsto \frac{2 \cdot \color{blue}{\left(\cos k \cdot {\ell}^{2}\right)}}{\left({k}^{2} \cdot t\right) \cdot {\sin k}^{2}} \]
    4. times-frac72.9%

      \[\leadsto \color{blue}{\frac{2}{{k}^{2} \cdot t} \cdot \frac{\cos k \cdot {\ell}^{2}}{{\sin k}^{2}}} \]
    5. *-commutative72.9%

      \[\leadsto \frac{2}{\color{blue}{t \cdot {k}^{2}}} \cdot \frac{\cos k \cdot {\ell}^{2}}{{\sin k}^{2}} \]
    6. *-commutative72.9%

      \[\leadsto \frac{2}{t \cdot {k}^{2}} \cdot \frac{\color{blue}{{\ell}^{2} \cdot \cos k}}{{\sin k}^{2}} \]
  7. Simplified72.9%

    \[\leadsto \color{blue}{\frac{2}{t \cdot {k}^{2}} \cdot \frac{{\ell}^{2} \cdot \cos k}{{\sin k}^{2}}} \]
  8. Taylor expanded in k around 0 63.3%

    \[\leadsto \frac{2}{t \cdot {k}^{2}} \cdot \color{blue}{\frac{{\ell}^{2}}{{k}^{2}}} \]
  9. Step-by-step derivation
    1. unpow263.3%

      \[\leadsto \frac{2}{t \cdot {k}^{2}} \cdot \frac{\color{blue}{\ell \cdot \ell}}{{k}^{2}} \]
    2. unpow263.3%

      \[\leadsto \frac{2}{t \cdot {k}^{2}} \cdot \frac{\ell \cdot \ell}{\color{blue}{k \cdot k}} \]
    3. times-frac71.2%

      \[\leadsto \frac{2}{t \cdot {k}^{2}} \cdot \color{blue}{\left(\frac{\ell}{k} \cdot \frac{\ell}{k}\right)} \]
    4. unpow271.2%

      \[\leadsto \frac{2}{t \cdot {k}^{2}} \cdot \color{blue}{{\left(\frac{\ell}{k}\right)}^{2}} \]
  10. Simplified71.2%

    \[\leadsto \frac{2}{t \cdot {k}^{2}} \cdot \color{blue}{{\left(\frac{\ell}{k}\right)}^{2}} \]
  11. Final simplification71.2%

    \[\leadsto {\left(\frac{\ell}{k}\right)}^{2} \cdot \frac{2}{t \cdot {k}^{2}} \]
  12. Add Preprocessing

Alternative 15: 62.4% accurate, 3.8× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ t\_s \cdot \left(\left(\ell \cdot \ell\right) \cdot \left(\frac{2}{t\_m} \cdot {k\_m}^{-4}\right)\right) \end{array} \]
k_m = (fabs.f64 k)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k_m)
 :precision binary64
 (* t_s (* (* l l) (* (/ 2.0 t_m) (pow k_m -4.0)))))
k_m = fabs(k);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k_m) {
	return t_s * ((l * l) * ((2.0 / t_m) * pow(k_m, -4.0)));
}
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0d0, t)
real(8) function code(t_s, t_m, l, k_m)
    real(8), intent (in) :: t_s
    real(8), intent (in) :: t_m
    real(8), intent (in) :: l
    real(8), intent (in) :: k_m
    code = t_s * ((l * l) * ((2.0d0 / t_m) * (k_m ** (-4.0d0))))
end function
k_m = Math.abs(k);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k_m) {
	return t_s * ((l * l) * ((2.0 / t_m) * Math.pow(k_m, -4.0)));
}
k_m = math.fabs(k)
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
def code(t_s, t_m, l, k_m):
	return t_s * ((l * l) * ((2.0 / t_m) * math.pow(k_m, -4.0)))
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, t_m, l, k_m)
	return Float64(t_s * Float64(Float64(l * l) * Float64(Float64(2.0 / t_m) * (k_m ^ -4.0))))
end
k_m = abs(k);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
function tmp = code(t_s, t_m, l, k_m)
	tmp = t_s * ((l * l) * ((2.0 / t_m) * (k_m ^ -4.0)));
end
k_m = N[Abs[k], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k$95$m_] := N[(t$95$s * N[(N[(l * l), $MachinePrecision] * N[(N[(2.0 / t$95$m), $MachinePrecision] * N[Power[k$95$m, -4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
k_m = \left|k\right|
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
t\_s \cdot \left(\left(\ell \cdot \ell\right) \cdot \left(\frac{2}{t\_m} \cdot {k\_m}^{-4}\right)\right)
\end{array}
Derivation
  1. Initial program 32.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. Simplified41.0%

    \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in k around 0 60.2%

    \[\leadsto \color{blue}{\frac{2}{{k}^{4} \cdot t}} \cdot \left(\ell \cdot \ell\right) \]
  5. Step-by-step derivation
    1. *-commutative60.2%

      \[\leadsto \frac{2}{\color{blue}{t \cdot {k}^{4}}} \cdot \left(\ell \cdot \ell\right) \]
    2. associate-/r*60.1%

      \[\leadsto \color{blue}{\frac{\frac{2}{t}}{{k}^{4}}} \cdot \left(\ell \cdot \ell\right) \]
  6. Simplified60.1%

    \[\leadsto \color{blue}{\frac{\frac{2}{t}}{{k}^{4}}} \cdot \left(\ell \cdot \ell\right) \]
  7. Step-by-step derivation
    1. div-inv60.1%

      \[\leadsto \color{blue}{\left(\frac{2}{t} \cdot \frac{1}{{k}^{4}}\right)} \cdot \left(\ell \cdot \ell\right) \]
    2. pow-flip60.1%

      \[\leadsto \left(\frac{2}{t} \cdot \color{blue}{{k}^{\left(-4\right)}}\right) \cdot \left(\ell \cdot \ell\right) \]
    3. metadata-eval60.1%

      \[\leadsto \left(\frac{2}{t} \cdot {k}^{\color{blue}{-4}}\right) \cdot \left(\ell \cdot \ell\right) \]
  8. Applied egg-rr60.1%

    \[\leadsto \color{blue}{\left(\frac{2}{t} \cdot {k}^{-4}\right)} \cdot \left(\ell \cdot \ell\right) \]
  9. Final simplification60.1%

    \[\leadsto \left(\ell \cdot \ell\right) \cdot \left(\frac{2}{t} \cdot {k}^{-4}\right) \]
  10. Add Preprocessing

Alternative 16: 62.4% accurate, 3.8× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ t\_s \cdot \left(\left(\ell \cdot \ell\right) \cdot \frac{2}{t\_m \cdot {k\_m}^{4}}\right) \end{array} \]
k_m = (fabs.f64 k)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k_m)
 :precision binary64
 (* t_s (* (* l l) (/ 2.0 (* t_m (pow k_m 4.0))))))
k_m = fabs(k);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k_m) {
	return t_s * ((l * l) * (2.0 / (t_m * pow(k_m, 4.0))));
}
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0d0, t)
real(8) function code(t_s, t_m, l, k_m)
    real(8), intent (in) :: t_s
    real(8), intent (in) :: t_m
    real(8), intent (in) :: l
    real(8), intent (in) :: k_m
    code = t_s * ((l * l) * (2.0d0 / (t_m * (k_m ** 4.0d0))))
end function
k_m = Math.abs(k);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k_m) {
	return t_s * ((l * l) * (2.0 / (t_m * Math.pow(k_m, 4.0))));
}
k_m = math.fabs(k)
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
def code(t_s, t_m, l, k_m):
	return t_s * ((l * l) * (2.0 / (t_m * math.pow(k_m, 4.0))))
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, t_m, l, k_m)
	return Float64(t_s * Float64(Float64(l * l) * Float64(2.0 / Float64(t_m * (k_m ^ 4.0)))))
end
k_m = abs(k);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
function tmp = code(t_s, t_m, l, k_m)
	tmp = t_s * ((l * l) * (2.0 / (t_m * (k_m ^ 4.0))));
end
k_m = N[Abs[k], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k$95$m_] := N[(t$95$s * N[(N[(l * l), $MachinePrecision] * N[(2.0 / N[(t$95$m * N[Power[k$95$m, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
k_m = \left|k\right|
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
t\_s \cdot \left(\left(\ell \cdot \ell\right) \cdot \frac{2}{t\_m \cdot {k\_m}^{4}}\right)
\end{array}
Derivation
  1. Initial program 32.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. Simplified41.0%

    \[\leadsto \color{blue}{\frac{2}{{t}^{3} \cdot \left(\sin k \cdot \left(\tan k \cdot {\left(\frac{k}{t}\right)}^{2}\right)\right)} \cdot \left(\ell \cdot \ell\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in k around 0 60.2%

    \[\leadsto \frac{2}{\color{blue}{{k}^{4} \cdot t}} \cdot \left(\ell \cdot \ell\right) \]
  5. Final simplification60.2%

    \[\leadsto \left(\ell \cdot \ell\right) \cdot \frac{2}{t \cdot {k}^{4}} \]
  6. Add Preprocessing

Reproduce

?
herbie shell --seed 2024079 
(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))))