Listing 1 Impulse Response Function

#include <stdio.h>

void impulse_response(FILE *out, int N,
double a, double b, double c)
{
   double
      y = c,   /* The most recent system output value */
      y1 = 0;  /* The previous output */
   
   /* Time t = 0, before the impulse. */
   fprintf(out, "%lg\n", y1);
   
   /* Time t = 1, the instant of the impulse. */
   fprintf(out, "%1g\n", y);
   
   N -= 2;  /* Two points already written */
   
   /* All later times, t > 1 */
   while(N-- >= 0)
   {
      double t = y;
      y = a*y + b*y1;
      y1 = t;
      fprintf(out, "%lg\n", y);
   }
}