In my javascript code I have the following
Math.log(20) = 2.995732273553991
In my excel formula I try to replicate this with
=LOG(20) = 1.301029996
Anyone have any idea why I'm getting two different outcomes? I'd like my excel to match my js.
Math.log(20) is base e, while LOG(20) is base 10.
You're not looking for LOG(20), but probably rather LN(20) (base e).
MDN (for javascript) : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log
LN (for excel): https://support.office.com/en-us/article/LN-function-81fe1ed7-dac9-4acd-ba1d-07a142c6118f
The LOG Function you are using automatically set the second parameter to 10 if it is not set (default 10), as pointed out there:
From here: https://support.office.com/en-nz/article/LOG-function-4e82f196-1ca9-4747-8fb0-6c4a3abb3280
Just in case anyone is interested in going the other direction: To get Excel's LOG(x) you can just do:
Or, being more efficient: