(12C) X to Power of X Equation
|
02-18-2018, 04:58 PM
(This post was last modified: 02-19-2018 08:45 AM by Dieter.)
Post: #4
|
|||
|
|||
RE: (12C) X to Power of X Equation
(02-18-2018 01:41 PM)Dieter Wrote: Now let's see if the iteration process can be done automatically. ;-) Here is another more compact version. It uses a simple yet effective initial estimate. Instead of xx = y it solves x · ln x = ln y, which has better numeric properties. The derivative is 1 + ln x which leads to a short and simple implementation of Newton's method: Code: 01 LN This should work for any input ≥ 1. The exit condition is a relative difference of less than 5 E–7 percent (i.e. 5 E–9) between the last two approximations. This can be modified by changing the exponent in line 31 (the higher, the earlier the iteration terminates). There also is a counter as a safeguard: if the last relative difference does not round to zero, it definitely will after it has been multiplied by the counter which will eventually become zero. Again, the last two approximations are returned in X and Y. 1000 [R/S] => 4,555535705 [X<>Y] => 4,555535705 3125 [R/S] => 5,000000001 [X<>Y] => 4,999999999 Edit: here is another version which is even slighty shorter. The exit condition now is a relative error < 1 E–7 percent. This can be adjusted by the constant in line 28...30 which simply is the reciprocal of the error threshold (in percent). So if, for example, you want the iteration to exit at a relative error of 2 E–8, that's 2 E–6 percent and 1/2E–6 = 5 E5 which then is the value in line 28...30. Code: 01 LN Dieter |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(12C) X to Power of X Equation - Gamo - 02-18-2018, 09:15 AM
RE: (12C) X to Power of X Equation - Dieter - 02-18-2018, 01:41 PM
RE: (12C) X to Power of X Equation - Dieter - 02-18-2018, 03:17 PM
RE: (12C) X to Power of X Equation - Dieter - 02-18-2018 04:58 PM
|
User(s) browsing this thread: 2 Guest(s)