Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Transformative functions...?

by edwyr (Sexton)
on Feb 13, 2017 at 20:33 UTC ( [id://1181921]=note: print w/replies, xml ) Need Help??


in reply to Re: Transformative functions...?
in thread Transformative functions...?

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1181921]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-25 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found