Toniolo and Linder, Equation (10-)

Percentage Accurate: 34.8% → 93.0%
Time: 21.6s
Alternatives: 9
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 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: 34.8% 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: 93.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -1 \cdot 10^{-311}:\\ \;\;\;\;\frac{2 \cdot \frac{\cos k}{{\left(\frac{k}{\ell}\right)}^{2}}}{t \cdot {\sin k}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{\left(\sin k \cdot \tan k\right) \cdot {\left(\frac{k}{\ell} \cdot \sqrt{t}\right)}^{2}}\\ \end{array} \end{array} \]
(FPCore (t l k)
 :precision binary64
 (if (<= t -1e-311)
   (/ (* 2.0 (/ (cos k) (pow (/ k l) 2.0))) (* t (pow (sin k) 2.0)))
   (/ 2.0 (* (* (sin k) (tan k)) (pow (* (/ k l) (sqrt t)) 2.0)))))
double code(double t, double l, double k) {
	double tmp;
	if (t <= -1e-311) {
		tmp = (2.0 * (cos(k) / pow((k / l), 2.0))) / (t * pow(sin(k), 2.0));
	} else {
		tmp = 2.0 / ((sin(k) * tan(k)) * pow(((k / l) * sqrt(t)), 2.0));
	}
	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 (t <= (-1d-311)) then
        tmp = (2.0d0 * (cos(k) / ((k / l) ** 2.0d0))) / (t * (sin(k) ** 2.0d0))
    else
        tmp = 2.0d0 / ((sin(k) * tan(k)) * (((k / l) * sqrt(t)) ** 2.0d0))
    end if
    code = tmp
end function
public static double code(double t, double l, double k) {
	double tmp;
	if (t <= -1e-311) {
		tmp = (2.0 * (Math.cos(k) / Math.pow((k / l), 2.0))) / (t * Math.pow(Math.sin(k), 2.0));
	} else {
		tmp = 2.0 / ((Math.sin(k) * Math.tan(k)) * Math.pow(((k / l) * Math.sqrt(t)), 2.0));
	}
	return tmp;
}
def code(t, l, k):
	tmp = 0
	if t <= -1e-311:
		tmp = (2.0 * (math.cos(k) / math.pow((k / l), 2.0))) / (t * math.pow(math.sin(k), 2.0))
	else:
		tmp = 2.0 / ((math.sin(k) * math.tan(k)) * math.pow(((k / l) * math.sqrt(t)), 2.0))
	return tmp
function code(t, l, k)
	tmp = 0.0
	if (t <= -1e-311)
		tmp = Float64(Float64(2.0 * Float64(cos(k) / (Float64(k / l) ^ 2.0))) / Float64(t * (sin(k) ^ 2.0)));
	else
		tmp = Float64(2.0 / Float64(Float64(sin(k) * tan(k)) * (Float64(Float64(k / l) * sqrt(t)) ^ 2.0)));
	end
	return tmp
end
function tmp_2 = code(t, l, k)
	tmp = 0.0;
	if (t <= -1e-311)
		tmp = (2.0 * (cos(k) / ((k / l) ^ 2.0))) / (t * (sin(k) ^ 2.0));
	else
		tmp = 2.0 / ((sin(k) * tan(k)) * (((k / l) * sqrt(t)) ^ 2.0));
	end
	tmp_2 = tmp;
end
code[t_, l_, k_] := If[LessEqual[t, -1e-311], N[(N[(2.0 * N[(N[Cos[k], $MachinePrecision] / N[Power[N[(k / l), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t * N[Power[N[Sin[k], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(N[Sin[k], $MachinePrecision] * N[Tan[k], $MachinePrecision]), $MachinePrecision] * N[Power[N[(N[(k / l), $MachinePrecision] * N[Sqrt[t], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -9.99999999999948e-312

    1. Initial program 31.5%

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{2}{{\left(\left(\sqrt{\tan k \cdot \sin k} \cdot \frac{k}{t}\right) \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def0.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{2}{{\left(\left(\sqrt{\tan k \cdot \sin k} \cdot \frac{k}{t}\right) \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}\right)\right)} \]
      2. expm1-log1p0.0%

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{2}{{\left(\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot \frac{{t}^{1.5}}{\ell}\right)\right)}^{2}}\right)\right)} \]
      2. expm1-udef0.0%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{2}{{\left(\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot \frac{{t}^{1.5}}{\ell}\right)\right)}^{2}}\right)} - 1} \]
      3. pow-prod-down0.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\color{blue}{{\left(\sqrt{\sin k \cdot \tan k}\right)}^{2} \cdot {\left(\frac{k}{t} \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}}\right)} - 1 \]
      4. pow20.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\color{blue}{\left(\sqrt{\sin k \cdot \tan k} \cdot \sqrt{\sin k \cdot \tan k}\right)} \cdot {\left(\frac{k}{t} \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}\right)} - 1 \]
      5. add-sqr-sqrt0.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\color{blue}{\left(\sin k \cdot \tan k\right)} \cdot {\left(\frac{k}{t} \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}\right)} - 1 \]
    7. Applied egg-rr0.0%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{2}{\left(\sin k \cdot \tan k\right) \cdot {\left(\frac{k}{t} \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def0.0%

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

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

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

        \[\leadsto \frac{2}{\left(\sin k \cdot \tan k\right) \cdot {\color{blue}{\left(\frac{k}{\frac{t \cdot \ell}{{t}^{1.5}}}\right)}}^{2}} \]
      5. associate-/r/0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999948e-312 < t

    1. Initial program 30.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. Simplified38.9%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{2}{{\left(\left(\sqrt{\tan k \cdot \sin k} \cdot \frac{k}{t}\right) \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def46.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{2}{{\left(\left(\sqrt{\tan k \cdot \sin k} \cdot \frac{k}{t}\right) \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}\right)\right)} \]
      2. expm1-log1p46.4%

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

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

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

      \[\leadsto \color{blue}{\frac{2}{{\left(\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot \frac{{t}^{1.5}}{\ell}\right)\right)}^{2}}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u46.1%

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{2}{{\left(\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot \frac{{t}^{1.5}}{\ell}\right)\right)}^{2}}\right)} - 1} \]
      3. pow-prod-down37.6%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\color{blue}{{\left(\sqrt{\sin k \cdot \tan k}\right)}^{2} \cdot {\left(\frac{k}{t} \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}}\right)} - 1 \]
      4. pow237.6%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\color{blue}{\left(\sqrt{\sin k \cdot \tan k} \cdot \sqrt{\sin k \cdot \tan k}\right)} \cdot {\left(\frac{k}{t} \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}\right)} - 1 \]
      5. add-sqr-sqrt56.3%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{2}{\left(\sin k \cdot \tan k\right) \cdot {\left(\frac{k}{t} \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def67.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{2}{\left(\sin k \cdot \tan k\right) \cdot {\left(\frac{k}{t} \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}\right)\right)} \]
      2. expm1-log1p69.5%

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

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

        \[\leadsto \frac{2}{\left(\sin k \cdot \tan k\right) \cdot {\color{blue}{\left(\frac{k}{\frac{t \cdot \ell}{{t}^{1.5}}}\right)}}^{2}} \]
      5. associate-/r/62.2%

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

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

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

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

Alternative 2: 92.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \sin k \cdot \tan k\\ \mathbf{if}\;t \leq 1.2 \cdot 10^{-305}:\\ \;\;\;\;\frac{2}{{\left(\frac{k}{\ell}\right)}^{2} \cdot \left(t \cdot t_1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{t_1 \cdot {\left(\frac{k}{\ell} \cdot \sqrt{t}\right)}^{2}}\\ \end{array} \end{array} \]
(FPCore (t l k)
 :precision binary64
 (let* ((t_1 (* (sin k) (tan k))))
   (if (<= t 1.2e-305)
     (/ 2.0 (* (pow (/ k l) 2.0) (* t t_1)))
     (/ 2.0 (* t_1 (pow (* (/ k l) (sqrt t)) 2.0))))))
double code(double t, double l, double k) {
	double t_1 = sin(k) * tan(k);
	double tmp;
	if (t <= 1.2e-305) {
		tmp = 2.0 / (pow((k / l), 2.0) * (t * t_1));
	} else {
		tmp = 2.0 / (t_1 * pow(((k / l) * sqrt(t)), 2.0));
	}
	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 = sin(k) * tan(k)
    if (t <= 1.2d-305) then
        tmp = 2.0d0 / (((k / l) ** 2.0d0) * (t * t_1))
    else
        tmp = 2.0d0 / (t_1 * (((k / l) * sqrt(t)) ** 2.0d0))
    end if
    code = tmp
end function
public static double code(double t, double l, double k) {
	double t_1 = Math.sin(k) * Math.tan(k);
	double tmp;
	if (t <= 1.2e-305) {
		tmp = 2.0 / (Math.pow((k / l), 2.0) * (t * t_1));
	} else {
		tmp = 2.0 / (t_1 * Math.pow(((k / l) * Math.sqrt(t)), 2.0));
	}
	return tmp;
}
def code(t, l, k):
	t_1 = math.sin(k) * math.tan(k)
	tmp = 0
	if t <= 1.2e-305:
		tmp = 2.0 / (math.pow((k / l), 2.0) * (t * t_1))
	else:
		tmp = 2.0 / (t_1 * math.pow(((k / l) * math.sqrt(t)), 2.0))
	return tmp
function code(t, l, k)
	t_1 = Float64(sin(k) * tan(k))
	tmp = 0.0
	if (t <= 1.2e-305)
		tmp = Float64(2.0 / Float64((Float64(k / l) ^ 2.0) * Float64(t * t_1)));
	else
		tmp = Float64(2.0 / Float64(t_1 * (Float64(Float64(k / l) * sqrt(t)) ^ 2.0)));
	end
	return tmp
end
function tmp_2 = code(t, l, k)
	t_1 = sin(k) * tan(k);
	tmp = 0.0;
	if (t <= 1.2e-305)
		tmp = 2.0 / (((k / l) ^ 2.0) * (t * t_1));
	else
		tmp = 2.0 / (t_1 * (((k / l) * sqrt(t)) ^ 2.0));
	end
	tmp_2 = tmp;
end
code[t_, l_, k_] := Block[{t$95$1 = N[(N[Sin[k], $MachinePrecision] * N[Tan[k], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, 1.2e-305], N[(2.0 / N[(N[Power[N[(k / l), $MachinePrecision], 2.0], $MachinePrecision] * N[(t * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(t$95$1 * N[Power[N[(N[(k / l), $MachinePrecision] * N[Sqrt[t], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \sin k \cdot \tan k\\
\mathbf{if}\;t \leq 1.2 \cdot 10^{-305}:\\
\;\;\;\;\frac{2}{{\left(\frac{k}{\ell}\right)}^{2} \cdot \left(t \cdot t_1\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 1.2000000000000001e-305

    1. Initial program 31.3%

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{2}{{\left(\left(\sqrt{\tan k \cdot \sin k} \cdot \frac{k}{t}\right) \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def0.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{2}{{\left(\left(\sqrt{\tan k \cdot \sin k} \cdot \frac{k}{t}\right) \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}\right)\right)} \]
      2. expm1-log1p0.0%

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\color{blue}{{\left(\sqrt{\sin k \cdot \tan k}\right)}^{2} \cdot {\left(\frac{k}{\ell} \cdot \sqrt{t}\right)}^{2}}}\right)} - 1 \]
      4. pow20.6%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\color{blue}{\left(\sqrt{\sin k \cdot \tan k} \cdot \sqrt{\sin k \cdot \tan k}\right)} \cdot {\left(\frac{k}{\ell} \cdot \sqrt{t}\right)}^{2}}\right)} - 1 \]
      5. add-sqr-sqrt0.6%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\color{blue}{\left(\sin k \cdot \tan k\right)} \cdot {\left(\frac{k}{\ell} \cdot \sqrt{t}\right)}^{2}}\right)} - 1 \]
      6. *-commutative0.6%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\left(\sin k \cdot \tan k\right) \cdot {\color{blue}{\left(\sqrt{t} \cdot \frac{k}{\ell}\right)}}^{2}}\right)} - 1 \]
      7. unpow-prod-down0.6%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\left(\sin k \cdot \tan k\right) \cdot \color{blue}{\left({\left(\sqrt{t}\right)}^{2} \cdot {\left(\frac{k}{\ell}\right)}^{2}\right)}}\right)} - 1 \]
      8. pow20.6%

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{2}{\left(\sin k \cdot \tan k\right) \cdot \left(t \cdot {\left(\frac{k}{\ell}\right)}^{2}\right)}\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def38.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{2}{\left(\sin k \cdot \tan k\right) \cdot \left(t \cdot {\left(\frac{k}{\ell}\right)}^{2}\right)}\right)\right)} \]
      2. expm1-log1p87.5%

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

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

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

    if 1.2000000000000001e-305 < t

    1. Initial program 30.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. Simplified39.2%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{2}{{\left(\left(\sqrt{\tan k \cdot \sin k} \cdot \frac{k}{t}\right) \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def46.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{2}{{\left(\left(\sqrt{\tan k \cdot \sin k} \cdot \frac{k}{t}\right) \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}\right)\right)} \]
      2. expm1-log1p46.8%

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

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

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

      \[\leadsto \color{blue}{\frac{2}{{\left(\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot \frac{{t}^{1.5}}{\ell}\right)\right)}^{2}}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u46.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{2}{{\left(\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot \frac{{t}^{1.5}}{\ell}\right)\right)}^{2}}\right)\right)} \]
      2. expm1-udef37.9%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{2}{{\left(\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{t} \cdot \frac{{t}^{1.5}}{\ell}\right)\right)}^{2}}\right)} - 1} \]
      3. pow-prod-down37.9%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\color{blue}{{\left(\sqrt{\sin k \cdot \tan k}\right)}^{2} \cdot {\left(\frac{k}{t} \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}}\right)} - 1 \]
      4. pow237.9%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\color{blue}{\left(\sqrt{\sin k \cdot \tan k} \cdot \sqrt{\sin k \cdot \tan k}\right)} \cdot {\left(\frac{k}{t} \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}\right)} - 1 \]
      5. add-sqr-sqrt56.8%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{2}{\left(\sin k \cdot \tan k\right) \cdot {\left(\frac{k}{t} \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def68.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{2}{\left(\sin k \cdot \tan k\right) \cdot {\left(\frac{k}{t} \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}\right)\right)} \]
      2. expm1-log1p70.1%

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

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

        \[\leadsto \frac{2}{\left(\sin k \cdot \tan k\right) \cdot {\color{blue}{\left(\frac{k}{\frac{t \cdot \ell}{{t}^{1.5}}}\right)}}^{2}} \]
      5. associate-/r/62.7%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq 1.2 \cdot 10^{-305}:\\ \;\;\;\;\frac{2}{{\left(\frac{k}{\ell}\right)}^{2} \cdot \left(t \cdot \left(\sin k \cdot \tan k\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{\left(\sin k \cdot \tan k\right) \cdot {\left(\frac{k}{\ell} \cdot \sqrt{t}\right)}^{2}}\\ \end{array} \]

Alternative 3: 81.0% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 10^{-139}:\\ \;\;\;\;\frac{2 \cdot {\left(\ell \cdot {k}^{-2}\right)}^{2}}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{\left(\sin k \cdot \tan k\right) \cdot \left(t \cdot {\left(\frac{k}{\ell}\right)}^{2}\right)}\\ \end{array} \end{array} \]
(FPCore (t l k)
 :precision binary64
 (if (<= l 1e-139)
   (/ (* 2.0 (pow (* l (pow k -2.0)) 2.0)) t)
   (/ 2.0 (* (* (sin k) (tan k)) (* t (pow (/ k l) 2.0))))))
double code(double t, double l, double k) {
	double tmp;
	if (l <= 1e-139) {
		tmp = (2.0 * pow((l * pow(k, -2.0)), 2.0)) / t;
	} else {
		tmp = 2.0 / ((sin(k) * tan(k)) * (t * pow((k / l), 2.0)));
	}
	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 <= 1d-139) then
        tmp = (2.0d0 * ((l * (k ** (-2.0d0))) ** 2.0d0)) / t
    else
        tmp = 2.0d0 / ((sin(k) * tan(k)) * (t * ((k / l) ** 2.0d0)))
    end if
    code = tmp
end function
public static double code(double t, double l, double k) {
	double tmp;
	if (l <= 1e-139) {
		tmp = (2.0 * Math.pow((l * Math.pow(k, -2.0)), 2.0)) / t;
	} else {
		tmp = 2.0 / ((Math.sin(k) * Math.tan(k)) * (t * Math.pow((k / l), 2.0)));
	}
	return tmp;
}
def code(t, l, k):
	tmp = 0
	if l <= 1e-139:
		tmp = (2.0 * math.pow((l * math.pow(k, -2.0)), 2.0)) / t
	else:
		tmp = 2.0 / ((math.sin(k) * math.tan(k)) * (t * math.pow((k / l), 2.0)))
	return tmp
function code(t, l, k)
	tmp = 0.0
	if (l <= 1e-139)
		tmp = Float64(Float64(2.0 * (Float64(l * (k ^ -2.0)) ^ 2.0)) / t);
	else
		tmp = Float64(2.0 / Float64(Float64(sin(k) * tan(k)) * Float64(t * (Float64(k / l) ^ 2.0))));
	end
	return tmp
end
function tmp_2 = code(t, l, k)
	tmp = 0.0;
	if (l <= 1e-139)
		tmp = (2.0 * ((l * (k ^ -2.0)) ^ 2.0)) / t;
	else
		tmp = 2.0 / ((sin(k) * tan(k)) * (t * ((k / l) ^ 2.0)));
	end
	tmp_2 = tmp;
end
code[t_, l_, k_] := If[LessEqual[l, 1e-139], N[(N[(2.0 * N[Power[N[(l * N[Power[k, -2.0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision], N[(2.0 / N[(N[(N[Sin[k], $MachinePrecision] * N[Tan[k], $MachinePrecision]), $MachinePrecision] * N[(t * N[Power[N[(k / l), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 1.00000000000000003e-139

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.00000000000000003e-139 < l

    1. Initial program 29.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. Simplified36.1%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{2}{{\left(\left(\sqrt{\tan k \cdot \sin k} \cdot \frac{k}{t}\right) \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def20.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{2}{{\left(\left(\sqrt{\tan k \cdot \sin k} \cdot \frac{k}{t}\right) \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}\right)\right)} \]
      2. expm1-log1p20.9%

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{2}{{\left(\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{\ell} \cdot \sqrt{t}\right)\right)}^{2}}\right)\right)} \]
      2. expm1-udef25.4%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{2}{{\left(\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{\ell} \cdot \sqrt{t}\right)\right)}^{2}}\right)} - 1} \]
      3. unpow-prod-down25.4%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\color{blue}{{\left(\sqrt{\sin k \cdot \tan k}\right)}^{2} \cdot {\left(\frac{k}{\ell} \cdot \sqrt{t}\right)}^{2}}}\right)} - 1 \]
      4. pow225.4%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\color{blue}{\left(\sqrt{\sin k \cdot \tan k} \cdot \sqrt{\sin k \cdot \tan k}\right)} \cdot {\left(\frac{k}{\ell} \cdot \sqrt{t}\right)}^{2}}\right)} - 1 \]
      5. add-sqr-sqrt30.2%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\color{blue}{\left(\sin k \cdot \tan k\right)} \cdot {\left(\frac{k}{\ell} \cdot \sqrt{t}\right)}^{2}}\right)} - 1 \]
      6. *-commutative30.2%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\left(\sin k \cdot \tan k\right) \cdot {\color{blue}{\left(\sqrt{t} \cdot \frac{k}{\ell}\right)}}^{2}}\right)} - 1 \]
      7. unpow-prod-down30.2%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\left(\sin k \cdot \tan k\right) \cdot \color{blue}{\left({\left(\sqrt{t}\right)}^{2} \cdot {\left(\frac{k}{\ell}\right)}^{2}\right)}}\right)} - 1 \]
      8. pow230.2%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\left(\sin k \cdot \tan k\right) \cdot \left(\color{blue}{\left(\sqrt{t} \cdot \sqrt{t}\right)} \cdot {\left(\frac{k}{\ell}\right)}^{2}\right)}\right)} - 1 \]
      9. add-sqr-sqrt40.8%

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

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{2}{\left(\sin k \cdot \tan k\right) \cdot \left(t \cdot {\left(\frac{k}{\ell}\right)}^{2}\right)}\right)\right)} \]
      2. expm1-log1p93.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 10^{-139}:\\ \;\;\;\;\frac{2 \cdot {\left(\ell \cdot {k}^{-2}\right)}^{2}}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{\left(\sin k \cdot \tan k\right) \cdot \left(t \cdot {\left(\frac{k}{\ell}\right)}^{2}\right)}\\ \end{array} \]

