
(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 21 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 (* (/ (* (cos k) l) k) (/ (+ l l) (* (pow (sin k) 2.0) (* k t)))))
double code(double t, double l, double k) {
return ((cos(k) * l) / k) * ((l + l) / (pow(sin(k), 2.0) * (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 = ((cos(k) * l) / k) * ((l + l) / ((sin(k) ** 2.0d0) * (k * t)))
end function
public static double code(double t, double l, double k) {
return ((Math.cos(k) * l) / k) * ((l + l) / (Math.pow(Math.sin(k), 2.0) * (k * t)));
}
def code(t, l, k): return ((math.cos(k) * l) / k) * ((l + l) / (math.pow(math.sin(k), 2.0) * (k * t)))
function code(t, l, k) return Float64(Float64(Float64(cos(k) * l) / k) * Float64(Float64(l + l) / Float64((sin(k) ^ 2.0) * Float64(k * t)))) end
function tmp = code(t, l, k) tmp = ((cos(k) * l) / k) * ((l + l) / ((sin(k) ^ 2.0) * (k * t))); end
code[t_, l_, k_] := N[(N[(N[(N[Cos[k], $MachinePrecision] * l), $MachinePrecision] / k), $MachinePrecision] * N[(N[(l + l), $MachinePrecision] / N[(N[Power[N[Sin[k], $MachinePrecision], 2.0], $MachinePrecision] * N[(k * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos k \cdot \ell}{k} \cdot \frac{\ell + \ell}{{\sin k}^{2} \cdot \left(k \cdot t\right)}
\end{array}
Initial program 39.5%
Taylor expanded in t around 0
associate-*r/N/A
lower-/.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
count-2N/A
lower-+.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f6474.5
Simplified74.5%
lift-cos.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
Applied egg-rr81.7%
count-2N/A
sqr-sin-aN/A
pow2N/A
lower-pow.f64N/A
lower-sin.f6493.4
Applied egg-rr93.4%
(FPCore (t l k) :precision binary64 (* (/ (+ l l) (* (pow (sin k) 2.0) (* k t))) (* l (/ (cos k) k))))
double code(double t, double l, double k) {
return ((l + l) / (pow(sin(k), 2.0) * (k * t))) * (l * (cos(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 = ((l + l) / ((sin(k) ** 2.0d0) * (k * t))) * (l * (cos(k) / k))
end function
public static double code(double t, double l, double k) {
return ((l + l) / (Math.pow(Math.sin(k), 2.0) * (k * t))) * (l * (Math.cos(k) / k));
}
def code(t, l, k): return ((l + l) / (math.pow(math.sin(k), 2.0) * (k * t))) * (l * (math.cos(k) / k))
function code(t, l, k) return Float64(Float64(Float64(l + l) / Float64((sin(k) ^ 2.0) * Float64(k * t))) * Float64(l * Float64(cos(k) / k))) end
function tmp = code(t, l, k) tmp = ((l + l) / ((sin(k) ^ 2.0) * (k * t))) * (l * (cos(k) / k)); end
code[t_, l_, k_] := N[(N[(N[(l + l), $MachinePrecision] / N[(N[Power[N[Sin[k], $MachinePrecision], 2.0], $MachinePrecision] * N[(k * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(l * N[(N[Cos[k], $MachinePrecision] / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\ell + \ell}{{\sin k}^{2} \cdot \left(k \cdot t\right)} \cdot \left(\ell \cdot \frac{\cos k}{k}\right)
\end{array}
Initial program 35.6%
Taylor expanded in t around 0
associate-*r/N/A
lower-/.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
count-2N/A
lower-+.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f6476.3
Simplified76.3%
lift-cos.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
Applied egg-rr83.6%
count-2N/A
sqr-sin-aN/A
pow2N/A
lower-pow.f64N/A
lower-sin.f6492.4
Applied egg-rr92.4%
lift-cos.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6492.4
Applied egg-rr92.4%
Final simplification92.4%
herbie shell --seed 2024218
(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))))