3
$\begingroup$

We give equations like $\ln(1-x)-\ln(x-2)=0$ to our calculus students. This equation clearly has no solution, since $\ln(1-x)$ is only defined if $x<1$ and $\ln(x-2)$ only if $x>2$.

Still, the Mathematica input

Solve[Log[1 - x] - Log[x - 2] == 0, x]

gives

 {{x -> 3/2}}

Also,

Reduce[Log[1 - x] - Log[x - 2] == 0, x]

gives

x == 3/2.

Since Mathematica uses the principal branch, this should not happen.

I guess that Mathematica first simplifies the equation to

$\quad \quad \ln\frac{1-x}{x-2}=0$

Now, $\tfrac{1-x}{x-2}>0$ for $1<x<2$, and $x=3/2$ really solves this last equation.

Thus, my question boils down to: Shouldn't Mathematica test if its solution really solves the original equation given by the user?

$\endgroup$
3
  • $\begingroup$ Hi @mickep, welcome to Mathematica.SE, please consider taking the tour so you learn the basic rules of the site. Once you gain enough reputation by making good questions you will be able to vote up and down both questions and answers. Your question has been answered, but its a good idea to wait a few hour for other answers before accepting the best one for you. $\endgroup$
    – rhermans
    Oct 14 '14 at 20:50
  • 1
    $\begingroup$ Hi @rhermans. Thank you for your suggestion, I will follow your advice next time. In this case, I understand what Mathematica does and even if I don't agree with its choice (of defining the argument/logarithm on the negative real axis and thus making it a non-continuous function), I'm now fully aware of it. $\endgroup$
    – mickep
    Oct 14 '14 at 20:58
  • 2
    $\begingroup$ When there are no undefined parameters, and input is not explicitly polynomial, Solve does in fact test solutions. That's the option VerifySolutions -> Automatic at work. $\endgroup$ Oct 14 '14 at 21:16
5
$\begingroup$

Well, both $(1-x)$ and $(x-2)$ evaluate to $-1/2$ when $x\rightarrow 3/2$, and Log[-1/2] its well defined in the complexes, for instance $e^{iπ}= −1$, implies that $\ln(−1)=i π$, and therefore Log[-1/2]= I π - Log[2] so you are subtracting two well defined identical complex numbers to get zero. Therefore, this solutions does really solve the original equation, in the complex domain.

If you want to force a restriction, you can specify the domain where Solve should look for the solution. i.e. Complexes, Reals, Integers or Rationals.

Solve[Log[1 - x] - Log[x - 2] == 0, x, Complexes]

{{x -> 3/2}}

Solve[Log[1 - x] - Log[x - 2] == 0, x, Reals]

{}

$\endgroup$
1
  • $\begingroup$ Thank you for your reply. Thus, I just learned that Mathematica actually is not giving something undefined along the branch cut of the logarithm, but rather uses $\log(x)=\ln(-x)+i\pi$ for $x<0$. $\endgroup$
    – mickep
    Oct 14 '14 at 20:36
3
$\begingroup$

As mentioned in the comments, Mathematica is assuming a complex valued logarithm (and hence can take negative inputs).

If you query this on Wolfram Alpha (here) you can see the pod clarifies the solution is assuming this complex valued logarithm:

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.