I guess this is as much a mathematics and computer science question as it is a Swift question.
I came across the need for π today while writing a function that calculates continuously compounding interest using the formula interest = π interest rate Γ number of compounding periods. Surprisingly, despite its importance and usefulness, I wasn't able to find π in the standard library, Numerics package, or Foundation. So, what are some ways to computing or approximating π, with what's available in Swift?
I admit I skimmed the Wikipedia article, but for the benefit of everyone can you please point out where it describes a use of e that isnβt as the base of an exponentiation or a logarithm?
It arises in probability. E.g. randomly select a number between 1 to n, n times. What's the probability a particular number, 1 say, never comes up? as n gets larger and larger the probability tends to 1 / e
Well, yes. But if you were asked to calculate 1 / e, in maths or computing, you would not normally reach for exp(). You could also reformulate the problem so the answer is e.