10 How to calculate the calculation process

Mondo Technology Updated on 2024-01-19

Tossing and dividing is a commonly used method of solving the square root, also known as the Newton-Raphson method. The basic idea of this method is to get an approximation that is getting closer and closer to the true value by constantly removing a certain number from the number of squares to be opened.

First, we need to choose an initial approximation, which can be any number greater than or equal to the root. We then use this approximation to remove the square number to get a remainder. Next, we divide the remainder as the new dividend, the original approximate as the new divisor, and divide it again to get the new remainder. We repeat this process until the remainder is 0.

In this process, each approximation is a further approximation of the true value. We can use a loop to repeat the process until we reach the accuracy we need.

Here's an example of a Python using tossing division to solve the square root:

python

def sqrt(x):

approx = x initial approximation.

while true:

remainder = x % approx to calculate the remainder.

if remainder == 0: If the remainder is 0, then the approximation is the root.

return approx

else:approx = (approx + x approx) 2 to update the approximation.

In this one, we use a while loop to repeat the division process until the remainder is 0. In each loop, we use the current approximation to calculate the remainder and update the approximation based on the value of the remainder. If the remainder is 0, then the current approximation is the root, and we can return this approximation directly.

The good thing about this approach is that with each loop, our approximation gets closer and closer to the true value. This allows us to get a fairly precise answer in a very short time.

For example: 10 square meters.

Find an approximate number that is 3, then divide 10 by 3, quotient 3 and balance 1, and continue to iterate until the remainder is zero.

Related Pages