
(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));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(t, l, k)
use fmin_fmax_functions
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));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(t, l, k)
use fmin_fmax_functions
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}
k_m = (fabs.f64 k)
(FPCore (t l k_m)
:precision binary64
(let* ((t_1 (/ (pow (sin k_m) 2.0) (cos k_m))))
(if (<= k_m 1.45e+142)
(/
2.0
(*
(/
(fma (* k_m k_m) t_1 (* (pow (* (sin k_m) t) 2.0) (/ 2.0 (cos k_m))))
l)
(/ t l)))
(/ 2.0 (* (* t_1 (* (/ k_m l) (/ k_m l))) t)))))k_m = fabs(k);
double code(double t, double l, double k_m) {
double t_1 = pow(sin(k_m), 2.0) / cos(k_m);
double tmp;
if (k_m <= 1.45e+142) {
tmp = 2.0 / ((fma((k_m * k_m), t_1, (pow((sin(k_m) * t), 2.0) * (2.0 / cos(k_m)))) / l) * (t / l));
} else {
tmp = 2.0 / ((t_1 * ((k_m / l) * (k_m / l))) * t);
}
return tmp;
}
k_m = abs(k) function code(t, l, k_m) t_1 = Float64((sin(k_m) ^ 2.0) / cos(k_m)) tmp = 0.0 if (k_m <= 1.45e+142) tmp = Float64(2.0 / Float64(Float64(fma(Float64(k_m * k_m), t_1, Float64((Float64(sin(k_m) * t) ^ 2.0) * Float64(2.0 / cos(k_m)))) / l) * Float64(t / l))); else tmp = Float64(2.0 / Float64(Float64(t_1 * Float64(Float64(k_m / l) * Float64(k_m / l))) * t)); end return tmp end
k_m = N[Abs[k], $MachinePrecision]
code[t_, l_, k$95$m_] := Block[{t$95$1 = N[(N[Power[N[Sin[k$95$m], $MachinePrecision], 2.0], $MachinePrecision] / N[Cos[k$95$m], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[k$95$m, 1.45e+142], N[(2.0 / N[(N[(N[(N[(k$95$m * k$95$m), $MachinePrecision] * t$95$1 + N[(N[Power[N[(N[Sin[k$95$m], $MachinePrecision] * t), $MachinePrecision], 2.0], $MachinePrecision] * N[(2.0 / N[Cos[k$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(t / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(t$95$1 * N[(N[(k$95$m / l), $MachinePrecision] * N[(k$95$m / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
k_m = \left|k\right|
\\
\begin{array}{l}
t_1 := \frac{{\sin k\_m}^{2}}{\cos k\_m}\\
\mathbf{if}\;k\_m \leq 1.45 \cdot 10^{+142}:\\
\;\;\;\;\frac{2}{\frac{\mathsf{fma}\left(k\_m \cdot k\_m, t\_1, {\left(\sin k\_m \cdot t\right)}^{2} \cdot \frac{2}{\cos k\_m}\right)}{\ell} \cdot \frac{t}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\left(t\_1 \cdot \left(\frac{k\_m}{\ell} \cdot \frac{k\_m}{\ell}\right)\right) \cdot t}\\
\end{array}
\end{array}
if k < 1.45000000000000007e142Initial program 56.1%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites77.5%
Applied rewrites78.0%
Applied rewrites88.6%
if 1.45000000000000007e142 < k Initial program 52.6%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites63.4%
Taylor expanded in t around 0
frac-timesN/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-cos.f64N/A
lift-/.f6471.3
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
Applied rewrites92.2%
k_m = (fabs.f64 k)
(FPCore (t l k_m)
:precision binary64
(let* ((t_1 (pow (sin k_m) 2.0)) (t_2 (/ t_1 (cos k_m))))
(if (<= k_m 1.45e+142)
(/
2.0
(*
(/ (fma (* k_m k_m) t_2 (* (* t (* t t_1)) (/ 2.0 (cos k_m)))) l)
(/ t l)))
(/ 2.0 (* (* t_2 (* (/ k_m l) (/ k_m l))) t)))))k_m = fabs(k);
double code(double t, double l, double k_m) {
double t_1 = pow(sin(k_m), 2.0);
double t_2 = t_1 / cos(k_m);
double tmp;
if (k_m <= 1.45e+142) {
tmp = 2.0 / ((fma((k_m * k_m), t_2, ((t * (t * t_1)) * (2.0 / cos(k_m)))) / l) * (t / l));
} else {
tmp = 2.0 / ((t_2 * ((k_m / l) * (k_m / l))) * t);
}
return tmp;
}
k_m = abs(k) function code(t, l, k_m) t_1 = sin(k_m) ^ 2.0 t_2 = Float64(t_1 / cos(k_m)) tmp = 0.0 if (k_m <= 1.45e+142) tmp = Float64(2.0 / Float64(Float64(fma(Float64(k_m * k_m), t_2, Float64(Float64(t * Float64(t * t_1)) * Float64(2.0 / cos(k_m)))) / l) * Float64(t / l))); else tmp = Float64(2.0 / Float64(Float64(t_2 * Float64(Float64(k_m / l) * Float64(k_m / l))) * t)); end return tmp end
k_m = N[Abs[k], $MachinePrecision]
code[t_, l_, k$95$m_] := Block[{t$95$1 = N[Power[N[Sin[k$95$m], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[Cos[k$95$m], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[k$95$m, 1.45e+142], N[(2.0 / N[(N[(N[(N[(k$95$m * k$95$m), $MachinePrecision] * t$95$2 + N[(N[(t * N[(t * t$95$1), $MachinePrecision]), $MachinePrecision] * N[(2.0 / N[Cos[k$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(t / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(t$95$2 * N[(N[(k$95$m / l), $MachinePrecision] * N[(k$95$m / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
k_m = \left|k\right|
\\
\begin{array}{l}
t_1 := {\sin k\_m}^{2}\\
t_2 := \frac{t\_1}{\cos k\_m}\\
\mathbf{if}\;k\_m \leq 1.45 \cdot 10^{+142}:\\
\;\;\;\;\frac{2}{\frac{\mathsf{fma}\left(k\_m \cdot k\_m, t\_2, \left(t \cdot \left(t \cdot t\_1\right)\right) \cdot \frac{2}{\cos k\_m}\right)}{\ell} \cdot \frac{t}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\left(t\_2 \cdot \left(\frac{k\_m}{\ell} \cdot \frac{k\_m}{\ell}\right)\right) \cdot t}\\
\end{array}
\end{array}
if k < 1.45000000000000007e142Initial program 56.1%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites77.5%
Applied rewrites78.0%
Applied rewrites88.6%
Taylor expanded in t around 0
pow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-pow.f6483.0
Applied rewrites83.0%
if 1.45000000000000007e142 < k Initial program 52.6%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites63.4%
Taylor expanded in t around 0
frac-timesN/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-cos.f64N/A
lift-/.f6471.3
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
Applied rewrites92.2%
k_m = (fabs.f64 k)
(FPCore (t l k_m)
:precision binary64
(let* ((t_1 (pow (sin k_m) 2.0)))
(if (<= t 6.8e+240)
(/ 2.0 (* (* (/ t_1 (cos k_m)) (* (/ k_m l) (/ k_m l))) t))
(* (/ (* l l) (pow t 3.0)) (/ (cos k_m) t_1)))))k_m = fabs(k);
double code(double t, double l, double k_m) {
double t_1 = pow(sin(k_m), 2.0);
double tmp;
if (t <= 6.8e+240) {
tmp = 2.0 / (((t_1 / cos(k_m)) * ((k_m / l) * (k_m / l))) * t);
} else {
tmp = ((l * l) / pow(t, 3.0)) * (cos(k_m) / t_1);
}
return tmp;
}
k_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(t, l, k_m)
use fmin_fmax_functions
real(8), intent (in) :: t
real(8), intent (in) :: l
real(8), intent (in) :: k_m
real(8) :: t_1
real(8) :: tmp
t_1 = sin(k_m) ** 2.0d0
if (t <= 6.8d+240) then
tmp = 2.0d0 / (((t_1 / cos(k_m)) * ((k_m / l) * (k_m / l))) * t)
else
tmp = ((l * l) / (t ** 3.0d0)) * (cos(k_m) / t_1)
end if
code = tmp
end function
k_m = Math.abs(k);
public static double code(double t, double l, double k_m) {
double t_1 = Math.pow(Math.sin(k_m), 2.0);
double tmp;
if (t <= 6.8e+240) {
tmp = 2.0 / (((t_1 / Math.cos(k_m)) * ((k_m / l) * (k_m / l))) * t);
} else {
tmp = ((l * l) / Math.pow(t, 3.0)) * (Math.cos(k_m) / t_1);
}
return tmp;
}
k_m = math.fabs(k) def code(t, l, k_m): t_1 = math.pow(math.sin(k_m), 2.0) tmp = 0 if t <= 6.8e+240: tmp = 2.0 / (((t_1 / math.cos(k_m)) * ((k_m / l) * (k_m / l))) * t) else: tmp = ((l * l) / math.pow(t, 3.0)) * (math.cos(k_m) / t_1) return tmp
k_m = abs(k) function code(t, l, k_m) t_1 = sin(k_m) ^ 2.0 tmp = 0.0 if (t <= 6.8e+240) tmp = Float64(2.0 / Float64(Float64(Float64(t_1 / cos(k_m)) * Float64(Float64(k_m / l) * Float64(k_m / l))) * t)); else tmp = Float64(Float64(Float64(l * l) / (t ^ 3.0)) * Float64(cos(k_m) / t_1)); end return tmp end
k_m = abs(k); function tmp_2 = code(t, l, k_m) t_1 = sin(k_m) ^ 2.0; tmp = 0.0; if (t <= 6.8e+240) tmp = 2.0 / (((t_1 / cos(k_m)) * ((k_m / l) * (k_m / l))) * t); else tmp = ((l * l) / (t ^ 3.0)) * (cos(k_m) / t_1); end tmp_2 = tmp; end
k_m = N[Abs[k], $MachinePrecision]
code[t_, l_, k$95$m_] := Block[{t$95$1 = N[Power[N[Sin[k$95$m], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t, 6.8e+240], N[(2.0 / N[(N[(N[(t$95$1 / N[Cos[k$95$m], $MachinePrecision]), $MachinePrecision] * N[(N[(k$95$m / l), $MachinePrecision] * N[(k$95$m / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], N[(N[(N[(l * l), $MachinePrecision] / N[Power[t, 3.0], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[k$95$m], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
k_m = \left|k\right|
\\
\begin{array}{l}
t_1 := {\sin k\_m}^{2}\\
\mathbf{if}\;t \leq 6.8 \cdot 10^{+240}:\\
\;\;\;\;\frac{2}{\left(\frac{t\_1}{\cos k\_m} \cdot \left(\frac{k\_m}{\ell} \cdot \frac{k\_m}{\ell}\right)\right) \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k\_m}{t\_1}\\
\end{array}
\end{array}
if t < 6.80000000000000017e240Initial program 54.5%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites74.6%
Taylor expanded in t around 0
frac-timesN/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-cos.f64N/A
lift-/.f6465.2
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
Applied rewrites74.8%
if 6.80000000000000017e240 < t Initial program 88.8%
Taylor expanded in t around inf
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
lift-pow.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-pow.f64N/A
lift-sin.f6487.5
Applied rewrites87.5%
k_m = (fabs.f64 k)
(FPCore (t l k_m)
:precision binary64
(let* ((t_1 (pow (sin k_m) 2.0)))
(if (<= t 4.8e+43)
(/
(fma (cos k_m) (* l l) (* (* (cos k_m) l) l))
(* (* k_m (* k_m t)) t_1))
(* (/ (* l l) (pow t 3.0)) (/ (cos k_m) t_1)))))k_m = fabs(k);
double code(double t, double l, double k_m) {
double t_1 = pow(sin(k_m), 2.0);
double tmp;
if (t <= 4.8e+43) {
tmp = fma(cos(k_m), (l * l), ((cos(k_m) * l) * l)) / ((k_m * (k_m * t)) * t_1);
} else {
tmp = ((l * l) / pow(t, 3.0)) * (cos(k_m) / t_1);
}
return tmp;
}
k_m = abs(k) function code(t, l, k_m) t_1 = sin(k_m) ^ 2.0 tmp = 0.0 if (t <= 4.8e+43) tmp = Float64(fma(cos(k_m), Float64(l * l), Float64(Float64(cos(k_m) * l) * l)) / Float64(Float64(k_m * Float64(k_m * t)) * t_1)); else tmp = Float64(Float64(Float64(l * l) / (t ^ 3.0)) * Float64(cos(k_m) / t_1)); end return tmp end
k_m = N[Abs[k], $MachinePrecision]
code[t_, l_, k$95$m_] := Block[{t$95$1 = N[Power[N[Sin[k$95$m], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t, 4.8e+43], N[(N[(N[Cos[k$95$m], $MachinePrecision] * N[(l * l), $MachinePrecision] + N[(N[(N[Cos[k$95$m], $MachinePrecision] * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] / N[(N[(k$95$m * N[(k$95$m * t), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(l * l), $MachinePrecision] / N[Power[t, 3.0], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[k$95$m], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
k_m = \left|k\right|
\\
\begin{array}{l}
t_1 := {\sin k\_m}^{2}\\
\mathbf{if}\;t \leq 4.8 \cdot 10^{+43}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\cos k\_m, \ell \cdot \ell, \left(\cos k\_m \cdot \ell\right) \cdot \ell\right)}{\left(k\_m \cdot \left(k\_m \cdot t\right)\right) \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k\_m}{t\_1}\\
\end{array}
\end{array}
if t < 4.80000000000000046e43Initial program 53.1%
Taylor expanded in t around 0
count-2-revN/A
div-add-revN/A
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
pow2N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites68.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6471.1
Applied rewrites71.1%
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f6471.2
Applied rewrites71.2%
if 4.80000000000000046e43 < t Initial program 68.0%
Taylor expanded in t around inf
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
lift-pow.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-pow.f64N/A
lift-sin.f6460.8
Applied rewrites60.8%
k_m = (fabs.f64 k)
(FPCore (t l k_m)
:precision binary64
(let* ((t_1 (pow (sin k_m) 2.0)))
(if (<= t 4.8e+43)
(/
(fma (cos k_m) (* l l) (* (cos k_m) (* l l)))
(* (* k_m (* k_m t)) t_1))
(* (/ (* l l) (pow t 3.0)) (/ (cos k_m) t_1)))))k_m = fabs(k);
double code(double t, double l, double k_m) {
double t_1 = pow(sin(k_m), 2.0);
double tmp;
if (t <= 4.8e+43) {
tmp = fma(cos(k_m), (l * l), (cos(k_m) * (l * l))) / ((k_m * (k_m * t)) * t_1);
} else {
tmp = ((l * l) / pow(t, 3.0)) * (cos(k_m) / t_1);
}
return tmp;
}
k_m = abs(k) function code(t, l, k_m) t_1 = sin(k_m) ^ 2.0 tmp = 0.0 if (t <= 4.8e+43) tmp = Float64(fma(cos(k_m), Float64(l * l), Float64(cos(k_m) * Float64(l * l))) / Float64(Float64(k_m * Float64(k_m * t)) * t_1)); else tmp = Float64(Float64(Float64(l * l) / (t ^ 3.0)) * Float64(cos(k_m) / t_1)); end return tmp end
k_m = N[Abs[k], $MachinePrecision]
code[t_, l_, k$95$m_] := Block[{t$95$1 = N[Power[N[Sin[k$95$m], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t, 4.8e+43], N[(N[(N[Cos[k$95$m], $MachinePrecision] * N[(l * l), $MachinePrecision] + N[(N[Cos[k$95$m], $MachinePrecision] * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(k$95$m * N[(k$95$m * t), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(l * l), $MachinePrecision] / N[Power[t, 3.0], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[k$95$m], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
k_m = \left|k\right|
\\
\begin{array}{l}
t_1 := {\sin k\_m}^{2}\\
\mathbf{if}\;t \leq 4.8 \cdot 10^{+43}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\cos k\_m, \ell \cdot \ell, \cos k\_m \cdot \left(\ell \cdot \ell\right)\right)}{\left(k\_m \cdot \left(k\_m \cdot t\right)\right) \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k\_m}{t\_1}\\
\end{array}
\end{array}
if t < 4.80000000000000046e43Initial program 53.1%
Taylor expanded in t around 0
count-2-revN/A
div-add-revN/A
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
pow2N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites68.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6471.1
Applied rewrites71.1%
if 4.80000000000000046e43 < t Initial program 68.0%
Taylor expanded in t around inf
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
lift-pow.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-pow.f64N/A
lift-sin.f6460.8
Applied rewrites60.8%
k_m = (fabs.f64 k) (FPCore (t l k_m) :precision binary64 (* (/ (* l l) (pow t 3.0)) (/ (cos k_m) (pow (sin k_m) 2.0))))
k_m = fabs(k);
double code(double t, double l, double k_m) {
return ((l * l) / pow(t, 3.0)) * (cos(k_m) / pow(sin(k_m), 2.0));
}
k_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(t, l, k_m)
use fmin_fmax_functions
real(8), intent (in) :: t
real(8), intent (in) :: l
real(8), intent (in) :: k_m
code = ((l * l) / (t ** 3.0d0)) * (cos(k_m) / (sin(k_m) ** 2.0d0))
end function
k_m = Math.abs(k);
public static double code(double t, double l, double k_m) {
return ((l * l) / Math.pow(t, 3.0)) * (Math.cos(k_m) / Math.pow(Math.sin(k_m), 2.0));
}
k_m = math.fabs(k) def code(t, l, k_m): return ((l * l) / math.pow(t, 3.0)) * (math.cos(k_m) / math.pow(math.sin(k_m), 2.0))
k_m = abs(k) function code(t, l, k_m) return Float64(Float64(Float64(l * l) / (t ^ 3.0)) * Float64(cos(k_m) / (sin(k_m) ^ 2.0))) end
k_m = abs(k); function tmp = code(t, l, k_m) tmp = ((l * l) / (t ^ 3.0)) * (cos(k_m) / (sin(k_m) ^ 2.0)); end
k_m = N[Abs[k], $MachinePrecision] code[t_, l_, k$95$m_] := N[(N[(N[(l * l), $MachinePrecision] / N[Power[t, 3.0], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[k$95$m], $MachinePrecision] / N[Power[N[Sin[k$95$m], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
k_m = \left|k\right|
\\
\frac{\ell \cdot \ell}{{t}^{3}} \cdot \frac{\cos k\_m}{{\sin k\_m}^{2}}
\end{array}
Initial program 55.6%
Taylor expanded in t around inf
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
lift-pow.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-pow.f64N/A
lift-sin.f6455.6
Applied rewrites55.6%
herbie shell --seed 2025064
(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))))