[FUN] CodeGolf: solve equation x^x=C

classic Classic list List threaded Threaded
46 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Re: [FUN] CodeGolf: solve equation x^x=C

Jim-2
27.06.2019, 19:54, "Philippe Verdy" <[hidden email]>:
> I revendicate the authorship to open it to the world

thank you !!
:D


Reply | Threaded
Open this post in threaded view
|

Re: [FUN] CodeGolf: solve equation x^x=C

Philippe Verdy
This public revendication is just to block unfair patents that these companies develop against the original authors (spoliating their legal right and any other open source developer), if someone get sued by them. Keep the track of my public mail record and date in your archives as an evidence that their possible future claim are invalid.

(The Lua mailing list archive may also be used as an evidence, but I can keep track of this series in my own Gmail account that Google should protect from reappropriation).

If you want an open licence, I choose the current LGPL v3 or later version published by the FSF, or if you prefer, the current French LO/OL licence (compatible with the GPL, LGPL and many other licences).

Of course my revendication is only valid starting today from my posted mails on this list, but it is not valid if someone authored and published that idea before and demonstrates it with other public records (for now I don't know is such prior art exists; those authors may manifest themselves to this list, or to me so that I can publicly deny my rights here or elsewhere: I don't want to abuse any legal prior rights).


Le jeu. 27 juin 2019 à 20:44, Jim <[hidden email]> a écrit :
27.06.2019, 19:54, "Philippe Verdy" <[hidden email]>:
> I revendicate the authorship to open it to the world

thank you !!
:D


Reply | Threaded
Open this post in threaded view
|

Re: [FUN] CodeGolf: solve equation x^x=C

Philippe Verdy
And the minimum for my claim to be valid starting today, is that I give a copyright notice in addition to the licence:

Fast computing of mathematical floatting point functions with arbitrary precision in constant time depending only on precision.
Alias "FC-MFPAP-CTDOP"
Copyright (c) 2019 Philippe Verdy ([hidden email])
Licenced under LGPL version 3 as published by the Free Software Foundation or later version,

Le jeu. 27 juin 2019 à 21:11, Philippe Verdy <[hidden email]> a écrit :
This public revendication is just to block unfair patents that these companies develop against the original authors (spoliating their legal right and any other open source developer), if someone get sued by them. Keep the track of my public mail record and date in your archives as an evidence that their possible future claim are invalid.

(The Lua mailing list archive may also be used as an evidence, but I can keep track of this series in my own Gmail account that Google should protect from reappropriation).

If you want an open licence, I choose the current LGPL v3 or later version published by the FSF, or if you prefer, the current French LO/OL licence (compatible with the GPL, LGPL and many other licences).

Of course my revendication is only valid starting today from my posted mails on this list, but it is not valid if someone authored and published that idea before and demonstrates it with other public records (for now I don't know is such prior art exists; those authors may manifest themselves to this list, or to me so that I can publicly deny my rights here or elsewhere: I don't want to abuse any legal prior rights).


Le jeu. 27 juin 2019 à 20:44, Jim <[hidden email]> a écrit :
27.06.2019, 19:54, "Philippe Verdy" <[hidden email]>:
> I revendicate the authorship to open it to the world

thank you !!
:D


Reply | Threaded
Open this post in threaded view
|

Re: [FUN] CodeGolf: solve equation x^x=C

Philippe Verdy
Sorry for the long designation, I had to choose one today, that was  significant, unique and that can be looked up in online searches. The "short alias" is nearly unpronouncable.

If you want, you may propose ideas of names, if you ever need to use such concept in the future for your implementations (even if you're a big company, a small one, or an individual author), but my revendication should protect you from future patent or copyright claims from third parties (at least for the duration of validity of this licence and of my authorship rights in France, i.e. at most my whole life + 70 years; after that I bet that better ideas will have been developed and such claims will no longer be valid, but the public domain, in which it will fatally fall after that time, is not protected from reappropriations; at that time you'll probably no longer need that concept if something better was developed, or there will be so many implementations that claims will be denied by evidences spread everywhere of "prior art").

