The connection to PERL is simply that I'm writing my code in PERL. Here's the example code I'm playing with for transformative functions:
#!/usr/bin/perl
use strict;
use warnings;
my @values = (-10, -9, -8, -7, -6, -5, -4,
-3, -2, -1, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0
+.2, -0.1,
0, 0.1, 0.111111, 0.12, 0.13, 0.16, 0.19, 0.2, 0.21, 0.2
+2,
0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.00001, 1.001, 1.
+1, 1.2,
1.3, 1.8, 1.9, 2.000001, 2.001, 2.1, 2.11, 2.2, 2.3, 2.4
+,
3.1, 4, 5, 6, 7, 8, 9, 10,
1.16873493792849e-06, 1088.99977561893);
my $wval;
my $wexp;
my $wtanh;
my $wfisher;
my $we2;
# http://mathworld.wolfram.com/HyperbolicTangent.html
sub tanh($) {
my $in = shift;
my $a = exp($in);
my $b = exp(-$in);
return ($a - $b) / ($a + $b);
}
# https://support.office.com/en-us/article/FISHER-function-D656523C-50
+76-4F95-B87B-7741BF236C69
sub fisher($) {
my $in = shift;
return 0 if $in == 1;
my $a = (1 + $in) / (1 - $in);
return 0 if $a <= 0;
return 0.5 * log($a);
}
sub e2($) {
my $in = shift;
return 0 if $in == 1;
return 0.5 * exp((1 + $in) / (1 - $in));
}
map {
$wval = $_;
$wexp = exp($_);
$wtanh = &tanh($_);
$wfisher = &fisher($_);
$we2 = &e2($_);
write;
} @values;
format STDOUT_TOP =
value exponent(e) tanh fisher e2
--------- -------------------- ----------------- --------------- -----
+----------
.
format STDOUT =
@###.#### @######.############ @###.############ @###.########## @###.
+##########
$wval, $wexp, $wtanh, $wfisher, $we2
.
Mike |