Posts: 652
Threads: 96
Joined: Apr 2022
Reputation:
22
Excuse me if I'm wrong, but should that be x^(1/100) ? I think powers are resolved before / without parenthesis.
Posts: 2,171
Threads: 222
Joined: Apr 2022
Reputation:
103
09-30-2022, 05:03 AM
(This post was last modified: 09-30-2022, 06:29 AM by Pete.)
Example: 8^.02 To do that using long division requires making a fraction of .02 as 02/100 = 2 /1000 = 1/500. So now here is the labor intensive part, 8 root of 500 to the power of 1. Even the structure needed in Pascal's triangle is huge at 500 iterations. As tested, I can get 8 to the root of 200 in a couple of seconds, but beyond that, things are hanging again, and will need to be investigated. So imagine the system strain with 8^.0002. 50,000 iterations.
To address the speed issues, yes, you do things similar to what you are proposing. The rabbit hole we have here is just how many conditions need to be meet to break down the excessive iterations.
Pete
Edit: It worked, it was just very slow at 8 root 500.
Shoot first and shoot people who ask questions, later.
Posts: 3,968
Threads: 177
Joined: Apr 2022
Reputation:
219
(09-30-2022, 04:51 AM)PhilOfPerth Wrote: Excuse me if I'm wrong, but should that be x^(1/100) ? I think powers are resolved before / without parenthesis.
You are correct. But my point was that if you can do x ^ (1/100 = .01) you could do x ^ (3/100 = .03) = (x^.01) * (x^.01) * (x^.01)
To show Pete that doing x ^ (.0y) calculations are possible (just not practical but we know already string math is the definition of NOT practical).
b = b + ...
Posts: 1,002
Threads: 50
Joined: May 2022
Reputation:
27
(09-30-2022, 04:51 AM)PhilOfPerth Wrote: Excuse me if I'm wrong, but should that be x^(1/100) ? I think powers are resolved before / without parenthesis.
Why should not that be right? I do not understand. I see no violation of a mathematical law.
Code: (Select All) 'Beispiel x ^ (a/b) - 30. Sept. 2022
Option _Explicit
Dim As Double a, b, x, potenz
Input "Basis x: ", x
Input "a : ", a
Input "b : ", b
Print
potenz = x ^ (a / b)
Print Using "Potenzwert = : #####.####"; potenz
End
Posts: 2,171
Threads: 222
Joined: Apr 2022
Reputation:
103
Well math manipulation for this process would have to be on the front end. Speed is not the issue on the back end, where the root calculations are now just raised to a power a single time, or multiplied together, as bplus has demonstrated.
The real slow down in long division root math is the binomial expansion equation. Those calculations get longer and longer with the component numbers getting larger and larger each iteration. So for .1, we use just 10 iterations, not bad, but with .001 we need 1,000 comprised with very huge numbers. That takes minutes to calculate, not seconds. Remember in regular long division where you bring down just one number per iteration to combine with the remainder? In root long division of .001, you would need to bring down 1,000 digits for every iteration. So if your remainder is something small like 3, your next division step is to find the binomial expansion that is closest to 3.0e+1000.
So thinking this through... 8^.001 can be root calculated as (8 root 1000) ^ 1 = 1.0020816050796327943603513248911. I wonder if there is a way to reduce the root 1000 while keeping the power as a WHOLE number?
Also... As a hybrid model, we could always use numeric computer math DOUBLE to produce results to 16-digits for numbers 8-digits or less and get a slightly inaccurate result like: (8 root 1000) ^ 1 = 1.002081605079633 but that last digit should be a 2, not a 3, but the whole concept of using string math is to avoid these inaccuracies.
Pete
Posts: 2,171
Threads: 222
Joined: Apr 2022
Reputation:
103
Got it.
So as Mark was pointing out, factoring. I just need to apply it to the front end where...
8 root 1000 becomes three iterations: 8 root 10 = 1.2311444133 root 10 = 1.0210121257 root 10 = 1.0020816051.
That will speed this up "exponentially" but how about other conditions that are not as straight forward? I'm wondering how much A.I. (conditional routines) will need to be added to keep chopping apart powers / roots?
Pete
Shoot first and shoot people who ask questions, later.
Posts: 1,002
Threads: 50
Joined: May 2022
Reputation:
27
(09-30-2022, 04:51 AM)PhilOfPerth Wrote: Excuse me if I'm wrong, but should that be x^(1/100) ? I think powers are resolved before / without parenthesis.
And back to the roots:
Code: (Select All) 'Beispiel x ^ (a/b) - 30. Sept. 2022
Option _Explicit
Dim As Double a, b, x, potenz
Input "Basis x: ", x
Input "a : ", a
Input "b : ", b
Print
potenz = x ^ (a / b)
Print Using "Potenzwert = : #####.####"; potenz
Print
Print "Und return:"
x = potenz ^ (b / a)
Print Using "Basis x: ###.####"; x
End
Posts: 2,171
Threads: 222
Joined: Apr 2022
Reputation:
103
09-30-2022, 08:08 PM
(This post was last modified: 09-30-2022, 09:20 PM by Pete.)
Okay, so for something like 8 root of 1025 = 1.0020307827 let's try... 10 * 10 * 10 * 1.025
8 root 10 = 1.2311444133 root of 10 = 1.0210121257 root 10 = 1.0020816051 root 1.025 = 1.0020307827
Pete
Shoot first and shoot people who ask questions, later.
Posts: 2,171
Threads: 222
Joined: Apr 2022
Reputation:
103
09-30-2022, 09:06 PM
(This post was last modified: 09-30-2022, 09:20 PM by Pete.)
Well to continue this, I have to put together some sort of an algorithm that limits roots to 10 and factors out ever root above 10 to a number of given iterations.
Pete
Posts: 3,968
Threads: 177
Joined: Apr 2022
Reputation:
219
09-30-2022, 11:02 PM
(This post was last modified: 09-30-2022, 11:11 PM by bplus.)
(09-30-2022, 08:08 PM)Pete Wrote: Okay, so for something like 8 root of 1025 = 1.0020307827 let's try... 10 * 10 * 10 * 1.025
8 root 10 = 1.2311444133 root of 10 = 1.0210121257 root 10 = 1.0020816051 root 1.025 = 1.0020307827
Pete You sure have funny way of saying X to the power of Y!
(09-30-2022, 09:06 PM)Pete Wrote: Well to continue this, I have to put together some sort of an algorithm that limits roots to 10 and factors out ever root above 10 to a number of given iterations.
Pete
Here's another approach, the cornerstone being what we rejected earlier ie natural logs and e^x:
Code: (Select All) Option _Explicit
Print power##(8, 1 / 1025)
Function power## (x As _Float, exponent As _Float)
Dim step1 As _Float
step1 = exponent * nLn##(x)
power## = eToTheX##(step1)
End Function
Function nLn## (x As _Float)
Dim As _Float term, xbase, coef, sum, newsum
Dim As Long k, count, kPower
sum = 0
term = (x - 1) / (x + 1)
k = 0
xbase = 1
Do
sum = newsum
coef = 2 / (2 * k + 1) ' 2
kPower = 2 * k + 1 ' 1
While count < kPower
xbase = xbase * term
count = count + 1
Wend
newsum = sum + coef * xbase
k = k + 1
Loop Until sum = newsum
nLn## = sum
End Function
Function eToTheX## (x As _Float)
Dim As _Float sum
Dim As Long n, i
sum = 1: n = 50
For i = n - 1 To 1 Step -1
sum = 1 + x * sum / i
Next
eToTheX## = sum
End Function
Converted to String Math routines of course.
b = b + ...
|