Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Newton had a fun way to approximate general roots...
#25
Well back to working with Euler approximations. So based on his work, I put together what I think is a pretty cool way to get decimal roots like 7^2.3, 8 ^.7, etc. calculated without using logs.

So if this works, it can be adopted to use with string math routines I have already made.

DECIMAL POWERS ROUTINE

Code: (Select All)
WIDTH 120, 42
_SCREENMOVE 0, 0
DO
    INPUT "Number: "; num
    LINE INPUT "Power: "; power$
    IF INSTR(power$, ".") THEN
        t = VAL(MID$(power$, INSTR(power$, ".")))
        power$ = MID$(power$, 1, INSTR(power$, ".") - 1)

        a = 1
        b = num
        x = 0
        y = 1

        highc = b
        lowc = a
        highz = 1

        DO
            t1 = a * b
            c = SQR(t1)
            t1 = x + y
            z = t1 / 2
            IF z = t THEN EXIT DO
            IF z > t THEN
                highz = z: highc = c
            ELSEIF z < t THEN
                lowz = z: lowc = c
            END IF
            PRINT a, b, highc, lowc, z, highz, lowz
            a = highc: b = lowc
            x = highz: y = lowz
        LOOP
        IF LEN(power$) THEN
            a = num ^ VAL(power$) * a
        END IF
        PRINT "Results = "; a
    ELSE
        PRINT "Results = "; num ^ VAL(power$)
    END IF
    PRINT
LOOP


Pete
Reply


Messages In This Thread
RE: Newton had a fun way to approximate general roots... - by Pete - 09-16-2022, 02:56 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  "I'm Having Fun." James D Jarvis 6 1,307 07-25-2023, 11:32 PM
Last Post: Kernelpanic
  New General Discussion Subforums admin 13 4,714 02-14-2023, 08:21 AM
Last Post: PhilOfPerth
  Fun with hardware acceleration. Pete 0 477 10-20-2022, 10:25 PM
Last Post: Pete
  Roots and powers playing nicely together... Pete 28 5,102 10-01-2022, 10:16 PM
Last Post: Kernelpanic
  Pascal's Triangle and nth roots. Pete 2 883 09-26-2022, 04:15 PM
Last Post: Pete

Forum Jump:


Users browsing this thread: 1 Guest(s)