# Is there an alternate way to calculate beyond the memory limit of the home edition?

I bought the Home Edition of Mathematica online 0.5 G of memory and costs \$150 per year. When I calculated the median of outputs from$[0,1]$with an interval of$.000001$I ended up with the follwoing Median[Table[2^x-x,{x,0,1,.000001}]] 0.935553527528773  Then I tried a smaller interval of$.0000001$and got. Median[Table[2^x-x,{x,0,1,.0000001}] Cloud::memlimit : *This computation has exceeded the memory limit for your plan*  I had limited knowledge of mathematica and am taking a college course on its next year. I tried the documentations but found little. Is there a way of calculating interval up to and smaller than seven digits without switching to the standard edition that costs \$950 per year?

• Most calculations can be done with limited memory (writing intermediate results to disk) if you are prepared to put enough effort into writing the software. – mikado Jun 18 '16 at 15:48
• @Feyre the function 2^x-x is not monotonic on [0 1] – mikado Jun 18 '16 at 15:50
• You may be able to compute the median of a large set by reexpressing as a minimization problem e.g. Minimize[Sum[Abs[(2^x - x) - y], {x, 0, 1, 0.00001}], y] – mikado Jun 18 '16 at 15:54
• I see that the code in the question has been changed so my comments regarding memory are now invalid. – Mr.Wizard Jun 18 '16 at 15:59
• FWIW, the answer is Root[{-(Log[2]/2) + ProductLog[-2^-#1 Log[2]] - ProductLog[-1, -2^-#1 Log[2]] &, 0.935553478022935551757231992253}]. – Chip Hurst Jun 18 '16 at 16:07

As mentioned in the comments, here's the answer to how I got the median.

I found the value $y$ that minimized

$$f(y) = \int_0^1 \left| 2^x-x-y \right| dx.$$

First, to break up the absolute value in the integrand, I solved for when $2^x = y$:

Solve[(2^x - x) == y && 9/10 < y < 1, x, Reals]


Then I integrated and found where $f'(y) = 0$:

int = Integrate[2^x - x - y, {x, 0, b1}]
- Integrate[2^x - x - y, {x, b1, b2}]
+ Integrate[2^x - x - y, {x, b2, 1}];

Solve[D[int, y] == 0 && 9/10 < y < 1, y, Reals]

{{y -> Root[{-(Log[2]/2) + ProductLog[-2^-#1 Log[2]] -
ProductLog[-1, -2^-#1 Log[2]] &, 0.935553478022935551757231992253}]}}


I decided to keep things symbolic in hopes of a nice looking answer. A numeric adaptation would probably be much easier.

• That is amazing! Is there a mathematical textbook on this or is it simply logic? – Arbuja Jun 18 '16 at 16:26
• Well I essentially just did what mikado did, but in integral form. It seems like it would be the median, but I have no source... – Chip Hurst Jun 18 '16 at 16:27