
(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 12 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}
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
:precision binary64
(let* ((t_0 (* (* s c_m) x)) (t_1 (cos (* x 2.0))))
(if (<= (/ t_1 (* (* (* (pow s 2.0) x) x) (pow c_m 2.0))) 2e+206)
(* (pow (* (* (- x) s) c_m) -2.0) t_1)
(/ (- (pow (cos x) 4.0) (pow (sin x) 4.0)) (* t_0 t_0)))))c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = (s * c_m) * x;
double t_1 = cos((x * 2.0));
double tmp;
if ((t_1 / (((pow(s, 2.0) * x) * x) * pow(c_m, 2.0))) <= 2e+206) {
tmp = pow(((-x * s) * c_m), -2.0) * t_1;
} else {
tmp = (pow(cos(x), 4.0) - pow(sin(x), 4.0)) / (t_0 * t_0);
}
return tmp;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (s * c_m) * x
t_1 = cos((x * 2.0d0))
if ((t_1 / ((((s ** 2.0d0) * x) * x) * (c_m ** 2.0d0))) <= 2d+206) then
tmp = (((-x * s) * c_m) ** (-2.0d0)) * t_1
else
tmp = ((cos(x) ** 4.0d0) - (sin(x) ** 4.0d0)) / (t_0 * t_0)
end if
code = tmp
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = (s * c_m) * x;
double t_1 = Math.cos((x * 2.0));
double tmp;
if ((t_1 / (((Math.pow(s, 2.0) * x) * x) * Math.pow(c_m, 2.0))) <= 2e+206) {
tmp = Math.pow(((-x * s) * c_m), -2.0) * t_1;
} else {
tmp = (Math.pow(Math.cos(x), 4.0) - Math.pow(Math.sin(x), 4.0)) / (t_0 * t_0);
}
return tmp;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = (s * c_m) * x t_1 = math.cos((x * 2.0)) tmp = 0 if (t_1 / (((math.pow(s, 2.0) * x) * x) * math.pow(c_m, 2.0))) <= 2e+206: tmp = math.pow(((-x * s) * c_m), -2.0) * t_1 else: tmp = (math.pow(math.cos(x), 4.0) - math.pow(math.sin(x), 4.0)) / (t_0 * t_0) return tmp
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = Float64(Float64(s * c_m) * x) t_1 = cos(Float64(x * 2.0)) tmp = 0.0 if (Float64(t_1 / Float64(Float64(Float64((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= 2e+206) tmp = Float64((Float64(Float64(Float64(-x) * s) * c_m) ^ -2.0) * t_1); else tmp = Float64(Float64((cos(x) ^ 4.0) - (sin(x) ^ 4.0)) / Float64(t_0 * t_0)); end return tmp end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp_2 = code(x, c_m, s)
t_0 = (s * c_m) * x;
t_1 = cos((x * 2.0));
tmp = 0.0;
if ((t_1 / ((((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= 2e+206)
tmp = (((-x * s) * c_m) ^ -2.0) * t_1;
else
tmp = ((cos(x) ^ 4.0) - (sin(x) ^ 4.0)) / (t_0 * t_0);
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(N[(s * c$95$m), $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$1 / N[(N[(N[(N[Power[s, 2.0], $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * N[Power[c$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+206], N[(N[Power[N[(N[((-x) * s), $MachinePrecision] * c$95$m), $MachinePrecision], -2.0], $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(N[Power[N[Cos[x], $MachinePrecision], 4.0], $MachinePrecision] - N[Power[N[Sin[x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \left(s \cdot c\_m\right) \cdot x\\
t_1 := \cos \left(x \cdot 2\right)\\
\mathbf{if}\;\frac{t\_1}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c\_m}^{2}} \leq 2 \cdot 10^{+206}:\\
\;\;\;\;{\left(\left(\left(-x\right) \cdot s\right) \cdot c\_m\right)}^{-2} \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{{\cos x}^{4} - {\sin x}^{4}}{t\_0 \cdot t\_0}\\
\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.0000000000000001e206Initial program 75.2%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
pow2N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6495.6
Applied rewrites95.6%
lift-/.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
unpow-prod-downN/A
lift-pow.f64N/A
pow2N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
Applied rewrites91.3%
Applied rewrites99.5%
if 2.0000000000000001e206 < (/.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 49.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
pow2N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6497.1
Applied rewrites97.1%
*-rgt-identityN/A
*-commutativeN/A
cos-sin-sumN/A
lift-cos.f64N/A
lift-*.f64N/A
cos-2N/A
difference-of-squaresN/A
lower--.f64N/A
pow2N/A
pow2N/A
pow-prod-upN/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lower-cos.f64N/A
metadata-evalN/A
pow2N/A
pow2N/A
pow-prod-upN/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lower-sin.f64N/A
metadata-eval98.3
Applied rewrites98.3%
Final simplification98.9%
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
:precision binary64
(let* ((t_0 (cos (* x 2.0))) (t_1 (* (* s c_m) x)))
(if (<= (/ t_0 (* (* (* (pow s 2.0) x) x) (pow c_m 2.0))) 0.0)
(* (pow (* (* (- x) s) c_m) -2.0) t_0)
(/ (/ (cos (+ x x)) t_1) t_1))))c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = cos((x * 2.0));
double t_1 = (s * c_m) * x;
double tmp;
if ((t_0 / (((pow(s, 2.0) * x) * x) * pow(c_m, 2.0))) <= 0.0) {
tmp = pow(((-x * s) * c_m), -2.0) * t_0;
} else {
tmp = (cos((x + x)) / t_1) / t_1;
}
return tmp;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((x * 2.0d0))
t_1 = (s * c_m) * x
if ((t_0 / ((((s ** 2.0d0) * x) * x) * (c_m ** 2.0d0))) <= 0.0d0) then
tmp = (((-x * s) * c_m) ** (-2.0d0)) * t_0
else
tmp = (cos((x + x)) / t_1) / t_1
end if
code = tmp
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = Math.cos((x * 2.0));
double t_1 = (s * c_m) * x;
double tmp;
if ((t_0 / (((Math.pow(s, 2.0) * x) * x) * Math.pow(c_m, 2.0))) <= 0.0) {
tmp = Math.pow(((-x * s) * c_m), -2.0) * t_0;
} else {
tmp = (Math.cos((x + x)) / t_1) / t_1;
}
return tmp;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = math.cos((x * 2.0)) t_1 = (s * c_m) * x tmp = 0 if (t_0 / (((math.pow(s, 2.0) * x) * x) * math.pow(c_m, 2.0))) <= 0.0: tmp = math.pow(((-x * s) * c_m), -2.0) * t_0 else: tmp = (math.cos((x + x)) / t_1) / t_1 return tmp
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = cos(Float64(x * 2.0)) t_1 = Float64(Float64(s * c_m) * x) tmp = 0.0 if (Float64(t_0 / Float64(Float64(Float64((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= 0.0) tmp = Float64((Float64(Float64(Float64(-x) * s) * c_m) ^ -2.0) * t_0); else tmp = Float64(Float64(cos(Float64(x + x)) / t_1) / t_1); end return tmp end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp_2 = code(x, c_m, s)
t_0 = cos((x * 2.0));
t_1 = (s * c_m) * x;
tmp = 0.0;
if ((t_0 / ((((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= 0.0)
tmp = (((-x * s) * c_m) ^ -2.0) * t_0;
else
tmp = (cos((x + x)) / t_1) / t_1;
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(s * c$95$m), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(N[(N[Power[s, 2.0], $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * N[Power[c$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[Power[N[(N[((-x) * s), $MachinePrecision] * c$95$m), $MachinePrecision], -2.0], $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision]]]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
t_1 := \left(s \cdot c\_m\right) \cdot x\\
\mathbf{if}\;\frac{t\_0}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c\_m}^{2}} \leq 0:\\
\;\;\;\;{\left(\left(\left(-x\right) \cdot s\right) \cdot c\_m\right)}^{-2} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(x + x\right)}{t\_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))) < 0.0Initial program 71.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
pow2N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6495.2
Applied rewrites95.2%
lift-/.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
unpow-prod-downN/A
lift-pow.f64N/A
pow2N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
Applied rewrites90.2%
Applied rewrites99.6%
if 0.0 < (/.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 55.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
pow2N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6497.3
Applied rewrites97.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6497.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6497.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6497.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6497.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6497.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6497.4
Applied rewrites97.4%
lift-*.f64N/A
*-commutativeN/A
count-2N/A
lower-+.f6497.4
Applied rewrites97.4%
Final simplification98.4%
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
:precision binary64
(let* ((t_0 (* (* s c_m) x)) (t_1 (* (* c_m x) s)))
(if (<=
(/ (cos (* x 2.0)) (* (* (* (pow s 2.0) x) x) (pow c_m 2.0)))
-1e-94)
(/ (fma (* x x) -2.0 1.0) (* t_0 t_0))
(/ 1.0 (* t_1 t_1)))))c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = (s * c_m) * x;
double t_1 = (c_m * x) * s;
double tmp;
if ((cos((x * 2.0)) / (((pow(s, 2.0) * x) * x) * pow(c_m, 2.0))) <= -1e-94) {
tmp = fma((x * x), -2.0, 1.0) / (t_0 * t_0);
} else {
tmp = 1.0 / (t_1 * t_1);
}
return tmp;
}
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = Float64(Float64(s * c_m) * x) t_1 = Float64(Float64(c_m * x) * s) tmp = 0.0 if (Float64(cos(Float64(x * 2.0)) / Float64(Float64(Float64((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= -1e-94) tmp = Float64(fma(Float64(x * x), -2.0, 1.0) / Float64(t_0 * t_0)); else tmp = Float64(1.0 / Float64(t_1 * t_1)); end return tmp end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(N[(s * c$95$m), $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c$95$m * x), $MachinePrecision] * s), $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(N[(N[Power[s, 2.0], $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * N[Power[c$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1e-94], N[(N[(N[(x * x), $MachinePrecision] * -2.0 + 1.0), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \left(s \cdot c\_m\right) \cdot x\\
t_1 := \left(c\_m \cdot x\right) \cdot s\\
\mathbf{if}\;\frac{\cos \left(x \cdot 2\right)}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c\_m}^{2}} \leq -1 \cdot 10^{-94}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x \cdot x, -2, 1\right)}{t\_0 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t\_1 \cdot 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))) < -9.9999999999999996e-95Initial program 59.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6441.3
Applied rewrites41.3%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
pow2N/A
lift-pow.f64N/A
unpow-prod-downN/A
unpow-prod-downN/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f6441.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.3
Applied rewrites41.3%
if -9.9999999999999996e-95 < (/.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 63.4%
Taylor expanded in x around 0
Applied rewrites61.0%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
pow2N/A
lift-pow.f64N/A
unpow-prod-downN/A
unpow-prod-downN/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f6482.2
remove-double-negN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
Applied rewrites82.6%
Final simplification79.2%
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
:precision binary64
(let* ((t_0 (* (* c_m x) s)))
(if (<=
(/ (cos (* x 2.0)) (* (* (* (pow s 2.0) x) x) (pow c_m 2.0)))
-1e+154)
(/ 1.0 (* t_0 (* (* s c_m) x)))
(/ 1.0 (* t_0 t_0)))))c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = (c_m * x) * s;
double tmp;
if ((cos((x * 2.0)) / (((pow(s, 2.0) * x) * x) * pow(c_m, 2.0))) <= -1e+154) {
tmp = 1.0 / (t_0 * ((s * c_m) * x));
} else {
tmp = 1.0 / (t_0 * t_0);
}
return tmp;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: tmp
t_0 = (c_m * x) * s
if ((cos((x * 2.0d0)) / ((((s ** 2.0d0) * x) * x) * (c_m ** 2.0d0))) <= (-1d+154)) then
tmp = 1.0d0 / (t_0 * ((s * c_m) * x))
else
tmp = 1.0d0 / (t_0 * t_0)
end if
code = tmp
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = (c_m * x) * s;
double tmp;
if ((Math.cos((x * 2.0)) / (((Math.pow(s, 2.0) * x) * x) * Math.pow(c_m, 2.0))) <= -1e+154) {
tmp = 1.0 / (t_0 * ((s * c_m) * x));
} else {
tmp = 1.0 / (t_0 * t_0);
}
return tmp;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = (c_m * x) * s tmp = 0 if (math.cos((x * 2.0)) / (((math.pow(s, 2.0) * x) * x) * math.pow(c_m, 2.0))) <= -1e+154: tmp = 1.0 / (t_0 * ((s * c_m) * x)) else: tmp = 1.0 / (t_0 * t_0) return tmp
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = Float64(Float64(c_m * x) * s) tmp = 0.0 if (Float64(cos(Float64(x * 2.0)) / Float64(Float64(Float64((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= -1e+154) tmp = Float64(1.0 / Float64(t_0 * Float64(Float64(s * c_m) * x))); else tmp = Float64(1.0 / Float64(t_0 * t_0)); end return tmp end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp_2 = code(x, c_m, s)
t_0 = (c_m * x) * s;
tmp = 0.0;
if ((cos((x * 2.0)) / ((((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= -1e+154)
tmp = 1.0 / (t_0 * ((s * c_m) * x));
else
tmp = 1.0 / (t_0 * t_0);
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(N[(c$95$m * x), $MachinePrecision] * s), $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(N[(N[Power[s, 2.0], $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * N[Power[c$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1e+154], N[(1.0 / N[(t$95$0 * N[(N[(s * c$95$m), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \left(c\_m \cdot x\right) \cdot s\\
\mathbf{if}\;\frac{\cos \left(x \cdot 2\right)}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c\_m}^{2}} \leq -1 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{t\_0 \cdot \left(\left(s \cdot c\_m\right) \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t\_0 \cdot t\_0}\\
\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))) < -1.00000000000000004e154Initial program 52.7%
Taylor expanded in x around 0
Applied rewrites0.3%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
pow2N/A
lift-pow.f64N/A
unpow-prod-downN/A
unpow-prod-downN/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f641.0
remove-double-negN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
Applied rewrites1.1%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
*-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-*.f64N/A
neg-sub0N/A
lower--.f6423.8
lift-*.f64N/A
*-commutativeN/A
lift-*.f6423.8
Applied rewrites23.8%
if -1.00000000000000004e154 < (/.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 63.8%
Taylor expanded in x around 0
Applied rewrites60.3%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
pow2N/A
lift-pow.f64N/A
unpow-prod-downN/A
unpow-prod-downN/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f6481.2
remove-double-negN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
Applied rewrites81.6%
Final simplification75.9%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (if (<= x 6.2e-53) (/ (/ 1.0 (* (* s c_m) x)) (* (* s x) c_m)) (/ (cos (+ x x)) (* (* (* (* c_m x) x) s) (* s c_m)))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double tmp;
if (x <= 6.2e-53) {
tmp = (1.0 / ((s * c_m) * x)) / ((s * x) * c_m);
} else {
tmp = cos((x + x)) / ((((c_m * x) * x) * s) * (s * c_m));
}
return tmp;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: tmp
if (x <= 6.2d-53) then
tmp = (1.0d0 / ((s * c_m) * x)) / ((s * x) * c_m)
else
tmp = cos((x + x)) / ((((c_m * x) * x) * s) * (s * c_m))
end if
code = tmp
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double tmp;
if (x <= 6.2e-53) {
tmp = (1.0 / ((s * c_m) * x)) / ((s * x) * c_m);
} else {
tmp = Math.cos((x + x)) / ((((c_m * x) * x) * s) * (s * c_m));
}
return tmp;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): tmp = 0 if x <= 6.2e-53: tmp = (1.0 / ((s * c_m) * x)) / ((s * x) * c_m) else: tmp = math.cos((x + x)) / ((((c_m * x) * x) * s) * (s * c_m)) return tmp
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) tmp = 0.0 if (x <= 6.2e-53) tmp = Float64(Float64(1.0 / Float64(Float64(s * c_m) * x)) / Float64(Float64(s * x) * c_m)); else tmp = Float64(cos(Float64(x + x)) / Float64(Float64(Float64(Float64(c_m * x) * x) * s) * Float64(s * c_m))); end return tmp end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp_2 = code(x, c_m, s)
tmp = 0.0;
if (x <= 6.2e-53)
tmp = (1.0 / ((s * c_m) * x)) / ((s * x) * c_m);
else
tmp = cos((x + x)) / ((((c_m * x) * x) * s) * (s * c_m));
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision] NOTE: x, c_m, and s should be sorted in increasing order before calling this function. code[x_, c$95$m_, s_] := If[LessEqual[x, 6.2e-53], N[(N[(1.0 / N[(N[(s * c$95$m), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / N[(N[(s * x), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(N[(N[(N[(c$95$m * x), $MachinePrecision] * x), $MachinePrecision] * s), $MachinePrecision] * N[(s * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.2 \cdot 10^{-53}:\\
\;\;\;\;\frac{\frac{1}{\left(s \cdot c\_m\right) \cdot x}}{\left(s \cdot x\right) \cdot c\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x + x\right)}{\left(\left(\left(c\_m \cdot x\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot c\_m\right)}\\
\end{array}
\end{array}
if x < 6.20000000000000031e-53Initial program 62.5%
Taylor expanded in x around 0
Applied rewrites59.0%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
pow2N/A
lift-pow.f64N/A
unpow-prod-downN/A
unpow-prod-downN/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f6481.9
remove-double-negN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
Applied rewrites82.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites81.3%
if 6.20000000000000031e-53 < x Initial program 63.9%
Taylor expanded in x around 0
unpow2N/A
associate-*l*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6487.3
Applied rewrites87.3%
lift-*.f64N/A
count-2N/A
lower-+.f6487.3
Applied rewrites87.3%
Final simplification83.5%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (let* ((t_0 (* (* s c_m) x))) (/ (/ (cos (+ x x)) t_0) t_0)))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = (s * c_m) * x;
return (cos((x + x)) / t_0) / t_0;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: t_0
t_0 = (s * c_m) * x
code = (cos((x + x)) / t_0) / t_0
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = (s * c_m) * x;
return (Math.cos((x + x)) / t_0) / t_0;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = (s * c_m) * x return (math.cos((x + x)) / t_0) / t_0
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = Float64(Float64(s * c_m) * x) return Float64(Float64(cos(Float64(x + x)) / t_0) / t_0) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
t_0 = (s * c_m) * x;
tmp = (cos((x + x)) / t_0) / t_0;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(N[(s * c$95$m), $MachinePrecision] * x), $MachinePrecision]}, N[(N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \left(s \cdot c\_m\right) \cdot x\\
\frac{\frac{\cos \left(x + x\right)}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 63.0%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
pow2N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6496.3
Applied rewrites96.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6496.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6496.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6496.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6496.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6496.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6496.6
Applied rewrites96.6%
lift-*.f64N/A
*-commutativeN/A
count-2N/A
lower-+.f6496.6
Applied rewrites96.6%
Final simplification96.6%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (if (<= (pow c_m 2.0) 0.001) (/ 1.0 (* (* (* s x) x) (* (* s c_m) c_m))) (/ 1.0 (* (* (* s x) s) (* (* c_m x) c_m)))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double tmp;
if (pow(c_m, 2.0) <= 0.001) {
tmp = 1.0 / (((s * x) * x) * ((s * c_m) * c_m));
} else {
tmp = 1.0 / (((s * x) * s) * ((c_m * x) * c_m));
}
return tmp;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: tmp
if ((c_m ** 2.0d0) <= 0.001d0) then
tmp = 1.0d0 / (((s * x) * x) * ((s * c_m) * c_m))
else
tmp = 1.0d0 / (((s * x) * s) * ((c_m * x) * c_m))
end if
code = tmp
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double tmp;
if (Math.pow(c_m, 2.0) <= 0.001) {
tmp = 1.0 / (((s * x) * x) * ((s * c_m) * c_m));
} else {
tmp = 1.0 / (((s * x) * s) * ((c_m * x) * c_m));
}
return tmp;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): tmp = 0 if math.pow(c_m, 2.0) <= 0.001: tmp = 1.0 / (((s * x) * x) * ((s * c_m) * c_m)) else: tmp = 1.0 / (((s * x) * s) * ((c_m * x) * c_m)) return tmp
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) tmp = 0.0 if ((c_m ^ 2.0) <= 0.001) tmp = Float64(1.0 / Float64(Float64(Float64(s * x) * x) * Float64(Float64(s * c_m) * c_m))); else tmp = Float64(1.0 / Float64(Float64(Float64(s * x) * s) * Float64(Float64(c_m * x) * c_m))); end return tmp end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp_2 = code(x, c_m, s)
tmp = 0.0;
if ((c_m ^ 2.0) <= 0.001)
tmp = 1.0 / (((s * x) * x) * ((s * c_m) * c_m));
else
tmp = 1.0 / (((s * x) * s) * ((c_m * x) * c_m));
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision] NOTE: x, c_m, and s should be sorted in increasing order before calling this function. code[x_, c$95$m_, s_] := If[LessEqual[N[Power[c$95$m, 2.0], $MachinePrecision], 0.001], N[(1.0 / N[(N[(N[(s * x), $MachinePrecision] * x), $MachinePrecision] * N[(N[(s * c$95$m), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(s * x), $MachinePrecision] * s), $MachinePrecision] * N[(N[(c$95$m * x), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
\mathbf{if}\;{c\_m}^{2} \leq 0.001:\\
\;\;\;\;\frac{1}{\left(\left(s \cdot x\right) \cdot x\right) \cdot \left(\left(s \cdot c\_m\right) \cdot c\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(s \cdot x\right) \cdot s\right) \cdot \left(\left(c\_m \cdot x\right) \cdot c\_m\right)}\\
\end{array}
\end{array}
if (pow.f64 c #s(literal 2 binary64)) < 1e-3Initial program 65.3%
Taylor expanded in x around 0
Applied rewrites57.4%
Taylor expanded in x around 0
*-commutativeN/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6461.0
Applied rewrites61.0%
Applied rewrites62.4%
Taylor expanded in x around 0
unpow2N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6469.5
Applied rewrites69.5%
if 1e-3 < (pow.f64 c #s(literal 2 binary64)) Initial program 60.8%
Taylor expanded in x around 0
Applied rewrites54.8%
Taylor expanded in x around 0
*-commutativeN/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6465.9
Applied rewrites65.9%
Applied rewrites72.1%
Final simplification70.8%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (let* ((t_0 (* (* s c_m) x))) (/ (cos (+ x x)) (* t_0 t_0))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = (s * c_m) * x;
return cos((x + x)) / (t_0 * t_0);
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: t_0
t_0 = (s * c_m) * x
code = cos((x + x)) / (t_0 * t_0)
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = (s * c_m) * x;
return Math.cos((x + x)) / (t_0 * t_0);
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = (s * c_m) * x return math.cos((x + x)) / (t_0 * t_0)
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = Float64(Float64(s * c_m) * x) return Float64(cos(Float64(x + x)) / Float64(t_0 * t_0)) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
t_0 = (s * c_m) * x;
tmp = cos((x + x)) / (t_0 * t_0);
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(N[(s * c$95$m), $MachinePrecision] * x), $MachinePrecision]}, N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \left(s \cdot c\_m\right) \cdot x\\
\frac{\cos \left(x + x\right)}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 63.0%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
pow2N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6496.3
Applied rewrites96.3%
lift-*.f64N/A
count-2N/A
lower-+.f6496.3
Applied rewrites96.3%
Final simplification96.3%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (let* ((t_0 (* (* c_m x) s))) (/ 1.0 (* t_0 t_0))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = (c_m * x) * s;
return 1.0 / (t_0 * t_0);
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: t_0
t_0 = (c_m * x) * s
code = 1.0d0 / (t_0 * t_0)
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = (c_m * x) * s;
return 1.0 / (t_0 * t_0);
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = (c_m * x) * s return 1.0 / (t_0 * t_0)
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = Float64(Float64(c_m * x) * s) return Float64(1.0 / Float64(t_0 * t_0)) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
t_0 = (c_m * x) * s;
tmp = 1.0 / (t_0 * t_0);
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(N[(c$95$m * x), $MachinePrecision] * s), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \left(c\_m \cdot x\right) \cdot s\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 63.0%
Taylor expanded in x around 0
Applied rewrites56.1%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
pow2N/A
lift-pow.f64N/A
unpow-prod-downN/A
unpow-prod-downN/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f6475.6
remove-double-negN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
Applied rewrites75.9%
Final simplification75.9%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (let* ((t_0 (* (* s c_m) x))) (/ 1.0 (* t_0 t_0))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = (s * c_m) * x;
return 1.0 / (t_0 * t_0);
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: t_0
t_0 = (s * c_m) * x
code = 1.0d0 / (t_0 * t_0)
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = (s * c_m) * x;
return 1.0 / (t_0 * t_0);
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = (s * c_m) * x return 1.0 / (t_0 * t_0)
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = Float64(Float64(s * c_m) * x) return Float64(1.0 / Float64(t_0 * t_0)) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
t_0 = (s * c_m) * x;
tmp = 1.0 / (t_0 * t_0);
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(N[(s * c$95$m), $MachinePrecision] * x), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \left(s \cdot c\_m\right) \cdot x\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 63.0%
Taylor expanded in x around 0
Applied rewrites56.1%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
pow2N/A
lift-pow.f64N/A
unpow-prod-downN/A
unpow-prod-downN/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f6475.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.6
Applied rewrites75.6%
Final simplification75.6%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (/ 1.0 (* (* (* s x) s) (* (* c_m x) c_m))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
return 1.0 / (((s * x) * s) * ((c_m * x) * c_m));
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
code = 1.0d0 / (((s * x) * s) * ((c_m * x) * c_m))
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
return 1.0 / (((s * x) * s) * ((c_m * x) * c_m));
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): return 1.0 / (((s * x) * s) * ((c_m * x) * c_m))
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) return Float64(1.0 / Float64(Float64(Float64(s * x) * s) * Float64(Float64(c_m * x) * c_m))) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
tmp = 1.0 / (((s * x) * s) * ((c_m * x) * c_m));
end
c_m = N[Abs[c], $MachinePrecision] NOTE: x, c_m, and s should be sorted in increasing order before calling this function. code[x_, c$95$m_, s_] := N[(1.0 / N[(N[(N[(s * x), $MachinePrecision] * s), $MachinePrecision] * N[(N[(c$95$m * x), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\frac{1}{\left(\left(s \cdot x\right) \cdot s\right) \cdot \left(\left(c\_m \cdot x\right) \cdot c\_m\right)}
\end{array}
Initial program 63.0%
Taylor expanded in x around 0
Applied rewrites56.1%
Taylor expanded in x around 0
*-commutativeN/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6463.4
Applied rewrites63.4%
Applied rewrites67.3%
Final simplification67.3%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (/ 1.0 (* (* (* c_m c_m) x) (* (* s x) s))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
return 1.0 / (((c_m * c_m) * x) * ((s * x) * s));
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
code = 1.0d0 / (((c_m * c_m) * x) * ((s * x) * s))
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
return 1.0 / (((c_m * c_m) * x) * ((s * x) * s));
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): return 1.0 / (((c_m * c_m) * x) * ((s * x) * s))
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) return Float64(1.0 / Float64(Float64(Float64(c_m * c_m) * x) * Float64(Float64(s * x) * s))) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
tmp = 1.0 / (((c_m * c_m) * x) * ((s * x) * s));
end
c_m = N[Abs[c], $MachinePrecision] NOTE: x, c_m, and s should be sorted in increasing order before calling this function. code[x_, c$95$m_, s_] := N[(1.0 / N[(N[(N[(c$95$m * c$95$m), $MachinePrecision] * x), $MachinePrecision] * N[(N[(s * x), $MachinePrecision] * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\frac{1}{\left(\left(c\_m \cdot c\_m\right) \cdot x\right) \cdot \left(\left(s \cdot x\right) \cdot s\right)}
\end{array}
Initial program 63.0%
Taylor expanded in x around 0
Applied rewrites56.1%
Taylor expanded in x around 0
*-commutativeN/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6463.4
Applied rewrites63.4%
herbie shell --seed 2024271
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))