5
$\begingroup$

Here's the domain of the function:

When I'm trying to plot it Mathematica just shows a graph of $x+1$.

Here's what happens if we put $x$ in formula from outside of a function's domain:

I'm not sure whether it's a bug or Mathematica simplifies the equation to $x+1$ but I'm searching for a way to plot it correctly. Any help would be appreciated!

$\endgroup$
  • 1
    $\begingroup$ If I just input x^Log[x, x + 1] Mathematica returns 1 + x. So I think it's a simplification thing. You could use Plot[x^Log[x, x + 1], {x, -5, 5}, RegionFunction -> Function[{x}, 0 < x < 1 || x > 1]] to get it plotting over the domain you want. $\endgroup$ – aardvark2012 Dec 21 '17 at 20:34
  • 1
    $\begingroup$ Even without simplification mathematica gladly works in the complex domain, Log[-5, -4] // N -> 0.971177 + 0.0562626 I then (-5)^(0.971177 + 0.0562626 I) -> -4+eps I $\endgroup$ – george2079 Dec 21 '17 at 20:51
  • $\begingroup$ You can tell MA that Logshould be real: Plot[x^Re[Log[x, x + 1]], {x, -5, 5}], although it is not quite the same. $\endgroup$ – yarchik Dec 21 '17 at 20:53
  • 4
    $\begingroup$ I claim that MA correctly plots this function, because the FunctionDomain is the whole real axis. Maybe you are concerned that intermediate steps are only possible in your domain. However, this is not right mathematical logic: have a look at $sin(x)=(e^{ix}+e^{-ix})/2i$---the result is real although each exponent is complex for each real $x$. $\endgroup$ – yarchik Dec 21 '17 at 21:13
  • 1
    $\begingroup$ Evaluation of x^Log[x, x + 1] expression to 1 + x is "generically correct" for Power and Log as functions of complex arguments, which is how they are defined in Mathematica. You could use my RestrictDomain function: RestrictDomain[x^Log[x, x + 1], x, Reals] to get expression with domain restriction, assuming all functions are restricted to Reals. $\endgroup$ – jkuczm Dec 22 '17 at 20:46
3
$\begingroup$

Assuming e.g. a real functions realm one could expect what you expect. But there is no straightforward way to do so and in expressions + complexes world it is correct.

The problem is that there is no FunctionFormula expression with special rules in Mathematica so your example will be simplified automatically.

Fortunately FunctionDomain handles uneavaluated formula well:

FunctionDomain[Unevaluated[x^Log[x, x + 1]], x]
0 < x < 1 || x > 1
Plot[
  x^Log[x, x + 1]
, {x, -10, 10}
, RegionFunction -> Function[
    x
  , Evaluate@FunctionDomain[Unevaluated[x^Log[x, x + 1]], x]
  ]
]
$\endgroup$
4
$\begingroup$
Clear[f]

f[x_] := x^Log[x, x + 1] /; 0 < x < 1 || x > 1;

f /@ {-5, 0, 1, 5}

(* {f[-5], f[0], f[1], 6} *)

Plot[f[x], {x, -5, 5}, AxesOrigin -> {0, 0}]

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.