
(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 5 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}
(FPCore (t l k)
:precision binary64
(let* ((t_1 (pow (* t (sin k)) 1.0)) (t_2 (pow (sin k) 2.0)))
(if (<=
(*
(* (* (/ (pow t 3.0) (* l l)) (sin k)) (tan k))
(+ (+ 1.0 (pow (/ k t) 2.0)) 1.0))
INFINITY)
(/
2.0
(*
(fma
(/ (/ (* k k) l) l)
(/ t_2 (cos k))
(/ (fma t_1 t_1 (* t_1 t_1)) (* (cos k) (* l l))))
t))
(/ 2.0 (* (* (/ k l) (/ k l)) (/ (* t t_2) (cos k)))))))
double code(double t, double l, double k) {
double t_1 = pow((t * sin(k)), 1.0);
double t_2 = pow(sin(k), 2.0);
double tmp;
if (((((pow(t, 3.0) / (l * l)) * sin(k)) * tan(k)) * ((1.0 + pow((k / t), 2.0)) + 1.0)) <= ((double) INFINITY)) {
tmp = 2.0 / (fma((((k * k) / l) / l), (t_2 / cos(k)), (fma(t_1, t_1, (t_1 * t_1)) / (cos(k) * (l * l)))) * t);
} else {
tmp = 2.0 / (((k / l) * (k / l)) * ((t * t_2) / cos(k)));
}
return tmp;
}
function code(t, l, k) t_1 = Float64(t * sin(k)) ^ 1.0 t_2 = sin(k) ^ 2.0 tmp = 0.0 if (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)) <= Inf) tmp = Float64(2.0 / Float64(fma(Float64(Float64(Float64(k * k) / l) / l), Float64(t_2 / cos(k)), Float64(fma(t_1, t_1, Float64(t_1 * t_1)) / Float64(cos(k) * Float64(l * l)))) * t)); else tmp = Float64(2.0 / Float64(Float64(Float64(k / l) * Float64(k / l)) * Float64(Float64(t * t_2) / cos(k)))); end return tmp end
code[t_, l_, k_] := Block[{t$95$1 = N[Power[N[(t * N[Sin[k], $MachinePrecision]), $MachinePrecision], 1.0], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[k], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[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], Infinity], N[(2.0 / N[(N[(N[(N[(N[(k * k), $MachinePrecision] / l), $MachinePrecision] / l), $MachinePrecision] * N[(t$95$2 / N[Cos[k], $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$1 * t$95$1 + N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[k], $MachinePrecision] * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(N[(k / l), $MachinePrecision] * N[(k / l), $MachinePrecision]), $MachinePrecision] * N[(N[(t * t$95$2), $MachinePrecision] / N[Cos[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := {\left(t \cdot \sin k\right)}^{1}\\
t_2 := {\sin k}^{2}\\
\mathbf{if}\;\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) \leq \infty:\\
\;\;\;\;\frac{2}{\mathsf{fma}\left(\frac{\frac{k \cdot k}{\ell}}{\ell}, \frac{t\_2}{\cos k}, \frac{\mathsf{fma}\left(t\_1, t\_1, t\_1 \cdot t\_1\right)}{\cos k \cdot \left(\ell \cdot \ell\right)}\right) \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\left(\frac{k}{\ell} \cdot \frac{k}{\ell}\right) \cdot \frac{t \cdot t\_2}{\cos k}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 (/.f64 (pow.f64 t #s(literal 3 binary64)) (*.f64 l l)) (sin.f64 k)) (tan.f64 k)) (+.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 k t) #s(literal 2 binary64))) #s(literal 1 binary64))) < +inf.0Initial program 83.7%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites87.0%
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6491.2
Applied rewrites91.2%
if +inf.0 < (*.f64 (*.f64 (*.f64 (/.f64 (pow.f64 t #s(literal 3 binary64)) (*.f64 l l)) (sin.f64 k)) (tan.f64 k)) (+.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 k t) #s(literal 2 binary64))) #s(literal 1 binary64))) Initial program 0.0%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites38.4%
Taylor expanded in t around 0
times-fracN/A
pow2N/A
pow2N/A
lower-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-cos.f6477.1
Applied rewrites77.1%
(FPCore (t l k)
:precision binary64
(let* ((t_1
(*
(* (* (/ (pow t 3.0) (* l l)) (sin k)) (tan k))
(+ (+ 1.0 (pow (/ k t) 2.0)) 1.0)))
(t_2 (pow (sin k) 2.0)))
(if (<= t_1 4e+214)
(/
(fma (cos k) (* l l) (* (cos k) (* l l)))
(* (* (fma (/ k t) (/ k t) 2.0) t_2) (pow t 3.0)))
(if (<= t_1 INFINITY)
(* (/ l k) (/ (/ l k) (pow t 3.0)))
(/ 2.0 (* (* (/ k l) (/ k l)) (/ (* t t_2) (cos k))))))))
double code(double t, double l, double k) {
double t_1 = (((pow(t, 3.0) / (l * l)) * sin(k)) * tan(k)) * ((1.0 + pow((k / t), 2.0)) + 1.0);
double t_2 = pow(sin(k), 2.0);
double tmp;
if (t_1 <= 4e+214) {
tmp = fma(cos(k), (l * l), (cos(k) * (l * l))) / ((fma((k / t), (k / t), 2.0) * t_2) * pow(t, 3.0));
} else if (t_1 <= ((double) INFINITY)) {
tmp = (l / k) * ((l / k) / pow(t, 3.0));
} else {
tmp = 2.0 / (((k / l) * (k / l)) * ((t * t_2) / cos(k)));
}
return tmp;
}
function code(t, l, k) t_1 = 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)) t_2 = sin(k) ^ 2.0 tmp = 0.0 if (t_1 <= 4e+214) tmp = Float64(fma(cos(k), Float64(l * l), Float64(cos(k) * Float64(l * l))) / Float64(Float64(fma(Float64(k / t), Float64(k / t), 2.0) * t_2) * (t ^ 3.0))); elseif (t_1 <= Inf) tmp = Float64(Float64(l / k) * Float64(Float64(l / k) / (t ^ 3.0))); else tmp = Float64(2.0 / Float64(Float64(Float64(k / l) * Float64(k / l)) * Float64(Float64(t * t_2) / cos(k)))); end return tmp end
code[t_, l_, k_] := Block[{t$95$1 = 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]}, Block[{t$95$2 = N[Power[N[Sin[k], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t$95$1, 4e+214], N[(N[(N[Cos[k], $MachinePrecision] * N[(l * l), $MachinePrecision] + N[(N[Cos[k], $MachinePrecision] * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(N[(k / t), $MachinePrecision] * N[(k / t), $MachinePrecision] + 2.0), $MachinePrecision] * t$95$2), $MachinePrecision] * N[Power[t, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(l / k), $MachinePrecision] * N[(N[(l / k), $MachinePrecision] / N[Power[t, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(N[(k / l), $MachinePrecision] * N[(k / l), $MachinePrecision]), $MachinePrecision] * N[(N[(t * t$95$2), $MachinePrecision] / N[Cos[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \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)\\
t_2 := {\sin k}^{2}\\
\mathbf{if}\;t\_1 \leq 4 \cdot 10^{+214}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left(\mathsf{fma}\left(\frac{k}{t}, \frac{k}{t}, 2\right) \cdot t\_2\right) \cdot {t}^{3}}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\ell}{k} \cdot \frac{\frac{\ell}{k}}{{t}^{3}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\left(\frac{k}{\ell} \cdot \frac{k}{\ell}\right) \cdot \frac{t \cdot t\_2}{\cos k}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 (/.f64 (pow.f64 t #s(literal 3 binary64)) (*.f64 l l)) (sin.f64 k)) (tan.f64 k)) (+.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 k t) #s(literal 2 binary64))) #s(literal 1 binary64))) < 3.9999999999999998e214Initial program 88.9%
Taylor expanded in l around 0
count-2-revN/A
div-add-revN/A
lower-/.f64N/A
Applied rewrites84.3%
if 3.9999999999999998e214 < (*.f64 (*.f64 (*.f64 (/.f64 (pow.f64 t #s(literal 3 binary64)) (*.f64 l l)) (sin.f64 k)) (tan.f64 k)) (+.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 k t) #s(literal 2 binary64))) #s(literal 1 binary64))) < +inf.0Initial program 72.0%
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 rewrites54.5%
Taylor expanded in k around 0
associate-/r*N/A
lower-/.f64N/A
pow2N/A
pow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lift-pow.f6483.0
Applied rewrites83.0%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-pow.f6481.6
Applied rewrites81.6%
if +inf.0 < (*.f64 (*.f64 (*.f64 (/.f64 (pow.f64 t #s(literal 3 binary64)) (*.f64 l l)) (sin.f64 k)) (tan.f64 k)) (+.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 k t) #s(literal 2 binary64))) #s(literal 1 binary64))) Initial program 0.0%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites38.4%
Taylor expanded in t around 0
times-fracN/A
pow2N/A
pow2N/A
lower-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-cos.f6477.1
Applied rewrites77.1%
(FPCore (t l k)
:precision binary64
(let* ((t_1 (pow (* t (sin k)) 1.0)) (t_2 (pow (sin k) 2.0)))
(if (<=
(/
2.0
(*
(* (* (/ (pow t 3.0) (* l l)) (sin k)) (tan k))
(+ (+ 1.0 (pow (/ k t) 2.0)) 1.0)))
2e+262)
(/
2.0
(*
(fma
(/ (* k k) (* l l))
(/ t_2 (cos k))
(/ (fma t_1 t_1 (* t_1 t_1)) (* (cos k) (* l l))))
t))
(/ 2.0 (* (* (/ k l) (/ k l)) (/ (* t t_2) (cos k)))))))
double code(double t, double l, double k) {
double t_1 = pow((t * sin(k)), 1.0);
double t_2 = pow(sin(k), 2.0);
double tmp;
if ((2.0 / ((((pow(t, 3.0) / (l * l)) * sin(k)) * tan(k)) * ((1.0 + pow((k / t), 2.0)) + 1.0))) <= 2e+262) {
tmp = 2.0 / (fma(((k * k) / (l * l)), (t_2 / cos(k)), (fma(t_1, t_1, (t_1 * t_1)) / (cos(k) * (l * l)))) * t);
} else {
tmp = 2.0 / (((k / l) * (k / l)) * ((t * t_2) / cos(k)));
}
return tmp;
}
function code(t, l, k) t_1 = Float64(t * sin(k)) ^ 1.0 t_2 = sin(k) ^ 2.0 tmp = 0.0 if (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))) <= 2e+262) tmp = Float64(2.0 / Float64(fma(Float64(Float64(k * k) / Float64(l * l)), Float64(t_2 / cos(k)), Float64(fma(t_1, t_1, Float64(t_1 * t_1)) / Float64(cos(k) * Float64(l * l)))) * t)); else tmp = Float64(2.0 / Float64(Float64(Float64(k / l) * Float64(k / l)) * Float64(Float64(t * t_2) / cos(k)))); end return tmp end
code[t_, l_, k_] := Block[{t$95$1 = N[Power[N[(t * N[Sin[k], $MachinePrecision]), $MachinePrecision], 1.0], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[k], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[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], 2e+262], N[(2.0 / N[(N[(N[(N[(k * k), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision] * N[(t$95$2 / N[Cos[k], $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$1 * t$95$1 + N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[k], $MachinePrecision] * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(N[(k / l), $MachinePrecision] * N[(k / l), $MachinePrecision]), $MachinePrecision] * N[(N[(t * t$95$2), $MachinePrecision] / N[Cos[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := {\left(t \cdot \sin k\right)}^{1}\\
t_2 := {\sin k}^{2}\\
\mathbf{if}\;\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)} \leq 2 \cdot 10^{+262}:\\
\;\;\;\;\frac{2}{\mathsf{fma}\left(\frac{k \cdot k}{\ell \cdot \ell}, \frac{t\_2}{\cos k}, \frac{\mathsf{fma}\left(t\_1, t\_1, t\_1 \cdot t\_1\right)}{\cos k \cdot \left(\ell \cdot \ell\right)}\right) \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\left(\frac{k}{\ell} \cdot \frac{k}{\ell}\right) \cdot \frac{t \cdot t\_2}{\cos k}}\\
\end{array}
\end{array}
if (/.f64 #s(literal 2 binary64) (*.f64 (*.f64 (*.f64 (/.f64 (pow.f64 t #s(literal 3 binary64)) (*.f64 l l)) (sin.f64 k)) (tan.f64 k)) (+.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 k t) #s(literal 2 binary64))) #s(literal 1 binary64)))) < 2e262Initial program 81.2%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites86.0%
if 2e262 < (/.f64 #s(literal 2 binary64) (*.f64 (*.f64 (*.f64 (/.f64 (pow.f64 t #s(literal 3 binary64)) (*.f64 l l)) (sin.f64 k)) (tan.f64 k)) (+.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 k t) #s(literal 2 binary64))) #s(literal 1 binary64)))) Initial program 24.1%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites51.9%
Taylor expanded in t around 0
times-fracN/A
pow2N/A
pow2N/A
lower-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lift-cos.f6482.2
Applied rewrites82.2%
(FPCore (t l k)
:precision binary64
(if (<= k 2.75e-18)
(* (/ l k) (/ (/ l k) (pow t 3.0)))
(/
(fma (cos k) (* l l) (* (cos k) (* l l)))
(* (* k (* k t)) (pow (sin k) 2.0)))))
double code(double t, double l, double k) {
double tmp;
if (k <= 2.75e-18) {
tmp = (l / k) * ((l / k) / pow(t, 3.0));
} else {
tmp = fma(cos(k), (l * l), (cos(k) * (l * l))) / ((k * (k * t)) * pow(sin(k), 2.0));
}
return tmp;
}
function code(t, l, k) tmp = 0.0 if (k <= 2.75e-18) tmp = Float64(Float64(l / k) * Float64(Float64(l / k) / (t ^ 3.0))); else tmp = Float64(fma(cos(k), Float64(l * l), Float64(cos(k) * Float64(l * l))) / Float64(Float64(k * Float64(k * t)) * (sin(k) ^ 2.0))); end return tmp end
code[t_, l_, k_] := If[LessEqual[k, 2.75e-18], N[(N[(l / k), $MachinePrecision] * N[(N[(l / k), $MachinePrecision] / N[Power[t, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[k], $MachinePrecision] * N[(l * l), $MachinePrecision] + N[(N[Cos[k], $MachinePrecision] * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(k * N[(k * t), $MachinePrecision]), $MachinePrecision] * N[Power[N[Sin[k], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.75 \cdot 10^{-18}:\\
\;\;\;\;\frac{\ell}{k} \cdot \frac{\frac{\ell}{k}}{{t}^{3}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\cos k, \ell \cdot \ell, \cos k \cdot \left(\ell \cdot \ell\right)\right)}{\left(k \cdot \left(k \cdot t\right)\right) \cdot {\sin k}^{2}}\\
\end{array}
\end{array}
if k < 2.75e-18Initial program 58.6%
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 rewrites59.0%
Taylor expanded in k around 0
associate-/r*N/A
lower-/.f64N/A
pow2N/A
pow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lift-pow.f6467.7
Applied rewrites67.7%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-pow.f6468.3
Applied rewrites68.3%
if 2.75e-18 < k Initial program 39.8%
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.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6471.8
Applied rewrites71.8%
(FPCore (t l k) :precision binary64 (* (/ l k) (/ (/ l k) (pow t 3.0))))
double code(double t, double l, double k) {
return (l / k) * ((l / k) / pow(t, 3.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 = (l / k) * ((l / k) / (t ** 3.0d0))
end function
public static double code(double t, double l, double k) {
return (l / k) * ((l / k) / Math.pow(t, 3.0));
}
def code(t, l, k): return (l / k) * ((l / k) / math.pow(t, 3.0))
function code(t, l, k) return Float64(Float64(l / k) * Float64(Float64(l / k) / (t ^ 3.0))) end
function tmp = code(t, l, k) tmp = (l / k) * ((l / k) / (t ^ 3.0)); end
code[t_, l_, k_] := N[(N[(l / k), $MachinePrecision] * N[(N[(l / k), $MachinePrecision] / N[Power[t, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\ell}{k} \cdot \frac{\frac{\ell}{k}}{{t}^{3}}
\end{array}
Initial program 53.3%
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 rewrites61.7%
Taylor expanded in k around 0
associate-/r*N/A
lower-/.f64N/A
pow2N/A
pow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lift-pow.f6460.1
Applied rewrites60.1%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-pow.f6460.6
Applied rewrites60.6%
herbie shell --seed 2025066
(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))))