#!/usr/bin/perl
#
# Compute the quantities we will graph for the pendulum experiment,
#  particularly the uncertainties.
#
# MWR 9/10/2014
#


# input data has form:
#
# group  length  d_length   omega  d_omega
#        (m)      (m)      (rad/s)  (rad/s)
#A       1.013   0.002      3.103   0.0103

$debug = 1;

while (<STDIN>) {
  $line = $_;
  if ($line =~ /^#/)  {
    next;
  }

  @words = split(/\s+/, " " . $line);
  $group = $words[1];
  $L = $words[2];
  $dL = $words[3];
  $Omega = $words[4];
  $dOmega = $words[5];

  # what is 1/length?  it goes on x-axis
  $x = 1.0 / $L;
  # what is uncertainty in x?
  $dx = $x * ($dL/$L);

  # what is square of omega?  It goes on y-axis
  $y = $Omega*$Omega;
  # what is uncertainty in y?
  $dy = $y * (2.0 * ($dOmega/$Omega));

  # print out one line per input line, with form
  # 
  #  group    x   dx    y    dy
  #
  printf "%-5s  %8.4f  %8.4f  %8.4f  %8.4f  \n",
       $group, $x, $dx, $y, $dy;


}


exit 0;

