(11C) X to Power of X Equation

02152018, 12:33 PM
(This post was last modified: 04162018 12:43 PM by Gamo.)
Post: #1




(11C) X to Power of X Equation
Here is the approximation of the equation of X^X=Y
X to the power of X for the given Y Procedure: Used FIX 6 or more, Store approximation value in R1 (STO 1) Example: X^X=1000 Use 4 to store approximation value 4 [STO 1] then 1000 f [A] result 4.555536... To check for answer: with answer already on display press [ENTER] [Y^X] Program: Code:
Gamo 

02152018, 08:04 PM
(This post was last modified: 02152018 08:21 PM by Dieter.)
Post: #2




RE: (11C) X to Power of X Equation
(02152018 12:33 PM)Gamo Wrote: Here is the approximation of the equation of X^X=Y There is a closed form solution for this: X = e^{W(ln Y)}. Here W is the Lambert W function, for instance featured on the WP34s. (02152018 12:33 PM)Gamo Wrote: Program: Gamo, this program will not work. When it passes LBL 1 for the first time the Xvalue is 0,01201 so that the program continues with the log of this counter value. It looks like a CLX + between STO I and LBL 1 might work – try it. Also the program does essentially the same in the first steps and then during the iteration loop. Finally the 0,01201 can simply be replaced with ,012. Or, even better, initialize the counter with 12 and use DSE instead of ISZ. (02152018 12:33 PM)Gamo Wrote: To check for answer [STO] answer then [ENTER] [RCL] [Y^X] Simply type [ENTER] [y^{x}]. ;) Here is a version that calculates an initial guess and then uses your approximation method. Press [R/S] to see the iteration converge. You may use [X<>Y] to compare the last and current approximation. Code: LBL A Example (assuming FIX 6 mode): 1000 [A] 3,824155 [R/S] 4,487028 [R/S] 4,544273 [R/S] 4,553629 [R/S] 4,555211 [R/S] 4,555480 [R/S] 4,555526 [R/S] 4,555534 [R/S] 4,555535 [R/S] 4,555536 [R/S] 4,555536 I still am not quite satisfied with the initial guess. It can be improved so that one or two iterations can be saved. Also the proposed algorithm does not work for any X. Maybe someone else has a better idea. Dieter 

02152018, 09:58 PM
(This post was last modified: 02152018 11:19 PM by Dieter.)
Post: #3




RE: (11C) X to Power of X Equation
(02152018 08:04 PM)Dieter Wrote: I still am not quite satisfied with the initial guess. It can be improved so that one or two iterations can be saved. Also the proposed algorithm does not work for any X. Maybe someone else has a better idea. Here is an improved version. It essentially calculates W(ln Y) and calculates the final result from this. The algorithm uses a third order Halley method as implemented in a thread in the old forum, cf. message #43. For ~10 digits it should converge within 5 iterations. BTW the WP34s Lambert W code is based on the versions in the linked thread. Code: LBL E Since there may be a slight error in the last digit the program returns two values in X and Y that usually bracket the exact solution. Example: 1000 [E] => 4,555535705 [X<>Y] => 4,555535705 3125 [E] => 5,000000001 [X<>Y] => 4,999999998 As far as I can tell the program should work well for input > 0,7. But try it yourself and see what you get. BTW, if you remove the LN in the second step and replace everything after LBL 3 with a RTN you have a program that calculates Lambert's W function of x. Here the program works well down to approx –0,36. For input closer to –1/e the returned result becomes inaccurate. That's why the linked program in the old forum switches to a different method here. Dieter Edit: Take a look at message #61 in the linked thread. This leads to the following method for manually calculating the solution of x^{x}=y: Type y [ln] [ENTER] [ENTER] [ENTER] Now repeat pressing [ln] [÷] until the desired accuracy is reached. 

02162018, 06:36 AM
(This post was last modified: 02162018 09:35 AM by Gamo.)
Post: #4




RE: (11C) X to Power of X Equation
Thank You Dieter
Very interesting topic in the old forum link and your program is also very good to give more variety of approximation. I did update my program to add [CLx] [+] as you recommended and now work perfectly. Gamo 

