Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

I also use Python

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

'Humanity is still kept intact. It remains within.' -Alokananda

Offline

**LeoC123****Member**- Registered: 2013-02-23
- Posts: 3

Yeah, I'm currently using Python because it is so much cleaner in style. It really just teaches you the concepts of computer science without really having to focus too much on syntax

Offline

I do not understand the program at podt #1

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

'Humanity is still kept intact. It remains within.' -Alokananda

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 84,563

Hi;

He is making use of a geometric probability to evaluate pi.

**In mathematics, you don't understand things. You just get used to them.I have the result, but I do not yet know how to get it.All physicists, and a good many quite respectable mathematicians are contemptuous about proof.**

Offline

**ShivamS****Member**- Registered: 2011-02-07
- Posts: 3,518

I do not tend to use Python at all anymore.

Offline

Hi bobbym,

I don't understand at all.

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

'Humanity is still kept intact. It remains within.' -Alokananda

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 84,563

Hi Agnishom;

You are picking random numbers in the range 0 - 1 for x and y, yes?

Do you follow so far, I can not upload a drawing so I will talk you through.

*Last edited by bobbym (2013-02-24 21:30:01)*

**In mathematics, you don't understand things. You just get used to them.I have the result, but I do not yet know how to get it.All physicists, and a good many quite respectable mathematicians are contemptuous about proof.**

Offline

Yes, two random numbers b/w 0 & 1

Then they are checking how many of them satisfy x^2 + y^2 < 1

So?

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

'Humanity is still kept intact. It remains within.' -Alokananda

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 84,563

You can pair the x's and y's to make points. They would all be inside of a 1 x 1 rectangle in the first quadrant. Do you agree?

**In mathematics, you don't understand things. You just get used to them.I have the result, but I do not yet know how to get it.All physicists, and a good many quite respectable mathematicians are contemptuous about proof.**

Offline

Ya.. All the points within a radius of 1 in the 1st quadrant

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

'Humanity is still kept intact. It remains within.' -Alokananda

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 84,563

Not yet. You are jumping ahead. If we generate x's from 0 to 1 and y's from 0 to 1 and form ordered pairs and then plot them we would get something like this:

*Last edited by bobbym (2013-02-25 00:37:05)*

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

And then we check how many of them are within a radius of 1 ?

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

'Humanity is still kept intact. It remains within.' -Alokananda

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 84,563

Yes, and form the ratio

if you throw a lot of points it will approximate π/4.

This is called "Monte Carlo Simulation" and is a very powerful technique.

*Last edited by bobbym (2013-02-25 00:57:14)*

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

Wonderful!

However that would hugely depend on the capability to generate random numbers

I think it would be a better idea to try this

```
...
for x in xrange(0.1, 1.0, 0.01):
for y in xrange(0.1, 1.0, 0.01):
.....
```

So that the points are not taken at random

*Last edited by Agnishom (2013-02-25 02:05:29)*

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

'Humanity is still kept intact. It remains within.' -Alokananda

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 84,563

Hi;

The randomness is very important. It is the whole key to the algorithm.

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

Why??? What If we try all the possible points?

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

'Humanity is still kept intact. It remains within.' -Alokananda

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 84,563

It would take too many to try them all there are an infinite number. The random generator samples the points that your scheme might miss.

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

I will see which is better .... I shall do the experiment

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

'Humanity is still kept intact. It remains within.' -Alokananda

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 84,563

It is easy to design areas that a uniform spread of points such as yours might miss.

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

I did it.

You seem to be correct........

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

'Humanity is still kept intact. It remains within.' -Alokananda

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 84,563

Hi;

That was an interesting idea though.

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,391

Hi bobbym

Is it just me or do the points in the plot in post #36 look a little denser near the line x=1/2?

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 84,563

Yes, that was when we could not upload any pictures and I had to use one from the internet. Unfortunately I chose one from a math forum. The guy who wrote the routine did a bad job and the points are not randomly placed.

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,391

Maybe they are randomly placed but with a different distribution.

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 84,563

Nah, his method of generating random numbers was not good.

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline