Toniolo and Linder, Equation (10-)

Percentage Accurate: 35.4% → 96.2%
Time: 15.6s
Alternatives: 10
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 10 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.4% 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: 96.2% 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 1.55:\\ \;\;\;\;2 \cdot {\left(k\_m \cdot \left(\frac{\sin k\_m}{\ell} \cdot \sqrt{\frac{t\_m}{\cos k\_m}}\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{\ell}{k\_m}\right)}^{2} \cdot \left(2 \cdot \frac{\frac{\cos k\_m}{t\_m}}{{\sin k\_m}^{2}}\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 1.55)
    (* 2.0 (pow (* k_m (* (/ (sin k_m) l) (sqrt (/ t_m (cos k_m))))) -2.0))
    (*
     (pow (/ l k_m) 2.0)
     (* 2.0 (/ (/ (cos k_m) t_m) (pow (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) {
	double tmp;
	if (k_m <= 1.55) {
		tmp = 2.0 * pow((k_m * ((sin(k_m) / l) * sqrt((t_m / cos(k_m))))), -2.0);
	} else {
		tmp = pow((l / k_m), 2.0) * (2.0 * ((cos(k_m) / t_m) / pow(sin(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 <= 1.55d0) then
        tmp = 2.0d0 * ((k_m * ((sin(k_m) / l) * sqrt((t_m / cos(k_m))))) ** (-2.0d0))
    else
        tmp = ((l / k_m) ** 2.0d0) * (2.0d0 * ((cos(k_m) / t_m) / (sin(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 <= 1.55) {
		tmp = 2.0 * Math.pow((k_m * ((Math.sin(k_m) / l) * Math.sqrt((t_m / Math.cos(k_m))))), -2.0);
	} else {
		tmp = Math.pow((l / k_m), 2.0) * (2.0 * ((Math.cos(k_m) / t_m) / Math.pow(Math.sin(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 <= 1.55:
		tmp = 2.0 * math.pow((k_m * ((math.sin(k_m) / l) * math.sqrt((t_m / math.cos(k_m))))), -2.0)
	else:
		tmp = math.pow((l / k_m), 2.0) * (2.0 * ((math.cos(k_m) / t_m) / math.pow(math.sin(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 <= 1.55)
		tmp = Float64(2.0 * (Float64(k_m * Float64(Float64(sin(k_m) / l) * sqrt(Float64(t_m / cos(k_m))))) ^ -2.0));
	else
		tmp = Float64((Float64(l / k_m) ^ 2.0) * Float64(2.0 * Float64(Float64(cos(k_m) / t_m) / (sin(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 <= 1.55)
		tmp = 2.0 * ((k_m * ((sin(k_m) / l) * sqrt((t_m / cos(k_m))))) ^ -2.0);
	else
		tmp = ((l / k_m) ^ 2.0) * (2.0 * ((cos(k_m) / t_m) / (sin(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, 1.55], N[(2.0 * N[Power[N[(k$95$m * N[(N[(N[Sin[k$95$m], $MachinePrecision] / l), $MachinePrecision] * N[Sqrt[N[(t$95$m / N[Cos[k$95$m], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(l / k$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(2.0 * N[(N[(N[Cos[k$95$m], $MachinePrecision] / t$95$m), $MachinePrecision] / N[Power[N[Sin[k$95$m], $MachinePrecision], 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 \begin{array}{l}
\mathbf{if}\;k\_m \leq 1.55:\\
\;\;\;\;2 \cdot {\left(k\_m \cdot \left(\frac{\sin k\_m}{\ell} \cdot \sqrt{\frac{t\_m}{\cos k\_m}}\right)\right)}^{-2}\\

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


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

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

      \[\leadsto \color{blue}{\frac{2}{\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \left(\sin k \cdot \tan k\right)\right) \cdot \left(1 + \left({\left(\frac{k}{t}\right)}^{2} - 1\right)\right)}} \]
    3. Add Preprocessing
    4. Applied egg-rr20.3%

      \[\leadsto \frac{2}{\color{blue}{{\left(\frac{k}{t} \cdot \frac{\sqrt{{t}^{3} \cdot \left(\sin k \cdot \tan k\right)}}{\ell}\right)}^{2} + \left({t}^{3} \cdot \left({\ell}^{-2} \cdot \left(\sin k \cdot \tan k\right)\right)\right) \cdot 0}} \]
    5. Step-by-step derivation
      1. mul0-rgt31.5%

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

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

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

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

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

      \[\leadsto \frac{2}{\color{blue}{{\left(\frac{\frac{k}{t} \cdot \sqrt{\sin k \cdot \left(\tan k \cdot {t}^{3}\right)}}{\ell}\right)}^{2}}} \]
    7. Taylor expanded in k around inf 54.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.55000000000000004 < k

    1. Initial program 26.2%

      \[\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. Simplified40.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 69.7%

      \[\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 69.7%

      \[\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. *-commutative69.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 96.2% 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 1.55:\\ \;\;\;\;2 \cdot {\left(k\_m \cdot \left(\frac{\sin k\_m}{\ell} \cdot \sqrt{\frac{t\_m}{\cos k\_m}}\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{\ell}{k\_m} \cdot \frac{\ell}{k\_m}\right) \cdot \left(2 \cdot \frac{\cos k\_m}{t\_m \cdot {\sin k\_m}^{2}}\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 1.55)
    (* 2.0 (pow (* k_m (* (/ (sin k_m) l) (sqrt (/ t_m (cos k_m))))) -2.0))
    (*
     (* (/ l k_m) (/ l k_m))
     (* 2.0 (/ (cos k_m) (* t_m (pow (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) {
	double tmp;
	if (k_m <= 1.55) {
		tmp = 2.0 * pow((k_m * ((sin(k_m) / l) * sqrt((t_m / cos(k_m))))), -2.0);
	} else {
		tmp = ((l / k_m) * (l / k_m)) * (2.0 * (cos(k_m) / (t_m * pow(sin(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 <= 1.55d0) then
        tmp = 2.0d0 * ((k_m * ((sin(k_m) / l) * sqrt((t_m / cos(k_m))))) ** (-2.0d0))
    else
        tmp = ((l / k_m) * (l / k_m)) * (2.0d0 * (cos(k_m) / (t_m * (sin(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 <= 1.55) {
		tmp = 2.0 * Math.pow((k_m * ((Math.sin(k_m) / l) * Math.sqrt((t_m / Math.cos(k_m))))), -2.0);
	} else {
		tmp = ((l / k_m) * (l / k_m)) * (2.0 * (Math.cos(k_m) / (t_m * Math.pow(Math.sin(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 <= 1.55:
		tmp = 2.0 * math.pow((k_m * ((math.sin(k_m) / l) * math.sqrt((t_m / math.cos(k_m))))), -2.0)
	else:
		tmp = ((l / k_m) * (l / k_m)) * (2.0 * (math.cos(k_m) / (t_m * math.pow(math.sin(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 <= 1.55)
		tmp = Float64(2.0 * (Float64(k_m * Float64(Float64(sin(k_m) / l) * sqrt(Float64(t_m / cos(k_m))))) ^ -2.0));
	else
		tmp = Float64(Float64(Float64(l / k_m) * Float64(l / k_m)) * Float64(2.0 * Float64(cos(k_m) / Float64(t_m * (sin(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 <= 1.55)
		tmp = 2.0 * ((k_m * ((sin(k_m) / l) * sqrt((t_m / cos(k_m))))) ^ -2.0);
	else
		tmp = ((l / k_m) * (l / k_m)) * (2.0 * (cos(k_m) / (t_m * (sin(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, 1.55], N[(2.0 * N[Power[N[(k$95$m * N[(N[(N[Sin[k$95$m], $MachinePrecision] / l), $MachinePrecision] * N[Sqrt[N[(t$95$m / N[Cos[k$95$m], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[(l / k$95$m), $MachinePrecision] * N[(l / k$95$m), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(N[Cos[k$95$m], $MachinePrecision] / N[(t$95$m * N[Power[N[Sin[k$95$m], $MachinePrecision], 2.0], $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 1.55:\\
\;\;\;\;2 \cdot {\left(k\_m \cdot \left(\frac{\sin k\_m}{\ell} \cdot \sqrt{\frac{t\_m}{\cos k\_m}}\right)\right)}^{-2}\\

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


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

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

      \[\leadsto \color{blue}{\frac{2}{\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \left(\sin k \cdot \tan k\right)\right) \cdot \left(1 + \left({\left(\frac{k}{t}\right)}^{2} - 1\right)\right)}} \]
    3. Add Preprocessing
    4. Applied egg-rr20.3%

      \[\leadsto \frac{2}{\color{blue}{{\left(\frac{k}{t} \cdot \frac{\sqrt{{t}^{3} \cdot \left(\sin k \cdot \tan k\right)}}{\ell}\right)}^{2} + \left({t}^{3} \cdot \left({\ell}^{-2} \cdot \left(\sin k \cdot \tan k\right)\right)\right) \cdot 0}} \]
    5. Step-by-step derivation
      1. mul0-rgt31.5%

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

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

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

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

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

      \[\leadsto \frac{2}{\color{blue}{{\left(\frac{\frac{k}{t} \cdot \sqrt{\sin k \cdot \left(\tan k \cdot {t}^{3}\right)}}{\ell}\right)}^{2}}} \]
    7. Taylor expanded in k around inf 54.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.55000000000000004 < k

    1. Initial program 26.2%

      \[\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. Simplified40.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 69.7%

      \[\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 69.7%

      \[\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. *-commutative69.7%

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 96.0% 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 4.6 \cdot 10^{-6}:\\ \;\;\;\;{\left(\frac{\ell}{k\_m} \cdot \frac{\sqrt{2}}{k\_m \cdot \sqrt{t\_m}}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{\ell}{k\_m} \cdot \frac{\ell}{k\_m}\right) \cdot \left(2 \cdot \frac{\cos k\_m}{t\_m \cdot {\sin k\_m}^{2}}\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.6e-6)
    (pow (* (/ l k_m) (/ (sqrt 2.0) (* k_m (sqrt t_m)))) 2.0)
    (*
     (* (/ l k_m) (/ l k_m))
     (* 2.0 (/ (cos k_m) (* t_m (pow (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) {
	double tmp;
	if (k_m <= 4.6e-6) {
		tmp = pow(((l / k_m) * (sqrt(2.0) / (k_m * sqrt(t_m)))), 2.0);
	} else {
		tmp = ((l / k_m) * (l / k_m)) * (2.0 * (cos(k_m) / (t_m * pow(sin(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 <= 4.6d-6) then
        tmp = ((l / k_m) * (sqrt(2.0d0) / (k_m * sqrt(t_m)))) ** 2.0d0
    else
        tmp = ((l / k_m) * (l / k_m)) * (2.0d0 * (cos(k_m) / (t_m * (sin(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 <= 4.6e-6) {
		tmp = Math.pow(((l / k_m) * (Math.sqrt(2.0) / (k_m * Math.sqrt(t_m)))), 2.0);
	} else {
		tmp = ((l / k_m) * (l / k_m)) * (2.0 * (Math.cos(k_m) / (t_m * Math.pow(Math.sin(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 <= 4.6e-6:
		tmp = math.pow(((l / k_m) * (math.sqrt(2.0) / (k_m * math.sqrt(t_m)))), 2.0)
	else:
		tmp = ((l / k_m) * (l / k_m)) * (2.0 * (math.cos(k_m) / (t_m * math.pow(math.sin(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 <= 4.6e-6)
		tmp = Float64(Float64(l / k_m) * Float64(sqrt(2.0) / Float64(k_m * sqrt(t_m)))) ^ 2.0;
	else
		tmp = Float64(Float64(Float64(l / k_m) * Float64(l / k_m)) * Float64(2.0 * Float64(cos(k_m) / Float64(t_m * (sin(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 <= 4.6e-6)
		tmp = ((l / k_m) * (sqrt(2.0) / (k_m * sqrt(t_m)))) ^ 2.0;
	else
		tmp = ((l / k_m) * (l / k_m)) * (2.0 * (cos(k_m) / (t_m * (sin(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, 4.6e-6], N[Power[N[(N[(l / k$95$m), $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / N[(k$95$m * N[Sqrt[t$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(N[(N[(l / k$95$m), $MachinePrecision] * N[(l / k$95$m), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(N[Cos[k$95$m], $MachinePrecision] / N[(t$95$m * N[Power[N[Sin[k$95$m], $MachinePrecision], 2.0], $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 4.6 \cdot 10^{-6}:\\
\;\;\;\;{\left(\frac{\ell}{k\_m} \cdot \frac{\sqrt{2}}{k\_m \cdot \sqrt{t\_m}}\right)}^{2}\\

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


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

    1. Initial program 34.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. Simplified38.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-sqrt24.7%

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

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

      \[\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-*r/36.9%

        \[\leadsto {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{\left(\sqrt{\sin k \cdot \tan k} \cdot \frac{k}{t}\right) \cdot {t}^{1.5}}\right)}}^{2} \]
      2. associate-*l*37.5%

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

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

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

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

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

    if 4.6e-6 < k

    1. Initial program 25.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. Simplified40.2%

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

      \[\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 70.5%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 78.5% 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 1.15:\\ \;\;\;\;{\left(\frac{\ell}{k\_m} \cdot \frac{\sqrt{2}}{k\_m \cdot \sqrt{t\_m}}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{\ell}{k\_m}\right)}^{2} \cdot \left(2 \cdot \frac{\cos k\_m}{t\_m \cdot {k\_m}^{2}}\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 1.15)
    (pow (* (/ l k_m) (/ (sqrt 2.0) (* k_m (sqrt t_m)))) 2.0)
    (* (pow (/ l k_m) 2.0) (* 2.0 (/ (cos k_m) (* 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) {
	double tmp;
	if (k_m <= 1.15) {
		tmp = pow(((l / k_m) * (sqrt(2.0) / (k_m * sqrt(t_m)))), 2.0);
	} else {
		tmp = pow((l / k_m), 2.0) * (2.0 * (cos(k_m) / (t_m * pow(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 <= 1.15d0) then
        tmp = ((l / k_m) * (sqrt(2.0d0) / (k_m * sqrt(t_m)))) ** 2.0d0
    else
        tmp = ((l / k_m) ** 2.0d0) * (2.0d0 * (cos(k_m) / (t_m * (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 <= 1.15) {
		tmp = Math.pow(((l / k_m) * (Math.sqrt(2.0) / (k_m * Math.sqrt(t_m)))), 2.0);
	} else {
		tmp = Math.pow((l / k_m), 2.0) * (2.0 * (Math.cos(k_m) / (t_m * Math.pow(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 <= 1.15:
		tmp = math.pow(((l / k_m) * (math.sqrt(2.0) / (k_m * math.sqrt(t_m)))), 2.0)
	else:
		tmp = math.pow((l / k_m), 2.0) * (2.0 * (math.cos(k_m) / (t_m * math.pow(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 <= 1.15)
		tmp = Float64(Float64(l / k_m) * Float64(sqrt(2.0) / Float64(k_m * sqrt(t_m)))) ^ 2.0;
	else
		tmp = Float64((Float64(l / k_m) ^ 2.0) * Float64(2.0 * Float64(cos(k_m) / Float64(t_m * (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 <= 1.15)
		tmp = ((l / k_m) * (sqrt(2.0) / (k_m * sqrt(t_m)))) ^ 2.0;
	else
		tmp = ((l / k_m) ^ 2.0) * (2.0 * (cos(k_m) / (t_m * (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, 1.15], N[Power[N[(N[(l / k$95$m), $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / N[(k$95$m * N[Sqrt[t$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(N[Power[N[(l / k$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(2.0 * N[(N[Cos[k$95$m], $MachinePrecision] / N[(t$95$m * N[Power[k$95$m, 2.0], $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 1.15:\\
\;\;\;\;{\left(\frac{\ell}{k\_m} \cdot \frac{\sqrt{2}}{k\_m \cdot \sqrt{t\_m}}\right)}^{2}\\

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


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

    1. Initial program 34.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. Simplified38.2%

      \[\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-sqrt25.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. pow225.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-rr37.6%

      \[\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-*r/37.6%

        \[\leadsto {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{\left(\sqrt{\sin k \cdot \tan k} \cdot \frac{k}{t}\right) \cdot {t}^{1.5}}\right)}}^{2} \]
      2. associate-*l*38.1%

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

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

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

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

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

    if 1.1499999999999999 < k

    1. Initial program 26.2%

      \[\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. Simplified40.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 69.7%

      \[\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 69.7%

      \[\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. *-commutative69.7%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 76.7% accurate, 1.4× 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{\ell}{k\_m} \cdot \frac{\sqrt{2}}{k\_m \cdot \sqrt{t\_m}}\right)}^{2} \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) (/ (sqrt 2.0) (* k_m (sqrt t_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) * (sqrt(2.0) / (k_m * sqrt(t_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) * (sqrt(2.0d0) / (k_m * sqrt(t_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) * (Math.sqrt(2.0) / (k_m * Math.sqrt(t_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) * (math.sqrt(2.0) / (k_m * math.sqrt(t_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) * Float64(sqrt(2.0) / Float64(k_m * sqrt(t_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) * (sqrt(2.0) / (k_m * sqrt(t_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[Power[N[(N[(l / k$95$m), $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / N[(k$95$m * N[Sqrt[t$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $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{\ell}{k\_m} \cdot \frac{\sqrt{2}}{k\_m \cdot \sqrt{t\_m}}\right)}^{2}
\end{array}
Derivation
  1. Initial program 32.0%

    \[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) - 1\right)} \]
  2. Simplified38.7%

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

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

      \[\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-rr34.6%

    \[\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-*r/34.6%

      \[\leadsto {\color{blue}{\left(\frac{\ell \cdot \sqrt{2}}{\left(\sqrt{\sin k \cdot \tan k} \cdot \frac{k}{t}\right) \cdot {t}^{1.5}}\right)}}^{2} \]
    2. associate-*l*35.0%

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

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

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

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

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

Alternative 6: 75.5% 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 \frac{2}{{\left(\frac{k\_m \cdot \left(k\_m \cdot \sqrt{t\_m}\right)}{\ell}\right)}^{2}} \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 (/ 2.0 (pow (/ (* k_m (* k_m (sqrt t_m))) l) 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 * (2.0 / pow(((k_m * (k_m * sqrt(t_m))) / l), 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 * (2.0d0 / (((k_m * (k_m * sqrt(t_m))) / l) ** 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 * (2.0 / Math.pow(((k_m * (k_m * Math.sqrt(t_m))) / l), 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 * (2.0 / math.pow(((k_m * (k_m * math.sqrt(t_m))) / l), 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(2.0 / (Float64(Float64(k_m * Float64(k_m * sqrt(t_m))) / l) ^ 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 * (2.0 / (((k_m * (k_m * sqrt(t_m))) / l) ^ 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[(2.0 / N[Power[N[(N[(k$95$m * N[(k$95$m * N[Sqrt[t$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $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 \frac{2}{{\left(\frac{k\_m \cdot \left(k\_m \cdot \sqrt{t\_m}\right)}{\ell}\right)}^{2}}
\end{array}
Derivation
  1. Initial program 32.0%

    \[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) - 1\right)} \]
  2. Simplified32.0%

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

    \[\leadsto \frac{2}{\color{blue}{{\left(\frac{k}{t} \cdot \frac{\sqrt{{t}^{3} \cdot \left(\sin k \cdot \tan k\right)}}{\ell}\right)}^{2} + \left({t}^{3} \cdot \left({\ell}^{-2} \cdot \left(\sin k \cdot \tan k\right)\right)\right) \cdot 0}} \]
  5. Step-by-step derivation
    1. mul0-rgt30.0%

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

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

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

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

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

    \[\leadsto \frac{2}{\color{blue}{{\left(\frac{\frac{k}{t} \cdot \sqrt{\sin k \cdot \left(\tan k \cdot {t}^{3}\right)}}{\ell}\right)}^{2}}} \]
  7. Taylor expanded in k around inf 52.8%

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

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

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

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

Alternative 7: 73.2% 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 \frac{\frac{2}{t\_m}}{{\left(\frac{{k\_m}^{2}}{\ell}\right)}^{2}} \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 (/ (/ 2.0 t_m) (pow (/ (pow k_m 2.0) l) 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 * ((2.0 / t_m) / pow((pow(k_m, 2.0) / l), 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 * ((2.0d0 / t_m) / (((k_m ** 2.0d0) / l) ** 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 * ((2.0 / t_m) / Math.pow((Math.pow(k_m, 2.0) / l), 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 * ((2.0 / t_m) / math.pow((math.pow(k_m, 2.0) / l), 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(2.0 / t_m) / (Float64((k_m ^ 2.0) / l) ^ 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 * ((2.0 / t_m) / (((k_m ^ 2.0) / l) ^ 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[(2.0 / t$95$m), $MachinePrecision] / N[Power[N[(N[Power[k$95$m, 2.0], $MachinePrecision] / l), $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 \frac{\frac{2}{t\_m}}{{\left(\frac{{k\_m}^{2}}{\ell}\right)}^{2}}
\end{array}
Derivation
  1. Initial program 32.0%

    \[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) - 1\right)} \]
  2. Simplified32.0%

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

    \[\leadsto \frac{2}{\color{blue}{{\left(\frac{k}{t} \cdot \frac{\sqrt{{t}^{3} \cdot \left(\sin k \cdot \tan k\right)}}{\ell}\right)}^{2} + \left({t}^{3} \cdot \left({\ell}^{-2} \cdot \left(\sin k \cdot \tan k\right)\right)\right) \cdot 0}} \]
  5. Step-by-step derivation
    1. mul0-rgt30.0%

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

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

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

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

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

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

    \[\leadsto \frac{2}{{\color{blue}{\left(\frac{{k}^{2}}{\ell} \cdot \sqrt{t}\right)}}^{2}} \]
  8. Step-by-step derivation
    1. *-un-lft-identity39.0%

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

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

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

      \[\leadsto 1 \cdot \frac{2}{\color{blue}{\left(\sqrt{t} \cdot \sqrt{t}\right)} \cdot {\left(\frac{{k}^{2}}{\ell}\right)}^{2}} \]
    5. add-sqr-sqrt68.9%

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

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

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

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

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

Alternative 8: 73.2% 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 \frac{2}{t\_m \cdot {\left(\frac{{k\_m}^{2}}{\ell}\right)}^{2}} \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 (/ 2.0 (* t_m (pow (/ (pow k_m 2.0) l) 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 * (2.0 / (t_m * pow((pow(k_m, 2.0) / l), 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 * (2.0d0 / (t_m * (((k_m ** 2.0d0) / l) ** 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 * (2.0 / (t_m * Math.pow((Math.pow(k_m, 2.0) / l), 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 * (2.0 / (t_m * math.pow((math.pow(k_m, 2.0) / l), 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(2.0 / Float64(t_m * (Float64((k_m ^ 2.0) / l) ^ 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 * (2.0 / (t_m * (((k_m ^ 2.0) / l) ^ 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[(2.0 / N[(t$95$m * N[Power[N[(N[Power[k$95$m, 2.0], $MachinePrecision] / l), $MachinePrecision], 2.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 \frac{2}{t\_m \cdot {\left(\frac{{k\_m}^{2}}{\ell}\right)}^{2}}
\end{array}
Derivation
  1. Initial program 32.0%

    \[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) - 1\right)} \]
  2. Simplified32.0%

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

    \[\leadsto \frac{2}{\color{blue}{{\left(\frac{k}{t} \cdot \frac{\sqrt{{t}^{3} \cdot \left(\sin k \cdot \tan k\right)}}{\ell}\right)}^{2} + \left({t}^{3} \cdot \left({\ell}^{-2} \cdot \left(\sin k \cdot \tan k\right)\right)\right) \cdot 0}} \]
  5. Step-by-step derivation
    1. mul0-rgt30.0%

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

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

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

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

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

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

    \[\leadsto \frac{2}{{\color{blue}{\left(\frac{{k}^{2}}{\ell} \cdot \sqrt{t}\right)}}^{2}} \]
  8. Step-by-step derivation
    1. unpow-prod-down37.6%

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

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

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

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

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

Alternative 9: 63.2% 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 \frac{2}{t\_m \cdot \frac{{k\_m}^{4}}{{\ell}^{2}}} \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 (/ 2.0 (* t_m (/ (pow k_m 4.0) (pow l 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 * (2.0 / (t_m * (pow(k_m, 4.0) / pow(l, 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 * (2.0d0 / (t_m * ((k_m ** 4.0d0) / (l ** 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 * (2.0 / (t_m * (Math.pow(k_m, 4.0) / Math.pow(l, 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 * (2.0 / (t_m * (math.pow(k_m, 4.0) / math.pow(l, 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(2.0 / Float64(t_m * Float64((k_m ^ 4.0) / (l ^ 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 * (2.0 / (t_m * ((k_m ^ 4.0) / (l ^ 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[(2.0 / N[(t$95$m * N[(N[Power[k$95$m, 4.0], $MachinePrecision] / N[Power[l, 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 \frac{2}{t\_m \cdot \frac{{k\_m}^{4}}{{\ell}^{2}}}
\end{array}
Derivation
  1. Initial program 32.0%

    \[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) - 1\right)} \]
  2. Simplified32.0%

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

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

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

      \[\leadsto \frac{2}{{k}^{2} \cdot \frac{t \cdot {\sin k}^{2}}{\color{blue}{\cos k \cdot {\ell}^{2}}}} \]
  6. Simplified73.0%

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

    \[\leadsto \frac{2}{\color{blue}{\frac{{k}^{4} \cdot t}{{\ell}^{2}}}} \]
  8. Step-by-step derivation
    1. *-commutative57.7%

      \[\leadsto \frac{2}{\frac{\color{blue}{t \cdot {k}^{4}}}{{\ell}^{2}}} \]
    2. associate-/l*58.5%

      \[\leadsto \frac{2}{\color{blue}{t \cdot \frac{{k}^{4}}{{\ell}^{2}}}} \]
  9. Simplified58.5%

    \[\leadsto \frac{2}{\color{blue}{t \cdot \frac{{k}^{4}}{{\ell}^{2}}}} \]
  10. Add Preprocessing

Alternative 10: 63.2% 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(\frac{2}{t\_m} \cdot {k\_m}^{-4}\right) \cdot \left(\ell \cdot \ell\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 (* (* (/ 2.0 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) {
	return t_s * (((2.0 / t_m) * pow(k_m, -4.0)) * (l * l));
}
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 * (((2.0d0 / t_m) * (k_m ** (-4.0d0))) * (l * l))
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 * (((2.0 / t_m) * Math.pow(k_m, -4.0)) * (l * l));
}
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 * (((2.0 / t_m) * math.pow(k_m, -4.0)) * (l * l))
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(Float64(2.0 / t_m) * (k_m ^ -4.0)) * Float64(l * l)))
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 * (((2.0 / t_m) * (k_m ^ -4.0)) * (l * l));
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[(2.0 / t$95$m), $MachinePrecision] * N[Power[k$95$m, -4.0], $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 \left(\left(\frac{2}{t\_m} \cdot {k\_m}^{-4}\right) \cdot \left(\ell \cdot \ell\right)\right)
\end{array}
Derivation
  1. Initial program 32.0%

    \[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) - 1\right)} \]
  2. Simplified38.7%

    \[\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 57.7%

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

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

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

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

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

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

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

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

Reproduce

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