Number refuses to divide
<p>I have made a simple function called "Approx" which multiplies two numbers together then divides them by two. When I use the function by itself it works great but it seems in the hunk of code I have it doesn't divide the number in half and I have no idea why. This is my code where is the error and how can I fix it?</p>

<pre><code>import math

def Approx(low,high):
    base = low * high
    return base/2

root = float(input("What to approx the sqrt of : "))
vague = float(input("How off can it be? : "))
wrong = True
oroot = root
root = math.floor(float(root))
trunk = root + 1
step = 0
while wrong:
    if Approx(root,trunk) &gt; oroot - vague and Approx(root,trunk) &lt; oroot:
        print("Done. " + str(step) + " steps taken.")
    else:
        if Approx(root,trunk) &gt; oroot:
            temproot = root
            root = Approx(root,trunk)
            trunk = temproot
            step += 1
            print("Step " + str(step) + " finished. Approx is " + str(Approx(root,trunk)))
        else:
            temptrunk = trunk
            trunk = Approx(root,trunk)
            root = trunk
            step += 1
            print("Step " + str(step) + " finished. Approx is " + str(Approx(root,trunk)))
    if step &gt; 50:
        print("More than fifty steps required.")
        wrong = False
</code></pre>

<p>It looks to me that it definitely <strong>does</strong> divide by two, it is just that dividing by two doesn't undo multiplying two large numbers together. For example, say you wanted to find the square root of <code>10</code>. <code>trunk</code> is set to <code>11</code>. <code>Approx(root, trunk)</code> is <code>10 * 11 / 2 = 55</code>. This is set to <code>root</code> and <code>trunk</code> becomes the old <code>root</code>, <code>10</code>. Now you have <code>55</code> and <code>10</code> instead of <code>10</code> and <code>11</code>. Repeat this a few times and you end up with <code>inf</code>. Look more into the method you're trying to implement (is it the Babylonian method?) and see where your program and the method differ. That is likely the source of your woes, and not a lack of division. </p>

python python-3.x