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

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.


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?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2015-11-29 17:24 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (751 votes), past polls