func exp(_ x: Double) -> Double {
if abs(x) < 1e-12 {
return 1 + x
}
let a = exp(x/2)
return a*a
}
print(exp(1)) // 2.718281808182473
理論値: $e = 2.71828 18284 59045 23536 02874 71352$
Go to list of users who liked
More than 1 year has passed since last update.
func exp(_ x: Double) -> Double {
if abs(x) < 1e-12 {
return 1 + x
}
let a = exp(x/2)
return a*a
}
print(exp(1)) // 2.718281808182473
理論値: $e = 2.71828 18284 59045 23536 02874 71352$
Register as a new user and use Qiita more conveniently
Go to list of users who liked