
(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}
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k)
:precision binary64
(let* ((t_2 (pow (sin k) 2.0)))
(*
t_s
(if (<= t_m 1.45e-129)
(* (* l (* l (/ (cos k) (* (* (* (* t_2 -1.0) t_m) k) k)))) -2.0)
(/ (* (/ (cos k) t_m) (* (pow (/ l k) 2.0) 2.0)) t_2)))))t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k) {
double t_2 = pow(sin(k), 2.0);
double tmp;
if (t_m <= 1.45e-129) {
tmp = (l * (l * (cos(k) / ((((t_2 * -1.0) * t_m) * k) * k)))) * -2.0;
} else {
tmp = ((cos(k) / t_m) * (pow((l / k), 2.0) * 2.0)) / t_2;
}
return t_s * tmp;
}
t\_m = private
t\_s = 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_s, t_m, l, k)
use fmin_fmax_functions
real(8), intent (in) :: t_s
real(8), intent (in) :: t_m
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8) :: t_2
real(8) :: tmp
t_2 = sin(k) ** 2.0d0
if (t_m <= 1.45d-129) then
tmp = (l * (l * (cos(k) / ((((t_2 * (-1.0d0)) * t_m) * k) * k)))) * (-2.0d0)
else
tmp = ((cos(k) / t_m) * (((l / k) ** 2.0d0) * 2.0d0)) / t_2
end if
code = t_s * tmp
end function
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k) {
double t_2 = Math.pow(Math.sin(k), 2.0);
double tmp;
if (t_m <= 1.45e-129) {
tmp = (l * (l * (Math.cos(k) / ((((t_2 * -1.0) * t_m) * k) * k)))) * -2.0;
} else {
tmp = ((Math.cos(k) / t_m) * (Math.pow((l / k), 2.0) * 2.0)) / t_2;
}
return t_s * tmp;
}
t\_m = math.fabs(t) t\_s = math.copysign(1.0, t) def code(t_s, t_m, l, k): t_2 = math.pow(math.sin(k), 2.0) tmp = 0 if t_m <= 1.45e-129: tmp = (l * (l * (math.cos(k) / ((((t_2 * -1.0) * t_m) * k) * k)))) * -2.0 else: tmp = ((math.cos(k) / t_m) * (math.pow((l / k), 2.0) * 2.0)) / t_2 return t_s * tmp
t\_m = abs(t) t\_s = copysign(1.0, t) function code(t_s, t_m, l, k) t_2 = sin(k) ^ 2.0 tmp = 0.0 if (t_m <= 1.45e-129) tmp = Float64(Float64(l * Float64(l * Float64(cos(k) / Float64(Float64(Float64(Float64(t_2 * -1.0) * t_m) * k) * k)))) * -2.0); else tmp = Float64(Float64(Float64(cos(k) / t_m) * Float64((Float64(l / k) ^ 2.0) * 2.0)) / t_2); end return Float64(t_s * tmp) end
t\_m = abs(t); t\_s = sign(t) * abs(1.0); function tmp_2 = code(t_s, t_m, l, k) t_2 = sin(k) ^ 2.0; tmp = 0.0; if (t_m <= 1.45e-129) tmp = (l * (l * (cos(k) / ((((t_2 * -1.0) * t_m) * k) * k)))) * -2.0; else tmp = ((cos(k) / t_m) * (((l / k) ^ 2.0) * 2.0)) / t_2; end tmp_2 = t_s * tmp; end
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k_] := Block[{t$95$2 = N[Power[N[Sin[k], $MachinePrecision], 2.0], $MachinePrecision]}, N[(t$95$s * If[LessEqual[t$95$m, 1.45e-129], N[(N[(l * N[(l * N[(N[Cos[k], $MachinePrecision] / N[(N[(N[(N[(t$95$2 * -1.0), $MachinePrecision] * t$95$m), $MachinePrecision] * k), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision], N[(N[(N[(N[Cos[k], $MachinePrecision] / t$95$m), $MachinePrecision] * N[(N[Power[N[(l / k), $MachinePrecision], 2.0], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)
\\
\begin{array}{l}
t_2 := {\sin k}^{2}\\
t\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_m \leq 1.45 \cdot 10^{-129}:\\
\;\;\;\;\left(\ell \cdot \left(\ell \cdot \frac{\cos k}{\left(\left(\left(t\_2 \cdot -1\right) \cdot t\_m\right) \cdot k\right) \cdot k}\right)\right) \cdot -2\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos k}{t\_m} \cdot \left({\left(\frac{\ell}{k}\right)}^{2} \cdot 2\right)}{t\_2}\\
\end{array}
\end{array}
\end{array}
if t < 1.45000000000000008e-129Initial program 27.0%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
sqr-powN/A
sqr-neg-revN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
metadata-evalN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
metadata-evalN/A
lower-neg.f648.2
Applied rewrites8.2%
lift-pow.f64N/A
sqr-powN/A
lower-*.f64N/A
lower-pow.f64N/A
metadata-evalN/A
lower-pow.f64N/A
metadata-eval8.2
Applied rewrites8.2%
Taylor expanded in t around -inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.2%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites85.3%
if 1.45000000000000008e-129 < t Initial program 46.7%
Taylor expanded in t around 0
associate-*r/N/A
associate-*r*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
pow2N/A
lift-*.f64N/A
lower-pow.f64N/A
lift-sin.f6475.9
Applied rewrites75.9%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
frac-timesN/A
pow2N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
associate-*r/N/A
Applied rewrites76.9%
lift-fma.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
Applied rewrites91.8%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites92.6%
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k)
:precision binary64
(let* ((t_2 (pow (sin k) 2.0)))
(*
t_s
(if (<= t_m 2.2e-129)
(* (* l (* l (/ (cos k) (* (* (* (* t_2 -1.0) t_m) k) k)))) -2.0)
(* (/ (/ (cos k) t_m) t_2) (fma (/ l k) (/ l k) (* (/ l k) (/ l k))))))))t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k) {
double t_2 = pow(sin(k), 2.0);
double tmp;
if (t_m <= 2.2e-129) {
tmp = (l * (l * (cos(k) / ((((t_2 * -1.0) * t_m) * k) * k)))) * -2.0;
} else {
tmp = ((cos(k) / t_m) / t_2) * fma((l / k), (l / k), ((l / k) * (l / k)));
}
return t_s * tmp;
}
t\_m = abs(t) t\_s = copysign(1.0, t) function code(t_s, t_m, l, k) t_2 = sin(k) ^ 2.0 tmp = 0.0 if (t_m <= 2.2e-129) tmp = Float64(Float64(l * Float64(l * Float64(cos(k) / Float64(Float64(Float64(Float64(t_2 * -1.0) * t_m) * k) * k)))) * -2.0); else tmp = Float64(Float64(Float64(cos(k) / t_m) / t_2) * fma(Float64(l / k), Float64(l / k), Float64(Float64(l / k) * Float64(l / k)))); end return Float64(t_s * tmp) end
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k_] := Block[{t$95$2 = N[Power[N[Sin[k], $MachinePrecision], 2.0], $MachinePrecision]}, N[(t$95$s * If[LessEqual[t$95$m, 2.2e-129], N[(N[(l * N[(l * N[(N[Cos[k], $MachinePrecision] / N[(N[(N[(N[(t$95$2 * -1.0), $MachinePrecision] * t$95$m), $MachinePrecision] * k), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision], N[(N[(N[(N[Cos[k], $MachinePrecision] / t$95$m), $MachinePrecision] / t$95$2), $MachinePrecision] * N[(N[(l / k), $MachinePrecision] * N[(l / k), $MachinePrecision] + N[(N[(l / k), $MachinePrecision] * N[(l / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)
\\
\begin{array}{l}
t_2 := {\sin k}^{2}\\
t\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_m \leq 2.2 \cdot 10^{-129}:\\
\;\;\;\;\left(\ell \cdot \left(\ell \cdot \frac{\cos k}{\left(\left(\left(t\_2 \cdot -1\right) \cdot t\_m\right) \cdot k\right) \cdot k}\right)\right) \cdot -2\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos k}{t\_m}}{t\_2} \cdot \mathsf{fma}\left(\frac{\ell}{k}, \frac{\ell}{k}, \frac{\ell}{k} \cdot \frac{\ell}{k}\right)\\
\end{array}
\end{array}
\end{array}
if t < 2.20000000000000003e-129Initial program 27.0%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
sqr-powN/A
sqr-neg-revN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
metadata-evalN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
metadata-evalN/A
lower-neg.f648.2
Applied rewrites8.2%
lift-pow.f64N/A
sqr-powN/A
lower-*.f64N/A
lower-pow.f64N/A
metadata-evalN/A
lower-pow.f64N/A
metadata-eval8.2
Applied rewrites8.2%
Taylor expanded in t around -inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.2%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites85.3%
if 2.20000000000000003e-129 < t Initial program 46.7%
Taylor expanded in t around 0
associate-*r/N/A
associate-*r*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
pow2N/A
lift-*.f64N/A
lower-pow.f64N/A
lift-sin.f6475.9
Applied rewrites75.9%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
frac-timesN/A
pow2N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
associate-*r/N/A
Applied rewrites76.9%
lift-fma.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
Applied rewrites91.8%
t\_m = (fabs.f64 t) t\_s = (copysign.f64 #s(literal 1 binary64) t) (FPCore (t_s t_m l k) :precision binary64 (* t_s (* (* l (* l (/ (cos k) (* (* (* (* (pow (sin k) 2.0) -1.0) t_m) k) k)))) -2.0)))
t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k) {
return t_s * ((l * (l * (cos(k) / ((((pow(sin(k), 2.0) * -1.0) * t_m) * k) * k)))) * -2.0);
}
t\_m = private
t\_s = 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_s, t_m, l, k)
use fmin_fmax_functions
real(8), intent (in) :: t_s
real(8), intent (in) :: t_m
real(8), intent (in) :: l
real(8), intent (in) :: k
code = t_s * ((l * (l * (cos(k) / (((((sin(k) ** 2.0d0) * (-1.0d0)) * t_m) * k) * k)))) * (-2.0d0))
end function
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k) {
return t_s * ((l * (l * (Math.cos(k) / ((((Math.pow(Math.sin(k), 2.0) * -1.0) * t_m) * k) * k)))) * -2.0);
}
t\_m = math.fabs(t) t\_s = math.copysign(1.0, t) def code(t_s, t_m, l, k): return t_s * ((l * (l * (math.cos(k) / ((((math.pow(math.sin(k), 2.0) * -1.0) * t_m) * k) * k)))) * -2.0)
t\_m = abs(t) t\_s = copysign(1.0, t) function code(t_s, t_m, l, k) return Float64(t_s * Float64(Float64(l * Float64(l * Float64(cos(k) / Float64(Float64(Float64(Float64((sin(k) ^ 2.0) * -1.0) * t_m) * k) * k)))) * -2.0)) end
t\_m = abs(t); t\_s = sign(t) * abs(1.0); function tmp = code(t_s, t_m, l, k) tmp = t_s * ((l * (l * (cos(k) / (((((sin(k) ^ 2.0) * -1.0) * t_m) * k) * k)))) * -2.0); end
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k_] := N[(t$95$s * N[(N[(l * N[(l * N[(N[Cos[k], $MachinePrecision] / N[(N[(N[(N[(N[Power[N[Sin[k], $MachinePrecision], 2.0], $MachinePrecision] * -1.0), $MachinePrecision] * t$95$m), $MachinePrecision] * k), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)
\\
t\_s \cdot \left(\left(\ell \cdot \left(\ell \cdot \frac{\cos k}{\left(\left(\left({\sin k}^{2} \cdot -1\right) \cdot t\_m\right) \cdot k\right) \cdot k}\right)\right) \cdot -2\right)
\end{array}
Initial program 34.4%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
sqr-powN/A
sqr-neg-revN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
metadata-evalN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
metadata-evalN/A
lower-neg.f6425.4
Applied rewrites25.4%
lift-pow.f64N/A
sqr-powN/A
lower-*.f64N/A
lower-pow.f64N/A
metadata-evalN/A
lower-pow.f64N/A
metadata-eval25.4
Applied rewrites25.4%
Taylor expanded in t around -inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites72.9%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites85.3%
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k)
:precision binary64
(let* ((t_2 (/ (* t_m t_m) (* k k)))
(t_3 (/ (cos k) (* (/ (/ (pow t_m 3.0) l) l) (pow (sin k) 2.0)))))
(* t_s (fma t_2 t_3 (* t_2 t_3)))))t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k) {
double t_2 = (t_m * t_m) / (k * k);
double t_3 = cos(k) / (((pow(t_m, 3.0) / l) / l) * pow(sin(k), 2.0));
return t_s * fma(t_2, t_3, (t_2 * t_3));
}
t\_m = abs(t) t\_s = copysign(1.0, t) function code(t_s, t_m, l, k) t_2 = Float64(Float64(t_m * t_m) / Float64(k * k)) t_3 = Float64(cos(k) / Float64(Float64(Float64((t_m ^ 3.0) / l) / l) * (sin(k) ^ 2.0))) return Float64(t_s * fma(t_2, t_3, Float64(t_2 * t_3))) end
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k_] := Block[{t$95$2 = N[(N[(t$95$m * t$95$m), $MachinePrecision] / N[(k * k), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[k], $MachinePrecision] / N[(N[(N[(N[Power[t$95$m, 3.0], $MachinePrecision] / l), $MachinePrecision] / l), $MachinePrecision] * N[Power[N[Sin[k], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(t$95$s * N[(t$95$2 * t$95$3 + N[(t$95$2 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)
\\
\begin{array}{l}
t_2 := \frac{t\_m \cdot t\_m}{k \cdot k}\\
t_3 := \frac{\cos k}{\frac{\frac{{t\_m}^{3}}{\ell}}{\ell} \cdot {\sin k}^{2}}\\
t\_s \cdot \mathsf{fma}\left(t\_2, t\_3, t\_2 \cdot t\_3\right)
\end{array}
\end{array}
Initial program 34.4%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-to-expN/A
pow2N/A
pow-to-expN/A
div-expN/A
lower-exp.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f6410.4
Applied rewrites10.4%
Taylor expanded in t around 0
count-2-revN/A
times-fracN/A
lower-fma.f64N/A
Applied rewrites33.8%
Final simplification33.8%
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k)
:precision binary64
(let* ((t_2 (/ (/ (pow t_m 3.0) l) l)))
(*
t_s
(/
(fma
(* (* k k) (/ (* t_m t_m) t_2))
-0.3333333333333333
(/ (* 2.0 (* t_m t_m)) t_2))
(pow (* k k) 2.0)))))t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k) {
double t_2 = (pow(t_m, 3.0) / l) / l;
return t_s * (fma(((k * k) * ((t_m * t_m) / t_2)), -0.3333333333333333, ((2.0 * (t_m * t_m)) / t_2)) / pow((k * k), 2.0));
}
t\_m = abs(t) t\_s = copysign(1.0, t) function code(t_s, t_m, l, k) t_2 = Float64(Float64((t_m ^ 3.0) / l) / l) return Float64(t_s * Float64(fma(Float64(Float64(k * k) * Float64(Float64(t_m * t_m) / t_2)), -0.3333333333333333, Float64(Float64(2.0 * Float64(t_m * t_m)) / t_2)) / (Float64(k * k) ^ 2.0))) end
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k_] := Block[{t$95$2 = N[(N[(N[Power[t$95$m, 3.0], $MachinePrecision] / l), $MachinePrecision] / l), $MachinePrecision]}, N[(t$95$s * N[(N[(N[(N[(k * k), $MachinePrecision] * N[(N[(t$95$m * t$95$m), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision] * -0.3333333333333333 + N[(N[(2.0 * N[(t$95$m * t$95$m), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision] / N[Power[N[(k * k), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)
\\
\begin{array}{l}
t_2 := \frac{\frac{{t\_m}^{3}}{\ell}}{\ell}\\
t\_s \cdot \frac{\mathsf{fma}\left(\left(k \cdot k\right) \cdot \frac{t\_m \cdot t\_m}{t\_2}, -0.3333333333333333, \frac{2 \cdot \left(t\_m \cdot t\_m\right)}{t\_2}\right)}{{\left(k \cdot k\right)}^{2}}
\end{array}
\end{array}
Initial program 34.4%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-to-expN/A
pow2N/A
pow-to-expN/A
div-expN/A
lower-exp.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f6410.4
Applied rewrites10.4%
Taylor expanded in k around 0
lower-/.f64N/A
Applied rewrites11.6%
Final simplification11.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))))