Alternative 4: 90.4% accurate, 1.3× speedup?

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

\\
\frac{2}{{\left(\frac{k}{\ell}\right)}^{2} \cdot \left(t \cdot \left(\sin k \cdot \tan k\right)\right)}
\end{array}
Derivation
  1. Initial program 30.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. Simplified39.6%

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

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{2}{{\left(\left(\sqrt{\tan k \cdot \sin k} \cdot \frac{k}{t}\right) \cdot \frac{{t}^{1.5}}{\ell}\right)}^{2}}\right)} - 1} \]
  4. Step-by-step derivation
    1. expm1-def21.6%

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

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

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

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

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

    \[\leadsto \frac{2}{{\left(\sqrt{\sin k \cdot \tan k} \cdot \color{blue}{\left(\frac{k}{\ell} \cdot \sqrt{t}\right)}\right)}^{2}} \]
  7. Step-by-step derivation
    1. expm1-log1p-u28.4%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{2}{{\left(\sqrt{\sin k \cdot \tan k} \cdot \left(\frac{k}{\ell} \cdot \sqrt{t}\right)\right)}^{2}}\right)} - 1} \]
    3. unpow-prod-down23.0%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\color{blue}{{\left(\sqrt{\sin k \cdot \tan k}\right)}^{2} \cdot {\left(\frac{k}{\ell} \cdot \sqrt{t}\right)}^{2}}}\right)} - 1 \]
    4. pow223.0%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\color{blue}{\left(\sqrt{\sin k \cdot \tan k} \cdot \sqrt{\sin k \cdot \tan k}\right)} \cdot {\left(\frac{k}{\ell} \cdot \sqrt{t}\right)}^{2}}\right)} - 1 \]
    5. add-sqr-sqrt32.3%

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

      \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\left(\sin k \cdot \tan k\right) \cdot {\color{blue}{\left(\sqrt{t} \cdot \frac{k}{\ell}\right)}}^{2}}\right)} - 1 \]
    7. unpow-prod-down31.7%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\left(\sin k \cdot \tan k\right) \cdot \color{blue}{\left({\left(\sqrt{t}\right)}^{2} \cdot {\left(\frac{k}{\ell}\right)}^{2}\right)}}\right)} - 1 \]
    8. pow231.7%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{2}{\left(\sin k \cdot \tan k\right) \cdot \left(\color{blue}{\left(\sqrt{t} \cdot \sqrt{t}\right)} \cdot {\left(\frac{k}{\ell}\right)}^{2}\right)}\right)} - 1 \]
    9. add-sqr-sqrt47.1%

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

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{2}{\left(\sin k \cdot \tan k\right) \cdot \left(t \cdot {\left(\frac{k}{\ell}\right)}^{2}\right)}\right)} - 1} \]
  9. Step-by-step derivation
    1. expm1-def58.3%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{2}{\left(\sin k \cdot \tan k\right) \cdot \left(t \cdot {\left(\frac{k}{\ell}\right)}^{2}\right)}\right)\right)} \]
    2. expm1-log1p88.6%

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

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

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

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

