Understanding the log() function

In summary, I was trying to find an equation that calculates the number of months required to pay off a loan, and I found this equation that uses the logarithm. I don't really understand what the logarithm does in this equation, but I am glad to have found it. I am not sure if I should trust this equation, but I am going to research it more to understand it better.
  • #1
jhudson1
16
0

Homework Statement



Working on a computer program that will create an amortization table (a table that lists each payment on an amortizing loan). I am going to use a simple c++ array to store each row of data, and need to know the number of months required to pay off a given loan so that i know the number of rows needed to initialize in the array.

I searched the internet for a formula to calculate this value (time in months to pay off the loan).

Homework Equations



This is the equation I found:
T = -log(1 - I x L / P) / log(1 + I)

in LaTeX:

[tex] T = \frac{- log(1-I \times L)}{log(1+I)}[/tex]

Where
T is the time to pay off the loan (in months)
I is the monthly interest rate
P is the amount of each payment

The Attempt at a Solution



I can take it on blind faith that this works, but I'd rather not. What seems like a simple, straightforward calculation is confusing me because of the nature of the log() function. What IS its function? What is its purpose in this equation? What is it doing here? HOW DOES IT WORK?

This question has been with me for some time and this seems the perfect opportunity to finally understand it. Any help would be greatly appreciated.
 
Last edited:
Physics news on Phys.org
  • #2
I have made a minor correction to your LaTeX below:
jhudson1 said:
[tex] T = \frac{- \log(1-IL/P)}{\log(1+I)}[/tex]
[...]
I can take it on blind faith that this works, but I'd rather not. What seems like a simple, straightforward calculation is confusing me because of the nature of the log() function.
Do you mean the logarithm in the above relation or the log() function in C++ ?

What IS its function? What is its purpose in this equation? What is it doing here? HOW DOES IT WORK?
... ah, guessing the former.

This problem arises because you didn't derive the equation, instead, you looked it up... therefore you do not understand the relation.

These finance equations involving interest often end up with exponential functions of time - if you want to solve these equations for time, you need an inverse exponential function. That is the role of the logarithm.

In this case the derivation probably used the property [itex]\log{(a^b)}=b\log{(a)}[/itex] to extract the T from an exponent - since:[tex](1+I)^T=\frac{1}{1-IL/P}[/tex]
 
  • #3
Thank you so much! Looking at it that way (as a tool used to manipulate an equation) makes so much sense.
 
  • #4
In the bad old days, that's what we mostly used logs for ... if I wanted to multiply two hard numbers, AxB say, I'd use log(AB)=log(A)+log(B) and look up the logs of A and B in a set of tables - add them to get log(AB) - then find the antilogarithm of that (another set of tables) to get the product.

Serious engineering was done with this sort of math.
Be glad - be very glad.
 
  • #5
Simon Bridge said:
In the bad old days, that's what we mostly used logs for ... if I wanted to multiply two hard numbers, AxB say, I'd use log(AB)=log(A)+log(B) and look up the logs of A and B in a set of tables - add them to get log(AB) - then find the antilogarithm of that (another set of tables) to get the product.

Serious engineering was done with this sort of math.
Be glad - be very glad.

This is also the basis of how multiplication works on a slide rule. The lengths you add correspond to the logs of the numbers, and the result you get is the log of the answer. Division works in a similar way by subtracting lengths, using the formula log(A/B) = log(A) - log(B).
 
  • #6
They confiscated my slide rule ... I had to make do with a couple of twigs and a bit of wool pulled from my jersey... ah the days I spent hunched over my math, clutching the unravelling ends of my jersey with one hand while Mr Matthews drummed his fingers on the yellow box containing his strap...
 
  • #7
You had twigs? What luxury! We dreamed of the day we would have a couple of nice twigs, let alone a jersey from which to pluck a tuft of wool.

(Apologies to Monte Python's Gentlemen's Club skit...)
 
  • #8
Well, I called them "twigs" but they were actually a couple of splinters I picked out of my rear from my last caning... but... ;)

You know, if we didn't keep riffing off Monty Python sketches this thread would be archived, already, in some harddrive somewhere... a dim memory in the pseudomind of a Google server, a relic for spiders the crawl for...
 

FAQ: Understanding the log() function

What is the purpose of the log() function?

The log() function is used to calculate the logarithm of a number. This is useful for solving exponential equations and understanding the rate of change in a given scenario.

What is the syntax for using the log() function?

The syntax for using the log() function varies depending on the programming language, but in general, it takes the form of log(base, number). The base can be any number, but is usually either 10 or the mathematical constant e.

How does the log() function work?

The log() function uses the base and number given as parameters to calculate the power to which the base must be raised to equal the given number. For example, if the base is 10 and the number is 100, the log() function would return 2 because 10^2 = 100.

What is the difference between log() and ln()?

The log() function uses a base of 10, while ln() uses the natural logarithm with a base of e. This means that ln() is more useful for solving problems involving exponential growth or decay, while log() is better for calculating rates of change.

What are some real-world applications of the log() function?

The log() function is used in a variety of fields, including finance, biology, and chemistry. It can be used to calculate interest rates, measure the growth of populations, and determine the pH of a solution, among many other applications.

Back
Top