Fastest way to produce huge amount of irrational numbers?

  • Thread starter Thread starter Vjay77
  • Start date Start date
V

Vjay77

I am working on the program where is necessary to calculate huge
amount of numbers in always the same sequence. In other words, these
number have to be calculated and saved into memory before the program
starts.

I was trying to use number pi, but to calculate 100 million decimal
places of number pi would take forever and no one would want to wait
that long. On the other hand I can't afford to include the whole 100
million dec. places along with the software, that would take too much
of the space and too much time to download.

Is there any other number like PI, which I could calculate faster?
No need for any specialities... just quickly generate 100 milion
numbers... only requirement is that I'll find the numbers on the same
positions no matter how often I generate them...

Just to add to it, I was already wondering about number e, where same
as in number pi, decimal digits never end, and they never repeat...
Well, e is just like Pi in this respect; if you keep going, it never
stops, and it never repeats. But is it faster to calculate e?

Did anyone ever tried to calculate it on his computer using vb.net?
Or did anyone programmed its formulae in some sort of a programming
language?

I was also thinking about using square root of 2 as another irrational
example... well

does anyone have formulaes or programs which will show how to compute
it fast in vb.net?

Thanks for your help.
 
I tried to find a square root of 2m which is good irrational
example...
But vb.net will not let me specify a number of decimal places,
So this code:


Dim result As Double = Math.Sqrt(2)
TextBox1.Text = result


will give me only this: 1.4142135623731

could someone show me how to calculate it to as many dec. places as I
specify?

Thanks a lot. I need to do this in vb.net.
 
I am working on the program where is necessary to calculate huge
amount of numbers in always the same sequence. In other words, these
number have to be calculated and saved into memory before the program
starts.

Have you considered simply using the Random class? When provided with
the same seed, it will always produce the same sequence. I haven't
benchmarked it, but I suspect performance will be better than
calculating an irrational number.
 
Random number is a good idea...
Can someone pls provide me with an algorithim that generates an random
number.
Something for vb.net? Perhaps Mersenne Twister, does anyone have a
code for it?
Thanx

vjay
 
really? can you give me some example code, please?

Assuming you want single digit numbers...

Private Const RAND_SEED as Integer = &H0F0E1231 ' Or anything
Private Const MAX_VALUE As Integer = 10 ' This assumes single digits

Public Sub GenerateSequence(ByVal ar() As Integer)
Dim r as New Random(RAND_SEED)
For i as Integer = 0 to ar.Length - 1
ar(i) = r.Next(MAX_VALUE)
Next
End Sub
 
this will always calculate the same sequence? starting with the same
digit and ending with the same?
 
this will always calculate the same sequence? starting with the same
digit and ending with the same?

Just a note, but your newsreader doesn't follow-up posts correctly, so
if you don't quote any of the message you're responding to it's just a
guess what your question refers to.

Assuming you're responding to my post about Random, the answer is yes.
If you use the same seed, the sequence will always be identical.
 
tested and it does... thanks for all your help, had to change the code
a bit, but it works now
thnx a bunch
vjay
 
Back
Top