5
$\begingroup$

Does anyone have any insight to a symbolic Mathematica solution to this equation for $x$ in terms of y? Symbolic of any sort, just not numeric.

$$y = x^x (1-x)^{(1-x)}$$

$\endgroup$
12
  • $\begingroup$ Note that Solve[y == x^x, x] works but Solve[y == (1 - x)^(1 - x), x] does not. $\endgroup$
    – bill s
    Commented May 23, 2015 at 0:30
  • 6
    $\begingroup$ Usually, transcendental equations of even moderate complexity do not even admit closed-form solutions. Sometimes, you get lucky, as with the Lambert function, but more often than not, there just isn't one. $\endgroup$ Commented May 23, 2015 at 2:35
  • $\begingroup$ How taking the logs of both sides, then separate $x$ by itself in terms of all the others terms (which will have $x$ in them), you get $x=\frac{\ln(y)-ln(1-x)}{ln(x)-ln(1-x)}$ and then take series expansion of the RHS in $x$, and then equate the $x$ coefficients, so you get $1=\frac{log(x)-log(y)}{log(x)^2}$ and now solve this for $x$ which gives E^(1/2 (1 - Sqrt[1 - 4 Log[y]])) with complicated conditionals. warning, I am not a math major, since the above might not make sense math wise, but something to look at. $\endgroup$
    – Nasser
    Commented May 23, 2015 at 3:06
  • $\begingroup$ @Nasser, here, taking the logarithms of both sides is not very productive; you end up with $\ln y= x\ln x + (1-x)\ln(1-x)$, which is no simpler than what we started with. $\endgroup$ Commented May 23, 2015 at 3:11
  • $\begingroup$ @Guesswhoitis. yes, but that is what I mean, now solve for $x$ from the above, and take series expansion of the RHS, then equate the $x$ coeffcients. There will be one term in the series with $x$ in it. That is what I meant. $\endgroup$
    – Nasser
    Commented May 23, 2015 at 3:13

1 Answer 1

7
$\begingroup$

Why not take a suitable Mathematica comand literally?

Let y as a function of x be given by

y = x^x (1 - x)^(1 - x);

Aren't we just looking for x as a function of y?

So let's simply write down what we want

