I heard some of you guys like maths.
Thats why i'm here with a little challenge for you today.
Here is the mathematical problem:
Assume that we have a sum called "s" that equals:
(n being every possible integer greater than zero)
Therefore, sum "s" should be an algebraic constant greater than zero.
Your challenge:
Are you able to compute the constant which sum "s" equals, precisely to 100 digits (hint: smartly rounded to 99 decimal places) only by the use of autohotkey?
If you do so, please show your code+result and how long it took to calculate.
Winner with the most efficient way gets glory, honor and 2 cookies.
Math Computing Challenge :D
Math Computing Challenge :D
"Nothing is quieter than a loaded gun." - Heinrich Heine
Re: Math Computing Challenge :D
Just tried this for fun, seemed that ahk couldn't handle the large floats, so I had to use libraries. But for some reason I got a negative result. I tried with both Avi's scientific maths library as well as Lazslo's long integer library. Both produced the same answer, although Laszlo's computed it much quicker (prob due to MCode). Also, didn't matter whether or not I used the MP_Divide func, still got the same answer, although even slower.
Code: Select all
s = -207151913161435000000000000000000000000000000000000000000000000000000000000000000000000000000.000000
Code: Select all
#include Maths.ahk ;// https://github.com/aviaryan/autohotkey-scripts/blob/master/Functions/Maths.ahk
s := 0.0
while (StrLen(s) < 100)
{
i := A_Index
s += (SM_fact(i)/((i+1)**i))
;s += SM_Divide(SM_fact(i), (i+1)**i, 99)
}
msgbox s=%s%
;Clipboard := s
return
Last edited by guest3456 on 18 Jun 2014, 02:11, edited 1 time in total.
Re: Math Computing Challenge :D
Well, you made a simple mistake. Avis Lib actually is a good choice, but think again, where large integers in the formula are going to appear and you'll notice something.
"Nothing is quieter than a loaded gun." - Heinrich Heine
Re: Math Computing Challenge :D
I am not sure though since it is difficult to tell if the nr. will still change or not.0.86980432098765432098765432098765432098765432098765432098765432098765432098765432098765432098765432097
This is my try:
Code: Select all
#include Maths.ahk ;// https://github.com/aviaryan/autohotkey-scripts/blob/master/Functions/Maths.ahk
SetBatchlines,-1
s := 0
i:= 0
while (strlen(s)<100||(substr(olds,3,97)!=substr(s,3,97))||(substr(oldolds,3,97)!=substr(s,3,97))(substr(oldoldolds,3,97)!=substr(s,3,97)))
{
i := SM_Add(i, 1)
;~ s += (SM_fact(i)/((i+1)**i))
oldoldolds:=oldolds
oldolds:=olds
olds:=s
s:=SM_Add(s, SM_Divide(SM_fact(i), SM_Pow(SM_Add(i, 1),i), 100))
}
msgbox s=%s%
Clipboard := s
return
This is the result if you use 200 iterations:
0.87985386217525853348630614507096003881987340048928990482961766912229638666121421136175444468678831036107444534186281838788136229268292783649361640007316052957179562523544381769477304709
Recommends AHK Studio
Re: Math Computing Challenge :D
Your result is slightly off of mine by approx. -0.01 but tbh i don't know why since i'm basically using the same technique as you.
But still, i'm sure yours is wrong, sorry.
But still, i'm sure yours is wrong, sorry.
"Nothing is quieter than a loaded gun." - Heinrich Heine
Re: Math Computing Challenge :D
Well i'm pretty sure that mine is too because I don't check properly if it stays the same.
my result after 200 iterations also looks differently.
my result after 200 iterations also looks differently.
Recommends AHK Studio
Re: Math Computing Challenge :D
Well, thought about checking each result for each single n?
"Nothing is quieter than a loaded gun." - Heinrich Heine
Re: Math Computing Challenge :D
Here is my code in a faster version:
Code: Select all
#include Maths.ahk ;// https://github.com/aviaryan/autohotkey-scripts/blob/master/Functions/Maths.ahk
SetBatchlines,-1
s := 0
i := 0
while (rep<20)
{
i := SM_Add(i, 1)
olds:=s
s:=SM_Add(s, SM_Divide(SM_fact(i), SM_Pow(SM_Add(i, 1),i), 300))
if (olds=s)
rep++
else
rep:=0
}
msgbox s=%s%
Clipboard := s
return
Recommends AHK Studio
Re: Math Computing Challenge :D
Do you still get the same result?
i think this one should be more precisely, bu i just realized you are missing the most important point! of course i won't simply tell you but look at the division.
i think this one should be more precisely, bu i just realized you are missing the most important point! of course i won't simply tell you but look at the division.
"Nothing is quieter than a loaded gun." - Heinrich Heine
Re: Math Computing Challenge :D
Sure, what is the result you get?
"Nothing is quieter than a loaded gun." - Heinrich Heine
Re: Math Computing Challenge :D
Btw does anyone have the image for this:
http://kubli-verlag.com/challengesum.png
http://kubli-verlag.com/challengesum.png
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Return to “Off-topic Discussion”
Who is online
Users browsing this forum: No registered users and 73 guests