02182018, 08:02 PM
(This post was last modified: 02192018 08:31 AM by Dieter.)
Post: #5




RE: (11C) X to Power of X Equation
(02162018 06:36 AM)Gamo Wrote: I did update my program to add [CLx] [+] as you recommended and now work perfectly. Fine. I just posted a new version in the respective 12C thread. Since it's a nice and compact program, here it is for the 11C: Code: LBL E For more details cf. the linked 12C thread. Dieter Edit: just noticed that two ENTERs will do. ;) 

02192018, 01:00 AM
(This post was last modified: 02192018 01:24 AM by Gamo.)
Post: #6




RE: (11C) X to Power of X Equation
I like to try the Newton Method program that provided in the 11C Owner's Handbook with this X to the X power equation.
What is the program steps use to solve this X^X=1000 change equation to X^X  1000=0 Example in the Handbook: f(x)=X^6  X  1 = 0 Steps: [STO 5] [6] [Y^X] [RCL] [5] [] [1] [] Gamo 

02192018, 08:15 AM
(This post was last modified: 02192018 09:00 AM by Dieter.)
Post: #7




RE: (11C) X to Power of X Equation
(02192018 01:00 AM)Gamo Wrote: I like to try the Newton Method program that provided in the 11C Owner's Handbook with this X to the X power equation. Gamo, what keys would you press if you have a number in X and you now want to calculate X^X–1000? I think you know that. [ENTER] [y^x] [EEX] 3 [–] You can also replace the EEX 3 with, say, RCL 5 (assuming this is not used by the program) and store 1000 or any other number in R5. This way you can solve for any Y without having to change the program: [ENTER] [y^x] [RCL] 5 [–] 1000 [STO] 5 (run the program) => 4,5555... 4711 [STO] 5 (run the program) => 5,1563... EEX 9 [STO] 5 (run the program) => 9,2950... Dieter 

02202018, 01:49 AM
(This post was last modified: 02202018 07:45 AM by Gamo.)
Post: #8




RE: (11C) X to Power of X Equation
According to the 11C Owner's Handbook to used the Newton's Method program.
The user must define the function f(x) by entering into program memory the keystrokes require to find f(x), assuming x is in the Xregister. The main program requires register 04. The equation is X^X1000=0 Program step: STO 5 RCL 5 Y^X EEX 3  This steps work on the smaller number size because according to the book state that sometime the loop is too much then must change the loop count lower to successfully converge. Gamo 

02202018, 08:07 AM
Post: #9




RE: (11C) X to Power of X Equation
(02202018 01:49 AM)Gamo Wrote: Program step: Why do you store X in R5 first? Why not simply ENTER Y^X? (02202018 01:49 AM)Gamo Wrote: This steps work on the smaller number size because according to the book state that sometime the loop is too much then must change the loop count lower to successfully converge. Sorry, I don't understand. What smaller number size do you mean? The loop is too much? The program converges if you reduce the number of loops? ?!? But more important: what results do you get with that program? Dieter 

02202018, 09:28 AM
(This post was last modified: 02202018 09:34 AM by Gamo.)
Post: #10




RE: (11C) X to Power of X Equation
When I try X^X=10 with Newton's Method program which I used STO 5, RCL 5, Y^X, 10,  program steps and this work fine.
Then I try X^X=1000 Program keep running with Error 3. So I was thinking about loop count on this problem that might be the cause of the error or not enough memory. About inserting program to solve problems. What I think is that this program need to use repeat same register for each unknown X. In the book example: X^6  X  1 = 0 Program: STO 5, 6, Y^X, RCL 5, , 1, STO 5 for X^6 RCL 5,  for  X Just wondering because program set up is not the same like 15C SOLVE Gamo 

02202018, 08:19 PM
(This post was last modified: 02202018 08:20 PM by Dieter.)
Post: #11




