Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Exponential Function Programming

by swampyankee (Parson)
on Nov 23, 2007 at 01:10 UTC ( [id://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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-25 23:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found