Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It is not clear what you are asking, but I will try to guess.</p> <p>We first solve the equation <code>z^z = a</code> for a real number <code>z</code>. Let <code>u</code> and <code>v</code> be <code>z</code> rounded down and up, respectively. Among the three candidates <code>(u,u)</code>, <code>(v,u)</code>, <code>(u,v)</code> we choose the largest one that does not exceed <code>a</code>.</p> <p>Example: Consder the case <code>a = 2000</code>. We solve <code>z^z = 2000</code> by numerical methods (see below) to get an approximate solution <code>z = 4.8278228255818725</code>. We round down an up to obtain <code>u = 4</code> and <code>v = 5</code>. We now have three candidates, <code>4^4 = 256</code>, <code>4^5 = 1023</code> and <code>5^4 = 625</code>. They are all smaller than <code>2000</code>, so we take the one that gives the largest answer, which is <code>x = 4</code>, <code>y = 5</code>.</p> <p>Here is Python code. The function <code>solve_approx</code> does what you want. It works well for <code>a &gt;= 3</code>. I am sure you can cope with the cases <code>a = 1</code> and <code>a = 2</code> by yourself.</p> <pre><code>import math def solve(a): """"Solve the equation x^x = a using Newton's method""" x = math.log(a) / math.log(math.log(a)) # Initial estimate while abs (x ** x - a) &gt; 0.1: x = x - (x ** x - a) / (x ** x * (1 + math.log(x))) return x def solve_approx(a): """"Find two integer numbers x and y such that x^y is smaller than a but as close to it as possible, and try to make x and y as equal as possible.""" # First we solve exactly to find z such that z^z = a z = solve(a) # We round z up and down u = math.floor(z) v = math.ceil(z) # We now have three possible candidates to choose from: # u ** zdwon, v ** u, u ** v candidates = [(u, u), (v, u), (u, v)] # We filter out those that are too big: candidates = [(x,y) for (x,y) in candidates if x ** y &lt;= a] # And we select the one that gives the largest result candidates.sort(key=(lambda key: key[0] ** key[1])) return candidates[-1] </code></pre> <p>Here is a little demo:</p> <pre><code> &gt;&gt;&gt; solve_approx(5) solve_approx(5) (2, 2) &gt;&gt;&gt; solve_approx(100) solve_approx(100) (3, 4) &gt;&gt;&gt; solve_approx(200) solve_approx(200) (3, 4) &gt;&gt;&gt; solve_approx(1000) solve_approx(1000) (5, 4) &gt;&gt;&gt; solve_approx(1000000) solve_approx(1000000) (7, 7) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload