Math::BigFloat
#!/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

In that case..
#!/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

In reply to Re: enumerating values for slopes by trippledubs
in thread enumerating values for slopes by Aldebaran

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.