Reply | Threaded
Open this post in threaded view
|

Re: [FUN] CodeGolf: solve equation x^x=C

Egor Skriptunoff-2
In reply to this post by Egor Skriptunoff-2
On Wed, Jun 26, 2019 at 11:47 PM Egor Skriptunoff wrote:
Global variable "C" contains numeric value > 15.5
The solution of math equation x^x=C must be printed
Your code must fit into 36 bytes
Dirty tricks are allowed


Some sort of codegold-related cheating is required to solve this task, so I should tell more about "dirty tricks".

Dirty trick #1:
   Please note that the task doesn't require that your program should exit after the job is done.
   The program might exit, but it doesn't have to.

What should we do if a program never stops?
Just wait until you runs out of patience and then kill the process.
My own patience lasts for 3 seconds :-)

Dirty trick #2:
   The task says that "the solution must be printed".
   But it wasn't required that your program should print only one number.

What should we do if a program prints a lot of text?
Just ignore the "invisible" text scrolled up beyond the screen.

These tricks are unfair, but they save several bytes of code.
With these tricks allowed, you can write a program which simply prints infinite sequence of numbers converging to the correct answer.
First lines of output would contain incorrect values, but later the old values would be scrolled up and replaced with more correct approximations.
At the moment when the program is killed, the whole screen would contain the correct answer on every line.


My program prints some sequence of numbers converging to the root of equation x^x=C.
Your task is either to write similar program which runs endlessly
or to print the root calculated using some other approach.

Now, with the "dirty tricks" explained, the task become quite solvable.

Reply | Threaded
Open this post in threaded view
|

Re: [FUN] CodeGolf: solve equation x^x=C

Philippe Verdy
But I showed that the program can end in a predictable very short time, without printing an infinite sequence or having to wait for an infinite amount of time.

And the statement to print the result can be a single "=" in the Lua console, followed by a single expression which uses a small limited number of trailing recursions. If your program loops infinitely, and prints an infinite list then it uses a self reference to itself (we have to know the name by which it can be referenced, meaning that its own name is predefined as a visible symbol like "f" in the "global" scope where you just define the code, and to print someting it needs a symbol like "o" for "out" for the function that will print something before recursing to itself by a trainling function call to that name with some computed parameters).

But as you don't want us to use "return", this program will never terminate and will loop infinitely in trailing calls, even if it has reached the maximum precision (which is then a stupid program). Add just a few bytes (6 or 7 for "return" or "return ", and 3 bytes for "o x"), then you have a clean useful program that will no longer loop infinitly and will return a response very fast (with just a few trailing recursions).





Le jeu. 27 juin 2019 à 23:39, Egor Skriptunoff <[hidden email]> a écrit :
On Wed, Jun 26, 2019 at 11:47 PM Egor Skriptunoff wrote:
Global variable "C" contains numeric value > 15.5
The solution of math equation x^x=C must be printed
Your code must fit into 36 bytes
Dirty tricks are allowed


Some sort of codegold-related cheating is required to solve this task, so I should tell more about "dirty tricks".

Dirty trick #1:
   Please note that the task doesn't require that your program should exit after the job is done.
   The program might exit, but it doesn't have to.

What should we do if a program never stops?
Just wait until you runs out of patience and then kill the process.
My own patience lasts for 3 seconds :-)

Dirty trick #2:
   The task says that "the solution must be printed".
   But it wasn't required that your program should print only one number.

What should we do if a program prints a lot of text?
Just ignore the "invisible" text scrolled up beyond the screen.

These tricks are unfair, but they save several bytes of code.
With these tricks allowed, you can write a program which simply prints infinite sequence of numbers converging to the correct answer.
First lines of output would contain incorrect values, but later the old values would be scrolled up and replaced with more correct approximations.
At the moment when the program is killed, the whole screen would contain the correct answer on every line.


