|
-
Sep 13th, 2001, 03:25 PM
#1
square root
Is there a formula to find out square roots, or do you just use approximate divisions to work out the answer?
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Sep 13th, 2001, 03:45 PM
#2
Lively Member
-
Sep 13th, 2001, 03:55 PM
#3
thanks
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Sep 14th, 2001, 12:00 AM
#4
Try the Sqr() function - although maybe that is only a VB6 function.. I never needed to use it before I got VB6 so I'm not sure 
- Aurilus
-
Sep 14th, 2001, 12:03 AM
#5
Originally posted by Aurilus
Try the Sqr() function - although maybe that is only a VB6 function.. I never needed to use it before I got VB6 so I'm not sure 
- Aurilus
Yeah, I know all about the functions, but I was looking for an explanation on how they work. And that link seems to explain it.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Sep 17th, 2001, 07:38 AM
#6
Addicted Member
Here is a manual method example, it’s similar to long division :
Pick a number, any number 18.6624
Draw a line above the number and a vertical line down the left hand side.
Starting at the decimal point, draw vertical lines grouping the numbers into pairs.
|---|-|---|------------
|18|.|66|24
Take the approx square root of the leftmost pair of digits 18, which is 4.
Write this number above the leftmost pair (add the decimal point if it’s next) this is the partial answer.
4 .
|---------------------
|18|.|66|24
Write the square of this partial answer under the first pair and subtract.
4 .
|---------------------
|18|.|66|24
|16
| --
| 2
Bring down the next pair of digits
4 .
|---------------------
|18|.|66|24
|16
| --
| 266
Multiply the partial answer by 2 and write it next to the new line, with an underline to the right of it.
4 .
|---------------------
|18|.|66|24
|16
| --
8_ | 266
Find a digit (x) that will replace the underline so that (10 times double the partial answer plus x) multiplied by x is less than the present remainder
or in this case so that x times eighty-x is less that 266.
4 . 3
|---------------------
|18|.|66|24
|16
| --
83 | 266
| 249
add this new digit to the partial answer on the top line and multiply the 83 by the new digit.
Subtract this new value from the line above it and bring down the next pair of digits
4 . 3
|---------------------
|18|.|66|24
|16
| --
83 | 266
| 249
|------
| 1724
Again, multiply the partial answer by 2 and leave an underline to the right
4 . 3
|---------------------
|18|.|66|24
|16
| --
83 | 266
| 249
|------
86_ | 1724
Find a replacement for the underline similar to above, add this to the partial answer, and multiply
(the 862 by 2)
4 . 3 2
|---------------------
|18|.|66|24
|16
| --
83 | 266
| 249
|------
862 | 1724
| 1724
----------
0
Subtract and continue until you have enough digits in the partial answer for your purposes.
In this case ( as I cheated) the result of the subtraction is zero so the answer is a proper square root.
-
Sep 25th, 2001, 11:02 AM
#7
Frenzied Member
Successive approximations.
See the following thread.
http://www.vbforums.com/showthread.p...threadid=65366
It describes the successive approximation method usually used for computer square root functions. It shows an example, and describes the use of the general method for solving other problems. I do not think it is difficult to understand. Briefly, square root is calculated as follows.- Guess at the square root. Suppose we wanted the square root of 100 and guessed twenty.
- Divide the number by the guess: 100/20 = 5
- Average the guess and the quotient: (5 + 20) / 2 = 12.5
- Use the average as the next guess.
- Continue the above until two successive guesses are almost equal.
When I was in elementary school, I got in trouble for using the above method instead of the method taught which looks a bit like division (see post by Starman). If you are good at making a first guess, the successive approximation method is faster.
When computers were very slow and had few resources, a minor problem was determining a first guess at a solution to an equation when successive approximation methods were to be used.
For example, consider a first guess at the square root of a number.- To minimize the code required, some programs used the number itself as the first approximation. This resulted in a lot of iterations and a slower program.
- A better approximation is the average of the number and one. For the square root of five you would use 3, which is a lot better the above approximation of five (the number itself). For the square root of .5, you would use .75 (this is pretty good).
- For very large or very small numbers, the above is not very good, but if calculating a first guess takes more time than 3-4 iterations of the successive approximation method, you might not save much.
Does anybody know what algorithm is used for a first guess in modern systems?
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
-
Sep 26th, 2001, 11:49 AM
#8
Some use tables. The fastest ones generally do use tables.
here is a discussion of it:
http://www.azillionmonkeys.com/qed/sqroot.html
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|