#!/usr/bin/perl
#
# Compute the coefficients of a square wave, 
#    as we discussed in the lecture notes,
#    to large orders.
#
#    Print out the coefficients, one per line.
#
#         n   A_n   B_n
#
# MWR 2/5/2019

$debug = 1;

$mypi = 3.141519;

$max_order = 50;

for ($i = 0; $i <= $max_order; $i++) {

  if ($i == 0) {
    $A_coeff = 0.5;
  }
  else {
    $A_coeff = 0.0;
  }

  if ($i % 2 == 1) {
    $B_coeff = (2.0)/($mypi*$i);
  }
  else {
    $B_coeff = 0;
  }

  printf " %5d  A %12.5f  B %12.5f \n", $i, $A_coeff, $B_coeff;


}

exit 0;


