0

How does sqrt function really work ? Does it go by any logical theorem to get the result.

Is there any way i can access the code of libarary function such as sqrt?

Fenris
  • 45
  • 2
  • 6
  • 1
    This would more be a question for http://programmers.stackexchange.com/ – AntonH Apr 08 '14 at 11:59
  • 1
    It's in the GNU library. Source code is readily available. – Engineer2021 Apr 08 '14 at 12:01
  • look http://www.gnu.org/software/gsl/manual/gsl-ref.html – Jayesh Bhoi Apr 08 '14 at 12:02
  • There are lots of algorithms [here](https://en.wikipedia.org/wiki/Methods_of_computing_square_roots) and [here](http://mathworld.wolfram.com/SquareRootAlgorithms.html). There are also answers on http://stackoverflow.com/questions/1623375/writing-your-own-square-root-function – phuclv Apr 08 '14 at 12:02
  • https://sourceware.org/git/?p=glibc.git;a=blob_plain;f=math/s_csqrt.c;hb=HEAD – Engineer2021 Apr 08 '14 at 12:03
  • can i access the file? on my pc – Fenris Apr 08 '14 at 12:03
  • Can I use google to find answers on the web ? (Sorry I just couldn't resist ;-) ) – Jabberwocky Apr 08 '14 at 12:05
  • thnx! ur info was valuable – Fenris Apr 08 '14 at 12:10
  • @AntonH [Please stop using Programmers.SE as your toilet bowl](http://meta.stackexchange.com/questions/73382/please-stop-using-programmers-se-as-your-toilet-bowl) – gnat Apr 08 '14 at 12:26
  • @gnat Given that it's a question about the conception of a language, I really don't see the point of your comment. If you could give more detail, I would be happy to read your answer. – AntonH Apr 08 '14 at 12:29
  • @AntonH see http://meta.stackexchange.com/questions/182266/how-much-research-effort-is-expected-of-stack-overflow-users and http://meta.programmers.stackexchange.com/a/6484/31260 – gnat Apr 08 '14 at 12:30

1 Answers1

4

You can download the source code from the libc, which is open source: http://www.gnu.org/software/libc/download.html

cnluzon
  • 1,054
  • 1
  • 11
  • 22
  • 1
    http://www.codeproject.com/Articles/69941/Best-Square-Root-Method-Algorithm-Function-Precisi – Fenris Apr 08 '14 at 12:13
  • This has a lot of very good information on the different ways to implement the sqrt function, and their speeds and precision – Fenris Apr 08 '14 at 12:14