Will the absolute logarithm always produce the correct real result if one exists?

39 Views Asked by At

I'm a computer scientist, so my math skills are a bit rudimentary. The application I'm writing is more or less about solving equations. I'm only interested in real number solutions, so imaginary numbers are forbidden. In this particular example, the equation has the form $$a = b^{x}$$ where $a$ and $b$ are given. What I'm looking for is a real solution for $x$ if it exists and if it doesn't I want to know that it doesn't.

What I can't do is calculating $$x = \frac{log(a)}{log(b)}$$ and check if it's real, because I'm restricted to real arithmetic functions. However I discovered, that calculating the "absolute log" $$x' = \frac{log(|a|)}{log(|b|)}$$ seems to produce the correct solution if a real solution exists and if it doesn't then $$-a= b^{x'}$$ will hold true. However, I have no proof of this.

So my question is: Does the "absolute log" function have the property that I described earlier? And if it does, how can I prove it?

1

There are 1 best solutions below

3
On

Your $x'$ solves the equation $|a| = |b|^x$. Note that you can face a multitude of problems if you assume that the numbers a and b can be nonpositive.

  • If $b = 0$, the equation only has a solution if $a \in \{0, 1\}$. For $a = 0$ every $x > 0$ solves the equation, while for $a = 1$ the only solution is $x = 0$ (c.f. Wikipedia).
  • If $b > 0$ and $a \le 0$, the equation does not have a solution at all.
  • If $b < 0$, the term $b^x$ is in general not well-defined for all real numbers $x$ (c.f. Wikipedia)