Alternative 5: 59.4% accurate, 2.0× speedup?

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

\\
2 \cdot \left({k}^{-4} \cdot \frac{{\ell}^{2}}{t}\right)
\end{array}
Derivation
  1. Initial program 30.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. Simplified39.6%

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

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

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

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

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

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

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

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

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

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

Alternative 6: 60.3% accurate, 2.0× speedup?

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

\\
2 \cdot \frac{{\ell}^{2} \cdot {k}^{-4}}{t}
\end{array}
Derivation
  1. Initial program 30.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. Simplified39.6%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 60.4% accurate, 2.0× speedup?

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

\\
2 \cdot \frac{{\ell}^{2}}{t \cdot {k}^{4}}
\end{array}
Derivation
  1. Initial program 30.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. Simplified39.6%

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

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

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

Alternative 8: 69.6% accurate, 2.0× speedup?

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

\\
\frac{2}{\frac{t}{{\left(\ell \cdot {k}^{-2}\right)}^{2}}}
\end{array}
Derivation
  1. Initial program 30.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. Simplified39.6%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 2 \cdot \color{blue}{\frac{{\ell}^{2} \cdot {k}^{-4}}{t}} \]
  10. Step-by-step derivation
    1. expm1-log1p-u41.6%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(2 \cdot \frac{{\ell}^{2} \cdot {k}^{-4}}{t}\right)\right)} \]
    2. expm1-udef40.3%

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

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{2 \cdot \left({\ell}^{2} \cdot {k}^{-4}\right)}{t}}\right)} - 1 \]
    4. add-sqr-sqrt40.3%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{2 \cdot \color{blue}{\left(\sqrt{{\ell}^{2} \cdot {k}^{-4}} \cdot \sqrt{{\ell}^{2} \cdot {k}^{-4}}\right)}}{t}\right)} - 1 \]
    5. pow240.3%

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

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

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

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

      \[\leadsto e^{\mathsf{log1p}\left(\frac{2 \cdot {\left(\color{blue}{\ell} \cdot \sqrt{{k}^{-4}}\right)}^{2}}{t}\right)} - 1 \]
    10. sqrt-pow143.4%

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

      \[\leadsto e^{\mathsf{log1p}\left(\frac{2 \cdot {\left(\ell \cdot {k}^{\color{blue}{-2}}\right)}^{2}}{t}\right)} - 1 \]
  11. Applied egg-rr43.4%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{2 \cdot {\left(\ell \cdot {k}^{-2}\right)}^{2}}{t}\right)} - 1} \]
  12. Step-by-step derivation
    1. expm1-def46.4%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{2 \cdot {\left(\ell \cdot {k}^{-2}\right)}^{2}}{t}\right)\right)} \]
    2. expm1-log1p68.2%

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

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

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

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

Alternative 9: 69.7% accurate, 2.0× speedup?

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

\\
\frac{2 \cdot {\left(\ell \cdot {k}^{-2}\right)}^{2}}{t}
\end{array}
Derivation
  1. Initial program 30.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. Simplified39.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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