xx = InverseFunction[#^# (1 - #)^(1 - #) &];

This function gives the symbolic solution the OP asked for.

Indeed, we can take values

Table[xx[(1 + Random[])/2], {10}]

(*
Out[53]= {0.0537599, 0.00203679, 0.12122, 0.151892, 0.0588153, 0.316227, 0.28835, \
0.0545701, 0.115355, 0.0168024}
*)

we can Plot it

Plot[xx[yy], {yy, 1/2, 1}, 
 PlotLabel -> "InverseFunction x[y] if y = x^x(1-x)^(1-x)]", 
 AxesLabel -> {"y", "x"}]
(* 150523_plot _xx.jpg *)

enter image description here

We can take the drivative

D[xx[yy], yy]

(*
Out[65]= 1/((-1 - Log[1 - InverseFunction[#1^#1 (1 - #1)^(1 - #1) &][yy]]) (1 - 
      InverseFunction[#1^#1 (1 - #1)^(1 - #1) &][yy])^(
    1 - InverseFunction[#1^#1 (1 - #1)^(1 - #1) &][yy])
     InverseFunction[#1^#1 (1 - #1)^(1 - #1) &][yy]^
    InverseFunction[#1^#1 (1 - #1)^(1 - #1) &][
     yy] + (1 + Log[InverseFunction[#1^#1 (1 - #1)^(1 - #1) &][yy]]) (1 - 
      InverseFunction[#1^#1 (1 - #1)^(1 - #1) &][yy])^(
    1 - InverseFunction[#1^#1 (1 - #1)^(1 - #1) &][yy])
     InverseFunction[#1^#1 (1 - #1)^(1 - #1) &][yy]^
    InverseFunction[#1^#1 (1 - #1)^(1 - #1) &][yy])
% /. yy -> 2/3

(*
Out[66]= 1/((-1 - 
      Log[1 - Root[{-3 + 2 ((1 - #1)/#1)^#1 + 3 #1 &, 
          0.140276506997464737195}]]) (1 - 
      Root[{-3 + 2 ((1 - #1)/#1)^#1 + 3 #1 &, 
        0.140276506997464737195}])^(
    1 - Root[{-3 + 2 ((1 - #1)/#1)^#1 + 3 #1 &, 
       0.140276506997464737195}])
     Root[{-3 + 2 ((1 - #1)/#1)^#1 + 3 #1 &, 
      0.140276506997464737195}]^
    Root[{-3 + 2 ((1 - #1)/#1)^#1 + 3 #1 &, 
      0.140276506997464737195}] + (1 + 
      Log[Root[{-3 + 2 ((1 - #1)/#1)^#1 + 3 #1 &, 
         0.140276506997464737195}]]) (1 - 
      Root[{-3 + 2 ((1 - #1)/#1)^#1 + 3 #1 &, 
        0.140276506997464737195}])^(
    1 - Root[{-3 + 2 ((1 - #1)/#1)^#1 + 3 #1 &, 
       0.140276506997464737195}])
     Root[{-3 + 2 ((1 - #1)/#1)^#1 + 3 #1 &, 
      0.140276506997464737195}]^
    Root[{-3 + 2 ((1 - #1)/#1)^#1 + 3 #1 &, 0.140276506997464737195}])
*)

% // N

(*
Out[67]= -0.82736
*)

And we can integrate it

Integrate[xx[yy], {yy, 1/2, 1}]

$$\int_{\frac{1}{2}}^1 \text{InverseFunction}\left[\text{$\#$1}^{\text{$\#$1}} (1-\text{$\#$1})^{1-\text{$\#$1}}\&\right][\text{yy}] \, d\text{yy}$$

NIntegrate[xx[yy], {yy, 1/2, 1}]

(*
Out[69]= 0.0589135
*)

Which is correct as we can see thus

NIntegrate[x^x (1 - x)^(1 - x), {x, 0, 1/2}]

(*
Out[74]= 0.308913
*)

from which we have to subtract the area of the rectangle below the minimum

1/2*x^x (1 - x)^(1 - x) /. x -> 1/2

(*
Out[71]= 1/4
*)

%% - %

(*
Out[72]= 0.0589135
*)

ok.

Remark: In order to just get the function plottet we could use

Off[Power::indet];
ParametricPlot[{y, x}, {x, 0, 1}, PlotRange -> {{1/2, 1}, {0, 1/2}}, 
 PlotLabel -> "x(y) for y = x^x(1-x)^(1-x)", AxesLabel -> {"y", "x"}]
On[Power::indet]
(* 150523_parametricplot.jpg *)

enter image description here

EDIT #1

Obviously you can solve many transcendental equations with this method in a very elegant an compact manner. Examples are x == Tan[x], 1 == x Exp[-x], Cos[x] == x and so on.

$\endgroup$
10
  • 1
    $\begingroup$ +1 I never knew InverseFunction, however I did know about InverseSeries which you can use in this way expanded around 1/2: Normal@InverseSeries[Series[x^x (1 - x)^(1 - x), {x, 1/2, 10}]] $\endgroup$
    – Histograms
    Commented May 23, 2015 at 13:43
  • $\begingroup$ Excellent! - I did not know about InverseFunction either, and its just what I am looking for. I have been using InverseSeries around x=1/2 as Histograms suggested, but it gets flaky around x=1. I tested InverseFunction, and it is much superior. Thank you Dr. Hintze, and everybody else who contributed. $\endgroup$
    – Paul R.
    Commented May 23, 2015 at 17:43
  • 1
    $\begingroup$ Actually, if you draw the function y[x] you can see that it has real values for x in 0-1, so the inverse function, restricted to reals, has two branches. One is the one you showed, the other one is the mirror of that with respect with the translated y axis at x=1/2. (It's like a "C"). And you can see that by exchanging the x and y axis in the plot of y[x] (there's a simple gesture that changes an "L" made with index and thumb into a "gun" that shows the required transformation to get the inverse of any plot, once one has seen that...) $\endgroup$
    – Peltio
    Commented May 23, 2015 at 21:15
  • $\begingroup$ ...in 0-1 AND it's not monotonic, SO... $\endgroup$
    – Peltio
    Commented May 23, 2015 at 21:22
  • 1
    $\begingroup$ @Peltio The suspense is killing me... $\endgroup$ Commented May 23, 2015 at 22:12

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