#Calculating x ** 0.000001 with pure arithmetic calculations
133 messages · Page 1 of 1 (latest)
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
😠holy shit
six?!
yes
so instead of the output being 0.000001112 i want it to be like 0.00000112
or whatever
how large is x
i mean
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
like this isnt enough sadly
it needs to be so accurate
(2^32)^0.000001 = 1.00002218
you might aswell take it to be 1 really
why? just curious
cuz the log function im using is so delicate with the way the decimal places are being handled
does minecraft even support that much precision
Post marked as solved by @last glade.
Use .unsolved if this was a mistake.
Browser-based Python development environment.
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
it will give exact result for b,x<64
no way
solved?
hmm
this still feels too complicated
is there like a polynomial expression for this?
nvm
@wise oar r u still on? sorry for ping
look att his code that I made
Browser-based Python development environment.
Yes
Basically in this code I have 2 types of functions
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?
ðŸ˜

so can u help
what doe sthis mean
I am trying but not getting something
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
Browser-based Python development environment.
@supple flicker i don't think there is any single polynomial expression for that but
Check this
woahhhhh
i see
what's this symbol?
are you sure this can still be written arithmetically? talking about the ;
It's just doing what you did above
.
This in short
Will it work in your minecraft?
I didn't calculate integer and decimal part seperately
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
ohhh
so its all in 1 motion?
Yes
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?
Give me a minute
cuz with this one the decimal remainder part approximation is horrible
but this one looks super promising
.reopen
Post marked as unsolved by @last glade.
Use .solved to mark as solved.
HOLY
broooooooooo
how is it so good????!!!!
its so, accurate wtf
wow i love u bro
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
yeah thats what im doing
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
Ok
Is this over? Everything working? Did you test if it's working for different inputs?
yes
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
Idk even about taylor series or many things but I know python and used gpt to make it work. 
dang
I use grok for mine but it didnt give me this answer
Your last floor division thing helped it a lot
oh ye, its the way the game im compiling this code in does
W bots
bye
I used gpt to create this
