Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Exponential Function Programming

by swampyankee (Parson)
on Nov 23, 2007 at 01:10 UTC ( #652466=note: print w/ replies, xml ) Need Help??


in reply to Exponential Function Programming

Perl has an exponentiation operator (**, just like Fortran's ;-)), so x**n is easy. I believe, however, that Perl uses the C math library's pow routine (and 0**0 is undefined, and should return NaN, regardless of Perl's behavior, but I digress). In any case, writing a sub to calculate small integer powers, with little concern for efficiency, is quite easy. The factorials require a routine. Don't make the mistake of writing a recursive routine to calculate factorials; they are easily, and much more efficiently, calculated by a for loop.

Neither piece is particularly difficult. Beware, though, that numerical programming can be quite tricky when values get large or small. There is a wealth of information to be had, for example at na net and the Dictionary of Algorithms and Data Structures.


emc

Information about American English usage here and here.

Any Northeastern US area jobs? I'm currently unemployed.


Comment on Re: Exponential Function Programming

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (14)
As of 2014-07-14 14:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (261 votes), past polls