Toniolo and Linder, Equation (10-)

Percentage Accurate: 35.5% → 95.4%
Time: 24.5s
Alternatives: 9
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 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 35.5% accurate, 1.0× speedup?

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

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

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

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

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


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

    1. Initial program 34.3%

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

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

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

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

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

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

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

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

    if 5.7999999999999996e-16 < k

    1. Initial program 23.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. Simplified33.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 34.3%

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

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

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

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

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

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

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

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

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

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

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

    if 5.7999999999999996e-16 < k

    1. Initial program 23.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. Simplified33.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 93.0% accurate, 1.3× speedup?

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

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

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


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

    1. Initial program 34.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.7999999999999996e-16 < k

    1. Initial program 23.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. Simplified33.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 74.2% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 69.7% accurate, 1.9× 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}\;t\_m \leq 1.7 \cdot 10^{-217}:\\ \;\;\;\;\left(\frac{2}{t\_m} \cdot {\ell}^{2}\right) \cdot {k\_m}^{-4}\\ \mathbf{elif}\;t\_m \leq 3.6 \cdot 10^{+127}:\\ \;\;\;\;\frac{2}{{\left(k\_m \cdot \left(\frac{k\_m}{t\_m} \cdot \frac{{t\_m}^{1.5}}{\ell}\right)\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\left({k\_m}^{-2} \cdot \frac{\frac{2}{t\_m}}{{k\_m}^{2}}\right) \cdot \left(\ell \cdot \ell\right)\\ \end{array} \end{array} \]
k_m = (fabs.f64 k)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 1 t)
(FPCore (t_s t_m l k_m)
 :precision binary64
 (*
  t_s
  (if (<= t_m 1.7e-217)
    (* (* (/ 2.0 t_m) (pow l 2.0)) (pow k_m -4.0))
    (if (<= t_m 3.6e+127)
      (/ 2.0 (pow (* k_m (* (/ k_m t_m) (/ (pow t_m 1.5) l))) 2.0))
      (* (* (pow k_m -2.0) (/ (/ 2.0 t_m) (pow k_m 2.0))) (* l l))))))
k_m = fabs(k);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k_m) {
	double tmp;
	if (t_m <= 1.7e-217) {
		tmp = ((2.0 / t_m) * pow(l, 2.0)) * pow(k_m, -4.0);
	} else if (t_m <= 3.6e+127) {
		tmp = 2.0 / pow((k_m * ((k_m / t_m) * (pow(t_m, 1.5) / l))), 2.0);
	} else {
		tmp = (pow(k_m, -2.0) * ((2.0 / t_m) / pow(k_m, 2.0))) * (l * l);
	}
	return t_s * tmp;
}
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0d0, t)
real(8) function code(t_s, t_m, l, k_m)
    real(8), intent (in) :: t_s
    real(8), intent (in) :: t_m
    real(8), intent (in) :: l
    real(8), intent (in) :: k_m
    real(8) :: tmp
    if (t_m <= 1.7d-217) then
        tmp = ((2.0d0 / t_m) * (l ** 2.0d0)) * (k_m ** (-4.0d0))
    else if (t_m <= 3.6d+127) then
        tmp = 2.0d0 / ((k_m * ((k_m / t_m) * ((t_m ** 1.5d0) / l))) ** 2.0d0)
    else
        tmp = ((k_m ** (-2.0d0)) * ((2.0d0 / t_m) / (k_m ** 2.0d0))) * (l * l)
    end if
    code = t_s * tmp
end function
k_m = Math.abs(k);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k_m) {
	double tmp;
	if (t_m <= 1.7e-217) {
		tmp = ((2.0 / t_m) * Math.pow(l, 2.0)) * Math.pow(k_m, -4.0);
	} else if (t_m <= 3.6e+127) {
		tmp = 2.0 / Math.pow((k_m * ((k_m / t_m) * (Math.pow(t_m, 1.5) / l))), 2.0);
	} else {
		tmp = (Math.pow(k_m, -2.0) * ((2.0 / t_m) / Math.pow(k_m, 2.0))) * (l * l);
	}
	return t_s * tmp;
}
k_m = math.fabs(k)
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
def code(t_s, t_m, l, k_m):
	tmp = 0
	if t_m <= 1.7e-217:
		tmp = ((2.0 / t_m) * math.pow(l, 2.0)) * math.pow(k_m, -4.0)
	elif t_m <= 3.6e+127:
		tmp = 2.0 / math.pow((k_m * ((k_m / t_m) * (math.pow(t_m, 1.5) / l))), 2.0)
	else:
		tmp = (math.pow(k_m, -2.0) * ((2.0 / t_m) / math.pow(k_m, 2.0))) * (l * l)
	return t_s * tmp
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, t_m, l, k_m)
	tmp = 0.0
	if (t_m <= 1.7e-217)
		tmp = Float64(Float64(Float64(2.0 / t_m) * (l ^ 2.0)) * (k_m ^ -4.0));
	elseif (t_m <= 3.6e+127)
		tmp = Float64(2.0 / (Float64(k_m * Float64(Float64(k_m / t_m) * Float64((t_m ^ 1.5) / l))) ^ 2.0));
	else
		tmp = Float64(Float64((k_m ^ -2.0) * Float64(Float64(2.0 / t_m) / (k_m ^ 2.0))) * Float64(l * l));
	end
	return Float64(t_s * tmp)
