Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Square root function in F#

Tags:

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.

like image 621
user2549169 Avatar asked Jul 04 '13 06:07

user2549169


2 Answers

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.

like image 152
Jon Skeet Avatar answered Oct 06 '22 01:10

Jon Skeet


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

like image 37
paulsm4 Avatar answered Oct 06 '22 01:10

paulsm4