Toniolo and Linder, Equation (10-)

Percentage Accurate: 35.0% → 90.7%
Time: 22.8s
Alternatives: 6
Speedup: 2.0×

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 6 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.0% 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: 90.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{2}{{\left(\frac{k}{\ell}\right)}^{2} \cdot \frac{{\sin k}^{2}}{\frac{\cos k}{t}}} \end{array} \]
(FPCore (t l k)
 :precision binary64
 (/ 2.0 (* (pow (/ k l) 2.0) (/ (pow (sin k) 2.0) (/ (cos k) t)))))
double code(double t, double l, double k) {
	return 2.0 / (pow((k / l), 2.0) * (pow(sin(k), 2.0) / (cos(k) / t)));
}
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 / (((k / l) ** 2.0d0) * ((sin(k) ** 2.0d0) / (cos(k) / t)))
end function
public static double code(double t, double l, double k) {
	return 2.0 / (Math.pow((k / l), 2.0) * (Math.pow(Math.sin(k), 2.0) / (Math.cos(k) / t)));
}
def code(t, l, k):
	return 2.0 / (math.pow((k / l), 2.0) * (math.pow(math.sin(k), 2.0) / (math.cos(k) / t)))
function code(t, l, k)
	return Float64(2.0 / Float64((Float64(k / l) ^ 2.0) * Float64((sin(k) ^ 2.0) / Float64(cos(k) / t))))
end
function tmp = code(t, l, k)
	tmp = 2.0 / (((k / l) ^ 2.0) * ((sin(k) ^ 2.0) / (cos(k) / t)));
