How to calculate log of a complex number to a base other than 'e'?
-
20-08-2019 - |
Question
I have this bit of VB6 sliced out of a project I'm working on:
Public Function C_Ln(c As ComplexNumber) As ComplexNumber
Set C_Ln = toComplex(Log(C_Abs(c)), Atan2(c.Imag, c.Real))
End Function
The VB6 Log() function is base-e. I'd like to cook up versions of this to do base-2, base-10 and base-n. Where do I start?
Solution
You can use the following mathematical identity:
In VB it would be something like:
Log10 = Log(X) / Log(10)
Log2 = Log(X) / Log(2)
' ... LogN = Log(X) / Log(N)
OTHER TIPS
If you divide the natural log of x by the log of the base you want to achieve you get the desired result, i.e. (ln x)/(ln n) = y
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow