in reply to enumerating values for slopes
#!/usr/bin/env perl use strict; use warnings; use Math::Trig; use Math::BigFloat; use feature 'say'; my $pi = Math::BigFloat->bpi(10); my ($run,$theta) = (3,8); my $radians = Math::BigFloat->new($theta * $pi / 180); #my $rise = Math::BigFloat->new($run * tan($radians)); my $rise = Math::BigFloat->new($run * (sin($radians) / cos($radians))) +; say "rise is $rise"; #rise is 0.42162250410717434055
Here is what I came up with for an equivalent. Supposedly the Math:: packages offer up to arbitrary precision or accuracy. The tan function is not working for me though, I get an error: Can't call Math::BigFloat->_cartesian, not a valid method at /usr/local/share/perl/5.14.2/Math/Complex.pm line 928. This inspired me to use a trig identity in real, well, almost real life for the first time..
So, if you can install packages, (Math::Trig and Math::BigFloat come with Perl) you can use those modules for really high accuracy calculations. If you don't then you might have to lose some accuracy
#!/usr/bin/env perl use strict; use warnings; my $pi = 355/113; my ($run,$theta) = (3,8); my $radians = $theta*$pi/180; my $rise = $run * (sin($radians) / cos($radians)); say "rise is $rise"; #rise is 0.421622540378273
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: enumerating values for slopes
by Laurent_R (Canon) on Sep 21, 2014 at 09:57 UTC | |
by Anonymous Monk on Sep 21, 2014 at 10:15 UTC | |
by Laurent_R (Canon) on Sep 21, 2014 at 10:34 UTC | |
by Aldebaran (Curate) on Sep 22, 2014 at 03:39 UTC |