What is the method of extracting the root of the assembly ?
mb78
long time ago read that if the processor does not support the operation of extracting the root, it is somehow calculated by simple operations.
long time ago read that if the processor does not support the operation of extracting the root, it is somehow calculated by simple operations.
The integer part of the square root can be calculated in a simple manner.To subtract this from the source of all the odd number as long as the balance is not smaller than the number of the next or subtracted becomes equal to zero.The number of subtractions is equal to the square root of an integer.
Example.There is the original number 16.
16-1 = 15
15-3 = 12 12-5 =
7
7-7 = 0
subtraction was 4, then the integer part of the square root of the initial number will be equal to 4.
With fractional numbers a bit more complicated, but also can be solved by simple operations.For example, if you equate
it can solve one of the known algorithms, for example, by interval bisection .We set an initial value, such as 100 (which is obviously more than the required number), we believe the value equation.If the equation has turned out greater than 0, then substitute the value of 100/2 = 50 (we had a closed interval [0, 100]).Again, we consider the value of the equation.If we now got less than zero, we substitute the value of the middle interval [50; 100] 75, again believe and value, etc.Calculations finish, when it reached the required accuracy of the result.As a result, we obtain the square root of numbers with a given accuracy.
Multiplication and division can be reduced to addition and subtraction operations.In our algorithm, division and multiplication will be used by 2. In computing, it is done at all simple.As used binary system , then multiply the number by 2 just need to make a shift to the left the number by one digit (attributed to the right toe), and when divided by 2 - slide number by one digit to the right.Shift operations - these are some of the basic commands of any, even the most primitive processors.
11 July 2016
Recommend the approximate formula : sqrt (a ^ 2 + b) = a + b / (2a).For practical purposes it gives amazing results in terms of accuracy. For example, sqrt ( 1000 ) = sqrt (1024-24) = 32 - 32 = 24/64 - 8.3 = 31.625. A precise value - 31.6228. .. If this accuracy is not sufficient, you can add the next term of the expansion : a + b / (2a) - b ^ 2 / (8a ^ 3 ).
11 July 2016