
(FPCore (x c s) :precision binary64 (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))
double code(double x, double c, double s) {
return cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x));
}
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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))
end function
public static double code(double x, double c, double s) {
return Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x));
}
def code(x, c, s): return math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))
function code(x, c, s) return Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) end
function tmp = code(x, c, s) tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x)); end
code[x_, c_, s_] := N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x c s) :precision binary64 (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))
double code(double x, double c, double s) {
return cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x));
}
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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))
end function
public static double code(double x, double c, double s) {
return Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x));
}
def code(x, c, s): return math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))
function code(x, c, s) return Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) end
function tmp = code(x, c, s) tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x)); end
code[x_, c_, s_] := N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\end{array}
(FPCore (x c s) :precision binary64 (let* ((t_0 (* (* c s) x))) (/ (cos (+ x x)) (* t_0 t_0))))
double code(double x, double c, double s) {
double t_0 = (c * s) * x;
return cos((x + x)) / (t_0 * t_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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = (c * s) * x
code = cos((x + x)) / (t_0 * t_0)
end function
public static double code(double x, double c, double s) {
double t_0 = (c * s) * x;
return Math.cos((x + x)) / (t_0 * t_0);
}
def code(x, c, s): t_0 = (c * s) * x return math.cos((x + x)) / (t_0 * t_0)
function code(x, c, s) t_0 = Float64(Float64(c * s) * x) return Float64(cos(Float64(x + x)) / Float64(t_0 * t_0)) end
function tmp = code(x, c, s) t_0 = (c * s) * x; tmp = cos((x + x)) / (t_0 * t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(c * s), $MachinePrecision] * x), $MachinePrecision]}, N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(c \cdot s\right) \cdot x\\
\frac{\cos \left(x + x\right)}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 69.0%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
pow-prod-downN/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6498.2
Applied rewrites98.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6498.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.2
Applied rewrites98.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6498.2
Applied rewrites98.2%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (* (* c s) x)) (t_1 (* t_0 t_0)))
(if (<= (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))) -2e-194)
(/ (* (* x x) -2.0) t_1)
(/ 1.0 t_1))))
double code(double x, double c, double s) {
double t_0 = (c * s) * x;
double t_1 = t_0 * t_0;
double tmp;
if ((cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x))) <= -2e-194) {
tmp = ((x * x) * -2.0) / t_1;
} else {
tmp = 1.0 / t_1;
}
return tmp;
}
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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (c * s) * x
t_1 = t_0 * t_0
if ((cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))) <= (-2d-194)) then
tmp = ((x * x) * (-2.0d0)) / t_1
else
tmp = 1.0d0 / t_1
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = (c * s) * x;
double t_1 = t_0 * t_0;
double tmp;
if ((Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x))) <= -2e-194) {
tmp = ((x * x) * -2.0) / t_1;
} else {
tmp = 1.0 / t_1;
}
return tmp;
}
def code(x, c, s): t_0 = (c * s) * x t_1 = t_0 * t_0 tmp = 0 if (math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))) <= -2e-194: tmp = ((x * x) * -2.0) / t_1 else: tmp = 1.0 / t_1 return tmp
function code(x, c, s) t_0 = Float64(Float64(c * s) * x) t_1 = Float64(t_0 * t_0) tmp = 0.0 if (Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) <= -2e-194) tmp = Float64(Float64(Float64(x * x) * -2.0) / t_1); else tmp = Float64(1.0 / t_1); end return tmp end
function tmp_2 = code(x, c, s) t_0 = (c * s) * x; t_1 = t_0 * t_0; tmp = 0.0; if ((cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x))) <= -2e-194) tmp = ((x * x) * -2.0) / t_1; else tmp = 1.0 / t_1; end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(c * s), $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * t$95$0), $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-194], N[(N[(N[(x * x), $MachinePrecision] * -2.0), $MachinePrecision] / t$95$1), $MachinePrecision], N[(1.0 / t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(c \cdot s\right) \cdot x\\
t_1 := t\_0 \cdot t\_0\\
\mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \leq -2 \cdot 10^{-194}:\\
\;\;\;\;\frac{\left(x \cdot x\right) \cdot -2}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t\_1}\\
\end{array}
\end{array}
if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < -2.00000000000000004e-194Initial program 66.3%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
pow-prod-downN/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6496.0
Applied rewrites96.0%
lift-pow.f64N/A
unpow2N/A
lower-*.f6496.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6496.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6496.0
Applied rewrites96.0%
Taylor expanded in x around 0
cos-neg-revN/A
distribute-lft-neg-inN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6437.6
Applied rewrites37.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6437.6
Applied rewrites37.6%
if -2.00000000000000004e-194 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) Initial program 69.4%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
pow-prod-downN/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6498.5
Applied rewrites98.5%
lift-pow.f64N/A
unpow2N/A
lower-*.f6498.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.5
Applied rewrites98.5%
Taylor expanded in x around 0
cos-neg-revN/A
distribute-lft-neg-inN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6463.1
Applied rewrites63.1%
Taylor expanded in x around 0
Applied rewrites86.5%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (* (* s x) c)) (t_1 (* (* c x) s)))
(if (<= x 0.0205)
(/ (/ (fma (* x x) -2.0 1.0) t_0) t_0)
(if (<= x 2.25e+148)
(/ (cos (+ x x)) (* (* (* c c) (* x x)) (* s s)))
(/ 1.0 (* t_1 t_1))))))
double code(double x, double c, double s) {
double t_0 = (s * x) * c;
double t_1 = (c * x) * s;
double tmp;
if (x <= 0.0205) {
tmp = (fma((x * x), -2.0, 1.0) / t_0) / t_0;
} else if (x <= 2.25e+148) {
tmp = cos((x + x)) / (((c * c) * (x * x)) * (s * s));
} else {
tmp = 1.0 / (t_1 * t_1);
}
return tmp;
}
function code(x, c, s) t_0 = Float64(Float64(s * x) * c) t_1 = Float64(Float64(c * x) * s) tmp = 0.0 if (x <= 0.0205) tmp = Float64(Float64(fma(Float64(x * x), -2.0, 1.0) / t_0) / t_0); elseif (x <= 2.25e+148) tmp = Float64(cos(Float64(x + x)) / Float64(Float64(Float64(c * c) * Float64(x * x)) * Float64(s * s))); else tmp = Float64(1.0 / Float64(t_1 * t_1)); end return tmp end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(s * x), $MachinePrecision] * c), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * x), $MachinePrecision] * s), $MachinePrecision]}, If[LessEqual[x, 0.0205], N[(N[(N[(N[(x * x), $MachinePrecision] * -2.0 + 1.0), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[x, 2.25e+148], N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(N[(N[(c * c), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(s \cdot x\right) \cdot c\\
t_1 := \left(c \cdot x\right) \cdot s\\
\mathbf{if}\;x \leq 0.0205:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(x \cdot x, -2, 1\right)}{t\_0}}{t\_0}\\
\mathbf{elif}\;x \leq 2.25 \cdot 10^{+148}:\\
\;\;\;\;\frac{\cos \left(x + x\right)}{\left(\left(c \cdot c\right) \cdot \left(x \cdot x\right)\right) \cdot \left(s \cdot s\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t\_1 \cdot t\_1}\\
\end{array}
\end{array}
if x < 0.0205000000000000009Initial program 67.5%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
pow-prod-downN/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6498.6
Applied rewrites98.6%
lift-pow.f64N/A
unpow2N/A
lower-*.f6498.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.6
Applied rewrites98.6%
Taylor expanded in x around 0
cos-neg-revN/A
distribute-lft-neg-inN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6475.0
Applied rewrites75.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.1
cos-neg-rev73.1
distribute-lft-neg-in73.1
metadata-eval73.1
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
Applied rewrites73.1%
if 0.0205000000000000009 < x < 2.24999999999999997e148Initial program 78.9%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6476.5
Applied rewrites76.5%
lift-*.f64N/A
count-2-revN/A
lower-+.f6476.5
Applied rewrites76.5%
if 2.24999999999999997e148 < x Initial program 68.0%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6447.9
Applied rewrites47.9%
Taylor expanded in x around 0
metadata-eval47.9
distribute-lft-neg-in47.9
cos-neg-rev47.9
Applied rewrites47.9%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
unswap-sqrN/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f6459.7
Applied rewrites59.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-*.f64N/A
lift-*.f6460.5
Applied rewrites60.5%
(FPCore (x c s) :precision binary64 (/ (cos (+ x x)) (* (* (* c s) x) (* s (* c x)))))
double code(double x, double c, double s) {
return cos((x + x)) / (((c * s) * x) * (s * (c * x)));
}
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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = cos((x + x)) / (((c * s) * x) * (s * (c * x)))
end function
public static double code(double x, double c, double s) {
return Math.cos((x + x)) / (((c * s) * x) * (s * (c * x)));
}
def code(x, c, s): return math.cos((x + x)) / (((c * s) * x) * (s * (c * x)))
function code(x, c, s) return Float64(cos(Float64(x + x)) / Float64(Float64(Float64(c * s) * x) * Float64(s * Float64(c * x)))) end
function tmp = code(x, c, s) tmp = cos((x + x)) / (((c * s) * x) * (s * (c * x))); end
code[x_, c_, s_] := N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(N[(N[(c * s), $MachinePrecision] * x), $MachinePrecision] * N[(s * N[(c * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos \left(x + x\right)}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \left(s \cdot \left(c \cdot x\right)\right)}
\end{array}
Initial program 69.0%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
pow-prod-downN/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6498.2
Applied rewrites98.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6498.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.2
Applied rewrites98.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6498.2
Applied rewrites98.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f6496.1
Applied rewrites96.1%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* (* c s) x))) (/ 1.0 (* t_0 t_0))))
double code(double x, double c, double s) {
double t_0 = (c * s) * x;
return 1.0 / (t_0 * t_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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = (c * s) * x
code = 1.0d0 / (t_0 * t_0)
end function
public static double code(double x, double c, double s) {
double t_0 = (c * s) * x;
return 1.0 / (t_0 * t_0);
}
def code(x, c, s): t_0 = (c * s) * x return 1.0 / (t_0 * t_0)
function code(x, c, s) t_0 = Float64(Float64(c * s) * x) return Float64(1.0 / Float64(t_0 * t_0)) end
function tmp = code(x, c, s) t_0 = (c * s) * x; tmp = 1.0 / (t_0 * t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(c * s), $MachinePrecision] * x), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(c \cdot s\right) \cdot x\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 69.0%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
pow-prod-downN/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6498.2
Applied rewrites98.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6498.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.2
Applied rewrites98.2%
Taylor expanded in x around 0
cos-neg-revN/A
distribute-lft-neg-inN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6460.2
Applied rewrites60.2%
Taylor expanded in x around 0
Applied rewrites76.8%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* (* c x) s))) (/ 1.0 (* t_0 t_0))))
double code(double x, double c, double s) {
double t_0 = (c * x) * s;
return 1.0 / (t_0 * t_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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = (c * x) * s
code = 1.0d0 / (t_0 * t_0)
end function
public static double code(double x, double c, double s) {
double t_0 = (c * x) * s;
return 1.0 / (t_0 * t_0);
}
def code(x, c, s): t_0 = (c * x) * s return 1.0 / (t_0 * t_0)
function code(x, c, s) t_0 = Float64(Float64(c * x) * s) return Float64(1.0 / Float64(t_0 * t_0)) end
function tmp = code(x, c, s) t_0 = (c * x) * s; tmp = 1.0 / (t_0 * t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(c * x), $MachinePrecision] * s), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(c \cdot x\right) \cdot s\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 69.0%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6458.9
Applied rewrites58.9%
Taylor expanded in x around 0
metadata-eval52.5
distribute-lft-neg-in52.5
cos-neg-rev52.5
Applied rewrites52.5%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
unswap-sqrN/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f6467.1
Applied rewrites67.1%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-*.f64N/A
lift-*.f6476.7
Applied rewrites76.7%
(FPCore (x c s) :precision binary64 (/ 1.0 (* (* c x) (* (* c x) (* s s)))))
double code(double x, double c, double s) {
return 1.0 / ((c * x) * ((c * x) * (s * s)));
}
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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = 1.0d0 / ((c * x) * ((c * x) * (s * s)))
end function
public static double code(double x, double c, double s) {
return 1.0 / ((c * x) * ((c * x) * (s * s)));
}
def code(x, c, s): return 1.0 / ((c * x) * ((c * x) * (s * s)))
function code(x, c, s) return Float64(1.0 / Float64(Float64(c * x) * Float64(Float64(c * x) * Float64(s * s)))) end
function tmp = code(x, c, s) tmp = 1.0 / ((c * x) * ((c * x) * (s * s))); end
code[x_, c_, s_] := N[(1.0 / N[(N[(c * x), $MachinePrecision] * N[(N[(c * x), $MachinePrecision] * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\left(c \cdot x\right) \cdot \left(\left(c \cdot x\right) \cdot \left(s \cdot s\right)\right)}
\end{array}
Initial program 69.0%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6458.9
Applied rewrites58.9%
Taylor expanded in x around 0
metadata-eval52.5
distribute-lft-neg-in52.5
cos-neg-rev52.5
Applied rewrites52.5%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
unswap-sqrN/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f6467.1
Applied rewrites67.1%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f6468.2
Applied rewrites68.2%
herbie shell --seed 2025064
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))