[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: mathlib
- From: Dirk Laurie <dirk.laurie@...>
- Date: Fri, 4 Apr 2014 11:48:06 +0200
2014-04-04 10:49 GMT+02:00 Joseph Manning <manning@cs.ucc.ie>:
> While on the subject of the 'math' library, why does Lua provide
>
> math.pi -- == 4 * math.atan( 1 )
>
> but not
>
> math.e -- == math.exp( 1 )
>
> It would seem more consistent to provide either both or neither.
>
> Is it due to the greater computational effort in 4 * math.atan( 1 ) ?
> This does not seem like a particularly strong reason; if 'pi' is used
> many times in a program, it could be cached into a local anyway.
>
> Or is it felt that people use 'pi' vastly more often than 'e'?
I can't think offhand of an application that needs the numerical value
of e. It appears in mathematical formulas almost exclusively as a base
for exponentiation, and we have exp for that. It's in fact more common
to find Euler's constant by itself in a formula, but even I will agree that
people who know what it is should also be able to put in their own
local euler = 0.57721566490153286060651209