Math::Yacas - Perl interface to YACAS


NAME

Math::Yacas - Perl interface to YACAS (Yet Another Computer Algebra System)


SUPPORTED PLATFORMS

Note: If you know how to adapt this module for another platform, contact me please (Yacas is multi-platform). For Win32 system, Yacas is provided as a dynamically linked library; therefore it's easy to integrate it in another application.


SYNOPSIS

  use Math::Yacas 'Evaluate';
  print Evaluate "Integrate(x) Ln(x)";  # print: x*Ln(x)-x;


DESCRIPTION

Yacas (Yet Another Computer Algebra System) is a small and highly flexible general-purpose computer algebra system and programming language. Yacas is multi-platform and is distributed under the GNU General Public License (GPL). This module provides an interface to Yacas and permits to do symbolic and numeric calculations in a Perl script.

Functions

There are only three functions: Evaluate() , Output() and LastErrorMsg() .

Evaluate
$result = Evaluate( $expression );
Evaluates an expression and returns the result or undef if an error occurs. In this case, the function LastErrorMsg() returns the error message.

Output
$string = Output();
Returns the output printed while evaluating an expression.
    use Math::Yacas ':all';
    print Evaluate "Taylor(x, 0, 5) Sin(x)";
      # prints: x-x^3/6+x^5/120;
    print "\n", Evaluate "PrettyForm(%)";
      # prints: True;
    print Output();
      # prints:      3    5
      #             x    x
      #         x - -- + ---
      #             6    120

LastErrorMsg
$message = LastErrorMsg() ;
Returns a string explaining the error if an error has occurred, or the empty string otherwise.

Exemple

A very simple script to use Yacas interactively in a console:

    #!/usr/bin/perl -w
    use strict;
    use Math::Yacas ':all';
    print "*** This is Yacas 1.0.55\nIn> ";
    while (<STDIN>) {
      chomp;
      last if $_ eq 'quit';
      next unless $_;
      my $r = Evaluate($_);
      if (defined($r)) {
        print Output() if Output();
        print "Out> $r\nIn> ";
      }
      else {
        print LastErrorMsg(), "In> ";
      }
    }

Export

None by default.


SEE ALSO

The Yacas home page : http://yacas.sourceforge.net/

Yacas documentation : http://yacas.sourceforge.net/manindex.html


AUTHOR

J-L Morel <jl_morel@bribes.org>


COPYRIGHT

Copyright (c) 2003 J-L Morel. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

 Math::Yacas - Perl interface to YACAS