#Calculating x ** 0.000001 with pure arithmetic calculations

133 messages · Page 1 of 1 (latest)

half geyserBOT
supple flicker
#

This is the closest I've been to for this solution, but it's still very inaccurate and I want it to be accurate down to 6-7 decimal points

#

For reference, I'm trying to arithmetically calculate a log function (passes X and B respectively, and outputs Y), here's my current code so far:

https://py3.codeskulptor.org/#user310_VIFUNXx3Y0_1.py

However, the exponentiation part is what's truly killing me, as the compiler I'm coding in doesn't accept the exponentiation operation.

#

These aren't allowed

last glade
#

😭 holy shit

supple flicker
#

yes

#

so instead of the output being 0.000001112 i want it to be like 0.00000112

#

or whatever

last glade
#

how large is x

supple flicker
#

greater than 0 i think

#

or 1

#

1 < x < 2^32-1 (integer limit)

#

or 2^32

last glade
#

i mean

supple flicker
#

there was this cancerous approach of doing taylor series, and it works for smaller numbers, just not for big ones (even as "big" as 2^6)

def approx_power_taylor(x):
"""
Approximates x^0.000001 using an expanded Taylor series for ln x (51 terms, up to w^101).
Uses only arithmetic operations (addition, subtraction, multiplication, division).
"""
w = (x - 1) / (x + 1)
w2 = w * w
w3 = w2 * w
w5 = w3 * w2
w7 = w5 * w2
w9 = w7 * w2
w11 = w9 * w2
w13 = w11 * w2
w15 = w13 * w2
w17 = w15 * w2
w19 = w17 * w2
w21 = w19 * w2
w23 = w21 * w2
w25 = w23 * w2
w27 = w25 * w2
w29 = w27 * w2
w31 = w29 * w2
w33 = w31 * w2
w35 = w33 * w2
w37 = w35 * w2
w39 = w37 * w2
w41 = w39 * w2
w43 = w41 * w2
w45 = w43 * w2
w47 = w45 * w2
w49 = w47 * w2
w51 = w49 * w2
w53 = w51 * w2
w55 = w53 * w2
w57 = w55 * w2
w59 = w57 * w2
w61 = w59 * w2
w63 = w61 * w2
w65 = w63 * w2
w67 = w65 * w2
w69 = w67 * w2
w71 = w69 * w2
w73 = w71 * w2
w75 = w73 * w2
w77 = w75 * w2
w79 = w77 * w2
w81 = w79 * w2
w83 = w81 * w2
w85 = w83 * w2
w87 = w85 * w2
w89 = w87 * w2
w91 = w89 * w2
w93 = w91 * w2
w95 = w93 * w2
w97 = w95 * w2
w99 = w97 * w2
w101 = w99 * w2
ln_x_approx = 2 * (w + w3/3 + w5/5 + w7/7 + w9/9 + w11/11 + w13/13 + w15/15 +
w17/17 + w19/19 + w21/21 + w23/23 + w25/25 + w27/27 + w29/29 + w31/31 +
w33/33 + w35/35 + w37/37 + w39/39 + w41/41 + w43/43 + w45/45 + w47/47 +
w49/49 + w51/51 + w53/53 + w55/55 + w57/57 + w59/59 + w61/61 + w63/63 +
w65/65 + w67/67 + w69/69 + w71/71 + w73/73 + w75/75 + w77/77 + w79/79 +
w81/81 + w83/83 + w85/85 + w87/87 + w89/89 + w91/91 + w93/93 + w95/95 +
w97/97 + w99/99 + w101/101)
return 1 + 0.000001 * ln_x_approx

supple flicker
#

it needs to be so accurate

last glade
supple flicker
#

might even be accurate down to 10-11 decimal places

#

yes

last glade
supple flicker
#

PROB

#

*prob

last glade
supple flicker
#

cuz the log function im using is so delicate with the way the decimal places are being handled

last glade
#

does minecraft even support that much precision

supple flicker
#

hmm

#

honestly

#

yeah ur right it prob doesnt

#

ima scrap this thread now

last glade
#

.close

half geyserBOT
#
Solved

Post marked as solved by @last glade.

Use .unsolved if this was a mistake.

wise oar
#

