4
$\begingroup$

I'm trying to solve:

$$1 - |x| Log(\frac{|1+x|}{|x|}) = 0.84$$

by using NSolve:

NSolve[1 - Abs[x] Log[Abs[(1 + x)/x]] == 0.84, x]

Mathematica doesn't return anything. However other procedures, like FindRoot, gives the desired result:

FindRoot[1 - Abs[x] Log[Abs[(1 + x)/x]] - 0.84, {x, 0.01}]

{x -> 0.0537759}

How can I solve this equation by NSolve?

$\endgroup$
4
$\begingroup$

If you want real solutions, try adding the domain Reals:

NSolve[1 - Abs[x] Log[Abs[(1 + x)/x]] == 0.84, x, Reals]
(*  {{x -> -0.401725}, {x -> -0.0570327}, {x -> 0.0537759}}  *)

Over the Complexes, there are dimension-1 components, which may be why NSolve balks. It probably ought to give an error message, so consider reporting it to WRI.

ContourPlot[
 1 - Abs[x] Log[Abs[(1 + x)/x]] == 0.84 /. x -> a + I b // 
  Evaluate, {a, -1, 1}, {b, -1, 1}]

enter image description here

| improve this answer | |
$\endgroup$
  • 3
    $\begingroup$ Changing Abs to RealAbs also gets the real roots (RealAbs was introduced in V11.1): NSolve[1 - RealAbs[x] Log[RealAbs[(1 + x)/x]] == 0.84, x] $\endgroup$ – Michael E2 Aug 21 '19 at 13:58
3
$\begingroup$

You should give Mathematica a hint, "what" you are looking for:

NSolve[1 - Abs[x] Log[Abs[(1 + x)/x]] == 0.84, x, Reals]
(*{{x -> -0.401725}, {x -> -0.0570327}, {x -> 0.0537759}}*)
| improve this answer | |
$\endgroup$

Your Answer

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