
(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:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
NOTE: k should be positive before calling this function (FPCore (t l k) :precision binary64 (if (<= k 2.3e-14) (* 2.0 (/ (cos k) (* (/ (* k k) l) (/ t (/ l (* k k)))))) (* (/ l (sin k)) (* (/ l (tan k)) (/ 2.0 (* k (* k t)))))))
k = abs(k);
double code(double t, double l, double k) {
double tmp;
if (k <= 2.3e-14) {
tmp = 2.0 * (cos(k) / (((k * k) / l) * (t / (l / (k * k)))));
} else {
tmp = (l / sin(k)) * ((l / tan(k)) * (2.0 / (k * (k * t))));
}
return tmp;
}
NOTE: k should be positive before calling this function
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 (k <= 2.3d-14) then
tmp = 2.0d0 * (cos(k) / (((k * k) / l) * (t / (l / (k * k)))))
else
tmp = (l / sin(k)) * ((l / tan(k)) * (2.0d0 / (k * (k * t))))
end if
code = tmp
end function
k = Math.abs(k);
public static double code(double t, double l, double k) {
double tmp;
if (k <= 2.3e-14) {
tmp = 2.0 * (Math.cos(k) / (((k * k) / l) * (t / (l / (k * k)))));
} else {
tmp = (l / Math.sin(k)) * ((l / Math.tan(k)) * (2.0 / (k * (k * t))));
}
return tmp;
}
k = abs(k) def code(t, l, k): tmp = 0 if k <= 2.3e-14: tmp = 2.0 * (math.cos(k) / (((k * k) / l) * (t / (l / (k * k))))) else: tmp = (l / math.sin(k)) * ((l / math.tan(k)) * (2.0 / (k * (k * t)))) return tmp
k = abs(k) function code(t, l, k) tmp = 0.0 if (k <= 2.3e-14) tmp = Float64(2.0 * Float64(cos(k) / Float64(Float64(Float64(k * k) / l) * Float64(t / Float64(l / Float64(k * k)))))); else tmp = Float64(Float64(l / sin(k)) * Float64(Float64(l / tan(k)) * Float64(2.0 / Float64(k * Float64(k * t))))); end return tmp end
k = abs(k) function tmp_2 = code(t, l, k) tmp = 0.0; if (k <= 2.3e-14) tmp = 2.0 * (cos(k) / (((k * k) / l) * (t / (l / (k * k))))); else tmp = (l / sin(k)) * ((l / tan(k)) * (2.0 / (k * (k * t)))); end tmp_2 = tmp; end
NOTE: k should be positive before calling this function code[t_, l_, k_] := If[LessEqual[k, 2.3e-14], N[(2.0 * N[(N[Cos[k], $MachinePrecision] / N[(N[(N[(k * k), $MachinePrecision] / l), $MachinePrecision] * N[(t / N[(l / N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(l / N[Sin[k], $MachinePrecision]), $MachinePrecision] * N[(N[(l / N[Tan[k], $MachinePrecision]), $MachinePrecision] * N[(2.0 / N[(k * N[(k * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
k = |k|\\
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.3 \cdot 10^{-14}:\\
\;\;\;\;2 \cdot \frac{\cos k}{\frac{k \cdot k}{\ell} \cdot \frac{t}{\frac{\ell}{k \cdot k}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\ell}{\sin k} \cdot \left(\frac{\ell}{\tan k} \cdot \frac{2}{k \cdot \left(k \cdot t\right)}\right)\\
\end{array}
\end{array}
if k < 2.29999999999999998e-14Initial program 43.1%
associate-*l*43.1%
associate-*l*43.1%
associate-/r*43.1%
associate-/r/41.6%
*-commutative41.6%
times-frac41.6%
+-commutative41.6%
associate--l+42.6%
metadata-eval42.6%
+-rgt-identity42.6%
times-frac60.7%
Simplified60.7%
Taylor expanded in t around 0 67.4%
associate-/l*67.4%
unpow267.4%
*-commutative67.4%
unpow267.4%
Simplified67.4%
Taylor expanded in k around 0 60.3%
unpow260.3%
Simplified60.3%
times-frac85.1%
Applied egg-rr85.1%
unpow285.1%
associate-/l*89.2%
unpow289.2%
Simplified89.2%
if 2.29999999999999998e-14 < k Initial program 45.9%
associate-*l*45.9%
associate-*l*45.9%
associate-/r*45.9%
associate-/r/44.5%
*-commutative44.5%
times-frac44.5%
+-commutative44.5%
associate--l+44.5%
metadata-eval44.5%
+-rgt-identity44.5%
times-frac44.5%
Simplified44.5%
Taylor expanded in t around 0 90.4%
unpow290.4%
Simplified90.4%
associate-*l/90.4%
associate-*l*94.2%
Applied egg-rr94.2%
expm1-log1p-u89.8%
expm1-udef67.1%
Applied egg-rr67.1%
expm1-def86.1%
expm1-log1p90.4%
associate-*l*95.8%
unpow295.8%
*-commutative95.8%
unpow295.8%
associate-*l*99.7%
Simplified99.7%
Final simplification92.2%
NOTE: k should be positive before calling this function (FPCore (t l k) :precision binary64 (if (<= k 7.2e-14) (* 2.0 (/ (cos k) (* (/ (* k k) l) (/ t (/ l (* k k)))))) (* (/ 2.0 k) (/ (* (/ l (sin k)) (/ l (tan k))) (* k t)))))
k = abs(k);
double code(double t, double l, double k) {
double tmp;
if (k <= 7.2e-14) {
tmp = 2.0 * (cos(k) / (((k * k) / l) * (t / (l / (k * k)))));
} else {
tmp = (2.0 / k) * (((l / sin(k)) * (l / tan(k))) / (k * t));
}
return tmp;
}
NOTE: k should be positive before calling this function
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 (k <= 7.2d-14) then
tmp = 2.0d0 * (cos(k) / (((k * k) / l) * (t / (l / (k * k)))))
else
tmp = (2.0d0 / k) * (((l / sin(k)) * (l / tan(k))) / (k * t))
end if
code = tmp
end function
k = Math.abs(k);
public static double code(double t, double l, double k) {
double tmp;
if (k <= 7.2e-14) {
tmp = 2.0 * (Math.cos(k) / (((k * k) / l) * (t / (l / (k * k)))));
} else {
tmp = (2.0 / k) * (((l / Math.sin(k)) * (l / Math.tan(k))) / (k * t));
}
return tmp;
}
k = abs(k) def code(t, l, k): tmp = 0 if k <= 7.2e-14: tmp = 2.0 * (math.cos(k) / (((k * k) / l) * (t / (l / (k * k))))) else: tmp = (2.0 / k) * (((l / math.sin(k)) * (l / math.tan(k))) / (k * t)) return tmp
k = abs(k) function code(t, l, k) tmp = 0.0 if (k <= 7.2e-14) tmp = Float64(2.0 * Float64(cos(k) / Float64(Float64(Float64(k * k) / l) * Float64(t / Float64(l / Float64(k * k)))))); else tmp = Float64(Float64(2.0 / k) * Float64(Float64(Float64(l / sin(k)) * Float64(l / tan(k))) / Float64(k * t))); end return tmp end
k = abs(k) function tmp_2 = code(t, l, k) tmp = 0.0; if (k <= 7.2e-14) tmp = 2.0 * (cos(k) / (((k * k) / l) * (t / (l / (k * k))))); else tmp = (2.0 / k) * (((l / sin(k)) * (l / tan(k))) / (k * t)); end tmp_2 = tmp; end
NOTE: k should be positive before calling this function code[t_, l_, k_] := If[LessEqual[k, 7.2e-14], N[(2.0 * N[(N[Cos[k], $MachinePrecision] / N[(N[(N[(k * k), $MachinePrecision] / l), $MachinePrecision] * N[(t / N[(l / N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / k), $MachinePrecision] * N[(N[(N[(l / N[Sin[k], $MachinePrecision]), $MachinePrecision] * N[(l / N[Tan[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(k * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
k = |k|\\
\\
\begin{array}{l}
\mathbf{if}\;k \leq 7.2 \cdot 10^{-14}:\\
\;\;\;\;2 \cdot \frac{\cos k}{\frac{k \cdot k}{\ell} \cdot \frac{t}{\frac{\ell}{k \cdot k}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{k} \cdot \frac{\frac{\ell}{\sin k} \cdot \frac{\ell}{\tan k}}{k \cdot t}\\
\end{array}
\end{array}
if k < 7.1999999999999996e-14Initial program 43.1%
associate-*l*43.1%
associate-*l*43.1%
associate-/r*43.1%
associate-/r/41.6%
*-commutative41.6%
times-frac41.6%
+-commutative41.6%
associate--l+42.6%
metadata-eval42.6%
+-rgt-identity42.6%
times-frac60.7%
Simplified60.7%
Taylor expanded in t around 0 67.4%
associate-/l*67.4%
unpow267.4%
*-commutative67.4%
unpow267.4%
Simplified67.4%
Taylor expanded in k around 0 60.3%
unpow260.3%
Simplified60.3%
times-frac85.1%
Applied egg-rr85.1%
unpow285.1%
associate-/l*89.2%
unpow289.2%
Simplified89.2%
if 7.1999999999999996e-14 < k Initial program 45.9%
associate-*l*45.9%
associate-*l*45.9%
associate-/r*45.9%
associate-/r/44.5%
*-commutative44.5%
times-frac44.5%
+-commutative44.5%
associate--l+44.5%
metadata-eval44.5%
+-rgt-identity44.5%
times-frac44.5%
Simplified44.5%
Taylor expanded in t around 0 90.4%
unpow290.4%
Simplified90.4%
associate-*l/90.4%
associate-*l*94.2%
Applied egg-rr94.2%
times-frac94.3%
Applied egg-rr94.3%
Final simplification90.7%
NOTE: k should be positive before calling this function (FPCore (t l k) :precision binary64 (* 2.0 (/ (cos k) (* (/ (* k k) l) (/ t (/ l (* k k)))))))
k = abs(k);
double code(double t, double l, double k) {
return 2.0 * (cos(k) / (((k * k) / l) * (t / (l / (k * k)))));
}
NOTE: k should be positive before calling this function
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 * (cos(k) / (((k * k) / l) * (t / (l / (k * k)))))
end function
k = Math.abs(k);
public static double code(double t, double l, double k) {
return 2.0 * (Math.cos(k) / (((k * k) / l) * (t / (l / (k * k)))));
}
k = abs(k) def code(t, l, k): return 2.0 * (math.cos(k) / (((k * k) / l) * (t / (l / (k * k)))))
k = abs(k) function code(t, l, k) return Float64(2.0 * Float64(cos(k) / Float64(Float64(Float64(k * k) / l) * Float64(t / Float64(l / Float64(k * k)))))) end
k = abs(k) function tmp = code(t, l, k) tmp = 2.0 * (cos(k) / (((k * k) / l) * (t / (l / (k * k))))); end
NOTE: k should be positive before calling this function code[t_, l_, k_] := N[(2.0 * N[(N[Cos[k], $MachinePrecision] / N[(N[(N[(k * k), $MachinePrecision] / l), $MachinePrecision] * N[(t / N[(l / N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
k = |k|\\
\\
2 \cdot \frac{\cos k}{\frac{k \cdot k}{\ell} \cdot \frac{t}{\frac{\ell}{k \cdot k}}}
\end{array}
Initial program 43.9%
associate-*l*43.9%
associate-*l*43.9%
associate-/r*43.9%
associate-/r/42.4%
*-commutative42.4%
times-frac42.4%
+-commutative42.4%
associate--l+43.1%
metadata-eval43.1%
+-rgt-identity43.1%
times-frac56.1%
Simplified56.1%
Taylor expanded in t around 0 73.8%
associate-/l*73.8%
unpow273.8%
*-commutative73.8%
unpow273.8%
Simplified73.8%
Taylor expanded in k around 0 61.9%
unpow261.9%
Simplified61.9%
times-frac79.8%
Applied egg-rr79.8%
unpow279.8%
associate-/l*82.8%
unpow282.8%
Simplified82.8%
Final simplification82.8%
NOTE: k should be positive before calling this function (FPCore (t l k) :precision binary64 (* 2.0 (* (/ l t) (/ l (pow k 4.0)))))
k = abs(k);
double code(double t, double l, double k) {
return 2.0 * ((l / t) * (l / pow(k, 4.0)));
}
NOTE: k should be positive before calling this function
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 / t) * (l / (k ** 4.0d0)))
end function
k = Math.abs(k);
public static double code(double t, double l, double k) {
return 2.0 * ((l / t) * (l / Math.pow(k, 4.0)));
}
k = abs(k) def code(t, l, k): return 2.0 * ((l / t) * (l / math.pow(k, 4.0)))
k = abs(k) function code(t, l, k) return Float64(2.0 * Float64(Float64(l / t) * Float64(l / (k ^ 4.0)))) end
k = abs(k) function tmp = code(t, l, k) tmp = 2.0 * ((l / t) * (l / (k ^ 4.0))); end
NOTE: k should be positive before calling this function code[t_, l_, k_] := N[(2.0 * N[(N[(l / t), $MachinePrecision] * N[(l / N[Power[k, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
k = |k|\\
\\
2 \cdot \left(\frac{\ell}{t} \cdot \frac{\ell}{{k}^{4}}\right)
\end{array}
Initial program 43.9%
associate-*l*43.9%
associate-*l*43.9%
associate-/r*43.9%
associate-/r/42.4%
*-commutative42.4%
times-frac42.4%
+-commutative42.4%
associate--l+43.1%
metadata-eval43.1%
+-rgt-identity43.1%
times-frac56.1%
Simplified56.1%
Taylor expanded in t around 0 73.8%
associate-/l*73.8%
unpow273.8%
*-commutative73.8%
unpow273.8%
Simplified73.8%
Taylor expanded in k around 0 61.8%
unpow261.8%
*-commutative61.8%
times-frac79.4%
Simplified79.4%
Final simplification79.4%
NOTE: k should be positive before calling this function (FPCore (t l k) :precision binary64 (* (/ 2.0 (* (* k k) t)) (* (/ l k) (/ l k))))
k = abs(k);
double code(double t, double l, double k) {
return (2.0 / ((k * k) * t)) * ((l / k) * (l / k));
}
NOTE: k should be positive before calling this function
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 * k) * t)) * ((l / k) * (l / k))
end function
k = Math.abs(k);
public static double code(double t, double l, double k) {
return (2.0 / ((k * k) * t)) * ((l / k) * (l / k));
}
k = abs(k) def code(t, l, k): return (2.0 / ((k * k) * t)) * ((l / k) * (l / k))
k = abs(k) function code(t, l, k) return Float64(Float64(2.0 / Float64(Float64(k * k) * t)) * Float64(Float64(l / k) * Float64(l / k))) end
k = abs(k) function tmp = code(t, l, k) tmp = (2.0 / ((k * k) * t)) * ((l / k) * (l / k)); end
NOTE: k should be positive before calling this function code[t_, l_, k_] := N[(N[(2.0 / N[(N[(k * k), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] * N[(N[(l / k), $MachinePrecision] * N[(l / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
k = |k|\\
\\
\frac{2}{\left(k \cdot k\right) \cdot t} \cdot \left(\frac{\ell}{k} \cdot \frac{\ell}{k}\right)
\end{array}
Initial program 43.9%
associate-*l*43.9%
associate-*l*43.9%
associate-/r*43.9%
associate-/r/42.4%
*-commutative42.4%
times-frac42.4%
+-commutative42.4%
associate--l+43.1%
metadata-eval43.1%
+-rgt-identity43.1%
times-frac56.1%
Simplified56.1%
Taylor expanded in t around 0 88.9%
unpow288.9%
Simplified88.9%
div-inv89.0%
Applied egg-rr89.0%
Taylor expanded in k around 0 63.0%
unpow263.0%
unpow263.0%
times-frac76.8%
Simplified76.8%
Final simplification76.8%
herbie shell --seed 2023278
(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))))