user2549169
user2549169

Reputation: 113

Square root function in F#

How can we find the square root of a number in F#? Do we have a Sqrt function in F# just like we have Math.Sqrt() function in Java? I am a beginner in F# and couldn't find any significant help on the internet.

Upvotes: 6

Views: 11658

Answers (2)

Jon Skeet
Jon Skeet

Reputation: 1502816

F# already has a sqrt function defined, so you should just be able to use:

sqrt x

where x is the value you wish to find the root of.

Upvotes: 26

paulsm4
paulsm4

Reputation: 121809

Yes, F# comes with a "sqrt" function. Called "sqrt" :)

http://blogs.msdn.com/b/dsyme/archive/2008/09/01/the-f-operators-and-basic-functions.aspx

Many more numerical libraries are available for F#, either open source (e.g. CodePlex) or from 3rd party vendors:

http://msdn.microsoft.com/en-us/library/vstudio/hh304372%28v=vs.100%29.aspx

Upvotes: 9

Related Questions