Hard Light Productions Forums
Off-Topic Discussion => General Discussion => Topic started by: Rampage on March 14, 2003, 07:58:17 am
-
Happy PI Day! That's right, it's March 14 today! Math and science nerds galore!
Post anything related to PI, Euler, etc. Or did I mention PIES?!?!
NOTE: I'm just bored!
-
Great, a math pr0n thread. At least CP will be happy.
-
It's the national Mothertongue day here. So **** PI.
-
Its the national End of school - Beginning of a new weekend day over here :D
-
oh yes, it's the end of school - beginning of the spring break day here. :ha:
-
* yawns * (http://pi.autopron.org/pi)
-
:lol:
Here's some c++ programs I've been working on lately... one calculates Bernoulli numbers recursively and the other makes usage of the numbers in stirling's approximation for the logarithm of the gamma function (and applies anti logarithm to get exact gamma function value).
http://denebsystem.250free.com/bernoulli.exe
http://denebsystem.250free.com/lngamma.exe
Edit: Oh ya, just now added the factorial, double factorial, and beta function in there... easy to implement. :p
-
:) Nice on styxx.
-
CP should release PI today. Yes, Procyon Insurgency. :p
-
This has to be the best thread around in a while. :D unfortunately, my campaign isn't ready yet though. :( but soon...
Styxx: That thing is really neat. :yes: It must have taken the guy quite a while to do it though...
Anyway, hmm lets see, here is some neat stuff involving pi and bernoulli numbers:
(http://www.3dap.com/hlp/hosted/procyon/misc/Image2.gif)
can anyone prove them? ;7
-
Originally posted by CP5670
(http://denebsystem.250free.com/math.gif)
:wtf: Which log base is that? :wtf:
-
eh...you know, the usual one, base e
-
Originally posted by CP5670
eh...you know, the usual one, base e
Hmm... weird... I don't get those results when I sum it...
-
probably a typo on my part then, one minute...
hmm, it seems to work fine for me if I try it numerically; how are you calculating it?
-
Originally posted by CP5670
probably a typo on my part then, one minute...
hmm, it seems to work fine for me if I try it numerically; how are you calculating it?
(java app)
sum = 0;
for (i = 1; i <= 9999999; i++)
sum += (i * Math.log(1 + 1/i) + 1/(2*i) - 1);
-
The convergence is quite slow, but with that many terms you should still get quite a few digits. The value I am getting (and an approximate value of the expression on the right) is 0.3696692992460937; what are you getting there?
-
-9999998.30685282
-
I think just plain "log" stands for logarithm base 10. You're supposed to use "ln" for natural logarithm (base e). Java ought to have a ln function - if not, use log(...)/log(e).
-
Originally posted by Goober5000
Possibly the program may be using log base 10. I think you're supposed to use ln for natural logarithm (base e). Java ought to have an ln function - if not, use log(...)/log(e).
Java's default log is base e.
-
-9999998.30685282
:wtf:
oh wait I think I know what is going on; the series is not absolutely convergent, and after some one million terms they start to oscillate between positive and negative values, so that may well be skewing the result. Try something like 50000 terms and see if that works any better.
I think just plain "log" stands for logarithm base 10. You're supposed to use "ln" for natural logarithm (base e). Java ought to have a ln function - if not, use log(...)/log(e).
:D This is one of the (many) cases of bad notations used in math. It seems that physicists and applied math guys use ln while pure math guys use log. Personally I like log much better; I mean, what the heck is ln supposed to mean when it is called a logarithm, and the e base is about the only one ever used anyway... :p :D
-
Originally posted by CP5670
:wtf:
oh wait I think I know what is going on; the series is not absolutely convergent, and after some one million terms they start to oscillate between positive and negative values, so that may well be skewing the result. Try something like 50000 terms and see if that works any better.
50000 terms: -49999.30685281944
5000 terms: -4999.30685281944
500 terms: -499.30685281944
Notice any pattern? :p
Edit: 50000 + -49999.30685281944 = ln(2) :wtf:
-
hmm there is definitely something wrong there. Mathematica seems to be giving the right answer, but if I am reading it correctly that java function looks correct as well. The only thing I can think of now is something funny with the logarithm base...
-
I did this test:
System.out.println(Math.log(2.718281828459045));
...and it returned 1.0
Another way of interpreting my loop above:
sum = 0;
i = 1;
while (i <= 9999999)
{
sum = sum + (i * Math.log(1 + 1/i) + 1/(2*i) - 1);
i = i + 1;
}
-
Originally posted by CP5670
(http://www.3dap.com/hlp/hosted/procyon/misc/Image2.gif)
Woah :eek: I understand it all.
-
A loss of "machine precision" maybe then? (e.g. where the log(1+1/k) gets very small and k gets very large) still, I doubt that would account for this much error. seems to work for me...
In[33]:= NSum[k Log[1+1/k]+1/(2k)-1,{k,1,Infinity}]
Out[33]= 0.3696692985404519
In[34]:= N[EulerGamma/2+1-1/2 Log[2Pi]]
Out[34]= 0.3696692992460937
Well, at any rate, I have a proof of the exact result. :D
-
Hmm... what programming language is that? or is that a language?
Anyway, here's a nice infinite approximation I like...
(http://denebsystem.250free.com/gamma.gif)
It makes a nice graph when I do 1/that.
(http://denebsystem.250free.com/gamgraph.gif)
;7
-
lol, PI was the answer to a bonous question on a math test i had today... its also Einsteins birthday...
-
Hmm... what programming language is that? or is that a language?
I did that with Mathematica 4.2, which is a bit similar to C++ but with some different syntax and stuff.
-
Stupid integer datatype!!!!! :mad: :mad:
I had 'i' defined as an integer in the code so when it was being divided by or whatever it would do integer division and just leave the whole part of the result and left the fractional portion off.
That's java for ya... :doubt:
C++ does the same thing! I probably wouldn't have ever realized this until looking over the code in good ole VB4. :thepimp:
-
yay.. pi... 3.1415926535897932384626... I only remember that far, bah :p
Coincidental, today I finished a good math book I was reading named Godel, Escher, Bach: The Eternal Golden Braid. It's about various things like formal systems, strange loops, AI, genetics, Godel's theorem and Godel numbers ;7
-
May I have a large container of coffee? Thank you!
3.141592653
You get two extra digits for being polite.
-
-
Originally posted by Joey_21
Stupid integer datatype!!!!! :mad: :mad:
I had 'i' defined as an integer in the code so when it was being divided by or whatever it would do integer division and just leave the whole part of the result and left the fractional portion off.
That's java for ya... :doubt:
C++ does the same thing! I probably wouldn't have ever realized this until looking over the code in good ole VB4. :thepimp:
...which is why you typecast it as a float...
-
Originally posted by Analazon
...which is why you typecast it as a float...
I suppose... I had kinda forgotten about integer division though because I don't like to make it a part of regular calculations. :)
-
Sesq: rofl :D :D
I have 41 digits of that one. :p 3.1415926535897932384626433832795028841971
I had 'i' defined as an integer in the code so when it was being divided by or whatever it would do integer division and just leave the whole part of the result and left the fractional portion off.
Ah, that would explain it. I was really puzzled about the multiplication by 10 thing; it must have been because the sum gave 1 every time after some point, and the log(2) must have come in from the first term.
Anyway, here's a nice infinite approximation I like...
(http://denebsystem.250free.com/gamma.gif)
That is actually an exact value of the gamma function if you do it forever; many books I have seen initially define the function with that product. The nice thing about this is that it is one of those products obtained with the weierstrass factor theorem, which all converge for all values of the function; that's always nice... :yes:
BTW here are the graphs of three functions closely related to the gamma function; can anyone recognize what they are? ;7
(http://www.3dap.com/hlp/hosted/procyon/misc/Image4.gif)
-
So, CP, did you intentionally name your campaign such that it would be abbreviated to pi, or was it mere deliciously fitting happenstance?
-
Actually that particular thing was just coincidence. I couldn't think of anything really good for the campaign title, so I decided to do Procyon (something) since the majority of it takes place there. I picked insurgency for the second word because just about all other synonyms for "political rebellion" were already taken by other campaigns. sorry, I'm no good with these names. :p