Toniolo and Linder, Equation (10-)

Percentage Accurate: 36.9% → 95.9%
Time: 16.2s
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: 36.9% accurate, 1.0× speedup?

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

\\
t\_s \cdot \begin{array}{l}
\mathbf{if}\;k\_m \leq 1.55:\\
\;\;\;\;\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 \frac{\sqrt{2}}{k\_m}\right)}^{2} \cdot \frac{\frac{\cos k\_m}{t\_m}}{{\sin k\_m}^{2}}\\


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

    1. Initial program 36.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.55000000000000004 < k

    1. Initial program 28.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 89.0% accurate, 1.0× speedup?

\[\begin{array}{l} k_m = \left|k\right| \\ t\_m = \left|t\right| \\ t\_s = \mathsf{copysign}\left(1, t\right) \\ \begin{array}{l} t_2 := k\_m \cdot \sin k\_m\\ t\_s \cdot \begin{array}{l} \mathbf{if}\;\ell \cdot \ell \leq 2 \cdot 10^{-204}:\\ \;\;\;\;{\left(\left(\frac{1}{k\_m} \cdot \frac{\ell \cdot \sqrt{2}}{k\_m}\right) \cdot \sqrt{\frac{1}{t\_m}}\right)}^{2}\\ \mathbf{elif}\;\ell \cdot \ell \leq 5 \cdot 10^{+303}:\\ \;\;\;\;\left(\ell \cdot \ell\right) \cdot \left(2 \cdot \frac{\cos k\_m}{{\left(t\_2 \cdot \sqrt{t\_m}\right)}^{2}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{{\left(\sqrt{\frac{t\_m}{\cos k\_m}} \cdot \frac{t\_2}{\ell}\right)}^{2}}\\ \end{array} \end{array} \end{array} \]
k_m = (fabs.f64 k)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k_m)
 :precision binary64
 (let* ((t_2 (* k_m (sin k_m))))
   (*
    t_s
    (if (<= (* l l) 2e-204)
      (pow (* (* (/ 1.0 k_m) (/ (* l (sqrt 2.0)) k_m)) (sqrt (/ 1.0 t_m))) 2.0)
      (if (<= (* l l) 5e+303)
        (* (* l l) (* 2.0 (/ (cos k_m) (pow (* t_2 (sqrt t_m)) 2.0))))
        (/ 2.0 (pow (* (sqrt (/ t_m (cos k_m))) (/ t_2 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 t_2 = k_m * sin(k_m);
	double tmp;
	if ((l * l) <= 2e-204) {
		tmp = pow((((1.0 / k_m) * ((l * sqrt(2.0)) / k_m)) * sqrt((1.0 / t_m))), 2.0);
	} else if ((l * l) <= 5e+303) {
		tmp = (l * l) * (2.0 * (cos(k_m) / pow((t_2 * sqrt(t_m)), 2.0)));
	} else {
		tmp = 2.0 / pow((sqrt((t_m / cos(k_m))) * (t_2 / 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) :: t_2
    real(8) :: tmp
    t_2 = k_m * sin(k_m)
    if ((l * l) <= 2d-204) then
        tmp = (((1.0d0 / k_m) * ((l * sqrt(2.0d0)) / k_m)) * sqrt((1.0d0 / t_m))) ** 2.0d0
    else if ((l * l) <= 5d+303) then
        tmp = (l * l) * (2.0d0 * (cos(k_m) / ((t_2 * sqrt(t_m)) ** 2.0d0)))
    else
        tmp = 2.0d0 / ((sqrt((t_m / cos(k_m))) * (t_2 / 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 t_2 = k_m * Math.sin(k_m);
	double tmp;
	if ((l * l) <= 2e-204) {
		tmp = Math.pow((((1.0 / k_m) * ((l * Math.sqrt(2.0)) / k_m)) * Math.sqrt((1.0 / t_m))), 2.0);
	} else if ((l * l) <= 5e+303) {
		tmp = (l * l) * (2.0 * (Math.cos(k_m) / Math.pow((t_2 * Math.sqrt(t_m)), 2.0)));
	} else {
		tmp = 2.0 / Math.pow((Math.sqrt((t_m / Math.cos(k_m))) * (t_2 / 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):
	t_2 = k_m * math.sin(k_m)
	tmp = 0
	if (l * l) <= 2e-204:
		tmp = math.pow((((1.0 / k_m) * ((l * math.sqrt(2.0)) / k_m)) * math.sqrt((1.0 / t_m))), 2.0)
	elif (l * l) <= 5e+303:
		tmp = (l * l) * (2.0 * (math.cos(k_m) / math.pow((t_2 * math.sqrt(t_m)), 2.0)))
	else:
		tmp = 2.0 / math.pow((math.sqrt((t_m / math.cos(k_m))) * (t_2 / 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)
	t_2 = Float64(k_m * sin(k_m))
	tmp = 0.0
	if (Float64(l * l) <= 2e-204)
		tmp = Float64(Float64(Float64(1.0 / k_m) * Float64(Float64(l * sqrt(2.0)) / k_m)) * sqrt(Float64(1.0 / t_m))) ^ 2.0;
	elseif (Float64(l * l) <= 5e+303)
		tmp = Float64(Float64(l * l) * Float64(2.0 * Float64(cos(k_m) / (Float64(t_2 * sqrt(t_m)) ^ 2.0))));
	else
		tmp = Float64(2.0 / (Float64(sqrt(Float64(t_m / cos(k_m))) * Float64(t_2 / 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)
	t_2 = k_m * sin(k_m);
	tmp = 0.0;
	if ((l * l) <= 2e-204)
		tmp = (((1.0 / k_m) * ((l * sqrt(2.0)) / k_m)) * sqrt((1.0 / t_m))) ^ 2.0;
	elseif ((l * l) <= 5e+303)
		tmp = (l * l) * (2.0 * (cos(k_m) / ((t_2 * sqrt(t_m)) ^ 2.0)));
	else
		tmp = 2.0 / ((sqrt((t_m / cos(k_m))) * (t_2 / 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_] := Block[{t$95$2 = N[(k$95$m * N[Sin[k$95$m], $MachinePrecision]), $MachinePrecision]}, N[(t$95$s * If[LessEqual[N[(l * l), $MachinePrecision], 2e-204], N[Power[N[(N[(N[(1.0 / k$95$m), $MachinePrecision] * N[(N[(l * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] / k$95$m), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 / t$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], If[LessEqual[N[(l * l), $MachinePrecision], 5e+303], N[(N[(l * l), $MachinePrecision] * N[(2.0 * N[(N[Cos[k$95$m], $MachinePrecision] / N[Power[N[(t$95$2 * N[Sqrt[t$95$m], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[Power[N[(N[Sqrt[N[(t$95$m / N[Cos[k$95$m], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(t$95$2 / l), $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)

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

\mathbf{elif}\;\ell \cdot \ell \leq 5 \cdot 10^{+303}:\\
\;\;\;\;\left(\ell \cdot \ell\right) \cdot \left(2 \cdot \frac{\cos k\_m}{{\left(t\_2 \cdot \sqrt{t\_m}\right)}^{2}}\right)\\

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


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

    1. Initial program 25.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. Step-by-step derivation
      1. *-commutative25.1%

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

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

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

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

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

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

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

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

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

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

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

    if 2e-204 < (*.f64 l l) < 4.9999999999999997e303

    1. Initial program 46.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. Simplified59.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.9999999999999997e303 < (*.f64 l l)

    1. Initial program 27.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. Simplified27.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. Taylor expanded in t around 0 61.1%

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 85.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 1.55:\\ \;\;\;\;\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(2 \cdot \frac{\cos k\_m}{\left(t\_m \cdot {k\_m}^{2}\right) \cdot \left(0.5 + \cos \left(k\_m \cdot 2\right) \cdot -0.5\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 1.55)
    (/ 2.0 (pow (* (sqrt (/ t_m (cos k_m))) (* k_m (/ (sin k_m) l))) 2.0))
    (*
     (* l l)
     (*
      2.0
      (/
       (cos k_m)
       (* (* t_m (pow k_m 2.0)) (+ 0.5 (* (cos (* k_m 2.0)) -0.5)))))))))
k_m = fabs(k);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k_m) {
	double tmp;
	if (k_m <= 1.55) {
		tmp = 2.0 / pow((sqrt((t_m / cos(k_m))) * (k_m * (sin(k_m) / l))), 2.0);
	} else {
		tmp = (l * l) * (2.0 * (cos(k_m) / ((t_m * pow(k_m, 2.0)) * (0.5 + (cos((k_m * 2.0)) * -0.5)))));
	}
	return t_s * tmp;
}
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0d0, t)
real(8) function code(t_s, t_m, l, k_m)
    real(8), intent (in) :: t_s
    real(8), intent (in) :: t_m
    real(8), intent (in) :: l
    real(8), intent (in) :: k_m
    real(8) :: tmp
    if (k_m <= 1.55d0) then
        tmp = 2.0d0 / ((sqrt((t_m / cos(k_m))) * (k_m * (sin(k_m) / l))) ** 2.0d0)
    else
        tmp = (l * l) * (2.0d0 * (cos(k_m) / ((t_m * (k_m ** 2.0d0)) * (0.5d0 + (cos((k_m * 2.0d0)) * (-0.5d0))))))
    end if
    code = t_s * tmp
end function
k_m = Math.abs(k);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k_m) {
	double tmp;
	if (k_m <= 1.55) {
		tmp = 2.0 / Math.pow((Math.sqrt((t_m / Math.cos(k_m))) * (k_m * (Math.sin(k_m) / l))), 2.0);
	} else {
		tmp = (l * l) * (2.0 * (Math.cos(k_m) / ((t_m * Math.pow(k_m, 2.0)) * (0.5 + (Math.cos((k_m * 2.0)) * -0.5)))));
	}
	return t_s * tmp;
}
k_m = math.fabs(k)
t\_m = math.fabs(t)
t\_s = math.copysign(1.0, t)
def code(t_s, t_m, l, k_m):
	tmp = 0
	if k_m <= 1.55:
		tmp = 2.0 / math.pow((math.sqrt((t_m / math.cos(k_m))) * (k_m * (math.sin(k_m) / l))), 2.0)
	else:
		tmp = (l * l) * (2.0 * (math.cos(k_m) / ((t_m * math.pow(k_m, 2.0)) * (0.5 + (math.cos((k_m * 2.0)) * -0.5)))))
	return t_s * tmp
k_m = abs(k)
t\_m = abs(t)
t\_s = copysign(1.0, t)
function code(t_s, t_m, l, k_m)
	tmp = 0.0
	if (k_m <= 1.55)
		tmp = Float64(2.0 / (Float64(sqrt(Float64(t_m / cos(k_m))) * Float64(k_m * Float64(sin(k_m) / l))) ^ 2.0));
	else
		tmp = Float64(Float64(l * l) * Float64(2.0 * Float64(cos(k_m) / Float64(Float64(t_m * (k_m ^ 2.0)) * Float64(0.5 + Float64(cos(Float64(k_m * 2.0)) * -0.5))))));
	end
	return Float64(t_s * tmp)
end
k_m = abs(k);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
function tmp_2 = code(t_s, t_m, l, k_m)
	tmp = 0.0;
	if (k_m <= 1.55)
		tmp = 2.0 / ((sqrt((t_m / cos(k_m))) * (k_m * (sin(k_m) / l))) ^ 2.0);
	else
		tmp = (l * l) * (2.0 * (cos(k_m) / ((t_m * (k_m ^ 2.0)) * (0.5 + (cos((k_m * 2.0)) * -0.5)))));
	end
	tmp_2 = t_s * tmp;
end
k_m = N[Abs[k], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k$95$m_] := N[(t$95$s * If[LessEqual[k$95$m, 1.55], N[(2.0 / N[Power[N[(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[(2.0 * N[(N[Cos[k$95$m], $MachinePrecision] / N[(N[(t$95$m * N[Power[k$95$m, 2.0], $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(N[Cos[N[(k$95$m * 2.0), $MachinePrecision]], $MachinePrecision] * -0.5), $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 1.55:\\
\;\;\;\;\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(2 \cdot \frac{\cos k\_m}{\left(t\_m \cdot {k\_m}^{2}\right) \cdot \left(0.5 + \cos \left(k\_m \cdot 2\right) \cdot -0.5\right)}\right)\\


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

    1. Initial program 36.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.55000000000000004 < k

    1. Initial program 28.8%

      \[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) - 1\right)} \]
    2. Simplified47.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 74.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(2 \cdot \frac{\cos k}{\left({k}^{2} \cdot t\right) \cdot \color{blue}{\left(0.5 + \left(-\cos \left(k \cdot 2\right) \cdot 0.5\right)\right)}}\right) \cdot \left(\ell \cdot \ell\right) \]
      5. distribute-rgt-neg-in74.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 1.55:\\ \;\;\;\;\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(2 \cdot \frac{\cos k}{\left(t \cdot {k}^{2}\right) \cdot \left(0.5 + \cos \left(k \cdot 2\right) \cdot -0.5\right)}\right)\\ \end{array} \]
  5. Add Preprocessing

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

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


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

    1. Initial program 36.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0038999999999999998 < k

    1. Initial program 28.8%

      \[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) - 1\right)} \]
    2. Simplified47.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 74.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(2 \cdot \frac{\cos k}{\left({k}^{2} \cdot t\right) \cdot \color{blue}{\left(0.5 + \left(-\cos \left(k \cdot 2\right) \cdot 0.5\right)\right)}}\right) \cdot \left(\ell \cdot \ell\right) \]
      5. distribute-rgt-neg-in74.2%

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

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

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

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

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

Alternative 5: 76.6% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 76.6% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 62.9% 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{1}{\frac{t\_m}{2 \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) (/ 1.0 (/ t_m (* 2.0 (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) * (1.0 / (t_m / (2.0 * 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) * (1.0d0 / (t_m / (2.0d0 * (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) * (1.0 / (t_m / (2.0 * 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) * (1.0 / (t_m / (2.0 * 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(1.0 / Float64(t_m / Float64(2.0 * (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) * (1.0 / (t_m / (2.0 * (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[(1.0 / N[(t$95$m / N[(2.0 * N[Power[k$95$m, -4.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 \left(\left(\ell \cdot \ell\right) \cdot \frac{1}{\frac{t\_m}{2 \cdot {k\_m}^{-4}}}\right)
\end{array}
Derivation
  1. Initial program 34.9%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 62.9% 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 \cdot {k\_m}^{-4}}{t\_m}\right) \end{array} \]
k_m = (fabs.f64 k)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k_m)
 :precision binary64
 (* t_s (* (* 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(Float64(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 * ((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[(N[(2.0 * 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(\left(\ell \cdot \ell\right) \cdot \frac{2 \cdot {k\_m}^{-4}}{t\_m}\right)
\end{array}
Derivation
  1. Initial program 34.9%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 63.1% 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 34.9%

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

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

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

Reproduce

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