RE: (11C) X to Power of X Equation
(02202018 09:28 AM)Gamo Wrote: When I try X^X=10 with Newton's Method program which I used STO 5, RCL 5, Y^X, 10,  program steps and this work fine. No. Of course the program does not consume more or less memory if it runs the iteration loop 5, 10 or 50 times. I have looked at the program code, and this is what happens: The program generates two different errors. Error 4 is displayed if even after 50 loops the iteration has not converged. If really you got an Error 3 and not Error 4 (sure?) this is not what happened here. Technically this error is generated in line 53: if the DSE loop is left after 50 iterations the program tries to jump to LBL 9 – which does not exist. Error 3 is displayed if the (approximated) derivative in the Newton formula is zero. In this case the Newton method cannot be used as it divides by this value, so this would lead to a division by zero. If you really got an Error 3 this is what must have happened. Both f(x) and f(x+δ) obviously had the same value. Technically this error is generated in line 37/38: if the mentioned difference is zero, the program tries to access register ,9 – which does not exist (the program has more than 63 lines). You may track down the problem by inserting a RCL 2 R/S (or PSE) right before the DSE in line 51. This way you see how the iteration converges – or not. Try it and write down the successive approximations. What was the initial guess you started with for Y=1000? Was it 4? 5? Or was it 0? The Newton merhod for this particular function does not converge very well. It should work if the initial guess is sufficiently close to the solution. But in other cases the iteration will show very slow convergence or will even lead away from the solution, and you get an error. Try it. The program also implements a quite ..."creative" way of determining the value for δ. This causes even more problems here. That's why I suggest solving a different equation. Instead of X^X = 1000 you better solve X*ln X = ln 1000. Both functions have the same solution, but the latter behaves far more relaxed and its slope changes much more moderately. So you may use this function at LBL C: [ENTER] [LN] [x] [EEX] 3 [LN] [–] Try different initial guesses and see what you get. Finally an important note: you have to (!) initialize the program with [A] each time before you calculate a solution with [B]. The program overwrites the values that are set with [A], so you have to restore them before you start another iteration with [B]. (02202018 09:28 AM)Gamo Wrote: What I think is that this program need to use repeat same register for each unknown X. No again. If X occurs several times in the function you may (!) store it somewhere and recall it from there each time an X occurs on the equation. But of course this is not required! You can just as well store X on the stack, for instance like this: [ENTER] [ENTER] 6 [Y^X] [X<>Y] [–] 1 [–] For the given example the STO 5 method is only a bit shorter and easier to understand for RPN beginners. But calculating X^X on a RPN calculator and NOT doing it with a simple [ENTER] [Y^X]... that's almost ...weird. ;) Dieter 

02202018, 09:05 PM
(This post was last modified: 02202018 09:08 PM by Dieter.)
Post: #12




RE: (11C) X to Power of X Equation
(02202018 08:19 PM)Dieter Wrote: The Newton merhod for this particular function does not converge very well. It should work if the initial guess is sufficiently close to the solution. But in other cases the iteration will show very slow convergence or will even lead away from the solution, and you get an error. To illustrate this point, here are the successive approximations for X^X–1000 = 0 for some different initial guesses, calculated with the exact derivative (and Excel ;)) Code: guess = 4 Fine. This seems to work. Code: guess = 3 This leads away from the solution and then moves veeeery slowly back in direction of the solution. It takes about 60 (!) iterations before the result is OK. Code: guess = 2 The iteration stops with an error because already the first new approximation becomes so large that the next step (requiring the evaluation of 149^149) will lead to an overflow error. Code: guess = 10 Again, the iteration converges veeery slowly. That's why I suggest solving X*ln X = ln 1000 instead. Dieter 

02212018, 04:25 AM
(This post was last modified: 02212018 06:04 AM by Gamo.)
Post: #13




RE: (11C) X to Power of X Equation
Thank You Dieter
Now I understand how this equation not work with this program and your alternative equation work better. For X^X=1000 changed equation to X*ln X = ln 1000 Program Steps: [ENTER] [LN] [x] [EEX] 3 [LN] [–] Initial Guesses comparison: 2 > 4,555535706 3 > 4,555535705 4 > 4,555535705 5 > 4,555535705 6 > 4,555535705 . . . 10 > 4,555535705 The closer guess to the root the faster the computation. Gamo Gamo 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)