The results obtained from Direct form1 and Direct form2 implementations (in C language) of IIR (BiQuad) filters are a little different. In the implementation, i have made the b0 coefficient as 1. So, I am just using 4 coefficients (a2,a1,b2,b1) in the implementation. The maximum error between the obtained outputs from these two implementations is in the range of 0.01 for the ITU-T standard audio test signal.

I just want to know whether this error is because of the implementation, or any other reasons? Will the Outputs of both implementations be the same, always (i.e. error is almost 0)?

In the implementation, I am using around 8 stages of filtering. (i.e. Cascaded Biquad filters)

The referred structure forms as attached below.

enter image description hereenter image description here

  • $\begingroup$ It is likely due to precision error / round-off error. What precision are you using? $\endgroup$ Jun 8, 2020 at 12:16
  • $\begingroup$ Hi, I'm working on float values. Is there a way to improve the precision of the results? $\endgroup$
    – rkc
    Jun 8, 2020 at 13:31
  • $\begingroup$ There should be no difference and you already did the right thing to implement it as a cascade of biquads. If you implement fixed point in an FPGA you could consider transposed Direct Form 2 to minimize parasitic delays in the adder tree, but that won't explain your errors. Can you post your coefficients you use for one of the stages and the error you get for that? $\endgroup$ Jun 8, 2020 at 13:35
  • $\begingroup$ The coefficients used at one of the stages are -0.95353f, 1.95293f, 1.00000f and -1.99991f and the results obtained are 0.0001643819 (Direct form 2) and 0.0001643784 (Direct form 1) $\endgroup$
    – rkc
    Jun 8, 2020 at 13:51

1 Answer 1


Will the Outputs of both implementations be the same, always (i.e. error is almost 0)?

That depends A LOT on the numerical precision of your data representation and mathematical operations and on the filter itself, specifically the location of the poles.

If you use double precision in a communication application, there should be little to no difference. If you are trying to do audio processing with 16-bit fixed point format, the errors induced by Direct Form II are so large that it's basically unusable.

  • $\begingroup$ Thanks for the response. The filter implementation in my case is based on float values. On comparison, I observed that most of the output sample values (obtained in both the cases) are getting differed only after the 5th or 6th decimal point (since I am working on float values). And also, I want to know which implementation will be better i.e. Direct form 1 or Direct form 2, in case, if I switch to fixed-point notation. $\endgroup$
    – rkc
    Jun 8, 2020 at 13:10
  • $\begingroup$ I also want to know which implementation will be better i.e. Direct form1 or Direct form2, in case, if I switch to 32-bit fixed-point notation instead of 16 bit fixed point. $\endgroup$
    – rkc
    Jun 8, 2020 at 13:26
  • $\begingroup$ Don't use Direct Form II. Use either Direct Form I (safest) or Transposed Form II (almost as safe but less storage requirements) $\endgroup$
    – Hilmar
    Jun 8, 2020 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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