#include
#include
#include
double
generic_Re(double c, double d)
{
double exp_v, cos_v;
exp_v = exp((-0.5) * M_PI * d);
cos_v = cos(M_PI * 0.5 * c);
return (exp_v * cos_v);
}
double
generic_Im(double c, double d)
{
double exp_v, sin_v;
exp_v = exp((-0.5) * M_PI * d);
sin_v = sin(M_PI * 0.5 * c);
return (exp_v * sin_v);
}
int main(int argc, char *argv[])
{
int times;
int i;
double c_v, d_v;
double c_t, d_t;
if (argc != 2) {
fprintf(stderr, "Usage: %s #times \n", argv[0]);
exit(-1);
}
times = atoi(argv[1]) + 1;
printf("# times\tRe\tIm\n");
printf("# ------------------------------------------------------\n");
c_v = 1;
d_v = 0;
for (i = 1; i < times; i++) {
c_t = generic_Re(c_v, d_v);
d_t = generic_Im(c_v, d_v);
printf("%d\t%f\t%f\n", i, c_t, d_t);
c_v = c_t;
d_v = d_t;
}
}