Saturday, November 13, 2010

Euler's formula in F#

  1. Create new F# application on VS2010
  2. Check the references containing System.Numerics
Then edit the code like below:
open System
open System.Numerics

let euler_formula = Numerics.Complex.Exp(Numerics.Complex(0.0, -Math.PI))
printfn "%O" euler_formula

At last, launch the command prompt with F5:
(-1, -1.22460635382238E-16)
It occurs by inexactness of floating-point.

No comments:

Post a Comment