I am trying to find the inverse function of $\frac{\ln{x}}{x^2}$ in Mathematica. I am using the Solve[] function to find the inverse (yes, I know about InverseFunction[], but I was told to solve it with Solve[]).

Why doesn't the following output evaluate correctly? I know that I shouldn't get imaginary values:

enter image description here

Plugging the equation into Solve[] directly also gives me the same result:

enter image description here

However, if I drop the x from the Log[] function, I get something that looks more plausible:

enter image description here

Does Log[x] and Log evaluate to the same thing? Thank you for your time!


No, Log is the name of the function and Log[x] is the function applied to x. Using Log without the argument is accepted by the system because Log is a symbol just like any other, but it does not make any sense.

The correct way to write it is

Solve[Log[x]/x^2 == y, x]


Reduce[Log[x]/x^2 == y, x]

The latter tries to give you full solution information, while the former's result may only be valid for certain values of x and y (see below). The differences are explained in this guide.

The first result you get from Solve is correct for some real values of y as you can check by numerical evaluation:

x /. Solve[Log[x]/x^2 == y, x]

==> {-(I Sqrt[ProductLog[-2 y]])/(Sqrt[2] Sqrt[y]), 
      (I Sqrt[ProductLog[-2 y]])/(Sqrt[2] Sqrt[y])}

% /. y -> 0.05

(* ==> {1.05751 + 0. I, -1.05751 + 0. I} *)

Log[x]/x^2 /. x -> %[[1]]

(* ==> 0.05 + 0. I *)

The second result is not correct for y == 0.05 but it is correct for other values such as y == 1.0 I for which the first result is incorrect.

Mathematica generally assumes that all variables are complex and tried to solve for the this general case. While the expression does contain an explicit I, it will evaluate to a real value for some real x.

Reduce will try to generate conditions under which the solutions are valid. We can also specify that we are interested in only positive real values of x:

Reduce[Log[x]/x^2 == y && x > 0, x]

==> (y == 0 && x == 1) || (y < 0 && 
   x == E^(-(1/2) ProductLog[-2 y])) || (0 < y <= 1/(
    2 E) && (x == E^(-(1/2) ProductLog[-1, -2 y]) || 
     x == E^(-(1/2) ProductLog[-2 y])))

Note though that this function has no inverse even for $x \in (0, \infty)$:

Plot[Log[x]/x^2, {x, 0, 10}]

Mathematica graphics


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.