
(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 (* (sin k) (* (* (sin k) (pow (/ k l) 2.0)) (/ t (cos k))))))
double code(double t, double l, double k) {
return 2.0 / (sin(k) * ((sin(k) * pow((k / l), 2.0)) * (t / cos(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 / (sin(k) * ((sin(k) * ((k / l) ** 2.0d0)) * (t / cos(k))))
end function
public static double code(double t, double l, double k) {
return 2.0 / (Math.sin(k) * ((Math.sin(k) * Math.pow((k / l), 2.0)) * (t / Math.cos(k))));
}
def code(t, l, k): return 2.0 / (math.sin(k) * ((math.sin(k) * math.pow((k / l), 2.0)) * (t / math.cos(k))))
function code(t, l, k) return Float64(2.0 / Float64(sin(k) * Float64(Float64(sin(k) * (Float64(k / l) ^ 2.0)) * Float64(t / cos(k))))) end
function tmp = code(t, l, k) tmp = 2.0 / (sin(k) * ((sin(k) * ((k / l) ^ 2.0)) * (t / cos(k)))); end
code[t_, l_, k_] := N[(2.0 / N[(N[Sin[k], $MachinePrecision] * N[(N[(N[Sin[k], $MachinePrecision] * N[Power[N[(k / l), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(t / N[Cos[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{\sin k \cdot \left(\left(\sin k \cdot {\left(\frac{k}{\ell}\right)}^{2}\right) \cdot \frac{t}{\cos k}\right)}
\end{array}
Initial program 32.2%
*-commutative32.2%
add-sqr-sqrt32.2%
associate-*l*32.2%
add-sqr-sqrt32.2%
add-sqr-sqrt32.2%
add-exp-log32.0%
expm1-define32.0%
log1p-define32.0%
expm1-log1p-u32.2%
sqrt-pow121.8%
metadata-eval21.8%
pow121.8%
Applied egg-rr31.5%
associate-*r*28.6%
expm1-log1p-u28.3%
unpow228.3%
log1p-define22.5%
expm1-define22.5%
add-exp-log22.8%
associate-*r*22.8%
*-commutative22.8%
*-commutative22.8%
associate-*l*23.0%
*-commutative23.0%
add-exp-log22.8%
expm1-define22.8%
log1p-define28.6%
Applied egg-rr28.8%
associate-*l*28.8%
*-commutative28.8%
unpow228.8%
*-lft-identity28.8%
associate-*l/28.8%
associate-/r/28.8%
unpow-128.8%
*-lft-identity28.8%
associate-*l/28.8%
associate-/r/28.8%
unpow-128.8%
pow-sqr28.8%
metadata-eval28.8%
Simplified28.8%
Taylor expanded in t around -inf 0.0%
mul-1-neg0.0%
times-frac0.0%
distribute-lft-neg-in0.0%
unpow20.0%
unpow20.0%
times-frac0.0%
*-rgt-identity0.0%
associate-*r/0.0%
*-rgt-identity0.0%
associate-*r/0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
associate-*l/0.0%
*-lft-identity0.0%
Simplified94.6%
associate-*r*94.8%
Applied egg-rr94.8%
Final simplification94.8%
(FPCore (t l k) :precision binary64 (/ 2.0 (* (sin k) (* (* (/ k l) (/ k l)) (* (sin k) (/ t (cos k)))))))
double code(double t, double l, double k) {
return 2.0 / (sin(k) * (((k / l) * (k / l)) * (sin(k) * (t / cos(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 / (sin(k) * (((k / l) * (k / l)) * (sin(k) * (t / cos(k)))))
end function
public static double code(double t, double l, double k) {
return 2.0 / (Math.sin(k) * (((k / l) * (k / l)) * (Math.sin(k) * (t / Math.cos(k)))));
}
def code(t, l, k): return 2.0 / (math.sin(k) * (((k / l) * (k / l)) * (math.sin(k) * (t / math.cos(k)))))
function code(t, l, k) return Float64(2.0 / Float64(sin(k) * Float64(Float64(Float64(k / l) * Float64(k / l)) * Float64(sin(k) * Float64(t / cos(k)))))) end
function tmp = code(t, l, k) tmp = 2.0 / (sin(k) * (((k / l) * (k / l)) * (sin(k) * (t / cos(k))))); end
code[t_, l_, k_] := N[(2.0 / N[(N[Sin[k], $MachinePrecision] * N[(N[(N[(k / l), $MachinePrecision] * N[(k / l), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[k], $MachinePrecision] * N[(t / N[Cos[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{\sin k \cdot \left(\left(\frac{k}{\ell} \cdot \frac{k}{\ell}\right) \cdot \left(\sin k \cdot \frac{t}{\cos k}\right)\right)}
\end{array}
Initial program 32.2%
*-commutative32.2%
add-sqr-sqrt32.2%
associate-*l*32.2%
add-sqr-sqrt32.2%
add-sqr-sqrt32.2%
add-exp-log32.0%
expm1-define32.0%
log1p-define32.0%
expm1-log1p-u32.2%
sqrt-pow121.8%
metadata-eval21.8%
pow121.8%
Applied egg-rr31.5%
associate-*r*28.6%
expm1-log1p-u28.3%
unpow228.3%
log1p-define22.5%
expm1-define22.5%
add-exp-log22.8%
associate-*r*22.8%
*-commutative22.8%
*-commutative22.8%
associate-*l*23.0%
*-commutative23.0%
add-exp-log22.8%
expm1-define22.8%
log1p-define28.6%
Applied egg-rr28.8%
associate-*l*28.8%
*-commutative28.8%
unpow228.8%
*-lft-identity28.8%
associate-*l/28.8%
associate-/r/28.8%
unpow-128.8%
*-lft-identity28.8%
associate-*l/28.8%
associate-/r/28.8%
unpow-128.8%
pow-sqr28.8%
metadata-eval28.8%
Simplified28.8%
Taylor expanded in t around -inf 0.0%
mul-1-neg0.0%
times-frac0.0%
distribute-lft-neg-in0.0%
unpow20.0%
unpow20.0%
times-frac0.0%
*-rgt-identity0.0%
associate-*r/0.0%
*-rgt-identity0.0%
associate-*r/0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
associate-*l/0.0%
*-lft-identity0.0%
Simplified94.6%
unpow294.6%
Applied egg-rr94.6%
Final simplification94.6%
(FPCore (t l k) :precision binary64 (/ 2.0 (* (sin k) (* (pow (/ k l) 2.0) (* k t)))))
double code(double t, double l, double k) {
return 2.0 / (sin(k) * (pow((k / l), 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 = 2.0d0 / (sin(k) * (((k / l) ** 2.0d0) * (k * t)))
end function
public static double code(double t, double l, double k) {
return 2.0 / (Math.sin(k) * (Math.pow((k / l), 2.0) * (k * t)));
}
def code(t, l, k): return 2.0 / (math.sin(k) * (math.pow((k / l), 2.0) * (k * t)))
function code(t, l, k) return Float64(2.0 / Float64(sin(k) * Float64((Float64(k / l) ^ 2.0) * Float64(k * t)))) end
function tmp = code(t, l, k) tmp = 2.0 / (sin(k) * (((k / l) ^ 2.0) * (k * t))); end
code[t_, l_, k_] := N[(2.0 / N[(N[Sin[k], $MachinePrecision] * N[(N[Power[N[(k / l), $MachinePrecision], 2.0], $MachinePrecision] * N[(k * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{\sin k \cdot \left({\left(\frac{k}{\ell}\right)}^{2} \cdot \left(k \cdot t\right)\right)}
\end{array}
Initial program 32.2%
*-commutative32.2%
add-sqr-sqrt32.2%
associate-*l*32.2%
add-sqr-sqrt32.2%
add-sqr-sqrt32.2%
add-exp-log32.0%
expm1-define32.0%
log1p-define32.0%
expm1-log1p-u32.2%
sqrt-pow121.8%
metadata-eval21.8%
pow121.8%
Applied egg-rr31.5%
associate-*r*28.6%
expm1-log1p-u28.3%
unpow228.3%
log1p-define22.5%
expm1-define22.5%
add-exp-log22.8%
associate-*r*22.8%
*-commutative22.8%
*-commutative22.8%
associate-*l*23.0%
*-commutative23.0%
add-exp-log22.8%
expm1-define22.8%
log1p-define28.6%
Applied egg-rr28.8%
associate-*l*28.8%
*-commutative28.8%
unpow228.8%
*-lft-identity28.8%
associate-*l/28.8%
associate-/r/28.8%
unpow-128.8%
*-lft-identity28.8%
associate-*l/28.8%
associate-/r/28.8%
unpow-128.8%
pow-sqr28.8%
metadata-eval28.8%
Simplified28.8%
Taylor expanded in t around -inf 0.0%
mul-1-neg0.0%
times-frac0.0%
distribute-lft-neg-in0.0%
unpow20.0%
unpow20.0%
times-frac0.0%
*-rgt-identity0.0%
associate-*r/0.0%
*-rgt-identity0.0%
associate-*r/0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
associate-*l/0.0%
*-lft-identity0.0%
Simplified94.6%
Taylor expanded in k around 0 71.6%
mul-1-neg71.6%
distribute-rgt-neg-in71.6%
Simplified71.6%
Final simplification71.6%
(FPCore (t l k) :precision binary64 (if (<= t 2.4e-57) (* l (* (pow k -4.0) (* 2.0 (/ l t)))) (* l (* l (/ 2.0 (* t (pow k 4.0)))))))
double code(double t, double l, double k) {
double tmp;
if (t <= 2.4e-57) {
tmp = l * (pow(k, -4.0) * (2.0 * (l / t)));
} else {
tmp = l * (l * (2.0 / (t * pow(k, 4.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 (t <= 2.4d-57) then
tmp = l * ((k ** (-4.0d0)) * (2.0d0 * (l / t)))
else
tmp = l * (l * (2.0d0 / (t * (k ** 4.0d0))))
end if
code = tmp
end function
public static double code(double t, double l, double k) {
double tmp;
if (t <= 2.4e-57) {
tmp = l * (Math.pow(k, -4.0) * (2.0 * (l / t)));
} else {
tmp = l * (l * (2.0 / (t * Math.pow(k, 4.0))));
}
return tmp;
}
def code(t, l, k): tmp = 0 if t <= 2.4e-57: tmp = l * (math.pow(k, -4.0) * (2.0 * (l / t))) else: tmp = l * (l * (2.0 / (t * math.pow(k, 4.0)))) return tmp
function code(t, l, k) tmp = 0.0 if (t <= 2.4e-57) tmp = Float64(l * Float64((k ^ -4.0) * Float64(2.0 * Float64(l / t)))); else tmp = Float64(l * Float64(l * Float64(2.0 / Float64(t * (k ^ 4.0))))); end return tmp end
function tmp_2 = code(t, l, k) tmp = 0.0; if (t <= 2.4e-57) tmp = l * ((k ^ -4.0) * (2.0 * (l / t))); else tmp = l * (l * (2.0 / (t * (k ^ 4.0)))); end tmp_2 = tmp; end
code[t_, l_, k_] := If[LessEqual[t, 2.4e-57], N[(l * N[(N[Power[k, -4.0], $MachinePrecision] * N[(2.0 * N[(l / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(l * N[(l * N[(2.0 / N[(t * N[Power[k, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 2.4 \cdot 10^{-57}:\\
\;\;\;\;\ell \cdot \left({k}^{-4} \cdot \left(2 \cdot \frac{\ell}{t}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\ell \cdot \left(\ell \cdot \frac{2}{t \cdot {k}^{4}}\right)\\
\end{array}
\end{array}
if t < 2.40000000000000006e-57Initial program 31.3%
Simplified38.1%
Taylor expanded in k around 0 53.7%
associate-*r*62.3%
*-commutative62.3%
Applied egg-rr62.3%
associate-/r*62.3%
Applied egg-rr62.3%
associate-/r*62.3%
add-sqr-sqrt31.6%
unpow231.6%
*-commutative31.6%
unpow231.6%
add-sqr-sqrt62.3%
associate-/r*62.3%
div-inv61.9%
pow-flip61.9%
metadata-eval61.9%
Applied egg-rr61.9%
associate-*r*63.8%
*-commutative63.8%
*-commutative63.8%
associate-*l/63.8%
associate-/l*63.8%
Simplified63.8%
if 2.40000000000000006e-57 < t Initial program 34.3%
Simplified49.0%
Taylor expanded in k around 0 61.1%
associate-*r*64.4%
*-commutative64.4%
Applied egg-rr64.4%
Final simplification64.0%
(FPCore (t l k) :precision binary64 (* l (* l (/ 2.0 (* t (pow k 4.0))))))
double code(double t, double l, double k) {
return l * (l * (2.0 / (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 * (l * (2.0d0 / (t * (k ** 4.0d0))))
end function
public static double code(double t, double l, double k) {
return l * (l * (2.0 / (t * Math.pow(k, 4.0))));
}
def code(t, l, k): return l * (l * (2.0 / (t * math.pow(k, 4.0))))
function code(t, l, k) return Float64(l * Float64(l * Float64(2.0 / Float64(t * (k ^ 4.0))))) end
function tmp = code(t, l, k) tmp = l * (l * (2.0 / (t * (k ^ 4.0)))); end
code[t_, l_, k_] := N[(l * N[(l * N[(2.0 / N[(t * N[Power[k, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\ell \cdot \left(\ell \cdot \frac{2}{t \cdot {k}^{4}}\right)
\end{array}
Initial program 32.2%
Simplified41.3%
Taylor expanded in k around 0 55.9%
associate-*r*63.0%
*-commutative63.0%
Applied egg-rr63.0%
Final simplification63.0%
(FPCore (t l k) :precision binary64 (* l (* l (* (pow k -4.0) (/ 2.0 t)))))
double code(double t, double l, double k) {
return l * (l * (pow(k, -4.0) * (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 = l * (l * ((k ** (-4.0d0)) * (2.0d0 / t)))
end function
public static double code(double t, double l, double k) {
return l * (l * (Math.pow(k, -4.0) * (2.0 / t)));
}
def code(t, l, k): return l * (l * (math.pow(k, -4.0) * (2.0 / t)))
function code(t, l, k) return Float64(l * Float64(l * Float64((k ^ -4.0) * Float64(2.0 / t)))) end
function tmp = code(t, l, k) tmp = l * (l * ((k ^ -4.0) * (2.0 / t))); end
code[t_, l_, k_] := N[(l * N[(l * N[(N[Power[k, -4.0], $MachinePrecision] * N[(2.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\ell \cdot \left(\ell \cdot \left({k}^{-4} \cdot \frac{2}{t}\right)\right)
\end{array}
Initial program 32.2%
Simplified41.3%
Taylor expanded in k around 0 55.9%
associate-*r*63.0%
*-commutative63.0%
Applied egg-rr63.0%
associate-/r*63.0%
Applied egg-rr63.0%
associate-/r*63.0%
add-sqr-sqrt41.4%
unpow241.4%
unpow241.4%
add-sqr-sqrt63.0%
associate-/r*63.0%
div-inv62.7%
pow-flip62.7%
metadata-eval62.7%
Applied egg-rr62.7%
Final simplification62.7%
herbie shell --seed 2024096
(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))))