#!/usr/bin/perl
# Integrate column data by trapezoid rule [positive frequencies only]
# Rok Zitko, zitko@theorie.physik.uni-goettingen.de, Mar 2008
# $Id$

use warnings;
use strict;

my $xprev = 0;
my $yprev = 0;
my $sum = 0;

while (<>) {
  chomp;
  my ($x,$y,$remainder) = split;
  
  if ($. != 1) {
      if ($x >= 0.0 && $xprev >= 0.0) {
        $sum += ($x-$xprev) * ($y + $yprev)/2.0;
      }
  }
  
  $xprev = $x;
  $yprev = $y;
}

print "$sum\n";
