Tuesday, March 1, 2011

Euler's formula in F# : #2

In last year, I wrote Euler's formula in F#. In this article, I used C# classes in System.Numerics namespace. At this time, i write again, with using F# PowerPack.
Microsoft (R) F# 2.0 Interactive build 2.0.0.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

For help type #help;;

> #r "FSharp.PowerPack";;

--> Referenced 'C:\Program Files\FSharpPowerPack-2.0.0.0\bin\FSharp.PowerPack.dll'

> open Microsoft.FSharp.Math;;
> let euler_formula = complex 0.0 -Complex.pi.RealPart |> Complex.exp;;

val euler_formula : Complex = -1r-1.22460635382238e-16i
But this also becomes inexact result of floating-point.

No comments:

Post a Comment