My program prints some sequence of numbers converging to the root of equation x^x=C.
Your task is either to write similar program which runs endlessly
or to print the root calculated using some other approach.

Now, with the "dirty tricks" explained, the task become quite solvable.

Reply | Threaded
Open this post in threaded view
|

Re: [FUN] CodeGolf: solve equation x^x=C

Philippe Verdy
Your program may also run in a console that will automatically print itself the last value computed when the code ends and may run it again in a loop if the program does not return a nil value, by calling the implied function again with that last value.
In that case, the program is a single expression that does not have to be printed in the program itself; the program will terminate in just a few microseconds, and the user will actually wait for the screen to be refreshed (typically about 15 ms on average on a 60Hz monitor), before the user has even released the "enter" key or the click on the "run" button, and the user will still need about 30 ms to assimilate visually the value displayed (the console may only print the last non-nil value returned and not every value returned by the loop (which is equivalent to a trailing call).

But having to return a specific nil costs some bytes, it is simpler to just call the function recursively for a predefined number of steps, using  explicit function calls as "f(f(f(f(f(some expression)))))". The console will print that returned value itself, without having to insert the "out" or "=" statement which is implied by the console, just like the global name "f" of the function we can call inside the program will be implied (the console predefines that in the global environment with your "C" constant that must be defined somewhere (in the specific console program you use to run your input code, which can never run "alone").

Reply | Threaded
Open this post in threaded view
|

Re: [FUN] CodeGolf: solve equation x^x=C

Philippe Verdy
Or your console may behave like a programmable calculator (that has a "RUN" or "f" button execute the monadic function just like when the user press the "sin" button to get the sinus, or the "x²" button to get the square):

x is the value of the display (that the user enters normally, it just has to be at least 3 at start), C is in fact the single "memory" store where you store the value from which you want to find the root.

The "program" is stored as a non-recursive function definition that will adjust the display y to converge to the next approximation value.

The user will just press the "f" or RUN button: he will get the next approximation. Pressing the RUN button 6 times will be enough to get the precise result (he can press the button more, nothing changes), and you then don't need any recursion code in your program, or any instruction to print the value.

With that basic calculator (which implements only the basic arithmetic or binary operations), you can compute many mathematics function not defined by the calculator itself (including trigonometry, hyperbolic, exponentials, resolve equations like x^x=C, using a convergent series that returns the correct answer with any precision needed and with a small number of steps needed for the series, as long as the starting value of the series is correctly entered to ensure that it will be in the convergent range; for your problem starting with the display showing x=3 is sufficient, and you need to press RUN six times).

The operations made by the user are simple: program the RUN button with the formula of the f series transforming f_n into f_(n+1): enter the Lua expression only.
Then enter the value of C, press "M+" to store it (the Lua program will see its value as the global "C")
Enter a start value (e.g. "3") then press RUN 6 times, you have the result !
In a UI, you would have 3 input boxes: one for the value of "x" (the conventional "display" of the calculator), one for the value of the single memory (the value given to C) one for the program (the Lua expression using only "x" and "C"), . And a single RUN button that the user will press multiple times (as he wants) until he gets the precision he wants or sees no more difference on the display. But we can warranty that it will get the most precise value for a 32-bit IEEE float by pressing it 5 times, and 6 times for a 64-bit IEEE float (more presses may be needed if your calculator can compute using Lua "number" with higher precision or infinite precision, but you'll need a larger display or a scrollbar in your calculator interface to show all the digits...


Le ven. 28 juin 2019 à 00:20, Philippe Verdy <[hidden email]> a écrit :
Your program may also run in a console that will automatically print itself the last value computed when the code ends and may run it again in a loop if the program does not return a nil value, by calling the implied function again with that last value.
In that case, the program is a single expression that does not have to be printed in the program itself; the program will terminate in just a few microseconds, and the user will actually wait for the screen to be refreshed (typically about 15 ms on average on a 60Hz monitor), before the user has even released the "enter" key or the click on the "run" button, and the user will still need about 30 ms to assimilate visually the value displayed (the console may only print the last non-nil value returned and not every value returned by the loop (which is equivalent to a trailing call).

But having to return a specific nil costs some bytes, it is simpler to just call the function recursively for a predefined number of steps, using  explicit function calls as "f(f(f(f(f(some expression)))))". The console will print that returned value itself, without having to insert the "out" or "=" statement which is implied by the console, just like the global name "f" of the function we can call inside the program will be implied (the console predefines that in the global environment with your "C" constant that must be defined somewhere (in the specific console program you use to run your input code, which can never run "alone").

Reply | Threaded
Open this post in threaded view
|

Re: [FUN] CodeGolf: solve equation x^x=C

Xavier Wang
In reply to this post by Egor Skriptunoff-2


Egor Skriptunoff <[hidden email]> 于2019年6月28日周五 上午5:39写道:
On Wed, Jun 26, 2019 at 11:47 PM Egor Skriptunoff wrote:
Global variable "C" contains numeric value > 15.5
The solution of math equation x^x=C must be printed
Your code must fit into 36 bytes
Dirty tricks are allowed


Some sort of codegold-related cheating is required to solve this task, so I should tell more about "dirty tricks".

Dirty trick #1:
   Please note that the task doesn't require that your program should exit after the job is done.
   The program might exit, but it doesn't have to.

What should we do if a program never stops?
Just wait until you runs out of patience and then kill the process.
My own patience lasts for 3 seconds :-)

Dirty trick #2:
   The task says that "the solution must be printed".
   But it wasn't required that your program should print only one number.

What should we do if a program prints a lot of text?
Just ignore the "invisible" text scrolled up beyond the screen.

These tricks are unfair, but they save several bytes of code.
With these tricks allowed, you can write a program which simply prints infinite sequence of numbers converging to the correct answer.
First lines of output would contain incorrect values, but later the old values would be scrolled up and replaced with more correct approximations.
At the moment when the program is killed, the whole screen would contain the correct answer on every line.


My program prints some sequence of numbers converging to the root of equation x^x=C.
Your task is either to write similar program which runs endlessly
or to print the root calculated using some other approach.

Now, with the "dirty tricks" explained, the task become quite solvable.


I have tried these tricks (just before your advice), but I only get a 51 byte solution:
x=1l=math.log::a::x=(l(C)+x)/(l(x)+1)print(x)goto a

and doesn't have any improve after that :-(

--
regards,
Xavier Wang.
Reply | Threaded
Open this post in threaded view
|

Re: [FUN] CodeGolf: solve equation x^x=C

Philippe Verdy
That's because your "log" function is inexact (use an integer log2 that extracts just the exponent part of the number instead of math.log)
And you did not use the modulo2 trick to make exact divisions, so there's an imprecision on the last bit.

Le ven. 28 juin 2019 à 00:46, Xavier Wang <[hidden email]> a écrit :


Egor Skriptunoff <[hidden email]> 于2019年6月28日周五 上午5:39写道:
On Wed, Jun 26, 2019 at 11:47 PM Egor Skriptunoff wrote:
Global variable "C" contains numeric value > 15.5
The solution of math equation x^x=C must be printed
Your code must fit into 36 bytes
Dirty tricks are allowed


Some sort of codegold-related cheating is required to solve this task, so I should tell more about "dirty tricks".

Dirty trick #1:
   Please note that the task doesn't require that your program should exit after the job is done.
   The program might exit, but it doesn't have to.

What should we do if a program never stops?
Just wait until you runs out of patience and then kill the process.
My own patience lasts for 3 seconds :-)

Dirty trick #2:
   The task says that "the solution must be printed".
   But it wasn't required that your program should print only one number.

What should we do if a program prints a lot of text?
Just ignore the "invisible" text scrolled up beyond the screen.

These tricks are unfair, but they save several bytes of code.
With these tricks allowed, you can write a program which simply prints infinite sequence of numbers converging to the correct answer.
First lines of output would contain incorrect values, but later the old values would be scrolled up and replaced with more correct approximations.
At the moment when the program is killed, the whole screen would contain the correct answer on every line.


My program prints some sequence of numbers converging to the root of equation x^x=C.
Your task is either to write similar program which runs endlessly
or to print the root calculated using some other approach.

Now, with the "dirty tricks" explained, the task become quite solvable.


I have tried these tricks (just before your advice), but I only get a 51 byte solution:
x=1l=math.log::a::x=(l(C)+x)/(l(x)+1)print(x)goto a

and doesn't have any improve after that :-(

--
regards,
Xavier Wang.
Reply | Threaded
Open this post in threaded view
|

Re: [FUN] CodeGolf: solve equation x^x=C

Philippe Verdy
Also you can avoid the ::a:: label and goto, using a finite for loop 
Or use the basic "calculator" interface to reduce the program only to the evaluation of the convergent series (as a single expression of x, the previous value of the series, and C). And then you don't need your program to perform an explicit loop or trailing recursive call.

In all cases you need an environment where you'll run the Lua engine and can provide the UI to enter your "program" and the value of C; printing does not have to be part of the program itself as the environment can do that itself. 


Le ven. 28 juin 2019 à 00:51, Philippe Verdy <[hidden email]> a écrit :
That's because your "log" function is inexact (use an integer log2 that extracts just the exponent part of the number instead of math.log)
And you did not use the modulo2 trick to make exact divisions, so there's an imprecision on the last bit.

Le ven. 28 juin 2019 à 00:46, Xavier Wang <[hidden email]> a écrit :


Egor Skriptunoff <[hidden email]> 于2019年6月28日周五 上午5:39写道:
On Wed, Jun 26, 2019 at 11:47 PM Egor Skriptunoff wrote:
Global variable "C" contains numeric value > 15.5
The solution of math equation x^x=C must be printed
Your code must fit into 36 bytes
Dirty tricks are allowed


Some sort of codegold-related cheating is required to solve this task, so I should tell more about "dirty tricks".

Dirty trick #1:
   Please note that the task doesn't require that your program should exit after the job is done.
   The program might exit, but it doesn't have to.

What should we do if a program never stops?
Just wait until you runs out of patience and then kill the process.
My own patience lasts for 3 seconds :-)

Dirty trick #2:
   The task says that "the solution must be printed".
   But it wasn't required that your program should print only one number.

What should we do if a program prints a lot of text?
Just ignore the "invisible" text scrolled up beyond the screen.

These tricks are unfair, but they save several bytes of code.
With these tricks allowed, you can write a program which simply prints infinite sequence of numbers converging to the correct answer.
First lines of output would contain incorrect values, but later the old values would be scrolled up and replaced with more correct approximations.
At the moment when the program is killed, the whole screen would contain the correct answer on every line.


My program prints some sequence of numbers converging to the root of equation x^x=C.
Your task is either to write similar program which runs endlessly
or to print the root calculated using some other approach.

Now, with the "dirty tricks" explained, the task become quite solvable.


I have tried these tricks (just before your advice), but I only get a 51 byte solution:
x=1l=math.log::a::x=(l(C)+x)/(l(x)+1)print(x)goto a

and doesn't have any improve after that :-(

--
regards,
Xavier Wang.
Reply | Threaded
Open this post in threaded view
|

Re: [FUN] CodeGolf: solve equation x^x=C

Egor Skriptunoff-2
In reply to this post by Xavier Wang
On Fri, Jun 28, 2019 at 1:46 AM Xavier Wang wrote:
I have tried these tricks (just before your advice), but I only get a 51 byte solution:

and doesn't have any improve after that :-(



Hint:
My program demonstrates unexpected usage of some Lua statement.
Out-of-the-box thinking might be helpful.

Reply | Threaded
Open this post in threaded view
|

Re: [FUN] CodeGolf: solve equation x^x=C

Dirk Laurie-2
In reply to this post by Egor Skriptunoff-2
I can do 41 bytes.

x=3 while 1 do x=math.log(C,x)print(x)end

Op Do. 27 Jun. 2019 om 23:39 het Egor Skriptunoff
<[hidden email]> geskryf:

>
> On Wed, Jun 26, 2019 at 11:47 PM Egor Skriptunoff wrote:
>>
>> Global variable "C" contains numeric value > 15.5
>> The solution of math equation x^x=C must be printed
>> Your code must fit into 36 bytes
>> Dirty tricks are allowed
>
>
>
> Some sort of codegold-related cheating is required to solve this task, so I should tell more about "dirty tricks".
>
> Dirty trick #1:
>    Please note that the task doesn't require that your program should exit after the job is done.
>    The program might exit, but it doesn't have to.
>
> What should we do if a program never stops?
> Just wait until you runs out of patience and then kill the process.
> My own patience lasts for 3 seconds :-)
>
> Dirty trick #2:
>    The task says that "the solution must be printed".
>    But it wasn't required that your program should print only one number.
>
> What should we do if a program prints a lot of text?
> Just ignore the "invisible" text scrolled up beyond the screen.
>
> These tricks are unfair, but they save several bytes of code.
> With these tricks allowed, you can write a program which simply prints infinite sequence of numbers converging to the correct answer.
> First lines of output would contain incorrect values, but later the old values would be scrolled up and replaced with more correct approximations.
> At the moment when the program is killed, the whole screen would contain the correct answer on every line.
>
>
> My program prints some sequence of numbers converging to the root of equation x^x=C.
> Your task is either to write similar program which runs endlessly
> or to print the root calculated using some other approach.
>
> Now, with the "dirty tricks" explained, the task become quite solvable.
>

Reply | Threaded
Open this post in threaded view
|

Re: [FUN] CodeGolf: solve equation x^x=C

Xavier Wang


Dirk Laurie <[hidden email]> 于2019年6月28日周五 下午6:22写道:
I can do 41 bytes.

x=3 while 1 do x=math.log(C,x)print(x)end

 
Thanks! combine with your method, I finally have a 34 bytes solution:
::a::x=math.log(C,x)print(x)goto a

btw, why (ln(C)+x)/(ln(x)+1) can be simplify to math.log(C,x)?

--
regards,
Xavier Wang.
Reply | Threaded
Open this post in threaded view
|

Re: [FUN] CodeGolf: solve equation x^x=C

Viacheslav Usov
In reply to this post by Dirk Laurie-2
On Fri, Jun 28, 2019 at 12:22 PM Dirk Laurie <[hidden email]> wrote:

> x=3 while 1 do x=math.log(C,x)print(x)end

34 chars: ::B::X=math.log(C,X)print(X)goto B

I acknowledge Dirk's idea for using math.log in an unorthodox way with a variable base. Endless printing using goto was my own idea before the endless printing was explicitly stipulated by Egor. The final guess to use uninitialised X was my own.

Cheers,
V.

Reply | Threaded
Open this post in threaded view
|

Re: [FUN] CodeGolf: solve equation x^x=C

Albert Chan
In reply to this post by Xavier Wang
> On Jun 28, 2019, at 6:42 AM, Xavier Wang <[hidden email]> wrote:
>
> btw, why (ln(C)+x)/(ln(x)+1) can be simplify to math.log(C,x)?

x^x = c
x ln(x) = ln(c)
x = ln(c)/ln(x) = log(c,x)

Above iterated solution converge only if denominator ln(x) > 1
x > e
c = x^x > e^e ~ 15.155 < 15.5



Reply | Threaded
Open this post in threaded view
|

Re: [FUN] CodeGolf: solve equation x^x=C

Xavier Wang


Albert Chan <[hidden email]>于2019年6月28日 周五20:37写道:
> On Jun 28, 2019, at 6:42 AM, Xavier Wang <[hidden email]> wrote:
>
> btw, why (ln(C)+x)/(ln(x)+1) can be simplify to math.log(C,x)?

x^x = c
x ln(x) = ln(c)
x = ln(c)/ln(x) = log(c,x)

Above iterated solution converge only if denominator ln(x) > 1
x > e
c = x^x > e^e ~ 15.155 < 15.5



Thanks! I got it.

--
regards,
Xavier Wang.
Reply | Threaded
Open this post in threaded view
|

Re: [FUN] CodeGolf: solve equation x^x=C

Albert Chan
In reply to this post by Albert Chan
On Jun 28, 2019, at 8:37 AM, Albert Chan <[hidden email]> wrote:
> x^x = c
> x ln(x) = ln(c)
> x = ln(c)/ln(x) = log(c,x)
>
> Above iterated solution converge only if denominator ln(x) > 1
> x > e
> c = x^x > e^e ~ 15.155 < 15.5

I made a mistake about the constant 15.5
It had nothing to do with e^e, but with the initial guess of x

With initial guess of 3, and actual x<3, we have
x0 = 3, x1 = log(c,3), x2 = log(c, log(c,3)) ...
Solving x2<3, we get c > 15.21708982

Had we use a higher guess, say 4, we would have c > 16

Reply | Threaded
Open this post in threaded view
|

Re: [FUN] CodeGolf: solve equation x^x=C

Dirk Laurie-2
Op Vr. 28 Jun. 2019 om 15:24 het Albert Chan <[hidden email]> geskryf:

>
> On Jun 28, 2019, at 8:37 AM, Albert Chan <[hidden email]> wrote:
> > x^x = c
> > x ln(x) = ln(c)
> > x = ln(c)/ln(x) = log(c,x)
> >
> > Above iterated solution converge only if denominator ln(x) > 1
> > x > e
> > c = x^x > e^e ~ 15.155 < 15.5
>
> I made a mistake about the constant 15.5
> It had nothing to do with e^e, but with the initial guess of x
>
> With initial guess of 3, and actual x<3, we have
> x0 = 3, x1 = log(c,3), x2 = log(c, log(c,3)) ...
> Solving x2<3, we get c > 15.21708982
>
> Had we use a higher guess, say 4, we would have c > 16

You were right the first time round. For the iteration to converge, we
need (a) that the equation x^x = C has a unique solution (b) that the
iteration function has derivative absolutely less than 1 in a
neighborhood of that solution (c) the initial value lies in that
neighborhood.

(a) is no problem in this case.

Iteration function  f(x) = log(C)/log(x)
Derivative:  f'(x) = -log(C)/(log(x))^2/x
Hence the neighborhood is x*log(x)^2 > log(C)
The initial value (taking x=nil) is log(C).
Thus C must satisfy  log(log(C))^2 > 1, giving C>e^e.

Reply | Threaded
Open this post in threaded view
|

Re: [FUN] CodeGolf: solve equation x^x=C

Albert Chan
In reply to this post by Albert Chan

> On Jun 28, 2019, at 9:24 AM, Albert Chan <[hidden email]> wrote:
>
> Had we use a higher guess, say 4, we would have c > 16

Example, x^x = c = 15.8, guess x0 = 4, iterations diverges:

x1 = log(c,x0) = 1.9909
x2 = log(c,x1) = 4.0081
x3 = log(c,x2) = 1.9880
x4 = log(c,x3) = 4.0167 ...

c > e^e work only if guess x0 = e


123