
(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));
}
real(8) function code(x, c, s)
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 13 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));
}
real(8) function code(x, c, s)
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}
s_m = (fabs.f64 s)
c_m = (fabs.f64 c)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
:precision binary64
(let* ((t_0 (cos (* -2.0 x))) (t_1 (* (* c_m s_m) x)))
(if (<= c_m 5.2e-34)
(/ (/ t_0 t_1) t_1)
(/ (/ (/ t_0 (* c_m c_m)) (* s_m x)) (* s_m x)))))s_m = fabs(s);
c_m = fabs(c);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double t_0 = cos((-2.0 * x));
double t_1 = (c_m * s_m) * x;
double tmp;
if (c_m <= 5.2e-34) {
tmp = (t_0 / t_1) / t_1;
} else {
tmp = ((t_0 / (c_m * c_m)) / (s_m * x)) / (s_m * x);
}
return tmp;
}
s_m = abs(s)
c_m = abs(c)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(((-2.0d0) * x))
t_1 = (c_m * s_m) * x
if (c_m <= 5.2d-34) then
tmp = (t_0 / t_1) / t_1
else
tmp = ((t_0 / (c_m * c_m)) / (s_m * x)) / (s_m * x)
end if
code = tmp
end function
s_m = Math.abs(s);
c_m = Math.abs(c);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
double t_0 = Math.cos((-2.0 * x));
double t_1 = (c_m * s_m) * x;
double tmp;
if (c_m <= 5.2e-34) {
tmp = (t_0 / t_1) / t_1;
} else {
tmp = ((t_0 / (c_m * c_m)) / (s_m * x)) / (s_m * x);
}
return tmp;
}
s_m = math.fabs(s) c_m = math.fabs(c) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): t_0 = math.cos((-2.0 * x)) t_1 = (c_m * s_m) * x tmp = 0 if c_m <= 5.2e-34: tmp = (t_0 / t_1) / t_1 else: tmp = ((t_0 / (c_m * c_m)) / (s_m * x)) / (s_m * x) return tmp
s_m = abs(s) c_m = abs(c) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = cos(Float64(-2.0 * x)) t_1 = Float64(Float64(c_m * s_m) * x) tmp = 0.0 if (c_m <= 5.2e-34) tmp = Float64(Float64(t_0 / t_1) / t_1); else tmp = Float64(Float64(Float64(t_0 / Float64(c_m * c_m)) / Float64(s_m * x)) / Float64(s_m * x)); end return tmp end
s_m = abs(s);
c_m = abs(c);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp_2 = code(x, c_m, s_m)
t_0 = cos((-2.0 * x));
t_1 = (c_m * s_m) * x;
tmp = 0.0;
if (c_m <= 5.2e-34)
tmp = (t_0 / t_1) / t_1;
else
tmp = ((t_0 / (c_m * c_m)) / (s_m * x)) / (s_m * x);
end
tmp_2 = tmp;
end
s_m = N[Abs[s], $MachinePrecision]
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[Cos[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(c$95$m * s$95$m), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[c$95$m, 5.2e-34], N[(N[(t$95$0 / t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(N[(t$95$0 / N[(c$95$m * c$95$m), $MachinePrecision]), $MachinePrecision] / N[(s$95$m * x), $MachinePrecision]), $MachinePrecision] / N[(s$95$m * x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
s_m = \left|s\right|
\\
c_m = \left|c\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := \cos \left(-2 \cdot x\right)\\
t_1 := \left(c\_m \cdot s\_m\right) \cdot x\\
\mathbf{if}\;c\_m \leq 5.2 \cdot 10^{-34}:\\
\;\;\;\;\frac{\frac{t\_0}{t\_1}}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{t\_0}{c\_m \cdot c\_m}}{s\_m \cdot x}}{s\_m \cdot x}\\
\end{array}
\end{array}
if c < 5.1999999999999999e-34Initial program 68.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f6488.5
Applied rewrites88.5%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6496.1
lift-*.f64N/A
*-commutativeN/A
lift-*.f6496.1
lift-*.f64N/A
*-commutativeN/A
lift-*.f6496.1
Applied rewrites96.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-cos.f64N/A
sin-+PI/2-revN/A
lift-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
sin-+PI/2-revN/A
cos-neg-revN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
Applied rewrites98.1%
if 5.1999999999999999e-34 < c Initial program 73.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites84.5%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6491.9
lift-*.f64N/A
*-commutativeN/A
lift-*.f6491.9
lift-*.f64N/A
*-commutativeN/A
lift-*.f6491.9
Applied rewrites91.9%
Taylor expanded in x around inf
associate-/r*N/A
cos-neg-revN/A
cos-neg-revN/A
distribute-lft-neg-inN/A
metadata-evalN/A
cos-neg-revN/A
cos-neg-revN/A
metadata-evalN/A
distribute-lft-neg-inN/A
cos-neg-revN/A
cos-neg-revN/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites89.7%
s_m = (fabs.f64 s)
c_m = (fabs.f64 c)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
:precision binary64
(if (<=
(/ (cos (* 2.0 x)) (* (pow c_m 2.0) (* (* x (pow s_m 2.0)) x)))
-5e-227)
(/ (- (pow (* x x) -1.0) 2.0) (* (* (* s_m c_m) c_m) s_m))
(/ 1.0 (* (* (* x (* s_m c_m)) (* s_m c_m)) x))))s_m = fabs(s);
c_m = fabs(c);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double tmp;
if ((cos((2.0 * x)) / (pow(c_m, 2.0) * ((x * pow(s_m, 2.0)) * x))) <= -5e-227) {
tmp = (pow((x * x), -1.0) - 2.0) / (((s_m * c_m) * c_m) * s_m);
} else {
tmp = 1.0 / (((x * (s_m * c_m)) * (s_m * c_m)) * x);
}
return tmp;
}
s_m = abs(s)
c_m = abs(c)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: tmp
if ((cos((2.0d0 * x)) / ((c_m ** 2.0d0) * ((x * (s_m ** 2.0d0)) * x))) <= (-5d-227)) then
tmp = (((x * x) ** (-1.0d0)) - 2.0d0) / (((s_m * c_m) * c_m) * s_m)
else
tmp = 1.0d0 / (((x * (s_m * c_m)) * (s_m * c_m)) * x)
end if
code = tmp
end function
s_m = Math.abs(s);
c_m = Math.abs(c);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
double tmp;
if ((Math.cos((2.0 * x)) / (Math.pow(c_m, 2.0) * ((x * Math.pow(s_m, 2.0)) * x))) <= -5e-227) {
tmp = (Math.pow((x * x), -1.0) - 2.0) / (((s_m * c_m) * c_m) * s_m);
} else {
tmp = 1.0 / (((x * (s_m * c_m)) * (s_m * c_m)) * x);
}
return tmp;
}
s_m = math.fabs(s) c_m = math.fabs(c) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): tmp = 0 if (math.cos((2.0 * x)) / (math.pow(c_m, 2.0) * ((x * math.pow(s_m, 2.0)) * x))) <= -5e-227: tmp = (math.pow((x * x), -1.0) - 2.0) / (((s_m * c_m) * c_m) * s_m) else: tmp = 1.0 / (((x * (s_m * c_m)) * (s_m * c_m)) * x) return tmp
s_m = abs(s) c_m = abs(c) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) tmp = 0.0 if (Float64(cos(Float64(2.0 * x)) / Float64((c_m ^ 2.0) * Float64(Float64(x * (s_m ^ 2.0)) * x))) <= -5e-227) tmp = Float64(Float64((Float64(x * x) ^ -1.0) - 2.0) / Float64(Float64(Float64(s_m * c_m) * c_m) * s_m)); else tmp = Float64(1.0 / Float64(Float64(Float64(x * Float64(s_m * c_m)) * Float64(s_m * c_m)) * x)); end return tmp end
s_m = abs(s);
c_m = abs(c);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp_2 = code(x, c_m, s_m)
tmp = 0.0;
if ((cos((2.0 * x)) / ((c_m ^ 2.0) * ((x * (s_m ^ 2.0)) * x))) <= -5e-227)
tmp = (((x * x) ^ -1.0) - 2.0) / (((s_m * c_m) * c_m) * s_m);
else
tmp = 1.0 / (((x * (s_m * c_m)) * (s_m * c_m)) * x);
end
tmp_2 = tmp;
end
s_m = N[Abs[s], $MachinePrecision] c_m = N[Abs[c], $MachinePrecision] NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. code[x_, c$95$m_, s$95$m_] := If[LessEqual[N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c$95$m, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s$95$m, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-227], N[(N[(N[Power[N[(x * x), $MachinePrecision], -1.0], $MachinePrecision] - 2.0), $MachinePrecision] / N[(N[(N[(s$95$m * c$95$m), $MachinePrecision] * c$95$m), $MachinePrecision] * s$95$m), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(x * N[(s$95$m * c$95$m), $MachinePrecision]), $MachinePrecision] * N[(s$95$m * c$95$m), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
s_m = \left|s\right|
\\
c_m = \left|c\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c\_m}^{2} \cdot \left(\left(x \cdot {s\_m}^{2}\right) \cdot x\right)} \leq -5 \cdot 10^{-227}:\\
\;\;\;\;\frac{{\left(x \cdot x\right)}^{-1} - 2}{\left(\left(s\_m \cdot c\_m\right) \cdot c\_m\right) \cdot s\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(x \cdot \left(s\_m \cdot c\_m\right)\right) \cdot \left(s\_m \cdot c\_m\right)\right) \cdot x}\\
\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))) < -4.99999999999999961e-227Initial program 79.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites84.6%
Taylor expanded in x around 0
associate-*r/N/A
div-add-revN/A
+-commutativeN/A
associate-/r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-/r*N/A
Applied rewrites40.4%
if -4.99999999999999961e-227 < (/.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 68.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f6487.7
Applied rewrites87.7%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6495.0
lift-*.f64N/A
*-commutativeN/A
lift-*.f6495.0
lift-*.f64N/A
*-commutativeN/A
lift-*.f6495.0
Applied rewrites95.0%
Taylor expanded in x around 0
Applied rewrites83.8%
Final simplification80.6%
s_m = (fabs.f64 s)
c_m = (fabs.f64 c)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
:precision binary64
(if (<=
(/ (cos (* 2.0 x)) (* (pow c_m 2.0) (* (* x (pow s_m 2.0)) x)))
-5e-227)
(/ 2.0 (* (* (* (- c_m) s_m) s_m) c_m))
(/ 1.0 (* (* (* x (* s_m c_m)) (* s_m c_m)) x))))s_m = fabs(s);
c_m = fabs(c);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double tmp;
if ((cos((2.0 * x)) / (pow(c_m, 2.0) * ((x * pow(s_m, 2.0)) * x))) <= -5e-227) {
tmp = 2.0 / (((-c_m * s_m) * s_m) * c_m);
} else {
tmp = 1.0 / (((x * (s_m * c_m)) * (s_m * c_m)) * x);
}
return tmp;
}
s_m = abs(s)
c_m = abs(c)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: tmp
if ((cos((2.0d0 * x)) / ((c_m ** 2.0d0) * ((x * (s_m ** 2.0d0)) * x))) <= (-5d-227)) then
tmp = 2.0d0 / (((-c_m * s_m) * s_m) * c_m)
else
tmp = 1.0d0 / (((x * (s_m * c_m)) * (s_m * c_m)) * x)
end if
code = tmp
end function
s_m = Math.abs(s);
c_m = Math.abs(c);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
double tmp;
if ((Math.cos((2.0 * x)) / (Math.pow(c_m, 2.0) * ((x * Math.pow(s_m, 2.0)) * x))) <= -5e-227) {
tmp = 2.0 / (((-c_m * s_m) * s_m) * c_m);
} else {
tmp = 1.0 / (((x * (s_m * c_m)) * (s_m * c_m)) * x);
}
return tmp;
}
s_m = math.fabs(s) c_m = math.fabs(c) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): tmp = 0 if (math.cos((2.0 * x)) / (math.pow(c_m, 2.0) * ((x * math.pow(s_m, 2.0)) * x))) <= -5e-227: tmp = 2.0 / (((-c_m * s_m) * s_m) * c_m) else: tmp = 1.0 / (((x * (s_m * c_m)) * (s_m * c_m)) * x) return tmp
s_m = abs(s) c_m = abs(c) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) tmp = 0.0 if (Float64(cos(Float64(2.0 * x)) / Float64((c_m ^ 2.0) * Float64(Float64(x * (s_m ^ 2.0)) * x))) <= -5e-227) tmp = Float64(2.0 / Float64(Float64(Float64(Float64(-c_m) * s_m) * s_m) * c_m)); else tmp = Float64(1.0 / Float64(Float64(Float64(x * Float64(s_m * c_m)) * Float64(s_m * c_m)) * x)); end return tmp end
s_m = abs(s);
c_m = abs(c);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp_2 = code(x, c_m, s_m)
tmp = 0.0;
if ((cos((2.0 * x)) / ((c_m ^ 2.0) * ((x * (s_m ^ 2.0)) * x))) <= -5e-227)
tmp = 2.0 / (((-c_m * s_m) * s_m) * c_m);
else
tmp = 1.0 / (((x * (s_m * c_m)) * (s_m * c_m)) * x);
end
tmp_2 = tmp;
end
s_m = N[Abs[s], $MachinePrecision] c_m = N[Abs[c], $MachinePrecision] NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. code[x_, c$95$m_, s$95$m_] := If[LessEqual[N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c$95$m, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s$95$m, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-227], N[(2.0 / N[(N[(N[((-c$95$m) * s$95$m), $MachinePrecision] * s$95$m), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(x * N[(s$95$m * c$95$m), $MachinePrecision]), $MachinePrecision] * N[(s$95$m * c$95$m), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
s_m = \left|s\right|
\\
c_m = \left|c\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c\_m}^{2} \cdot \left(\left(x \cdot {s\_m}^{2}\right) \cdot x\right)} \leq -5 \cdot 10^{-227}:\\
\;\;\;\;\frac{2}{\left(\left(\left(-c\_m\right) \cdot s\_m\right) \cdot s\_m\right) \cdot c\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(x \cdot \left(s\_m \cdot c\_m\right)\right) \cdot \left(s\_m \cdot c\_m\right)\right) \cdot x}\\
\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))) < -4.99999999999999961e-227Initial program 79.6%
Taylor expanded in x around 0
associate-*r/N/A
div-add-revN/A
+-commutativeN/A
associate-/l/N/A
associate-*r*N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
associate-*r*N/A
Applied rewrites34.3%
Taylor expanded in x around inf
Applied rewrites40.4%
Applied rewrites40.4%
Taylor expanded in c around 0
Applied rewrites40.4%
if -4.99999999999999961e-227 < (/.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 68.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f6487.7
Applied rewrites87.7%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6495.0
lift-*.f64N/A
*-commutativeN/A
lift-*.f6495.0
lift-*.f64N/A
*-commutativeN/A
lift-*.f6495.0
Applied rewrites95.0%
Taylor expanded in x around 0
Applied rewrites83.8%
s_m = (fabs.f64 s)
c_m = (fabs.f64 c)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
:precision binary64
(let* ((t_0 (* (* s_m x) c_m)))
(if (<= x 7.2e+42)
(/ (fma -2.0 (* x x) 1.0) (* t_0 t_0))
(pow (pow (* (* c_m x) s_m) 2.0) -1.0))))s_m = fabs(s);
c_m = fabs(c);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double t_0 = (s_m * x) * c_m;
double tmp;
if (x <= 7.2e+42) {
tmp = fma(-2.0, (x * x), 1.0) / (t_0 * t_0);
} else {
tmp = pow(pow(((c_m * x) * s_m), 2.0), -1.0);
}
return tmp;
}
s_m = abs(s) c_m = abs(c) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(Float64(s_m * x) * c_m) tmp = 0.0 if (x <= 7.2e+42) tmp = Float64(fma(-2.0, Float64(x * x), 1.0) / Float64(t_0 * t_0)); else tmp = (Float64(Float64(c_m * x) * s_m) ^ 2.0) ^ -1.0; end return tmp end
s_m = N[Abs[s], $MachinePrecision]
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(N[(s$95$m * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, If[LessEqual[x, 7.2e+42], N[(N[(-2.0 * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[Power[N[Power[N[(N[(c$95$m * x), $MachinePrecision] * s$95$m), $MachinePrecision], 2.0], $MachinePrecision], -1.0], $MachinePrecision]]]
\begin{array}{l}
s_m = \left|s\right|
\\
c_m = \left|c\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := \left(s\_m \cdot x\right) \cdot c\_m\\
\mathbf{if}\;x \leq 7.2 \cdot 10^{+42}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-2, x \cdot x, 1\right)}{t\_0 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;{\left({\left(\left(c\_m \cdot x\right) \cdot s\_m\right)}^{2}\right)}^{-1}\\
\end{array}
\end{array}
if x < 7.2000000000000002e42Initial program 70.3%
Taylor expanded in x around 0
associate-*r/N/A
div-add-revN/A
+-commutativeN/A
associate-/l/N/A
associate-*r*N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
associate-*r*N/A
Applied rewrites59.0%
Applied rewrites73.2%
Applied rewrites75.0%
if 7.2000000000000002e42 < x Initial program 66.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites87.7%
Taylor expanded in x around 0
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6461.7
Applied rewrites61.7%
Applied rewrites62.8%
Final simplification72.3%
s_m = (fabs.f64 s)
c_m = (fabs.f64 c)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
:precision binary64
(let* ((t_0 (* (* c_m s_m) x)))
(if (<= c_m 1.7e+62)
(/ (/ (cos (* -2.0 x)) t_0) t_0)
(/ (pow (* (* (* c_m c_m) x) (* s_m x)) -1.0) s_m))))s_m = fabs(s);
c_m = fabs(c);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double t_0 = (c_m * s_m) * x;
double tmp;
if (c_m <= 1.7e+62) {
tmp = (cos((-2.0 * x)) / t_0) / t_0;
} else {
tmp = pow((((c_m * c_m) * x) * (s_m * x)), -1.0) / s_m;
}
return tmp;
}
s_m = abs(s)
c_m = abs(c)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
real(8) :: tmp
t_0 = (c_m * s_m) * x
if (c_m <= 1.7d+62) then
tmp = (cos(((-2.0d0) * x)) / t_0) / t_0
else
tmp = ((((c_m * c_m) * x) * (s_m * x)) ** (-1.0d0)) / s_m
end if
code = tmp
end function
s_m = Math.abs(s);
c_m = Math.abs(c);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
double t_0 = (c_m * s_m) * x;
double tmp;
if (c_m <= 1.7e+62) {
tmp = (Math.cos((-2.0 * x)) / t_0) / t_0;
} else {
tmp = Math.pow((((c_m * c_m) * x) * (s_m * x)), -1.0) / s_m;
}
return tmp;
}
s_m = math.fabs(s) c_m = math.fabs(c) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): t_0 = (c_m * s_m) * x tmp = 0 if c_m <= 1.7e+62: tmp = (math.cos((-2.0 * x)) / t_0) / t_0 else: tmp = math.pow((((c_m * c_m) * x) * (s_m * x)), -1.0) / s_m return tmp
s_m = abs(s) c_m = abs(c) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(Float64(c_m * s_m) * x) tmp = 0.0 if (c_m <= 1.7e+62) tmp = Float64(Float64(cos(Float64(-2.0 * x)) / t_0) / t_0); else tmp = Float64((Float64(Float64(Float64(c_m * c_m) * x) * Float64(s_m * x)) ^ -1.0) / s_m); end return tmp end
s_m = abs(s);
c_m = abs(c);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp_2 = code(x, c_m, s_m)
t_0 = (c_m * s_m) * x;
tmp = 0.0;
if (c_m <= 1.7e+62)
tmp = (cos((-2.0 * x)) / t_0) / t_0;
else
tmp = ((((c_m * c_m) * x) * (s_m * x)) ^ -1.0) / s_m;
end
tmp_2 = tmp;
end
s_m = N[Abs[s], $MachinePrecision]
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(N[(c$95$m * s$95$m), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[c$95$m, 1.7e+62], N[(N[(N[Cos[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[Power[N[(N[(N[(c$95$m * c$95$m), $MachinePrecision] * x), $MachinePrecision] * N[(s$95$m * x), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision] / s$95$m), $MachinePrecision]]]
\begin{array}{l}
s_m = \left|s\right|
\\
c_m = \left|c\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := \left(c\_m \cdot s\_m\right) \cdot x\\
\mathbf{if}\;c\_m \leq 1.7 \cdot 10^{+62}:\\
\;\;\;\;\frac{\frac{\cos \left(-2 \cdot x\right)}{t\_0}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\left(\left(c\_m \cdot c\_m\right) \cdot x\right) \cdot \left(s\_m \cdot x\right)\right)}^{-1}}{s\_m}\\
\end{array}
\end{array}
if c < 1.70000000000000007e62Initial program 69.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f6488.7
Applied rewrites88.7%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6496.3
lift-*.f64N/A
*-commutativeN/A
lift-*.f6496.3
lift-*.f64N/A
*-commutativeN/A
lift-*.f6496.3
Applied rewrites96.3%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-cos.f64N/A
sin-+PI/2-revN/A
lift-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
sin-+PI/2-revN/A
cos-neg-revN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
Applied rewrites98.1%
if 1.70000000000000007e62 < c Initial program 69.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites82.9%
Taylor expanded in x around 0
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6478.5
Applied rewrites78.5%
Applied rewrites80.2%
Final simplification94.5%
s_m = (fabs.f64 s)
c_m = (fabs.f64 c)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
:precision binary64
(let* ((t_0 (* (* s_m x) c_m)))
(if (<= x 2e-123)
(/ (fma -2.0 (* x x) 1.0) (* t_0 t_0))
(/ (cos (+ x x)) (* (* (* x (* s_m c_m)) (* s_m c_m)) x)))))s_m = fabs(s);
c_m = fabs(c);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double t_0 = (s_m * x) * c_m;
double tmp;
if (x <= 2e-123) {
tmp = fma(-2.0, (x * x), 1.0) / (t_0 * t_0);
} else {
tmp = cos((x + x)) / (((x * (s_m * c_m)) * (s_m * c_m)) * x);
}
return tmp;
}
s_m = abs(s) c_m = abs(c) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(Float64(s_m * x) * c_m) tmp = 0.0 if (x <= 2e-123) tmp = Float64(fma(-2.0, Float64(x * x), 1.0) / Float64(t_0 * t_0)); else tmp = Float64(cos(Float64(x + x)) / Float64(Float64(Float64(x * Float64(s_m * c_m)) * Float64(s_m * c_m)) * x)); end return tmp end
s_m = N[Abs[s], $MachinePrecision]
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(N[(s$95$m * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, If[LessEqual[x, 2e-123], N[(N[(-2.0 * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(N[(N[(x * N[(s$95$m * c$95$m), $MachinePrecision]), $MachinePrecision] * N[(s$95$m * c$95$m), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
s_m = \left|s\right|
\\
c_m = \left|c\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := \left(s\_m \cdot x\right) \cdot c\_m\\
\mathbf{if}\;x \leq 2 \cdot 10^{-123}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-2, x \cdot x, 1\right)}{t\_0 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x + x\right)}{\left(\left(x \cdot \left(s\_m \cdot c\_m\right)\right) \cdot \left(s\_m \cdot c\_m\right)\right) \cdot x}\\
\end{array}
\end{array}
if x < 2.0000000000000001e-123Initial program 69.2%
Taylor expanded in x around 0
associate-*r/N/A
div-add-revN/A
+-commutativeN/A
associate-/l/N/A
associate-*r*N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
associate-*r*N/A
Applied rewrites53.5%
Applied rewrites69.1%
Applied rewrites71.1%
if 2.0000000000000001e-123 < x Initial program 69.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f6491.3
Applied rewrites91.3%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6498.0
lift-*.f64N/A
*-commutativeN/A
lift-*.f6498.0
lift-*.f64N/A
*-commutativeN/A
lift-*.f6498.0
Applied rewrites98.0%
lift-*.f64N/A
count-2-revN/A
lower-+.f6498.0
Applied rewrites98.0%
Final simplification80.2%
s_m = (fabs.f64 s)
c_m = (fabs.f64 c)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
:precision binary64
(let* ((t_0 (* (* s_m x) c_m)))
(if (<= x 1.04e-23)
(/ (fma -2.0 (* x x) 1.0) (* t_0 t_0))
(/ (cos (+ x x)) (* (* x c_m) (* (* (* s_m s_m) x) c_m))))))s_m = fabs(s);
c_m = fabs(c);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double t_0 = (s_m * x) * c_m;
double tmp;
if (x <= 1.04e-23) {
tmp = fma(-2.0, (x * x), 1.0) / (t_0 * t_0);
} else {
tmp = cos((x + x)) / ((x * c_m) * (((s_m * s_m) * x) * c_m));
}
return tmp;
}
s_m = abs(s) c_m = abs(c) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(Float64(s_m * x) * c_m) tmp = 0.0 if (x <= 1.04e-23) tmp = Float64(fma(-2.0, Float64(x * x), 1.0) / Float64(t_0 * t_0)); else tmp = Float64(cos(Float64(x + x)) / Float64(Float64(x * c_m) * Float64(Float64(Float64(s_m * s_m) * x) * c_m))); end return tmp end
s_m = N[Abs[s], $MachinePrecision]
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(N[(s$95$m * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, If[LessEqual[x, 1.04e-23], N[(N[(-2.0 * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(N[(x * c$95$m), $MachinePrecision] * N[(N[(N[(s$95$m * s$95$m), $MachinePrecision] * x), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
s_m = \left|s\right|
\\
c_m = \left|c\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := \left(s\_m \cdot x\right) \cdot c\_m\\
\mathbf{if}\;x \leq 1.04 \cdot 10^{-23}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-2, x \cdot x, 1\right)}{t\_0 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x + x\right)}{\left(x \cdot c\_m\right) \cdot \left(\left(\left(s\_m \cdot s\_m\right) \cdot x\right) \cdot c\_m\right)}\\
\end{array}
\end{array}
if x < 1.04e-23Initial program 70.0%
Taylor expanded in x around 0
associate-*r/N/A
div-add-revN/A
+-commutativeN/A
associate-/l/N/A
associate-*r*N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
associate-*r*N/A
Applied rewrites57.6%
Applied rewrites72.5%
Applied rewrites74.3%
if 1.04e-23 < x Initial program 67.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6482.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6482.4
lift-pow.f64N/A
unpow2N/A
lower-*.f6482.4
Applied rewrites82.4%
lift-*.f64N/A
count-2-revN/A
lower-+.f6482.4
Applied rewrites82.4%
Final simplification76.3%
s_m = (fabs.f64 s)
c_m = (fabs.f64 c)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
:precision binary64
(let* ((t_0 (* (* s_m x) c_m)))
(if (<= x 7.2e+42)
(/ (fma -2.0 (* x x) 1.0) (* t_0 t_0))
(pow (* (* c_m x) s_m) -2.0))))s_m = fabs(s);
c_m = fabs(c);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double t_0 = (s_m * x) * c_m;
double tmp;
if (x <= 7.2e+42) {
tmp = fma(-2.0, (x * x), 1.0) / (t_0 * t_0);
} else {
tmp = pow(((c_m * x) * s_m), -2.0);
}
return tmp;
}
s_m = abs(s) c_m = abs(c) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(Float64(s_m * x) * c_m) tmp = 0.0 if (x <= 7.2e+42) tmp = Float64(fma(-2.0, Float64(x * x), 1.0) / Float64(t_0 * t_0)); else tmp = Float64(Float64(c_m * x) * s_m) ^ -2.0; end return tmp end
s_m = N[Abs[s], $MachinePrecision]
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(N[(s$95$m * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, If[LessEqual[x, 7.2e+42], N[(N[(-2.0 * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[Power[N[(N[(c$95$m * x), $MachinePrecision] * s$95$m), $MachinePrecision], -2.0], $MachinePrecision]]]
\begin{array}{l}
s_m = \left|s\right|
\\
c_m = \left|c\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := \left(s\_m \cdot x\right) \cdot c\_m\\
\mathbf{if}\;x \leq 7.2 \cdot 10^{+42}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-2, x \cdot x, 1\right)}{t\_0 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;{\left(\left(c\_m \cdot x\right) \cdot s\_m\right)}^{-2}\\
\end{array}
\end{array}
if x < 7.2000000000000002e42Initial program 70.3%
Taylor expanded in x around 0
associate-*r/N/A
div-add-revN/A
+-commutativeN/A
associate-/l/N/A
associate-*r*N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
associate-*r*N/A
Applied rewrites59.0%
Applied rewrites73.2%
Applied rewrites75.0%
if 7.2000000000000002e42 < x Initial program 66.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites87.7%
Taylor expanded in x around 0
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6461.7
Applied rewrites61.7%
Applied rewrites62.8%
Final simplification72.3%
s_m = (fabs.f64 s)
c_m = (fabs.f64 c)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
:precision binary64
(let* ((t_0 (* (* s_m x) c_m)))
(if (<= x 7.2e+42)
(/ (fma -2.0 (* x x) 1.0) (* t_0 t_0))
(/ 1.0 (* (* (* x (* s_m c_m)) (* s_m c_m)) x)))))s_m = fabs(s);
c_m = fabs(c);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double t_0 = (s_m * x) * c_m;
double tmp;
if (x <= 7.2e+42) {
tmp = fma(-2.0, (x * x), 1.0) / (t_0 * t_0);
} else {
tmp = 1.0 / (((x * (s_m * c_m)) * (s_m * c_m)) * x);
}
return tmp;
}
s_m = abs(s) c_m = abs(c) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(Float64(s_m * x) * c_m) tmp = 0.0 if (x <= 7.2e+42) tmp = Float64(fma(-2.0, Float64(x * x), 1.0) / Float64(t_0 * t_0)); else tmp = Float64(1.0 / Float64(Float64(Float64(x * Float64(s_m * c_m)) * Float64(s_m * c_m)) * x)); end return tmp end
s_m = N[Abs[s], $MachinePrecision]
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(N[(s$95$m * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, If[LessEqual[x, 7.2e+42], N[(N[(-2.0 * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(x * N[(s$95$m * c$95$m), $MachinePrecision]), $MachinePrecision] * N[(s$95$m * c$95$m), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
s_m = \left|s\right|
\\
c_m = \left|c\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := \left(s\_m \cdot x\right) \cdot c\_m\\
\mathbf{if}\;x \leq 7.2 \cdot 10^{+42}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-2, x \cdot x, 1\right)}{t\_0 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(x \cdot \left(s\_m \cdot c\_m\right)\right) \cdot \left(s\_m \cdot c\_m\right)\right) \cdot x}\\
\end{array}
\end{array}
if x < 7.2000000000000002e42Initial program 70.3%
Taylor expanded in x around 0
associate-*r/N/A
div-add-revN/A
+-commutativeN/A
associate-/l/N/A
associate-*r*N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
associate-*r*N/A
Applied rewrites59.0%
Applied rewrites73.2%
Applied rewrites75.0%
if 7.2000000000000002e42 < x Initial program 66.1%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f6486.8
Applied rewrites86.8%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6497.1
lift-*.f64N/A
*-commutativeN/A
lift-*.f6497.1
lift-*.f64N/A
*-commutativeN/A
lift-*.f6497.1
Applied rewrites97.1%
Taylor expanded in x around 0
Applied rewrites62.4%
Final simplification72.2%
s_m = (fabs.f64 s)
c_m = (fabs.f64 c)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
:precision binary64
(let* ((t_0 (* (* s_m c_m) x)))
(if (<= x 7.2e+42)
(/ (fma -2.0 (* x x) 1.0) (* t_0 t_0))
(/ 1.0 (* (* (* x (* s_m c_m)) (* s_m c_m)) x)))))s_m = fabs(s);
c_m = fabs(c);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double t_0 = (s_m * c_m) * x;
double tmp;
if (x <= 7.2e+42) {
tmp = fma(-2.0, (x * x), 1.0) / (t_0 * t_0);
} else {
tmp = 1.0 / (((x * (s_m * c_m)) * (s_m * c_m)) * x);
}
return tmp;
}
s_m = abs(s) c_m = abs(c) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(Float64(s_m * c_m) * x) tmp = 0.0 if (x <= 7.2e+42) tmp = Float64(fma(-2.0, Float64(x * x), 1.0) / Float64(t_0 * t_0)); else tmp = Float64(1.0 / Float64(Float64(Float64(x * Float64(s_m * c_m)) * Float64(s_m * c_m)) * x)); end return tmp end
s_m = N[Abs[s], $MachinePrecision]
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(N[(s$95$m * c$95$m), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, 7.2e+42], N[(N[(-2.0 * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(x * N[(s$95$m * c$95$m), $MachinePrecision]), $MachinePrecision] * N[(s$95$m * c$95$m), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
s_m = \left|s\right|
\\
c_m = \left|c\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := \left(s\_m \cdot c\_m\right) \cdot x\\
\mathbf{if}\;x \leq 7.2 \cdot 10^{+42}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-2, x \cdot x, 1\right)}{t\_0 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(x \cdot \left(s\_m \cdot c\_m\right)\right) \cdot \left(s\_m \cdot c\_m\right)\right) \cdot x}\\
\end{array}
\end{array}
if x < 7.2000000000000002e42Initial program 70.3%
Taylor expanded in x around 0
associate-*r/N/A
div-add-revN/A
+-commutativeN/A
associate-/l/N/A
associate-*r*N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
associate-*r*N/A
Applied rewrites59.0%
Applied rewrites73.2%
if 7.2000000000000002e42 < x Initial program 66.1%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f6486.8
Applied rewrites86.8%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6497.1
lift-*.f64N/A
*-commutativeN/A
lift-*.f6497.1
lift-*.f64N/A
*-commutativeN/A
lift-*.f6497.1
Applied rewrites97.1%
Taylor expanded in x around 0
Applied rewrites62.4%
s_m = (fabs.f64 s)
c_m = (fabs.f64 c)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
:precision binary64
(let* ((t_0 (* (* c_m x) s_m)))
(if (<= x 7.2e+42)
(/ (fma -2.0 (* x x) 1.0) (* t_0 t_0))
(/ 1.0 (* (* (* x (* s_m c_m)) (* s_m c_m)) x)))))s_m = fabs(s);
c_m = fabs(c);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double t_0 = (c_m * x) * s_m;
double tmp;
if (x <= 7.2e+42) {
tmp = fma(-2.0, (x * x), 1.0) / (t_0 * t_0);
} else {
tmp = 1.0 / (((x * (s_m * c_m)) * (s_m * c_m)) * x);
}
return tmp;
}
s_m = abs(s) c_m = abs(c) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(Float64(c_m * x) * s_m) tmp = 0.0 if (x <= 7.2e+42) tmp = Float64(fma(-2.0, Float64(x * x), 1.0) / Float64(t_0 * t_0)); else tmp = Float64(1.0 / Float64(Float64(Float64(x * Float64(s_m * c_m)) * Float64(s_m * c_m)) * x)); end return tmp end
s_m = N[Abs[s], $MachinePrecision]
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(N[(c$95$m * x), $MachinePrecision] * s$95$m), $MachinePrecision]}, If[LessEqual[x, 7.2e+42], N[(N[(-2.0 * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(x * N[(s$95$m * c$95$m), $MachinePrecision]), $MachinePrecision] * N[(s$95$m * c$95$m), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
s_m = \left|s\right|
\\
c_m = \left|c\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := \left(c\_m \cdot x\right) \cdot s\_m\\
\mathbf{if}\;x \leq 7.2 \cdot 10^{+42}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-2, x \cdot x, 1\right)}{t\_0 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(x \cdot \left(s\_m \cdot c\_m\right)\right) \cdot \left(s\_m \cdot c\_m\right)\right) \cdot x}\\
\end{array}
\end{array}
if x < 7.2000000000000002e42Initial program 70.3%
Taylor expanded in x around 0
associate-*r/N/A
div-add-revN/A
+-commutativeN/A
associate-/l/N/A
associate-*r*N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
associate-*r*N/A
Applied rewrites59.0%
Applied rewrites63.2%
Applied rewrites73.6%
if 7.2000000000000002e42 < x Initial program 66.1%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f6486.8
Applied rewrites86.8%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6497.1
lift-*.f64N/A
*-commutativeN/A
lift-*.f6497.1
lift-*.f64N/A
*-commutativeN/A
lift-*.f6497.1
Applied rewrites97.1%
Taylor expanded in x around 0
Applied rewrites62.4%
s_m = (fabs.f64 s) c_m = (fabs.f64 c) NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x c_m s_m) :precision binary64 (/ 2.0 (* (* (* (- s_m) s_m) c_m) c_m)))
s_m = fabs(s);
c_m = fabs(c);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
return 2.0 / (((-s_m * s_m) * c_m) * c_m);
}
s_m = abs(s)
c_m = abs(c)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
code = 2.0d0 / (((-s_m * s_m) * c_m) * c_m)
end function
s_m = Math.abs(s);
c_m = Math.abs(c);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
return 2.0 / (((-s_m * s_m) * c_m) * c_m);
}
s_m = math.fabs(s) c_m = math.fabs(c) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): return 2.0 / (((-s_m * s_m) * c_m) * c_m)
s_m = abs(s) c_m = abs(c) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) return Float64(2.0 / Float64(Float64(Float64(Float64(-s_m) * s_m) * c_m) * c_m)) end
s_m = abs(s);
c_m = abs(c);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
tmp = 2.0 / (((-s_m * s_m) * c_m) * c_m);
end
s_m = N[Abs[s], $MachinePrecision] c_m = N[Abs[c], $MachinePrecision] NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. code[x_, c$95$m_, s$95$m_] := N[(2.0 / N[(N[(N[((-s$95$m) * s$95$m), $MachinePrecision] * c$95$m), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s_m = \left|s\right|
\\
c_m = \left|c\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\frac{2}{\left(\left(\left(-s\_m\right) \cdot s\_m\right) \cdot c\_m\right) \cdot c\_m}
\end{array}
Initial program 69.4%
Taylor expanded in x around 0
associate-*r/N/A
div-add-revN/A
+-commutativeN/A
associate-/l/N/A
associate-*r*N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
associate-*r*N/A
Applied rewrites50.0%
Taylor expanded in x around inf
Applied rewrites29.5%
Applied rewrites28.8%
Applied rewrites29.5%
s_m = (fabs.f64 s) c_m = (fabs.f64 c) NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x c_m s_m) :precision binary64 (/ 2.0 (* (* (* (- c_m) s_m) s_m) c_m)))
s_m = fabs(s);
c_m = fabs(c);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
return 2.0 / (((-c_m * s_m) * s_m) * c_m);
}
s_m = abs(s)
c_m = abs(c)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
code = 2.0d0 / (((-c_m * s_m) * s_m) * c_m)
end function
s_m = Math.abs(s);
c_m = Math.abs(c);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
return 2.0 / (((-c_m * s_m) * s_m) * c_m);
}
s_m = math.fabs(s) c_m = math.fabs(c) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): return 2.0 / (((-c_m * s_m) * s_m) * c_m)
s_m = abs(s) c_m = abs(c) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) return Float64(2.0 / Float64(Float64(Float64(Float64(-c_m) * s_m) * s_m) * c_m)) end
s_m = abs(s);
c_m = abs(c);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
tmp = 2.0 / (((-c_m * s_m) * s_m) * c_m);
end
s_m = N[Abs[s], $MachinePrecision] c_m = N[Abs[c], $MachinePrecision] NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. code[x_, c$95$m_, s$95$m_] := N[(2.0 / N[(N[(N[((-c$95$m) * s$95$m), $MachinePrecision] * s$95$m), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s_m = \left|s\right|
\\
c_m = \left|c\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\frac{2}{\left(\left(\left(-c\_m\right) \cdot s\_m\right) \cdot s\_m\right) \cdot c\_m}
\end{array}
Initial program 69.4%
Taylor expanded in x around 0
associate-*r/N/A
div-add-revN/A
+-commutativeN/A
associate-/l/N/A
associate-*r*N/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
associate-*r*N/A
Applied rewrites50.0%
Taylor expanded in x around inf
Applied rewrites29.5%
Applied rewrites28.8%
Taylor expanded in c around 0
Applied rewrites28.5%
herbie shell --seed 2024343
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))