Hi, everyone please i wanna know how calculator and pc's could calculate the square root of a number and please explain the algo behind the sqrt() function in cpp for example !! :)

Recommended Answers

All 3 Replies

If Heron (an old Greek) could do it, so can you.

The algo behind square root? Well, there's a few ways to do it.

A naive way to do is with a binary search (divide by two and square to test accuracy).

You can get much faster approximations (without the need for trials) using Calculus (like newtons method as a simple example). Even better, you can use calculus to guerentee a certian percision (even if your using IEEE numbers). Trying to guerentee precisions though larger calculations (quickly) is called numerical computation, and is pretty interesting with it's involvement with applied mathematics.

for those who said im lazy student well im not a #cs student im just intrested in #CS ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.