[system] / trunk / pg / macros / PGauxiliaryFunctions.pl Repository:
ViewVC logotype

Diff of /trunk/pg/macros/PGauxiliaryFunctions.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1303 Revision 2576
1 1
2sub _PGauxiliaryFunctions_init { 2sub _PGauxiliaryFunctions_init {
3 3
4} 4}
5 5
6sub tan {
7 sin($_[0])/cos($_[0]);
8}
9sub cot {
10 cos($_[0])/sin($_[0]);
11}
12sub sec {
13 1/cos($_[0]);
14}
15sub csc {
16 1/sin($_[0]);
17}
18sub ln {
19 log($_[0]);
20}
21sub logten {
22 log($_[0])/log(10);
23}
24sub arcsin {
25 atan2 ($_[0],sqrt(1-$_[0]*$_[0]));
26}
27sub asin {
28 atan2 ($_[0],sqrt(1-$_[0]*$_[0]));
29}
30sub arccos {
31 atan2 (sqrt(1-$_[0]*$_[0]),$_[0]);
32}
33sub acos {
34 atan2 (sqrt(1-$_[0]*$_[0]),$_[0]);
35}
36sub arctan {
37 atan2($_[0],1);
38}
39sub atan {
40 atan2($_[0],1);
41}
42sub arccot {
43 atan2(1,$_[0]);
44}
45sub acot {
46 atan2(1,$_[0]);
47}
48sub sinh {
49 (exp($_[0]) - exp(-$_[0]))/2;
50}
51sub cosh {
52 (exp($_[0]) + exp(-$_[0]))/2;
53}
54sub tanh {
55 (exp($_[0]) - exp(-$_[0]))/(exp($_[0]) + exp(-$_[0]));
56}
57sub sech {
58 2/(exp($_[0]) + exp(-$_[0]));
59}
60# 6#
61# DPVC -- 2002/03/31 7# Get the functions that are in common with Parser.pm
62# added missing trig, inverse and hyperbolic functions
63# 8#
64sub csch {2.0/(exp($_[0]) - exp(-$_[0]))} 9loadMacros("PGcommonFunctions.pl");
65sub coth {(exp($_[0]) + exp(-$_[0]))/(exp($_[0]) - exp(-$_[0]))}
66 10
67sub arcsec {acos(1.0/$_[0])}; sub asec {acos(1.0/$_[0])}
68sub arccsc {asin(1.0/$_[0])}; sub acsc {asin(1.0/$_[0])}
69
70sub arcsinh {log($_[0]+sqrt($_[0]*$_[0]+1.0))}
71sub arccosh {log($_[0]+sqrt($_[0]*$_[0]-1.0))}
72sub arctanh {log((1.0+$_[0])/(1.0-$_[0]))/2.0}
73sub arcsech {log((1.0+sqrt(1-$_[0]*$_[0]))/$_[0])}
74sub arccsch {log((1.0+sqrt(1+$_[0]*$_[0]))/$_[0])}
75sub arccoth {log(($_[0]+1.0)/($_[0]-1.0))/2.0}
76
77sub asinh {log($_[0]+sqrt($_[0]*$_[0]+1.0))}
78sub acosh {log($_[0]+sqrt($_[0]*$_[0]-1.0))}
79sub atanh {log((1.0+$_[0])/(1.0-$_[0]))/2.0}
80sub asech {log((1.0+sqrt(1-$_[0]*$_[0]))/$_[0])}
81sub acsch {log((1.0+sqrt(1+$_[0]*$_[0]))/$_[0])}
82sub acoth {log(($_[0]+1.0)/($_[0]-1.0))/2.0}
83# 11#
84# End DPVC 12# Do the additional functions
85# 13#
86sub sgn {
87 my $x = shift;
88 my $out;
89 $out = 1 if $x > 0;
90 $out = 0 if $x == 0;
91 $out = -1 if $x<0;
92 $out;
93}
94sub step { # heavyside function (1 or x>0) 14sub step { # heavyside function (1 or x>0)
95 my $x = shift; 15 my $x = shift;
96 ($x > 0 ) ? 1 : 0; 16 ($x > 0 ) ? 1 : 0;
97} 17}
98sub ceil { 18sub ceil {

Legend:
Removed from v.1303  
changed lines
  Added in v.2576

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9