end
code[t_, l_, k_] := N[(2.0 / N[(N[Power[N[(k / l), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Power[N[Sin[k], $MachinePrecision], 2.0], $MachinePrecision] / N[(N[Cos[k], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{2}{{\left(\frac{k}{\ell}\right)}^{2} \cdot \frac{{\sin k}^{2}}{\frac{\cos k}{t}}}
\end{array}
Derivation
  1. Initial program 32.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 80.6% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := {\left(k \cdot \frac{1}{\ell}\right)}^{2}\\ \mathbf{if}\;k \leq 2.2 \cdot 10^{-5}:\\ \;\;\;\;\frac{2}{t_1 \cdot \frac{t \cdot {k}^{2}}{\cos k}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{t_1 \cdot \frac{t \cdot \left(0.5 - \frac{\cos \left(2 \cdot k\right)}{2}\right)}{\cos k}}\\ \end{array} \end{array} \]
(FPCore (t l k)
 :precision binary64
 (let* ((t_1 (pow (* k (/ 1.0 l)) 2.0)))
   (if (<= k 2.2e-5)
     (/ 2.0 (* t_1 (/ (* t (pow k 2.0)) (cos k))))
     (/ 2.0 (* t_1 (/ (* t (- 0.5 (/ (cos (* 2.0 k)) 2.0))) (cos k)))))))
double code(double t, double l, double k) {
	double t_1 = pow((k * (1.0 / l)), 2.0);
	double tmp;
	if (k <= 2.2e-5) {
		tmp = 2.0 / (t_1 * ((t * pow(k, 2.0)) / cos(k)));
	} else {
		tmp = 2.0 / (t_1 * ((t * (0.5 - (cos((2.0 * k)) / 2.0))) / cos(k)));
	}
	return tmp;
}
real(8) function code(t, l, k)
    real(8), intent (in) :: t
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (k * (1.0d0 / l)) ** 2.0d0
    if (k <= 2.2d-5) then
        tmp = 2.0d0 / (t_1 * ((t * (k ** 2.0d0)) / cos(k)))
    else
        tmp = 2.0d0 / (t_1 * ((t * (0.5d0 - (cos((2.0d0 * k)) / 2.0d0))) / cos(k)))
    end if
    code = tmp
end function
public static double code(double t, double l, double k) {
	double t_1 = Math.pow((k * (1.0 / l)), 2.0);
	double tmp;
	if (k <= 2.2e-5) {
		tmp = 2.0 / (t_1 * ((t * Math.pow(k, 2.0)) / Math.cos(k)));
	} else {
		tmp = 2.0 / (t_1 * ((t * (0.5 - (Math.cos((2.0 * k)) / 2.0))) / Math.cos(k)));
	}
	return tmp;
}
def code(t, l, k):
	t_1 = math.pow((k * (1.0 / l)), 2.0)
	tmp = 0
	if k <= 2.2e-5:
		tmp = 2.0 / (t_1 * ((t * math.pow(k, 2.0)) / math.cos(k)))
	else:
		tmp = 2.0 / (t_1 * ((t * (0.5 - (math.cos((2.0 * k)) / 2.0))) / math.cos(k)))
	return tmp
function code(t, l, k)
	t_1 = Float64(k * Float64(1.0 / l)) ^ 2.0
	tmp = 0.0
	if (k <= 2.2e-5)
		tmp = Float64(2.0 / Float64(t_1 * Float64(Float64(t * (k ^ 2.0)) / cos(k))));
	else
		tmp = Float64(2.0 / Float64(t_1 * Float64(Float64(t * Float64(0.5 - Float64(cos(Float64(2.0 * k)) / 2.0))) / cos(k))));
	end
	return tmp
end
function tmp_2 = code(t, l, k)
	t_1 = (k * (1.0 / l)) ^ 2.0;
	tmp = 0.0;
	if (k <= 2.2e-5)
		tmp = 2.0 / (t_1 * ((t * (k ^ 2.0)) / cos(k)));
	else
		tmp = 2.0 / (t_1 * ((t * (0.5 - (cos((2.0 * k)) / 2.0))) / cos(k)));
	end
	tmp_2 = tmp;
end
code[t_, l_, k_] := Block[{t$95$1 = N[Power[N[(k * N[(1.0 / l), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[k, 2.2e-5], N[(2.0 / N[(t$95$1 * N[(N[(t * N[Power[k, 2.0], $MachinePrecision]), $MachinePrecision] / N[Cos[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(t$95$1 * N[(N[(t * N[(0.5 - N[(N[Cos[N[(2.0 * k), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := {\left(k \cdot \frac{1}{\ell}\right)}^{2}\\
\mathbf{if}\;k \leq 2.2 \cdot 10^{-5}:\\
\;\;\;\;\frac{2}{t_1 \cdot \frac{t \cdot {k}^{2}}{\cos k}}\\

\mathbf{else}:\\
\;\;\;\;\frac{2}{t_1 \cdot \frac{t \cdot \left(0.5 - \frac{\cos \left(2 \cdot k\right)}{2}\right)}{\cos k}}\\


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

    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. Taylor expanded in t around 0 72.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.1999999999999999e-5 < k

    1. Initial program 25.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. Taylor expanded in t around 0 66.3%

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

        \[\leadsto \frac{2}{\color{blue}{\frac{{k}^{2}}{{\ell}^{2}} \cdot \frac{t \cdot {\sin k}^{2}}{\cos k}}} \]
    4. Simplified65.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 2.2 \cdot 10^{-5}:\\ \;\;\;\;\frac{2}{{\left(k \cdot \frac{1}{\ell}\right)}^{2} \cdot \frac{t \cdot {k}^{2}}{\cos k}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{{\left(k \cdot \frac{1}{\ell}\right)}^{2} \cdot \frac{t \cdot \left(0.5 - \frac{\cos \left(2 \cdot k\right)}{2}\right)}{\cos k}}\\ \end{array} \]

Alternative 3: 70.8% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \frac{2}{{\left(k \cdot \frac{1}{\ell}\right)}^{2} \cdot \frac{t \cdot {k}^{2}}{\cos k}} \end{array} \]
(FPCore (t l k)
 :precision binary64
 (/ 2.0 (* (pow (* k (/ 1.0 l)) 2.0) (/ (* t (pow k 2.0)) (cos k)))))
double code(double t, double l, double k) {
	return 2.0 / (pow((k * (1.0 / l)), 2.0) * ((t * pow(k, 2.0)) / cos(k)));
}
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 / (((k * (1.0d0 / l)) ** 2.0d0) * ((t * (k ** 2.0d0)) / cos(k)))
end function
public static double code(double t, double l, double k) {
	return 2.0 / (Math.pow((k * (1.0 / l)), 2.0) * ((t * Math.pow(k, 2.0)) / Math.cos(k)));
}
def code(t, l, k):
	return 2.0 / (math.pow((k * (1.0 / l)), 2.0) * ((t * math.pow(k, 2.0)) / math.cos(k)))
function code(t, l, k)
	return Float64(2.0 / Float64((Float64(k * Float64(1.0 / l)) ^ 2.0) * Float64(Float64(t * (k ^ 2.0)) / cos(k))))
end
function tmp = code(t, l, k)
	tmp = 2.0 / (((k * (1.0 / l)) ^ 2.0) * ((t * (k ^ 2.0)) / cos(k)));
end
code[t_, l_, k_] := N[(2.0 / N[(N[Power[N[(k * N[(1.0 / l), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(t * N[Power[k, 2.0], $MachinePrecision]), $MachinePrecision] / N[Cos[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{2}{{\left(k \cdot \frac{1}{\ell}\right)}^{2} \cdot \frac{t \cdot {k}^{2}}{\cos k}}
\end{array}
Derivation
  1. Initial program 32.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 66.9% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 1.35 \cdot 10^{+91}:\\ \;\;\;\;\frac{2}{t} \cdot {\left(\ell \cdot \sqrt{{k}^{-4}}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{\frac{t}{{\ell}^{2}} \cdot \frac{{k}^{4}}{\cos k}}\\ \end{array} \end{array} \]
(FPCore (t l k)
 :precision binary64
 (if (<= l 1.35e+91)
   (* (/ 2.0 t) (pow (* l (sqrt (pow k -4.0))) 2.0))
   (/ 2.0 (* (/ t (pow l 2.0)) (/ (pow k 4.0) (cos k))))))
double code(double t, double l, double k) {
	double tmp;
	if (l <= 1.35e+91) {
		tmp = (2.0 / t) * pow((l * sqrt(pow(k, -4.0))), 2.0);
	} else {
		tmp = 2.0 / ((t / pow(l, 2.0)) * (pow(k, 4.0) / cos(k)));
	}
	return tmp;
}
real(8) function code(t, l, k)
    real(8), intent (in) :: t
    real(8), intent (in) :: l
    real(8), intent (in) :: k
    real(8) :: tmp
    if (l <= 1.35d+91) then
        tmp = (2.0d0 / t) * ((l * sqrt((k ** (-4.0d0)))) ** 2.0d0)
    else
        tmp = 2.0d0 / ((t / (l ** 2.0d0)) * ((k ** 4.0d0) / cos(k)))
    end if
    code = tmp
end function
public static double code(double t, double l, double k) {
	double tmp;
	if (l <= 1.35e+91) {
		tmp = (2.0 / t) * Math.pow((l * Math.sqrt(Math.pow(k, -4.0))), 2.0);
	} else {
		tmp = 2.0 / ((t / Math.pow(l, 2.0)) * (Math.pow(k, 4.0) / Math.cos(k)));
	}
	return tmp;
}
def code(t, l, k):
	tmp = 0
	if l <= 1.35e+91:
		tmp = (2.0 / t) * math.pow((l * math.sqrt(math.pow(k, -4.0))), 2.0)
	else:
		tmp = 2.0 / ((t / math.pow(l, 2.0)) * (math.pow(k, 4.0) / math.cos(k)))
	return tmp
function code(t, l, k)
	tmp = 0.0
	if (l <= 1.35e+91)
		tmp = Float64(Float64(2.0 / t) * (Float64(l * sqrt((k ^ -4.0))) ^ 2.0));
	else
		tmp = Float64(2.0 / Float64(Float64(t / (l ^ 2.0)) * Float64((k ^ 4.0) / cos(k))));
	end
	return tmp
end
function tmp_2 = code(t, l, k)
	tmp = 0.0;
	if (l <= 1.35e+91)
		tmp = (2.0 / t) * ((l * sqrt((k ^ -4.0))) ^ 2.0);
	else
		tmp = 2.0 / ((t / (l ^ 2.0)) * ((k ^ 4.0) / cos(k)));
	end
	tmp_2 = tmp;
end
code[t_, l_, k_] := If[LessEqual[l, 1.35e+91], N[(N[(2.0 / t), $MachinePrecision] * N[Power[N[(l * N[Sqrt[N[Power[k, -4.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(t / N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision] * N[(N[Power[k, 4.0], $MachinePrecision] / N[Cos[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.35 \cdot 10^{+91}:\\
\;\;\;\;\frac{2}{t} \cdot {\left(\ell \cdot \sqrt{{k}^{-4}}\right)}^{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{t}{{\ell}^{2}} \cdot \frac{{k}^{4}}{\cos k}}\\


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

    1. Initial program 33.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. Step-by-step derivation
      1. associate-/r*33.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.35e91 < l

    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. Taylor expanded in t around 0 72.0%

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

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

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

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

      \[\leadsto \frac{2}{\frac{{k}^{2} \cdot t}{{\ell}^{2}} \cdot \frac{\color{blue}{{k}^{2}}}{\cos k}} \]
    6. Taylor expanded in k around inf 58.1%

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

        \[\leadsto \frac{2}{\frac{\color{blue}{t \cdot {k}^{4}}}{{\ell}^{2} \cdot \cos k}} \]
      2. times-frac62.1%

        \[\leadsto \frac{2}{\color{blue}{\frac{t}{{\ell}^{2}} \cdot \frac{{k}^{4}}{\cos k}}} \]
    8. Simplified62.1%

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

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

Alternative 5: 66.2% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \frac{2}{t} \cdot {\left(\ell \cdot \sqrt{{k}^{-4}}\right)}^{2} \end{array} \]
(FPCore (t l k)
 :precision binary64
 (* (/ 2.0 t) (pow (* l (sqrt (pow k -4.0))) 2.0)))
double code(double t, double l, double k) {
	return (2.0 / t) * pow((l * sqrt(pow(k, -4.0))), 2.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) * ((l * sqrt((k ** (-4.0d0)))) ** 2.0d0)
end function
public static double code(double t, double l, double k) {
	return (2.0 / t) * Math.pow((l * Math.sqrt(Math.pow(k, -4.0))), 2.0);
}
def code(t, l, k):
	return (2.0 / t) * math.pow((l * math.sqrt(math.pow(k, -4.0))), 2.0)
function code(t, l, k)
	return Float64(Float64(2.0 / t) * (Float64(l * sqrt((k ^ -4.0))) ^ 2.0))
end
function tmp = code(t, l, k)
	tmp = (2.0 / t) * ((l * sqrt((k ^ -4.0))) ^ 2.0);
end
code[t_, l_, k_] := N[(N[(2.0 / t), $MachinePrecision] * N[Power[N[(l * N[Sqrt[N[Power[k, -4.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) - 1\right)} \]
  2. Step-by-step derivation
    1. associate-/r*32.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 60.3% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \frac{2}{t} \cdot \frac{{\ell}^{2}}{{k}^{4}} \end{array} \]
(FPCore (t l k) :precision binary64 (* (/ 2.0 t) (/ (pow l 2.0) (pow k 4.0))))
double code(double t, double l, double k) {
	return (2.0 / t) * (pow(l, 2.0) / pow(k, 4.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) * ((l ** 2.0d0) / (k ** 4.0d0))
end function
public static double code(double t, double l, double k) {
	return (2.0 / t) * (Math.pow(l, 2.0) / Math.pow(k, 4.0));
}
def code(t, l, k):
	return (2.0 / t) * (math.pow(l, 2.0) / math.pow(k, 4.0))
function code(t, l, k)
	return Float64(Float64(2.0 / t) * Float64((l ^ 2.0) / (k ^ 4.0)))
end
function tmp = code(t, l, k)
	tmp = (2.0 / t) * ((l ^ 2.0) / (k ^ 4.0));
end
code[t_, l_, k_] := N[(N[(2.0 / t), $MachinePrecision] * N[(N[Power[l, 2.0], $MachinePrecision] / N[Power[k, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{2}{t} \cdot \frac{{\ell}^{2}}{{k}^{4}}
\end{array}
Derivation
  1. Initial program 32.2%

    \[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) - 1\right)} \]
  2. Step-by-step derivation
    1. associate-/r*32.2%

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{2}{t} \cdot \frac{{\ell}^{2}}{{k}^{4}}} \]
  7. Final simplification58.8%

    \[\leadsto \frac{2}{t} \cdot \frac{{\ell}^{2}}{{k}^{4}} \]

Reproduce

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