If I write two pieces of software that compute the same thing but one does it twice as fast. Does that imply different orders of complexity?
<p>For a given balance and interest rate my programs compute the minimum monthly payment to pay off the debt in a year.
However One computes it on average in ~0.000150s and the other in ~0.000300s. Does that imply different degrees of asymptotic complexity?</p>

<p>These are the code samples: </p>

<p>The slower one:</p>

<pre><code>import time
start_time = time.time()

balance = 999999
annualInterestRate = 0.18
mRate = annualInterestRate/12
high = (((mRate+1)**12)*balance)/12
low = balance/12
guessed = False

def balanceLeft(balance,mRate,minPayment):
    monthsLeft = 12
    while monthsLeft &gt; 0:
        unpaidBalance =  balance - minPayment
        interest = mRate * unpaidBalance
        balance = unpaidBalance
        balance += interest
        monthsLeft -= 1
    return balance

while guessed == False:
    minPayment = (high + low) / 2
    if round(balanceLeft(balance,mRate,minPayment),2) &lt; 0:
        high = minPayment
    elif round(balanceLeft(balance,mRate,minPayment),2)&gt; 0:
        low = minPayment
    else:
        if abs(round(balanceLeft(balance,mRate,minPayment),2) - 0) &lt; 0.01:
            guessed = True

print('Lowest Payment: ',end='')
print(round(minPayment,2))

print("time elapsed: {:.6f}s".format(time.time() - start_time))
</code></pre>

<p>The faster one</p>

<pre><code>import time
start_time = time.time()

annualInterestRate = 0.18
rate = annualInterestRate / 12
monthsLeftr = 12
xCoefficent = 1 + rate
ConstantTerm = 1 + rate
while monthsLeftr &gt; 1:
    xCoefficent = (xCoefficent + 1) * ConstantTerm
    monthsLeftr -= 1


balance = 999999
monthsLeft = 12
while monthsLeft &gt; 0:
    balance = balance * ConstantTerm
    monthsLeft -= 1
minPayment = balance / xCoefficent


print('Lowest Payment: ', end="")
print(round(minPayment,2))

print("time elapsed: {:.6f}s".format(time.time() - start_time))
</code></pre>

<p>No, they are not same program. The first one has a while loop that calls a function that has another while loop - looks like, both of them has different complexity.</p>

<p>The first one is clearly the slower one (a squared complexity program)- the second one has no such inner loops and is a linear complexity program. </p>

python algorithm python-3.x complexity-theory