Bug introduced in 6.0, persisting through 13.3.1.

This is SINC filter, integrate $|H|^2$ from $-\pi/2$ to $\pi/2$.

MMA CODE, Result = 7.27956e-12

osr = 16;z = E^(I*w);
h = (1-z^-osr)/(1-z^-1)/osr;
N[Integrate[0.5*(Abs[h^5])^2, {w, -π, π}]/(2*π/osr), 5]

MATLAB CODE, Result = 0.2156

syms w
osr = 16;

Further, if increasing OSR=32, MMA will come up with a more outrageous answer; while if decreasing the order to 4, h^4, MMA's result is correct. Could anyone help explain this, thank you!

  • $\begingroup$ NIntegrate[0.5*(Abs[h^5])^2, {w, -π, π}]/(2*π/osr). $\endgroup$
    – Syed
    Commented Oct 31, 2023 at 1:30
  • $\begingroup$ To close voters, this isn't a simple mistake at all, it's a bug, see my answer below. $\endgroup$
    – xzczd
    Commented Oct 31, 2023 at 2:20

1 Answer 1


This is a bug introduced in v6. To be precise, a regression is first introduced in v5.1 or v5.2:

enter image description here

enter image description here

Then it evolves to a bug in v6:

enter image description here

As shown by Syed in comment above, if you just need numeric solution, then using NIntegrate instead is a possible work-around:

NIntegrate[1/2 (Abs[h^5])^2, {w, -π, π}]/(2 π/osr)
(* 0.215606 *)

It's also possible to fix the issue in Integrate. We just need ComplexExpand:

osr = 16; z = E^(I*w);
h = (1 - z^-osr)/(1 - z^-1)/osr;
Integrate[1/2 (Abs[h^5])^2 // ComplexExpand, {w, -π, π}]/(2 π/osr)
(* 1852037801/8589934592 *)
(* 0.215606 *)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.