Natural Logarithm in Swift

Hey all,

I have tried programming a Riemann Zeta Function calculator, but quickly encountered a problem, I need to calculate the Natural Logarithm (ln) of a value, but Swift seems to have no built-in solution.

Are there any solutions to this problem?

-Yuval Gat

The Darwin module has several logarithm functions. Put a text file of their documentation on your desktop by pasting the following command in Terminal app:


man 3 log | col -b > ~/Desktop/log.txt



You can use these functions in Swift by importing the Foundation framework or just the Darwin module itself. For example:


import Foundation
print(log(Double(10))) // 2.30258509299405
Natural Logarithm in Swift
 
 
Q