File: 19misccalc.t

package info (click to toggle)
libmath-symbolic-perl 0.613-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,268 kB
  • sloc: perl: 12,638; makefile: 9
file content (49 lines) | stat: -rw-r--r-- 1,468 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!perl
use strict;
use warnings;

use Test::More tests => 11;

BEGIN {
	use_ok('Math::Symbolic');
	use_ok('Math::Symbolic::MiscCalculus');
}

if ($ENV{TEST_YAPP_PARSER}) {
	require Math::Symbolic::Parser::Yapp;
	$Math::Symbolic::Parser = Math::Symbolic::Parser::Yapp->new();
}

use Math::Symbolic qw/:all/;
use Math::Symbolic::ExportConstants qw/:all/;
use Math::Symbolic::MiscCalculus qw/:all/;

my $func = 'sin(x)';
my $taylor = TaylorPolynomial $func, 0, 'x', 'x_0';
ok( $taylor->is_identical('sin(x_0)'), 'simple taylor poly of 0-th degree' );

$taylor = TaylorPolynomial $func, 1, 'x';
ok( $taylor->is_identical('(sin(x_0)) + (((cos(x_0)) / 1) * ((x - x_0) ^ 1))'),
    'simple taylor poly of first degree' );

$taylor = TaylorPolynomial 'tan(a)', 3, 'a', 'b';
ok( defined $taylor, 'complex taylor poly of third degree' );

my $error = TaylorErrorLagrange 'sin(x)', 3, 'x';
ok( defined $error, 'simple lagrange error' );

$error = TaylorErrorLagrange 'tan(x)', 1, 'x', 'var';
ok( defined $error, 'more simple lagrange error' );

$error = TaylorErrorLagrange 'tan(x)', 0, 'x', 'var', 'that';
ok( defined $error, 'more simple lagrange error' );

$error = TaylorErrorCauchy 'cos(x)', 2, 'x';
ok( defined $error, 'simple cauchy error' );

$error = TaylorErrorCauchy 'sin(x)*cos(x)', 1, 'x', 'var';
ok( defined $error, 'more simple cauchy error' );

$error = TaylorErrorCauchy 'tan(x)*sin(x)', 1, 'x', 'var', 'that';
ok( defined $error, 'more simple cauchy error' );