
(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}
(FPCore (t l k) :precision binary64 (/ 2.0 (* (* (tan k) (/ (* t (sin k)) (/ l k))) (/ k l))))
double code(double t, double l, double k) {
return 2.0 / ((tan(k) * ((t * sin(k)) / (l / k))) * (k / l));
}
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 / ((tan(k) * ((t * sin(k)) / (l / k))) * (k / l))
end function
public static double code(double t, double l, double k) {
return 2.0 / ((Math.tan(k) * ((t * Math.sin(k)) / (l / k))) * (k / l));
}
def code(t, l, k): return 2.0 / ((math.tan(k) * ((t * math.sin(k)) / (l / k))) * (k / l))
function code(t, l, k) return Float64(2.0 / Float64(Float64(tan(k) * Float64(Float64(t * sin(k)) / Float64(l / k))) * Float64(k / l))) end
function tmp = code(t, l, k) tmp = 2.0 / ((tan(k) * ((t * sin(k)) / (l / k))) * (k / l)); end
code[t_, l_, k_] := N[(2.0 / N[(N[(N[Tan[k], $MachinePrecision] * N[(N[(t * N[Sin[k], $MachinePrecision]), $MachinePrecision] / N[(l / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(k / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{\left(\tan k \cdot \frac{t \cdot \sin k}{\frac{\ell}{k}}\right) \cdot \frac{k}{\ell}}
\end{array}
Initial program 38.0%
Taylor expanded in t around 0
unpow2N/A
associate-*l*N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
times-fracN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-/.f64N/A
Applied rewrites92.3%
Applied rewrites96.3%
Applied rewrites96.4%
Applied rewrites98.3%
(FPCore (t l k) :precision binary64 (if (<= k 3.1e-89) (/ 2.0 (pow (/ (/ (/ l k) k) (* (* (/ k l) k) t)) -1.0)) (/ 2.0 (* (* (* (/ t l) k) (* (tan k) (sin k))) (/ k l)))))
double code(double t, double l, double k) {
double tmp;
if (k <= 3.1e-89) {
tmp = 2.0 / pow((((l / k) / k) / (((k / l) * k) * t)), -1.0);
} else {
tmp = 2.0 / ((((t / l) * k) * (tan(k) * sin(k))) * (k / l));
}
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 (k <= 3.1d-89) then
tmp = 2.0d0 / ((((l / k) / k) / (((k / l) * k) * t)) ** (-1.0d0))
else
tmp = 2.0d0 / ((((t / l) * k) * (tan(k) * sin(k))) * (k / l))
end if
code = tmp
end function
public static double code(double t, double l, double k) {
double tmp;
if (k <= 3.1e-89) {
tmp = 2.0 / Math.pow((((l / k) / k) / (((k / l) * k) * t)), -1.0);
} else {
tmp = 2.0 / ((((t / l) * k) * (Math.tan(k) * Math.sin(k))) * (k / l));
}
return tmp;
}
def code(t, l, k): tmp = 0 if k <= 3.1e-89: tmp = 2.0 / math.pow((((l / k) / k) / (((k / l) * k) * t)), -1.0) else: tmp = 2.0 / ((((t / l) * k) * (math.tan(k) * math.sin(k))) * (k / l)) return tmp
function code(t, l, k) tmp = 0.0 if (k <= 3.1e-89) tmp = Float64(2.0 / (Float64(Float64(Float64(l / k) / k) / Float64(Float64(Float64(k / l) * k) * t)) ^ -1.0)); else tmp = Float64(2.0 / Float64(Float64(Float64(Float64(t / l) * k) * Float64(tan(k) * sin(k))) * Float64(k / l))); end return tmp end
function tmp_2 = code(t, l, k) tmp = 0.0; if (k <= 3.1e-89) tmp = 2.0 / ((((l / k) / k) / (((k / l) * k) * t)) ^ -1.0); else tmp = 2.0 / ((((t / l) * k) * (tan(k) * sin(k))) * (k / l)); end tmp_2 = tmp; end
code[t_, l_, k_] := If[LessEqual[k, 3.1e-89], N[(2.0 / N[Power[N[(N[(N[(l / k), $MachinePrecision] / k), $MachinePrecision] / N[(N[(N[(k / l), $MachinePrecision] * k), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(N[(N[(t / l), $MachinePrecision] * k), $MachinePrecision] * N[(N[Tan[k], $MachinePrecision] * N[Sin[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(k / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 3.1 \cdot 10^{-89}:\\
\;\;\;\;\frac{2}{{\left(\frac{\frac{\frac{\ell}{k}}{k}}{\left(\frac{k}{\ell} \cdot k\right) \cdot t}\right)}^{-1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\left(\left(\frac{t}{\ell} \cdot k\right) \cdot \left(\tan k \cdot \sin k\right)\right) \cdot \frac{k}{\ell}}\\
\end{array}
\end{array}
if k < 3.09999999999999996e-89Initial program 42.7%
Taylor expanded in k around 0
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-pow.f6476.5
Applied rewrites76.5%
Applied rewrites82.7%
Applied rewrites85.3%
if 3.09999999999999996e-89 < k Initial program 28.9%
Taylor expanded in t around 0
unpow2N/A
associate-*l*N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
times-fracN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-/.f64N/A
Applied rewrites95.3%
Applied rewrites99.7%
Applied rewrites99.7%
Applied rewrites96.5%
Final simplification89.1%
(FPCore (t l k) :precision binary64 (/ 2.0 (* (/ k l) (* (* (/ (* t (sin k)) l) (tan k)) k))))
double code(double t, double l, double k) {
return 2.0 / ((k / l) * ((((t * sin(k)) / l) * tan(k)) * 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) * ((((t * sin(k)) / l) * tan(k)) * k))
end function
public static double code(double t, double l, double k) {
return 2.0 / ((k / l) * ((((t * Math.sin(k)) / l) * Math.tan(k)) * k));
}
def code(t, l, k): return 2.0 / ((k / l) * ((((t * math.sin(k)) / l) * math.tan(k)) * k))
function code(t, l, k) return Float64(2.0 / Float64(Float64(k / l) * Float64(Float64(Float64(Float64(t * sin(k)) / l) * tan(k)) * k))) end
function tmp = code(t, l, k) tmp = 2.0 / ((k / l) * ((((t * sin(k)) / l) * tan(k)) * k)); end
code[t_, l_, k_] := N[(2.0 / N[(N[(k / l), $MachinePrecision] * N[(N[(N[(N[(t * N[Sin[k], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[Tan[k], $MachinePrecision]), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{\frac{k}{\ell} \cdot \left(\left(\frac{t \cdot \sin k}{\ell} \cdot \tan k\right) \cdot k\right)}
\end{array}
Initial program 38.0%
Taylor expanded in t around 0
unpow2N/A
associate-*l*N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
times-fracN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-/.f64N/A
Applied rewrites92.3%
Applied rewrites96.3%
Applied rewrites96.4%
Applied rewrites96.8%
(FPCore (t l k) :precision binary64 (/ 2.0 (/ (* (* (/ k l) k) t) (/ (/ l k) k))))
double code(double t, double l, double k) {
return 2.0 / ((((k / l) * k) * t) / ((l / k) / 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) * k) * t) / ((l / k) / k))
end function
public static double code(double t, double l, double k) {
return 2.0 / ((((k / l) * k) * t) / ((l / k) / k));
}
def code(t, l, k): return 2.0 / ((((k / l) * k) * t) / ((l / k) / k))
function code(t, l, k) return Float64(2.0 / Float64(Float64(Float64(Float64(k / l) * k) * t) / Float64(Float64(l / k) / k))) end
function tmp = code(t, l, k) tmp = 2.0 / ((((k / l) * k) * t) / ((l / k) / k)); end
code[t_, l_, k_] := N[(2.0 / N[(N[(N[(N[(k / l), $MachinePrecision] * k), $MachinePrecision] * t), $MachinePrecision] / N[(N[(l / k), $MachinePrecision] / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{\frac{\left(\frac{k}{\ell} \cdot k\right) \cdot t}{\frac{\frac{\ell}{k}}{k}}}
\end{array}
Initial program 38.0%
Taylor expanded in k around 0
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-pow.f6473.5
Applied rewrites73.5%
Applied rewrites78.0%
Applied rewrites79.7%
(FPCore (t l k) :precision binary64 (let* ((t_1 (* (/ k l) k))) (/ 2.0 (* t_1 (* t_1 t)))))
double code(double t, double l, double k) {
double t_1 = (k / l) * k;
return 2.0 / (t_1 * (t_1 * t));
}
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 = (k / l) * k
code = 2.0d0 / (t_1 * (t_1 * t))
end function
public static double code(double t, double l, double k) {
double t_1 = (k / l) * k;
return 2.0 / (t_1 * (t_1 * t));
}
def code(t, l, k): t_1 = (k / l) * k return 2.0 / (t_1 * (t_1 * t))
function code(t, l, k) t_1 = Float64(Float64(k / l) * k) return Float64(2.0 / Float64(t_1 * Float64(t_1 * t))) end
function tmp = code(t, l, k) t_1 = (k / l) * k; tmp = 2.0 / (t_1 * (t_1 * t)); end
code[t_, l_, k_] := Block[{t$95$1 = N[(N[(k / l), $MachinePrecision] * k), $MachinePrecision]}, N[(2.0 / N[(t$95$1 * N[(t$95$1 * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{k}{\ell} \cdot k\\
\frac{2}{t\_1 \cdot \left(t\_1 \cdot t\right)}
\end{array}
\end{array}
Initial program 38.0%
Taylor expanded in k around 0
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-pow.f6473.5
Applied rewrites73.5%
Applied rewrites78.0%
Applied rewrites79.7%
(FPCore (t l k) :precision binary64 (/ 2.0 (* k (* (/ k l) (* (* (/ k l) k) t)))))
double code(double t, double l, double k) {
return 2.0 / (k * ((k / l) * (((k / l) * k) * t)));
}
real(8) function code(t, l, k)
real(8), intent (in) :: t
real(8), intent (in) :: l
real(8), intent (in) :: k
code = 2.0d0 / (k * ((k / l) * (((k / l) * k) * t)))
end function
public static double code(double t, double l, double k) {
return 2.0 / (k * ((k / l) * (((k / l) * k) * t)));
}
def code(t, l, k): return 2.0 / (k * ((k / l) * (((k / l) * k) * t)))
function code(t, l, k) return Float64(2.0 / Float64(k * Float64(Float64(k / l) * Float64(Float64(Float64(k / l) * k) * t)))) end
function tmp = code(t, l, k) tmp = 2.0 / (k * ((k / l) * (((k / l) * k) * t))); end
code[t_, l_, k_] := N[(2.0 / N[(k * N[(N[(k / l), $MachinePrecision] * N[(N[(N[(k / l), $MachinePrecision] * k), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{k \cdot \left(\frac{k}{\ell} \cdot \left(\left(\frac{k}{\ell} \cdot k\right) \cdot t\right)\right)}
\end{array}
Initial program 38.0%
Taylor expanded in k around 0
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-pow.f6473.5
Applied rewrites73.5%
Applied rewrites78.0%
Applied rewrites79.4%
herbie shell --seed 2024303
(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))))