
(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 6 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 (or (<= k 2.55e-96) (not (<= k 9.6e+124))) (/ 2.0 (* (pow (* (/ k l) (sin k)) 2.0) (/ t (cos k)))) (/ 2.0 (/ (* (/ (* t (pow k 2.0)) (cos k)) (/ (pow (sin k) 2.0) l)) l))))
k = abs(k);
double code(double t, double l, double k) {
double tmp;
if ((k <= 2.55e-96) || !(k <= 9.6e+124)) {
tmp = 2.0 / (pow(((k / l) * sin(k)), 2.0) * (t / cos(k)));
} else {
tmp = 2.0 / ((((t * pow(k, 2.0)) / cos(k)) * (pow(sin(k), 2.0) / l)) / l);
}
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.55d-96) .or. (.not. (k <= 9.6d+124))) then
tmp = 2.0d0 / ((((k / l) * sin(k)) ** 2.0d0) * (t / cos(k)))
else
tmp = 2.0d0 / ((((t * (k ** 2.0d0)) / cos(k)) * ((sin(k) ** 2.0d0) / l)) / l)
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.55e-96) || !(k <= 9.6e+124)) {
tmp = 2.0 / (Math.pow(((k / l) * Math.sin(k)), 2.0) * (t / Math.cos(k)));
} else {
tmp = 2.0 / ((((t * Math.pow(k, 2.0)) / Math.cos(k)) * (Math.pow(Math.sin(k), 2.0) / l)) / l);
}
return tmp;
}
k = abs(k) def code(t, l, k): tmp = 0 if (k <= 2.55e-96) or not (k <= 9.6e+124): tmp = 2.0 / (math.pow(((k / l) * math.sin(k)), 2.0) * (t / math.cos(k))) else: tmp = 2.0 / ((((t * math.pow(k, 2.0)) / math.cos(k)) * (math.pow(math.sin(k), 2.0) / l)) / l) return tmp
k = abs(k) function code(t, l, k) tmp = 0.0 if ((k <= 2.55e-96) || !(k <= 9.6e+124)) tmp = Float64(2.0 / Float64((Float64(Float64(k / l) * sin(k)) ^ 2.0) * Float64(t / cos(k)))); else tmp = Float64(2.0 / Float64(Float64(Float64(Float64(t * (k ^ 2.0)) / cos(k)) * Float64((sin(k) ^ 2.0) / l)) / l)); end return tmp end
k = abs(k) function tmp_2 = code(t, l, k) tmp = 0.0; if ((k <= 2.55e-96) || ~((k <= 9.6e+124))) tmp = 2.0 / ((((k / l) * sin(k)) ^ 2.0) * (t / cos(k))); else tmp = 2.0 / ((((t * (k ^ 2.0)) / cos(k)) * ((sin(k) ^ 2.0) / l)) / l); end tmp_2 = tmp; end
NOTE: k should be positive before calling this function code[t_, l_, k_] := If[Or[LessEqual[k, 2.55e-96], N[Not[LessEqual[k, 9.6e+124]], $MachinePrecision]], N[(2.0 / N[(N[Power[N[(N[(k / l), $MachinePrecision] * N[Sin[k], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(t / N[Cos[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(N[(N[(t * N[Power[k, 2.0], $MachinePrecision]), $MachinePrecision] / N[Cos[k], $MachinePrecision]), $MachinePrecision] * N[(N[Power[N[Sin[k], $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
k = |k|\\
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.55 \cdot 10^{-96} \lor \neg \left(k \leq 9.6 \cdot 10^{+124}\right):\\
\;\;\;\;\frac{2}{{\left(\frac{k}{\ell} \cdot \sin k\right)}^{2} \cdot \frac{t}{\cos k}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{\frac{t \cdot {k}^{2}}{\cos k} \cdot \frac{{\sin k}^{2}}{\ell}}{\ell}}\\
\end{array}
\end{array}
if k < 2.54999999999999986e-96 or 9.60000000000000026e124 < k Initial program 39.3%
Simplified46.3%
associate-*l*46.3%
+-rgt-identity46.3%
*-commutative46.3%
associate-*r*46.3%
*-commutative46.3%
add-sqr-sqrt16.3%
pow216.3%
Applied egg-rr16.7%
Taylor expanded in k around inf 34.9%
associate-/l*35.3%
Simplified35.3%
unpow-prod-down33.0%
associate-/r/33.0%
pow233.0%
add-sqr-sqrt93.1%
Applied egg-rr93.1%
if 2.54999999999999986e-96 < k < 9.60000000000000026e124Initial program 31.8%
Simplified35.9%
associate-*l*35.9%
+-rgt-identity35.9%
*-commutative35.9%
associate-*r*35.9%
*-commutative35.9%
*-commutative35.9%
associate-/r*37.8%
associate-*r/39.6%
Applied egg-rr39.6%
Taylor expanded in k around inf 92.3%
associate-*r*92.3%
*-commutative92.3%
times-frac94.0%
Simplified94.0%
Final simplification93.3%
NOTE: k should be positive before calling this function (FPCore (t l k) :precision binary64 (if (<= t 9.5e-262) (/ 2.0 (/ (/ (/ (* t (pow k 4.0)) l) (cos k)) l)) (/ 2.0 (pow (* (/ k (/ l (sin k))) (sqrt t)) 2.0))))
k = abs(k);
double code(double t, double l, double k) {
double tmp;
if (t <= 9.5e-262) {
tmp = 2.0 / ((((t * pow(k, 4.0)) / l) / cos(k)) / l);
} else {
tmp = 2.0 / pow(((k / (l / sin(k))) * sqrt(t)), 2.0);
}
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 (t <= 9.5d-262) then
tmp = 2.0d0 / ((((t * (k ** 4.0d0)) / l) / cos(k)) / l)
else
tmp = 2.0d0 / (((k / (l / sin(k))) * sqrt(t)) ** 2.0d0)
end if
code = tmp
end function
k = Math.abs(k);
public static double code(double t, double l, double k) {
double tmp;
if (t <= 9.5e-262) {
tmp = 2.0 / ((((t * Math.pow(k, 4.0)) / l) / Math.cos(k)) / l);
} else {
tmp = 2.0 / Math.pow(((k / (l / Math.sin(k))) * Math.sqrt(t)), 2.0);
}
return tmp;
}
k = abs(k) def code(t, l, k): tmp = 0 if t <= 9.5e-262: tmp = 2.0 / ((((t * math.pow(k, 4.0)) / l) / math.cos(k)) / l) else: tmp = 2.0 / math.pow(((k / (l / math.sin(k))) * math.sqrt(t)), 2.0) return tmp
k = abs(k) function code(t, l, k) tmp = 0.0 if (t <= 9.5e-262) tmp = Float64(2.0 / Float64(Float64(Float64(Float64(t * (k ^ 4.0)) / l) / cos(k)) / l)); else tmp = Float64(2.0 / (Float64(Float64(k / Float64(l / sin(k))) * sqrt(t)) ^ 2.0)); end return tmp end
k = abs(k) function tmp_2 = code(t, l, k) tmp = 0.0; if (t <= 9.5e-262) tmp = 2.0 / ((((t * (k ^ 4.0)) / l) / cos(k)) / l); else tmp = 2.0 / (((k / (l / sin(k))) * sqrt(t)) ^ 2.0); end tmp_2 = tmp; end
NOTE: k should be positive before calling this function code[t_, l_, k_] := If[LessEqual[t, 9.5e-262], N[(2.0 / N[(N[(N[(N[(t * N[Power[k, 4.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] / N[Cos[k], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[Power[N[(N[(k / N[(l / N[Sin[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[t], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
k = |k|\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq 9.5 \cdot 10^{-262}:\\
\;\;\;\;\frac{2}{\frac{\frac{\frac{t \cdot {k}^{4}}{\ell}}{\cos k}}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{{\left(\frac{k}{\frac{\ell}{\sin k}} \cdot \sqrt{t}\right)}^{2}}\\
\end{array}
\end{array}
if t < 9.4999999999999999e-262Initial program 36.8%
Simplified41.3%
associate-*l*41.3%
+-rgt-identity41.3%
*-commutative41.3%
associate-*r*41.3%
*-commutative41.3%
*-commutative41.3%
associate-/r*43.7%
associate-*r/44.0%
Applied egg-rr44.0%
Taylor expanded in k around inf 83.5%
times-frac85.6%
Simplified85.6%
associate-*r/85.6%
Applied egg-rr85.6%
Taylor expanded in k around 0 69.4%
if 9.4999999999999999e-262 < t Initial program 39.3%
Simplified48.6%
associate-*l*48.6%
+-rgt-identity48.6%
*-commutative48.6%
associate-*r*48.6%
*-commutative48.6%
add-sqr-sqrt32.2%
pow232.2%
Applied egg-rr51.6%
Taylor expanded in k around inf 65.8%
associate-/l*66.8%
Simplified66.8%
Taylor expanded in k around 0 76.9%
Final simplification72.3%
NOTE: k should be positive before calling this function (FPCore (t l k) :precision binary64 (/ 2.0 (* (pow (* (/ k l) (sin k)) 2.0) (/ t (cos k)))))
k = abs(k);
double code(double t, double l, double k) {
return 2.0 / (pow(((k / l) * sin(k)), 2.0) * (t / cos(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 / l) * sin(k)) ** 2.0d0) * (t / cos(k)))
end function
k = Math.abs(k);
public static double code(double t, double l, double k) {
return 2.0 / (Math.pow(((k / l) * Math.sin(k)), 2.0) * (t / Math.cos(k)));
}
k = abs(k) def code(t, l, k): return 2.0 / (math.pow(((k / l) * math.sin(k)), 2.0) * (t / math.cos(k)))
k = abs(k) function code(t, l, k) return Float64(2.0 / Float64((Float64(Float64(k / l) * sin(k)) ^ 2.0) * Float64(t / cos(k)))) end
k = abs(k) function tmp = code(t, l, k) tmp = 2.0 / ((((k / l) * sin(k)) ^ 2.0) * (t / cos(k))); end
NOTE: k should be positive before calling this function code[t_, l_, k_] := N[(2.0 / N[(N[Power[N[(N[(k / l), $MachinePrecision] * N[Sin[k], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(t / N[Cos[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
k = |k|\\
\\
\frac{2}{{\left(\frac{k}{\ell} \cdot \sin k\right)}^{2} \cdot \frac{t}{\cos k}}
\end{array}
Initial program 37.8%
Simplified44.1%
associate-*l*44.1%
+-rgt-identity44.1%
*-commutative44.1%
associate-*r*44.1%
*-commutative44.1%
add-sqr-sqrt17.7%
pow217.7%
Applied egg-rr20.2%
Taylor expanded in k around inf 39.3%
associate-/l*39.7%
Simplified39.7%
unpow-prod-down36.0%
associate-/r/36.0%
pow236.0%
add-sqr-sqrt90.8%
Applied egg-rr90.8%
Final simplification90.8%
NOTE: k should be positive before calling this function (FPCore (t l k) :precision binary64 (/ 2.0 (/ (/ (/ (* t (pow k 4.0)) l) (cos k)) l)))
k = abs(k);
double code(double t, double l, double k) {
return 2.0 / ((((t * pow(k, 4.0)) / l) / cos(k)) / l);
}
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 / ((((t * (k ** 4.0d0)) / l) / cos(k)) / l)
end function
k = Math.abs(k);
public static double code(double t, double l, double k) {
return 2.0 / ((((t * Math.pow(k, 4.0)) / l) / Math.cos(k)) / l);
}
k = abs(k) def code(t, l, k): return 2.0 / ((((t * math.pow(k, 4.0)) / l) / math.cos(k)) / l)
k = abs(k) function code(t, l, k) return Float64(2.0 / Float64(Float64(Float64(Float64(t * (k ^ 4.0)) / l) / cos(k)) / l)) end
k = abs(k) function tmp = code(t, l, k) tmp = 2.0 / ((((t * (k ^ 4.0)) / l) / cos(k)) / l); end
NOTE: k should be positive before calling this function code[t_, l_, k_] := N[(2.0 / N[(N[(N[(N[(t * N[Power[k, 4.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] / N[Cos[k], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
k = |k|\\
\\
\frac{2}{\frac{\frac{\frac{t \cdot {k}^{4}}{\ell}}{\cos k}}{\ell}}
\end{array}
Initial program 37.8%
Simplified44.1%
associate-*l*44.1%
+-rgt-identity44.1%
*-commutative44.1%
associate-*r*44.1%
*-commutative44.1%
*-commutative44.1%
associate-/r*47.6%
associate-*r/48.2%
Applied egg-rr48.2%
Taylor expanded in k around inf 83.1%
times-frac85.5%
Simplified85.5%
associate-*r/85.5%
Applied egg-rr85.5%
Taylor expanded in k around 0 69.4%
Final simplification69.4%
NOTE: k should be positive before calling this function (FPCore (t l k) :precision binary64 (* l (/ 2.0 (/ (pow k 4.0) (/ l t)))))
k = abs(k);
double code(double t, double l, double k) {
return l * (2.0 / (pow(k, 4.0) / (l / t)));
}
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 = l * (2.0d0 / ((k ** 4.0d0) / (l / t)))
end function
k = Math.abs(k);
public static double code(double t, double l, double k) {
return l * (2.0 / (Math.pow(k, 4.0) / (l / t)));
}
k = abs(k) def code(t, l, k): return l * (2.0 / (math.pow(k, 4.0) / (l / t)))
k = abs(k) function code(t, l, k) return Float64(l * Float64(2.0 / Float64((k ^ 4.0) / Float64(l / t)))) end
k = abs(k) function tmp = code(t, l, k) tmp = l * (2.0 / ((k ^ 4.0) / (l / t))); end
NOTE: k should be positive before calling this function code[t_, l_, k_] := N[(l * N[(2.0 / N[(N[Power[k, 4.0], $MachinePrecision] / N[(l / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
k = |k|\\
\\
\ell \cdot \frac{2}{\frac{{k}^{4}}{\frac{\ell}{t}}}
\end{array}
Initial program 37.8%
Simplified44.1%
associate-*l*44.1%
+-rgt-identity44.1%
*-commutative44.1%
associate-*r*44.1%
*-commutative44.1%
*-commutative44.1%
associate-/r*47.6%
associate-*r/48.2%
Applied egg-rr48.2%
Taylor expanded in k around 0 67.6%
associate-/r/67.6%
associate-/l*66.3%
Applied egg-rr66.3%
Final simplification66.3%
NOTE: k should be positive before calling this function (FPCore (t l k) :precision binary64 (/ 2.0 (/ (* t (/ (pow k 4.0) l)) l)))
k = abs(k);
double code(double t, double l, double k) {
return 2.0 / ((t * (pow(k, 4.0) / l)) / l);
}
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 / ((t * ((k ** 4.0d0) / l)) / l)
end function
k = Math.abs(k);
public static double code(double t, double l, double k) {
return 2.0 / ((t * (Math.pow(k, 4.0) / l)) / l);
}
k = abs(k) def code(t, l, k): return 2.0 / ((t * (math.pow(k, 4.0) / l)) / l)
k = abs(k) function code(t, l, k) return Float64(2.0 / Float64(Float64(t * Float64((k ^ 4.0) / l)) / l)) end
k = abs(k) function tmp = code(t, l, k) tmp = 2.0 / ((t * ((k ^ 4.0) / l)) / l); end
NOTE: k should be positive before calling this function code[t_, l_, k_] := N[(2.0 / N[(N[(t * N[(N[Power[k, 4.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
k = |k|\\
\\
\frac{2}{\frac{t \cdot \frac{{k}^{4}}{\ell}}{\ell}}
\end{array}
Initial program 37.8%
Simplified44.1%
associate-*l*44.1%
+-rgt-identity44.1%
*-commutative44.1%
associate-*r*44.1%
*-commutative44.1%
*-commutative44.1%
associate-/r*47.6%
associate-*r/48.2%
Applied egg-rr48.2%
Taylor expanded in k around inf 83.1%
times-frac85.5%
Simplified85.5%
Taylor expanded in k around 0 67.6%
associate-*l/68.0%
Simplified68.0%
Final simplification68.0%
herbie shell --seed 2023333
(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))))