What would be the best way to calculate interest rate using the following notations I need to calculate the interest rate automatically, but my maths is not very strong and i couldnt figure it out. I am pretty sure its just a game of seconds for the experts. Thank you very much for the help.
Minimum loan = 100,000
Maximum loan = 1,000,000
At 100k the loan interest is 7% whereas at 1000k the interest rate is 5%.
Now, using that data, how can a computer automatically calculate the interest rate based on that scale? Like interest for 500k or 437,698$
Against thanks alot
 A: There is no automatic answer, the appropriate interest rate is a business decision, which might be influenced by various factors.  
But a mathematically simple possibility is to use linear interpolation. For a sum $S$ between $100000$ and $1000000$ we would then set the interest rate at the following percentage:
$$7 -(7-5)\frac{S-100000}{1000000-100000}.$$
We have given the answer in "raw" form in order to make it easy to adjust if the numbers change.
Edit: This is in answer to a request for a derivation. We will lie a bit about how we actually did it. Linear interpolation is such a common tool that after a while the answer becomes almost automatic. Instead we will use an unpleasant amount of algebra.  
Let $A$ be the lower amount, here $100000$, and $B$ the higher amount, here $1000000$. Let $a$ be the interest rate at the lower amount, here $7$ (percent), and let $b$ be the interest rate at the higher amount. Let $x$ be the interest rate when the loan size is $S$. (If the symbols $A$, $B$, $a$, $B$ get in the way of understanding, substitute their actual values in your problem in the algebra below.)  
Assume that $x$ is a linear function of $S$. More precisely, assume that $x=a-(pS+q)$, where $p$ and $q$ are numbers to be determined. 
When $S=A$, we have $x=a$, so $0=pA+q$. Thus $q=-pA$. 
When $S=B$, we have $x=b$, so $b=a-(pB+q)=a-(pB-pA)$.  It follows that $a-b=p(B-A)$, and therefore $p=\frac{a-b}{B-A}$.
We find that 
$$x=a-(pS-pA)=a-p(S-A)=a-\frac{a-b}{B-A}(S-A)=a-(a-b)\frac{B-A}{S-A}.$$
That is the general formula.  
