Toniolo and Linder, Equation (10-)

Percentage Accurate: 36.1% → 85.5%
Time: 34.1s
Alternatives: 11
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 11 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: 36.1% 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: 85.5% 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 1.25 \cdot 10^{-8}:\\ \;\;\;\;\frac{2}{{\left(\sqrt{\frac{t\_m}{\cos k\_m}} \cdot \left(k\_m \cdot \frac{\sin k\_m}{\ell}\right)\right)}^{2}}\\ \mathbf{elif}\;k\_m \leq 1.3 \cdot 10^{+182}:\\ \;\;\;\;\frac{2}{\frac{t\_m \cdot \left({\sin k\_m}^{2} \cdot {k\_m}^{2}\right)}{\cos k\_m}} \cdot \left(\ell \cdot \ell\right)\\ \mathbf{elif}\;k\_m \leq 4.2 \cdot 10^{+246}:\\ \;\;\;\;\frac{2}{\left({\left(\frac{{t\_m}^{1.5}}{\ell}\right)}^{2} \cdot \left(\sin k\_m \cdot \tan k\_m\right)\right) \cdot {\left(\frac{k\_m}{t\_m}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{{\left(\frac{{k\_m}^{2}}{\ell} \cdot \sqrt{t\_m}\right)}^{2}}\\ \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.25e-8)
    (/ 2.0 (pow (* (sqrt (/ t_m (cos k_m))) (* k_m (/ (sin k_m) l))) 2.0))
    (if (<= k_m 1.3e+182)
      (*
       (/ 2.0 (/ (* t_m (* (pow (sin k_m) 2.0) (pow k_m 2.0))) (cos k_m)))
       (* l l))
      (if (<= k_m 4.2e+246)
        (/
         2.0
         (*
          (* (pow (/ (pow t_m 1.5) l) 2.0) (* (sin k_m) (tan k_m)))
          (pow (/ k_m t_m) 2.0)))
        (/ 2.0 (pow (* (/ (pow k_m 2.0) l) (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) {
	double tmp;
	if (k_m <= 1.25e-8) {
		tmp = 2.0 / pow((sqrt((t_m / cos(k_m))) * (k_m * (sin(k_m) / l))), 2.0);
	} else if (k_m <= 1.3e+182) {
		tmp = (2.0 / ((t_m * (pow(sin(k_m), 2.0) * pow(k_m, 2.0))) / cos(k_m))) * (l * l);
	} else if (k_m <= 4.2e+246) {
		tmp = 2.0 / ((pow((pow(t_m, 1.5) / l), 2.0) * (sin(k_m) * tan(k_m))) * pow((k_m / t_m), 2.0));
	} else {
		tmp = 2.0 / pow(((pow(k_m, 2.0) / l) * sqrt(t_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.25d-8) then
        tmp = 2.0d0 / ((sqrt((t_m / cos(k_m))) * (k_m * (sin(k_m) / l))) ** 2.0d0)
    else if (k_m <= 1.3d+182) then
        tmp = (2.0d0 / ((t_m * ((sin(k_m) ** 2.0d0) * (k_m ** 2.0d0))) / cos(k_m))) * (l * l)
    else if (k_m <= 4.2d+246) then
        tmp = 2.0d0 / (((((t_m ** 1.5d0) / l) ** 2.0d0) * (sin(k_m) * tan(k_m))) * ((k_m / t_m) ** 2.0d0))
    else
        tmp = 2.0d0 / ((((k_m ** 2.0d0) / l) * sqrt(t_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.25e-8) {
		tmp = 2.0 / Math.pow((Math.sqrt((t_m / Math.cos(k_m))) * (k_m * (Math.sin(k_m) / l))), 2.0);
	} else if (k_m <= 1.3e+182) {
		tmp = (2.0 / ((t_m * (Math.pow(Math.sin(k_m), 2.0) * Math.pow(k_m, 2.0))) / Math.cos(k_m))) * (l * l);
	} else if (k_m <= 4.2e+246) {
		tmp = 2.0 / ((Math.pow((Math.pow(t_m, 1.5) / l), 2.0) * (Math.sin(k_m) * Math.tan(k_m))) * Math.pow((k_m / t_m), 2.0));
	} else {
		tmp = 2.0 / Math.pow(((Math.pow(k_m, 2.0) / l) * Math.sqrt(t_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.25e-8:
		tmp = 2.0 / math.pow((math.sqrt((t_m / math.cos(k_m))) * (k_m * (math.sin(k_m) / l))), 2.0)
	elif k_m <= 1.3e+182:
		tmp = (2.0 / ((t_m * (math.pow(math.sin(k_m), 2.0) * math.pow(k_m, 2.0))) / math.cos(k_m))) * (l * l)
	elif k_m <= 4.2e+246:
		tmp = 2.0 / ((math.pow((math.pow(t_m, 1.5) / l), 2.0) * (math.sin(k_m) * math.tan(k_m))) * math.pow((k_m / t_m), 2.0))
	else:
		tmp = 2.0 / math.pow(((math.pow(k_m, 2.0) / l) * math.sqrt(t_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.25e-8)
		tmp = Float64(2.0 / (Float64(sqrt(Float64(t_m / cos(k_m))) * Float64(k_m * Float64(sin(k_m) / l))) ^ 2.0));
	elseif (k_m <= 1.3e+182)
		tmp = Float64(Float64(2.0 / Float64(Float64(t_m * Float64((sin(k_m) ^ 2.0) * (k_m ^ 2.0))) / cos(k_m))) * Float64(l * l));
	elseif (k_m <= 4.2e+246)
		tmp = Float64(2.0 / Float64(Float64((Float64((t_m ^ 1.5) / l) ^ 2.0) * Float64(sin(k_m) * tan(k_m))) * (Float64(k_m / t_m) ^ 2.0)));
	else
		tmp = Float64(2.0 / (Float64(Float64((k_m ^ 2.0) / l) * sqrt(t_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.25e-8)
		tmp = 2.0 / ((sqrt((t_m / cos(k_m))) * (k_m * (sin(k_m) / l))) ^ 2.0);
	elseif (k_m <= 1.3e+182)
		tmp = (2.0 / ((t_m * ((sin(k_m) ^ 2.0) * (k_m ^ 2.0))) / cos(k_m))) * (l * l);
	elseif (k_m <= 4.2e+246)
		tmp = 2.0 / (((((t_m ^ 1.5) / l) ^ 2.0) * (sin(k_m) * tan(k_m))) * ((k_m / t_m) ^ 2.0));
	else
		tmp = 2.0 / ((((k_m ^ 2.0) / l) * sqrt(t_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.25e-8], N[(2.0 / N[Power[N[(N[Sqrt[N[(t$95$m / N[Cos[k$95$m], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(k$95$m * N[(N[Sin[k$95$m], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[k$95$m, 1.3e+182], N[(N[(2.0 / N[(N[(t$95$m * N[(N[Power[N[Sin[k$95$m], $MachinePrecision], 2.0], $MachinePrecision] * N[Power[k$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[k$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(l * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[k$95$m, 4.2e+246], N[(2.0 / N[(N[(N[Power[N[(N[Power[t$95$m, 1.5], $MachinePrecision] / l), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Sin[k$95$m], $MachinePrecision] * N[Tan[k$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[N[(k$95$m / t$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[Power[N[(N[(N[Power[k$95$m, 2.0], $MachinePrecision] / l), $MachinePrecision] * N[Sqrt[t$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 \begin{array}{l}
\mathbf{if}\;k\_m \leq 1.25 \cdot 10^{-8}:\\
\;\;\;\;\frac{2}{{\left(\sqrt{\frac{t\_m}{\cos k\_m}} \cdot \left(k\_m \cdot \frac{\sin k\_m}{\ell}\right)\right)}^{2}}\\

\mathbf{elif}\;k\_m \leq 1.3 \cdot 10^{+182}:\\
\;\;\;\;\frac{2}{\frac{t\_m \cdot \left({\sin k\_m}^{2} \cdot {k\_m}^{2}\right)}{\cos k\_m}} \cdot \left(\ell \cdot \ell\right)\\

\mathbf{elif}\;k\_m \leq 4.2 \cdot 10^{+246}:\\
\;\;\;\;\frac{2}{\left({\left(\frac{{t\_m}^{1.5}}{\ell}\right)}^{2} \cdot \left(\sin k\_m \cdot \tan k\_m\right)\right) \cdot {\left(\frac{k\_m}{t\_m}\right)}^{2}}\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.2499999999999999e-8 < k < 1.3e182

    1. Initial program 29.4%

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

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

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

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

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

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

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

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

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

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

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

    if 1.3e182 < k < 4.2e246

    1. Initial program 29.4%

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

      \[\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. Step-by-step derivation
      1. +-commutative29.4%

        \[\leadsto \frac{2}{\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \left(\sin k \cdot \tan k\right)\right) \cdot \color{blue}{\left(\left({\left(\frac{k}{t}\right)}^{2} - 1\right) + 1\right)}} \]
      2. associate-+l-29.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.2e246 < k

    1. Initial program 50.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. Simplified50.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-rr8.2%

      \[\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-rgt41.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-identity41.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. *-commutative41.5%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 1.25 \cdot 10^{-8}:\\ \;\;\;\;\frac{2}{{\left(\sqrt{\frac{t}{\cos k}} \cdot \left(k \cdot \frac{\sin k}{\ell}\right)\right)}^{2}}\\ \mathbf{elif}\;k \leq 1.3 \cdot 10^{+182}:\\ \;\;\;\;\frac{2}{\frac{t \cdot \left({\sin k}^{2} \cdot {k}^{2}\right)}{\cos k}} \cdot \left(\ell \cdot \ell\right)\\ \mathbf{elif}\;k \leq 4.2 \cdot 10^{+246}:\\ \;\;\;\;\frac{2}{\left({\left(\frac{{t}^{1.5}}{\ell}\right)}^{2} \cdot \left(\sin k \cdot \tan k\right)\right) \cdot {\left(\frac{k}{t}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{{\left(\frac{{k}^{2}}{\ell} \cdot \sqrt{t}\right)}^{2}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 85.5% 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 7.5 \cdot 10^{-9}:\\ \;\;\;\;\frac{2}{{\left(\sqrt{\frac{t\_m}{\cos k\_m}} \cdot \left(k\_m \cdot \frac{\sin k\_m}{\ell}\right)\right)}^{2}}\\ \mathbf{elif}\;k\_m \leq 2.3 \cdot 10^{+182}:\\ \;\;\;\;\frac{2}{\frac{t\_m \cdot \left({\sin k\_m}^{2} \cdot {k\_m}^{2}\right)}{\cos k\_m}} \cdot \left(\ell \cdot \ell\right)\\ \mathbf{elif}\;k\_m \leq 4.2 \cdot 10^{+246}:\\ \;\;\;\;\frac{2}{\left(\sin k\_m \cdot \tan k\_m\right) \cdot \left({\left(\frac{{t\_m}^{1.5}}{\ell}\right)}^{2} \cdot {\left(\frac{k\_m}{t\_m}\right)}^{2}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{{\left(\frac{{k\_m}^{2}}{\ell} \cdot \sqrt{t\_m}\right)}^{2}}\\ \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 7.5e-9)
    (/ 2.0 (pow (* (sqrt (/ t_m (cos k_m))) (* k_m (/ (sin k_m) l))) 2.0))
    (if (<= k_m 2.3e+182)
      (*
       (/ 2.0 (/ (* t_m (* (pow (sin k_m) 2.0) (pow k_m 2.0))) (cos k_m)))
       (* l l))
      (if (<= k_m 4.2e+246)
        (/
         2.0
         (*
          (* (sin k_m) (tan k_m))
          (* (pow (/ (pow t_m 1.5) l) 2.0) (pow (/ k_m t_m) 2.0))))
        (/ 2.0 (pow (* (/ (pow k_m 2.0) l) (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) {
	double tmp;
	if (k_m <= 7.5e-9) {
		tmp = 2.0 / pow((sqrt((t_m / cos(k_m))) * (k_m * (sin(k_m) / l))), 2.0);
	} else if (k_m <= 2.3e+182) {
		tmp = (2.0 / ((t_m * (pow(sin(k_m), 2.0) * pow(k_m, 2.0))) / cos(k_m))) * (l * l);
	} else if (k_m <= 4.2e+246) {
		tmp = 2.0 / ((sin(k_m) * tan(k_m)) * (pow((pow(t_m, 1.5) / l), 2.0) * pow((k_m / t_m), 2.0)));
	} else {
		tmp = 2.0 / pow(((pow(k_m, 2.0) / l) * sqrt(t_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 <= 7.5d-9) then
        tmp = 2.0d0 / ((sqrt((t_m / cos(k_m))) * (k_m * (sin(k_m) / l))) ** 2.0d0)
    else if (k_m <= 2.3d+182) then
        tmp = (2.0d0 / ((t_m * ((sin(k_m) ** 2.0d0) * (k_m ** 2.0d0))) / cos(k_m))) * (l * l)
    else if (k_m <= 4.2d+246) then
        tmp = 2.0d0 / ((sin(k_m) * tan(k_m)) * ((((t_m ** 1.5d0) / l) ** 2.0d0) * ((k_m / t_m) ** 2.0d0)))
    else
        tmp = 2.0d0 / ((((k_m ** 2.0d0) / l) * sqrt(t_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 <= 7.5e-9) {
		tmp = 2.0 / Math.pow((Math.sqrt((t_m / Math.cos(k_m))) * (k_m * (Math.sin(k_m) / l))), 2.0);
	} else if (k_m <= 2.3e+182) {
		tmp = (2.0 / ((t_m * (Math.pow(Math.sin(k_m), 2.0) * Math.pow(k_m, 2.0))) / Math.cos(k_m))) * (l * l);
	} else if (k_m <= 4.2e+246) {
		tmp = 2.0 / ((Math.sin(k_m) * Math.tan(k_m)) * (Math.pow((Math.pow(t_m, 1.5) / l), 2.0) * Math.pow((k_m / t_m), 2.0)));
	} else {
		tmp = 2.0 / Math.pow(((Math.pow(k_m, 2.0) / l) * Math.sqrt(t_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 <= 7.5e-9:
		tmp = 2.0 / math.pow((math.sqrt((t_m / math.cos(k_m))) * (k_m * (math.sin(k_m) / l))), 2.0)
	elif k_m <= 2.3e+182:
		tmp = (2.0 / ((t_m * (math.pow(math.sin(k_m), 2.0) * math.pow(k_m, 2.0))) / math.cos(k_m))) * (l * l)
	elif k_m <= 4.2e+246:
		tmp = 2.0 / ((math.sin(k_m) * math.tan(k_m)) * (math.pow((math.pow(t_m, 1.5) / l), 2.0) * math.pow((k_m / t_m), 2.0)))
	else:
		tmp = 2.0 / math.pow(((math.pow(k_m, 2.0) / l) * math.sqrt(t_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 <= 7.5e-9)
		tmp = Float64(2.0 / (Float64(sqrt(Float64(t_m / cos(k_m))) * Float64(k_m * Float64(sin(k_m) / l))) ^ 2.0));
	elseif (k_m <= 2.3e+182)
		tmp = Float64(Float64(2.0 / Float64(Float64(t_m * Float64((sin(k_m) ^ 2.0) * (k_m ^ 2.0))) / cos(k_m))) * Float64(l * l));
	elseif (k_m <= 4.2e+246)
		tmp = Float64(2.0 / Float64(Float64(sin(k_m) * tan(k_m)) * Float64((Float64((t_m ^ 1.5) / l) ^ 2.0) * (Float64(k_m / t_m) ^ 2.0))));
	else
		tmp = Float64(2.0 / (Float64(Float64((k_m ^ 2.0) / l) * sqrt(t_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 <= 7.5e-9)
		tmp = 2.0 / ((sqrt((t_m / cos(k_m))) * (k_m * (sin(k_m) / l))) ^ 2.0);
	elseif (k_m <= 2.3e+182)
		tmp = (2.0 / ((t_m * ((sin(k_m) ^ 2.0) * (k_m ^ 2.0))) / cos(k_m))) * (l * l);
	elseif (k_m <= 4.2e+246)
		tmp = 2.0 / ((sin(k_m) * tan(k_m)) * ((((t_m ^ 1.5) / l) ^ 2.0) * ((k_m / t_m) ^ 2.0)));
	else
		tmp = 2.0 / ((((k_m ^ 2.0) / l) * sqrt(t_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, 7.5e-9], N[(2.0 / N[Power[N[(N[Sqrt[N[(t$95$m / N[Cos[k$95$m], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(k$95$m * N[(N[Sin[k$95$m], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[k$95$m, 2.3e+182], N[(N[(2.0 / N[(N[(t$95$m * N[(N[Power[N[Sin[k$95$m], $MachinePrecision], 2.0], $MachinePrecision] * N[Power[k$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[k$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(l * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[k$95$m, 4.2e+246], N[(2.0 / N[(N[(N[Sin[k$95$m], $MachinePrecision] * N[Tan[k$95$m], $MachinePrecision]), $MachinePrecision] * N[(N[Power[N[(N[Power[t$95$m, 1.5], $MachinePrecision] / l), $MachinePrecision], 2.0], $MachinePrecision] * N[Power[N[(k$95$m / t$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[Power[N[(N[(N[Power[k$95$m, 2.0], $MachinePrecision] / l), $MachinePrecision] * N[Sqrt[t$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 \begin{array}{l}
\mathbf{if}\;k\_m \leq 7.5 \cdot 10^{-9}:\\
\;\;\;\;\frac{2}{{\left(\sqrt{\frac{t\_m}{\cos k\_m}} \cdot \left(k\_m \cdot \frac{\sin k\_m}{\ell}\right)\right)}^{2}}\\

\mathbf{elif}\;k\_m \leq 2.3 \cdot 10^{+182}:\\
\;\;\;\;\frac{2}{\frac{t\_m \cdot \left({\sin k\_m}^{2} \cdot {k\_m}^{2}\right)}{\cos k\_m}} \cdot \left(\ell \cdot \ell\right)\\

\mathbf{elif}\;k\_m \leq 4.2 \cdot 10^{+246}:\\
\;\;\;\;\frac{2}{\left(\sin k\_m \cdot \tan k\_m\right) \cdot \left({\left(\frac{{t\_m}^{1.5}}{\ell}\right)}^{2} \cdot {\left(\frac{k\_m}{t\_m}\right)}^{2}\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if k < 7.49999999999999933e-9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.49999999999999933e-9 < k < 2.3e182

    1. Initial program 29.4%

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

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

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

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

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

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

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

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

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

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

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

    if 2.3e182 < k < 4.2e246

    1. Initial program 29.4%

      \[\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. Step-by-step derivation
      1. *-commutative29.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{2}{\left({\left(\frac{{t}^{1.5}}{\color{blue}{\ell}}\right)}^{2} \cdot \left(\sin k \cdot \tan k\right)\right) \cdot \frac{k}{\frac{t}{k} \cdot t}} \]
    6. Applied egg-rr23.1%

      \[\leadsto \frac{\frac{2}{{\left(\frac{k}{t}\right)}^{2} + 0}}{\color{blue}{{\left(\frac{{t}^{1.5}}{\ell}\right)}^{2}} \cdot \left(\sin k \cdot \tan k\right)} \]
    7. Step-by-step derivation
      1. *-un-lft-identity23.1%

        \[\leadsto \color{blue}{1 \cdot \frac{\frac{2}{{\left(\frac{k}{t}\right)}^{2} + 0}}{{\left(\frac{{t}^{1.5}}{\ell}\right)}^{2} \cdot \left(\sin k \cdot \tan k\right)}} \]
      2. associate-/l/23.3%

        \[\leadsto 1 \cdot \color{blue}{\frac{2}{\left({\left(\frac{{t}^{1.5}}{\ell}\right)}^{2} \cdot \left(\sin k \cdot \tan k\right)\right) \cdot \left({\left(\frac{k}{t}\right)}^{2} + 0\right)}} \]
      3. *-commutative23.3%

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

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

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

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

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

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

    if 4.2e246 < k

    1. Initial program 50.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. Simplified50.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-rr8.2%

      \[\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-rgt41.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-identity41.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. *-commutative41.5%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 7.5 \cdot 10^{-9}:\\ \;\;\;\;\frac{2}{{\left(\sqrt{\frac{t}{\cos k}} \cdot \left(k \cdot \frac{\sin k}{\ell}\right)\right)}^{2}}\\ \mathbf{elif}\;k \leq 2.3 \cdot 10^{+182}:\\ \;\;\;\;\frac{2}{\frac{t \cdot \left({\sin k}^{2} \cdot {k}^{2}\right)}{\cos k}} \cdot \left(\ell \cdot \ell\right)\\ \mathbf{elif}\;k \leq 4.2 \cdot 10^{+246}:\\ \;\;\;\;\frac{2}{\left(\sin k \cdot \tan k\right) \cdot \left({\left(\frac{{t}^{1.5}}{\ell}\right)}^{2} \cdot {\left(\frac{k}{t}\right)}^{2}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{{\left(\frac{{k}^{2}}{\ell} \cdot \sqrt{t}\right)}^{2}}\\ \end{array} \]
  5. Add Preprocessing

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.0000000000000005e-9 < k

    1. Initial program 33.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. Simplified45.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 69.7%

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.30000000000000031e-9 < k

    1. Initial program 33.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. Simplified45.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 69.7%

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

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

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

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

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

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

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 l l) < 1.99999999999999997e-45

    1. Initial program 39.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. Simplified39.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-rr12.9%

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

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

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

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

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

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

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

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

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

    if 1.99999999999999997e-45 < (*.f64 l l)

    1. Initial program 40.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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-rr19.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} + \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.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-identity31.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. *-commutative31.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{2 \cdot \color{blue}{{\ell}^{2}}}{{k}^{4} \cdot t} \]
    3. *-commutative69.9%

      \[\leadsto \frac{2 \cdot {\ell}^{2}}{\color{blue}{t \cdot {k}^{4}}} \]
  6. Applied egg-rr69.9%

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

      \[\leadsto \color{blue}{\frac{2}{t} \cdot \frac{{\ell}^{2}}{{k}^{4}}} \]
  8. Applied egg-rr69.6%

    \[\leadsto \color{blue}{\frac{2}{t} \cdot \frac{{\ell}^{2}}{{k}^{4}}} \]
  9. Step-by-step derivation
    1. associate-*l/69.6%

      \[\leadsto \color{blue}{\frac{2 \cdot \frac{{\ell}^{2}}{{k}^{4}}}{t}} \]
    2. pow269.6%

      \[\leadsto \frac{2 \cdot \frac{\color{blue}{\ell \cdot \ell}}{{k}^{4}}}{t} \]
    3. div-inv69.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 63.3% 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 39.6%

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

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

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

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

Alternative 11: 63.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{\frac{2}{t\_m}}{{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(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 \frac{\frac{2}{t\_m}}{{k\_m}^{4}}\right)
\end{array}
Derivation
  1. Initial program 39.6%

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

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

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

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

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

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

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

Reproduce

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