1 - The natural logarithm
So just calling the method and passing some numbers to it to get a result is one thing, but in order to get a real hold on why this method is useful it is required to get into at least a few actually use case examples. So for the rest of this post I will be touching base on at least a few of these, and then link to some additional posts in which I am writing about actually projects that make use of the Math.log method.
2 - Getting the exponent of a number when the base is known
So if I ever get into a situation in which I know a number, and a base, and want to know the exponent that will result in the number when the exponent is used with the base using Math.pow then a solution will likely involve the use of Math.log. The only problem is that the Math.log method only excepts one argument that is the number, and there is no way to set a base other than the Math.E constant at least with the Math.log method anyway. There are of course other options in the Math object, and there are also ways of doing simple operations and expressions to get whatever kind of value that you need.
However it is possible to work out a simple expression that can be used to get an exponent of a number when it is just the base that is known with just Math.log, and this is one of the most important actual use case examples that seems to come up often so lets touch base on this one then. By default Math.log will return the exponent of the given number relative to the base of the mathematical constant known as e. However it is not to hard to change that base to something else, to do that I just need to divide the result of Math.log(num) over Math.log(base).
So then when it comes to getting a number that is result of a base raised to the exponent of that base there is Math.pow, but when it comes to doing the inverse of this, there is Math.log.
3 - Values table example and getting a better idea of what the deal is with Math.log, and Math.pow
So maybe the best way to get a better understanding of Math.log and how it relates to Math.pow would involve just getting into making some examples of its use. It would be best to experiment with your own examples and learn by doing, however I guess I can write about some examples of my own that should help as a starting point of sorts to learn more about Math.log and why it can be useful when working out certain expressions.
So this helps to get a good idea of a use for the Math.log method. In a situation in which you know the base (b), and the power (p) but do not know the exponent (e) then the Math.log method can be used to find the exponent (e).
4 - Percent values
When I am working out logic for some kind of canvas project that is a game, animation of anything to that effect I often find myself working with a value that will go from zero to one. Often these values are the result of a index value the is divided over a max value, as a result the nature of the percent value is one that goes up in a straight line kind of way. So this prompted me to look into ways to go about making such values not so linear in nature, and of course the Math.log method is one way ti go about doing so.
5 - Conclusion