
(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}
(FPCore (t l k) :precision binary64 (* 2.0 (* (pow (/ l k) 2.0) (/ (cos k) (* (pow (sin k) 2.0) t)))))
double code(double t, double l, double k) {
return 2.0 * (pow((l / k), 2.0) * (cos(k) / (pow(sin(k), 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) * (cos(k) / ((sin(k) ** 2.0d0) * t)))
end function
public static double code(double t, double l, double k) {
return 2.0 * (Math.pow((l / k), 2.0) * (Math.cos(k) / (Math.pow(Math.sin(k), 2.0) * t)));
}
def code(t, l, k): return 2.0 * (math.pow((l / k), 2.0) * (math.cos(k) / (math.pow(math.sin(k), 2.0) * t)))
function code(t, l, k) return Float64(2.0 * Float64((Float64(l / k) ^ 2.0) * Float64(cos(k) / Float64((sin(k) ^ 2.0) * t)))) end
function tmp = code(t, l, k) tmp = 2.0 * (((l / k) ^ 2.0) * (cos(k) / ((sin(k) ^ 2.0) * t))); end
code[t_, l_, k_] := N[(2.0 * N[(N[Power[N[(l / k), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Cos[k], $MachinePrecision] / N[(N[Power[N[Sin[k], $MachinePrecision], 2.0], $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left({\left(\frac{\ell}{k}\right)}^{2} \cdot \frac{\cos k}{{\sin k}^{2} \cdot t}\right)
\end{array}
Initial program 32.0%
*-commutative32.0%
associate-/r*32.0%
Simplified37.9%
clear-num37.9%
+-rgt-identity37.9%
associate-/r/37.9%
pow-flip38.5%
metadata-eval38.5%
Applied egg-rr38.5%
Taylor expanded in k around inf 69.7%
times-frac71.0%
*-commutative71.0%
Simplified71.0%
add-sqr-sqrt71.0%
pow271.0%
div-inv70.6%
sqrt-prod70.6%
sqrt-pow181.9%
metadata-eval81.9%
pow181.9%
pow-flip82.3%
metadata-eval82.3%
Applied egg-rr82.3%
Taylor expanded in l around 0 71.0%
unpow271.0%
unpow271.0%
times-frac93.0%
*-lft-identity93.0%
associate-*l/93.0%
*-lft-identity93.0%
associate-*l/93.0%
unpow293.0%
associate-*l/93.0%
*-lft-identity93.0%
Simplified93.0%
(FPCore (t l k) :precision binary64 (let* ((t_1 (* l (/ 1.0 k)))) (* 2.0 (* (/ (cos k) (* (pow (sin k) 2.0) t)) (* t_1 t_1)))))
double code(double t, double l, double k) {
double t_1 = l * (1.0 / k);
return 2.0 * ((cos(k) / (pow(sin(k), 2.0) * t)) * (t_1 * t_1));
}
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
t_1 = l * (1.0d0 / k)
code = 2.0d0 * ((cos(k) / ((sin(k) ** 2.0d0) * t)) * (t_1 * t_1))
end function
public static double code(double t, double l, double k) {
double t_1 = l * (1.0 / k);
return 2.0 * ((Math.cos(k) / (Math.pow(Math.sin(k), 2.0) * t)) * (t_1 * t_1));
}
def code(t, l, k): t_1 = l * (1.0 / k) return 2.0 * ((math.cos(k) / (math.pow(math.sin(k), 2.0) * t)) * (t_1 * t_1))
function code(t, l, k) t_1 = Float64(l * Float64(1.0 / k)) return Float64(2.0 * Float64(Float64(cos(k) / Float64((sin(k) ^ 2.0) * t)) * Float64(t_1 * t_1))) end
function tmp = code(t, l, k) t_1 = l * (1.0 / k); tmp = 2.0 * ((cos(k) / ((sin(k) ^ 2.0) * t)) * (t_1 * t_1)); end
code[t_, l_, k_] := Block[{t$95$1 = N[(l * N[(1.0 / k), $MachinePrecision]), $MachinePrecision]}, N[(2.0 * N[(N[(N[Cos[k], $MachinePrecision] / N[(N[Power[N[Sin[k], $MachinePrecision], 2.0], $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \ell \cdot \frac{1}{k}\\
2 \cdot \left(\frac{\cos k}{{\sin k}^{2} \cdot t} \cdot \left(t\_1 \cdot t\_1\right)\right)
\end{array}
\end{array}
Initial program 32.0%
*-commutative32.0%
associate-/r*32.0%
Simplified37.9%
clear-num37.9%
+-rgt-identity37.9%
associate-/r/37.9%
pow-flip38.5%
metadata-eval38.5%
Applied egg-rr38.5%
Taylor expanded in k around inf 69.7%
times-frac71.0%
*-commutative71.0%
Simplified71.0%
add-sqr-sqrt71.0%
pow271.0%
div-inv70.6%
sqrt-prod70.6%
sqrt-pow181.9%
metadata-eval81.9%
pow181.9%
pow-flip82.3%
metadata-eval82.3%
Applied egg-rr82.3%
unpow282.3%
*-commutative82.3%
sqrt-pow154.7%
metadata-eval54.7%
inv-pow54.7%
*-commutative54.7%
sqrt-pow193.0%
metadata-eval93.0%
inv-pow93.0%
Applied egg-rr93.0%
Final simplification93.0%
(FPCore (t l k) :precision binary64 (if (<= l 4.2e-159) (* l (* 2.0 (/ (/ l (pow k 4.0)) t))) (* 2.0 (* (/ (pow l 2.0) (pow k 2.0)) (/ 1.0 (* t (pow k 2.0)))))))
double code(double t, double l, double k) {
double tmp;
if (l <= 4.2e-159) {
tmp = l * (2.0 * ((l / pow(k, 4.0)) / t));
} else {
tmp = 2.0 * ((pow(l, 2.0) / pow(k, 2.0)) * (1.0 / (t * pow(k, 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 <= 4.2d-159) then
tmp = l * (2.0d0 * ((l / (k ** 4.0d0)) / t))
else
tmp = 2.0d0 * (((l ** 2.0d0) / (k ** 2.0d0)) * (1.0d0 / (t * (k ** 2.0d0))))
end if
code = tmp
end function
public static double code(double t, double l, double k) {
double tmp;
if (l <= 4.2e-159) {
tmp = l * (2.0 * ((l / Math.pow(k, 4.0)) / t));
} else {
tmp = 2.0 * ((Math.pow(l, 2.0) / Math.pow(k, 2.0)) * (1.0 / (t * Math.pow(k, 2.0))));
}
return tmp;
}
def code(t, l, k): tmp = 0 if l <= 4.2e-159: tmp = l * (2.0 * ((l / math.pow(k, 4.0)) / t)) else: tmp = 2.0 * ((math.pow(l, 2.0) / math.pow(k, 2.0)) * (1.0 / (t * math.pow(k, 2.0)))) return tmp
function code(t, l, k) tmp = 0.0 if (l <= 4.2e-159) tmp = Float64(l * Float64(2.0 * Float64(Float64(l / (k ^ 4.0)) / t))); else tmp = Float64(2.0 * Float64(Float64((l ^ 2.0) / (k ^ 2.0)) * Float64(1.0 / Float64(t * (k ^ 2.0))))); end return tmp end
function tmp_2 = code(t, l, k) tmp = 0.0; if (l <= 4.2e-159) tmp = l * (2.0 * ((l / (k ^ 4.0)) / t)); else tmp = 2.0 * (((l ^ 2.0) / (k ^ 2.0)) * (1.0 / (t * (k ^ 2.0)))); end tmp_2 = tmp; end
code[t_, l_, k_] := If[LessEqual[l, 4.2e-159], N[(l * N[(2.0 * N[(N[(l / N[Power[k, 4.0], $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[(N[Power[l, 2.0], $MachinePrecision] / N[Power[k, 2.0], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(t * N[Power[k, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 4.2 \cdot 10^{-159}:\\
\;\;\;\;\ell \cdot \left(2 \cdot \frac{\frac{\ell}{{k}^{4}}}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\frac{{\ell}^{2}}{{k}^{2}} \cdot \frac{1}{t \cdot {k}^{2}}\right)\\
\end{array}
\end{array}
if l < 4.1999999999999998e-159Initial program 32.4%
Simplified38.7%
Taylor expanded in k around 0 61.2%
add-exp-log49.1%
*-commutative49.1%
pow249.1%
Applied egg-rr49.1%
associate-/r*49.1%
pow249.1%
associate-*r*56.0%
add-exp-log72.7%
div-inv72.7%
pow-flip72.7%
metadata-eval72.7%
Applied egg-rr72.7%
Taylor expanded in t around 0 72.7%
associate-/r*73.5%
Simplified73.5%
if 4.1999999999999998e-159 < l Initial program 31.1%
*-commutative31.1%
associate-/r*31.1%
Simplified39.4%
clear-num39.4%
+-rgt-identity39.4%
associate-/r/39.4%
pow-flip41.3%
metadata-eval41.3%
Applied egg-rr41.3%
Taylor expanded in k around inf 76.0%
times-frac77.1%
*-commutative77.1%
Simplified77.1%
Taylor expanded in k around 0 59.3%
Final simplification68.9%
(FPCore (t l k) :precision binary64 (* l (* 2.0 (/ (/ l (pow k 4.0)) t))))
double code(double t, double l, double k) {
return l * (2.0 * ((l / 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 = l * (2.0d0 * ((l / (k ** 4.0d0)) / t))
end function
public static double code(double t, double l, double k) {
return l * (2.0 * ((l / Math.pow(k, 4.0)) / t));
}
def code(t, l, k): return l * (2.0 * ((l / math.pow(k, 4.0)) / t))
function code(t, l, k) return Float64(l * Float64(2.0 * Float64(Float64(l / (k ^ 4.0)) / t))) end
function tmp = code(t, l, k) tmp = l * (2.0 * ((l / (k ^ 4.0)) / t)); end
code[t_, l_, k_] := N[(l * N[(2.0 * N[(N[(l / N[Power[k, 4.0], $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\ell \cdot \left(2 \cdot \frac{\frac{\ell}{{k}^{4}}}{t}\right)
\end{array}
Initial program 32.0%
Simplified39.3%
Taylor expanded in k around 0 58.6%
add-exp-log43.1%
*-commutative43.1%
pow243.1%
Applied egg-rr43.1%
associate-/r*43.1%
pow243.1%
associate-*r*48.3%
add-exp-log66.9%
div-inv66.8%
pow-flip66.8%
metadata-eval66.8%
Applied egg-rr66.8%
Taylor expanded in t around 0 66.9%
associate-/r*67.1%
Simplified67.1%
Final simplification67.1%
(FPCore (t l k) :precision binary64 (* l (* 2.0 (/ l (* t (pow k 4.0))))))
double code(double t, double l, double k) {
return l * (2.0 * (l / (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 = l * (2.0d0 * (l / (t * (k ** 4.0d0))))
end function
public static double code(double t, double l, double k) {
return l * (2.0 * (l / (t * Math.pow(k, 4.0))));
}
def code(t, l, k): return l * (2.0 * (l / (t * math.pow(k, 4.0))))
function code(t, l, k) return Float64(l * Float64(2.0 * Float64(l / Float64(t * (k ^ 4.0))))) end
function tmp = code(t, l, k) tmp = l * (2.0 * (l / (t * (k ^ 4.0)))); end
code[t_, l_, k_] := N[(l * N[(2.0 * N[(l / N[(t * N[Power[k, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\ell \cdot \left(2 \cdot \frac{\ell}{t \cdot {k}^{4}}\right)
\end{array}
Initial program 32.0%
Simplified39.3%
Taylor expanded in k around 0 58.6%
add-exp-log43.1%
*-commutative43.1%
pow243.1%
Applied egg-rr43.1%
associate-/r*43.1%
pow243.1%
associate-*r*48.3%
add-exp-log66.9%
div-inv66.8%
pow-flip66.8%
metadata-eval66.8%
Applied egg-rr66.8%
Taylor expanded in t around 0 66.9%
Final simplification66.9%
herbie shell --seed 2024094
(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))))