Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Roots and powers playing nicely together...
#20
(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 + ...
Reply


Messages In This Thread
RE: Roots and powers playing nicely together... - by bplus - 09-30-2022, 11:02 PM



Users browsing this thread: 9 Guest(s)