数式処理は「Math::ematica」モジュールを使うと楽だYO!

http://search.cpan.org/author/ULPFR/Math-ematica-1.108/ematica.pm