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

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://652466]
[Eily]: congrats Discipulus :)
[choroba]: I often can't log in to pause. But after it fails for the first time, everything works for the second time.

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2017-02-22 09:06 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (325 votes). Check out past polls.