hmmcat I used gpt to create this
Tell me if you can use this or not

#

@supple flicker

wise oar
wise oar
#

I repeated the scale up/down statement 20 times so if gives exact value for x,b<2^20, if you repeat that 64 times sully it will give exact result for b,x<64

supple flicker
#

no way

#

solved?

#

hmm

#

this still feels too complicated

#

is there like a polynomial expression for this?

#

nvm

supple flicker
#

@wise oar r u still on? sorry for ping

#

look att his code that I made

wise oar
#

Yes

supple flicker
#

1 function for calculating the logarithm of a whole number using binary division which is somewhat easy

#

and then the other function for calculating the logarithm once the remainder is calculated (between 0 -> 1)

#

this means that if I'm trying to calculate log(4, 16.5), the 1st function will be performed which undergoes binary division to calculate the "16" part

#

then the second function will be performed which will calculate the "0.5" part of the 16, and then itll add both together

#

the issue is, the way im approximating the 2nd function is really really bad, like sometimes itll get the tenths place correctly, but other times it wont at all

#

my question is is there a polynomial approximation that calculates the decimal portion of a logarithm once the whole number is calculated?

#

😭

wise oar
supple flicker
#

so can u help

supple flicker
wise oar
#

I am trying but not getting something

supple flicker
#

npp

#

is it hard to approximate the decimal part thats why?

#

i was looking into pade approximations i didnt know they were a think i thought it would be possible with them

wise oar
#

@supple flicker i don't think there is any single polynomial expression for that but

supple flicker
#

woahhhhh

wise oar
#

It gives accurate result

#

For x,b < 2^64

supple flicker
#

i see

#

what's this symbol?

#

are you sure this can still be written arithmetically? talking about the ;

wise oar
#

Oh

#

It's just means
a=7
b=8

You can write it as
a=7 ; b=8

supple flicker
#

ohhhh

#

oh mb

wise oar
#

It's just doing what you did above

supple flicker
#

this is really good thanks man

#

i will probably use this

wise oar
#

Will it work in your minecraft?

supple flicker
#

hmm probably

#

where here is the decimal portion part?

wise oar
#

I didn't calculate integer and decimal part seperately

supple flicker
#

to be honest I'd still go with my other one with the binary division, the change of base method might be too intensive for me since I'm having to perform the ln(x) function twice, but with my binary division thing it's only once

supple flicker
#

so its all in 1 motion?

wise oar
#

Yes

supple flicker
#

what about this part?

#

I have one with binary division, and im just left with the decimal portion thing

#

theoretically if I just implement this to calculate for the remainder will it still work?

wise oar
#

Give me a minute

supple flicker
#

yes

supple flicker
# supple flicker

cuz with this one the decimal remainder part approximation is horrible

supple flicker
last glade
#

.reopen

half geyserBOT
#
Unsolved

Post marked as unsolved by @last glade.

Use .solved to mark as solved.

wise oar
#

@supple flicker

supple flicker
#

HOLY

#

broooooooooo

#

how is it so good????!!!!

#

its so, accurate wtf

#

wow i love u bro

wise oar
#

Wait

#

log(x,b) here b should be base and we should be calculating log of x but I the code i provided, for some reason it is taking x as base

#

You try log(2,4) and it gives 2

supple flicker
#

yeah thats what im doing

wise oar
#

Idk why is it like this but if you still want it log(x,b) you can just change parameters
def log(b,x)
And let everything else as it is

supple flicker
#

its the way i did it

#

i prefer small number, big number makes it easier to read

wise oar
#

Ok

#

Is this over? Everything working? Did you test if it's working for different inputs?

supple flicker
#

yes

wise oar
#

Holy

supple flicker
#

its sooo accurate

#

even with big numbers

#

i love u bruh

#

in a community im in weve been trying to crack down making a log function and u solved it after 3 years

wise oar
#

Idk even about taylor series or many things but I know python and used gpt to make it work. catking

supple flicker
#

dang

supple flicker
wise oar
#

Your last floor division thing helped it a lot

supple flicker
#

oh ye, its the way the game im compiling this code in does

wise oar
#

W bots

supple flicker
#

frrrr

#

thanks bro i owe u in the future

wise oar
#

KEK bye