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.
   
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


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

Possibly Related Threads…
Thread Author Replies Views Last Post
  I advanced my AI to a black jack playing robot. Pete 1 585 04-17-2024, 12:46 AM
Last Post: PhilOfPerth
  Pascal's Triangle and nth roots. Pete 2 870 09-26-2022, 04:15 PM
Last Post: Pete
  Newton had a fun way to approximate general roots... Pete 35 6,289 09-22-2022, 12:38 AM
Last Post: Kernelpanic
  String math: Whole # powers easy, decimal powers!!! Pete 0 510 09-12-2022, 08:58 PM
Last Post: Pete

Forum Jump:


Users browsing this thread: 1 Guest(s)