App-ErrorCalculator

 view release on metacpan or  search on metacpan

lib/App/ErrorCalculator.pm  view on Meta::CPAN

		new_and_run
		Gtk2::Ex::Dialogs::ErrorMsg( text => "Could not open output file for writing: $!" );	
		return();
	}
}


1;

__END__

=head1 NAME

App::ErrorCalculator - Calculations with Gaussian Error Propagation

=head1 SYNOPSIS

  # You can use the 'errorcalculator' script instead.
  
  require App::ErrorCalculator;
  App::ErrorCalculator->run();

  # Using the script:
  # errorcalculator

=head1 DESCRIPTION

C<errorcalculator> and its implementing Perl module
C<App::ErrorCalculator> is a Gtk2 tool that lets you do
calculations with automatic error propagation.

Start the script, enter a function into the function entry
field, select an input file, select an output file and hit
the I<Run Calculation> button to have all data in the input
field processed according to the function and written to the
output file.

Functions should consist of a function name followed by an
equals sign and a function body. All identifiers
(both the function name and all variables in the function body)
should start with a letter. They may contain letters, numbers and
underscores.

The function body may contain any number of constants, variables,
operators, functions and parenthesis.
The exact syntax can be obtained by reading
the manual page for L<Math::Symbolic::Parser>. Arithmetic
operators (C<+ - * / ^>) are supported. The caret indicates
exponentiation. Trigonometric, inverse
trigonometric and hyperbolic functions are implemented
(C<sin cos tan cot asin acos atan acot sinh cosh asinh acoth>).
C<log> indicates a natural logarithm.

Additionally, you may include derivatives in the formula which
will be evaluated (analytically) for you. The syntax for this is:
C<partial_derivative(a * x + b, x)>. (Would evaluate to C<a>.)

In order to allow for errors in constants, the program uses the
L<Math::SymbolicX::Error> parser extension: use the
C<error(1 +/- 0.2)> function to include constants with
associated uncertainties in your formulas.

The input files may be of any format recognized by the
L<Spreadsheet::Read> module. That means: Excel sheets,
OpenOffice (1.0) spreadsheets, CSV (comma separated values)
text files, etc.

The program reads tabular data from the spreadsheet file.
It expects each column to contain the data for one variable
in the formula.

  a,   b,   c
  1,   2,   3
  4,   5,   6
  7,   8,   9

This would assign C<1> to the variable C<a>, C<2> to C<b>
and C<3> to C<c> and then evaluate the formula with those
values. The result would be written to the first data line
of the output file. Then, the data in the next row will be
used and so on. If a column is missing data, it is assumed
to be zero.

Since this is about errors, you can declare any number of
errors to the numbers as demonstrated below:

  a,    a_1,  a_2,  b,    b_1
  1,    0.2,  0.1,  2,    0.3
  4,    0.3,  0.3,  5,    0.6
  7,    0.4,  0,1,  8,    0.9

Apart from dropping C<c> for brevity, this example input
adds columns for the errors of C<a> and C<b>. C<a>
has two errors: C<a_1> and C<a_2>. C<b> only has one
error C<b_1> which corresponds to the error C<a_1>.
When calculating, C<a> will be used as C<1 +/- 0.2 +/- 0.1>
in the first calculation and C<b> as C<2 +/- 0.3 +/- 0>.
The error propagation is implemented using
L<Number::WithError> so that's where you go for details.

The output file will be a CSV file similar to the input examples
above.

=head1 EXAMPLES

=head2 Sample input file

  "a", "a_1", "a_2", "x", "x_1", "x_2"
  1,   "0.1", "1.1", 10,  "0.1", "1.1"
  2,   "0.2", "1.2", 11,  "0.2", "1.2"
  3,   "0.3", "1.3", 12,  "0.3", "1.3"
  4,   "0.4", "1.4", 13,  "0.4", "1.4"
  5,   "0.5", "1.5", 14,  "0.5", "1.5"

=head2 Example function

  f = a * x^2

=head2 Example output file

  "f",       "f_1",     "f_2"



( run in 0.500 second using v1.01-cache-2.11-cpan-df04353d9ac )