end
k_m = abs(k);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
function tmp_2 = code(t_s, t_m, l, k_m)
	tmp = 0.0;
	if (t_m <= 1.7e-217)
		tmp = ((2.0 / t_m) * (l ^ 2.0)) * (k_m ^ -4.0);
	elseif (t_m <= 3.6e+127)
		tmp = 2.0 / ((k_m * ((k_m / t_m) * ((t_m ^ 1.5) / l))) ^ 2.0);
	else
		tmp = ((k_m ^ -2.0) * ((2.0 / t_m) / (k_m ^ 2.0))) * (l * l);
	end
	tmp_2 = t_s * tmp;
end
k_m = N[Abs[k], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k$95$m_] := N[(t$95$s * If[LessEqual[t$95$m, 1.7e-217], N[(N[(N[(2.0 / t$95$m), $MachinePrecision] * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision] * N[Power[k$95$m, -4.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$m, 3.6e+127], N[(2.0 / N[Power[N[(k$95$m * N[(N[(k$95$m / t$95$m), $MachinePrecision] * N[(N[Power[t$95$m, 1.5], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[k$95$m, -2.0], $MachinePrecision] * N[(N[(2.0 / t$95$m), $MachinePrecision] / N[Power[k$95$m, 2.0], $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}\;t\_m \leq 1.7 \cdot 10^{-217}:\\
\;\;\;\;\left(\frac{2}{t\_m} \cdot {\ell}^{2}\right) \cdot {k\_m}^{-4}\\

\mathbf{elif}\;t\_m \leq 3.6 \cdot 10^{+127}:\\
\;\;\;\;\frac{2}{{\left(k\_m \cdot \left(\frac{k\_m}{t\_m} \cdot \frac{{t\_m}^{1.5}}{\ell}\right)\right)}^{2}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < 1.70000000000000008e-217

    1. Initial program 29.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.70000000000000008e-217 < t < 3.59999999999999979e127

    1. Initial program 52.6%

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

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

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

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

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

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

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

    if 3.59999999999999979e127 < t

    1. Initial program 6.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq 1.7 \cdot 10^{-217}:\\ \;\;\;\;\left(\frac{2}{t} \cdot {\ell}^{2}\right) \cdot {k}^{-4}\\ \mathbf{elif}\;t \leq 3.6 \cdot 10^{+127}:\\ \;\;\;\;\frac{2}{{\left(k \cdot \left(\frac{k}{t} \cdot \frac{{t}^{1.5}}{\ell}\right)\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\left({k}^{-2} \cdot \frac{\frac{2}{t}}{{k}^{2}}\right) \cdot \left(\ell \cdot \ell\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 63.7% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 62.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(2 \cdot \frac{{\ell}^{2} \cdot {k\_m}^{-4}}{t\_m}\right) \end{array} \]
k_m = (fabs.f64 k)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 1 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(Float64((l ^ 2.0) * (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[(N[Power[l, 2.0], $MachinePrecision] * N[Power[k$95$m, -4.0], $MachinePrecision]), $MachinePrecision] / t$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
k_m = \left|k\right|
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)

\\
t\_s \cdot \left(2 \cdot \frac{{\ell}^{2} \cdot {k\_m}^{-4}}{t\_m}\right)
\end{array}
Derivation
  1. Initial program 31.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot \color{blue}{\frac{{\ell}^{2} \cdot {k}^{-4}}{t}} \]
  14. Simplified62.4%

    \[\leadsto \color{blue}{2 \cdot \frac{{\ell}^{2} \cdot {k}^{-4}}{t}} \]
  15. Final simplification62.4%

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

Alternative 8: 62.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 \left(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 1 t)
(FPCore (t_s t_m l k_m)
 :precision binary64
 (* t_s (* (* l 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 * ((l * 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 * ((l * 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 * ((l * 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 * ((l * 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(Float64(l * l) * Float64(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 * ((l * 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[(N[(l * l), $MachinePrecision] * N[(2.0 * 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(\left(\ell \cdot \ell\right) \cdot \left(2 \cdot \frac{{k\_m}^{-4}}{t\_m}\right)\right)
\end{array}
Derivation
  1. Initial program 31.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 62.4% accurate, 3.8× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ t\_s \cdot \left(\left(\ell \cdot \ell\right) \cdot \frac{\frac{2}{t\_m}}{{k\_m}^{4}}\right) \end{array} \]
k_m = (fabs.f64 k)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 1 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 31.5%

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

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

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

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

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

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

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

Reproduce

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