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

You are not logged in.

- Topics: Active | Unanswered

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,654

But they say it like this Yaaaaaaaaay geogebra!

**In mathematics, you don't understand things. You just get used to them.**

**I agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.**

Offline

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

Yes, I know. I prefer the way they would say Go geogebra.

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

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,654

Maybe the german is better, Ja Geogebra!

**In mathematics, you don't understand things. You just get used to them.**

**I agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.**

Offline

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

I love the German accent. Actually, I love all accents except the American.

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

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,654

Unless you are from the south where My geogebra becomes Ma geogebra.

**In mathematics, you don't understand things. You just get used to them.**

**I agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 3,946

Hi Bobby,

bobbym wrote:

New Problem:

A used car salesman has 8 lots with 100 cars each. He wants to repaint all his cars. Each day one of his employees picks 35 cars at random from all his cars and paints them. Then he returns them to the lots. Since they do not keep records some cars get painted more than once. After 23 days the manager would like to know how many cars have been painted. he wants to do this without going down to the lots. Can you figure it for him?

A says) 522.

B says) I do not have an answer but I know that A's answer is wrong.

C says) I got that, and it is definitely wrong.

D says) No answer yet.

E says) I got it!

I did a simulation in Excel and after just over 1 million iterations got about 514.67, which is very close to gAr's simulation result of about 514.4.

"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,654

Hi Phrontister;

**In mathematics, you don't understand things. You just get used to them.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 3,946

Hi Bobby,

"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,654

Hi;

3. Why is the output shown as a fraction instead of a decimal number?

You are working with exact arithmetic so the answer will be the exact answer. This will be very, very slow and unnecessary.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 3,946

Hi Bobby,

This will be very, very slow and unnecessary.

True, but I got nowhere trying to understand the methods used by you, gAr and stefy because I haven't a clue about those more advanced approaches. So I opted just for the simulation, first in Excel and then in M, and am pleased I got them to work (clunkiness aside).

Anyway, the long processing time was just right for me to have a nice cup of coffee (latte) from a new pod machine I bought recently from the local supermarket: <$100AU for coffee maker and milk frother.

"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,654

Hi;

He probably reduced the fraction that is why there is a smaller number on the bottom than a 1000000.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 3,946

Ah yes...obvious answer. Thanks!

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,654

I am buried right now but I will try to code a simulation for you. I will post it here. Maybe you will like it. And thanks for working on the problem!

**In mathematics, you don't understand things. You just get used to them.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 3,946

Ok, looking forward to seeing it and learning some more M...which I already did a little with the simulation as some of the coding was new to me. I'm off to bed now so I'll catch you later.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,654

Okay, you did very well with the M code. See you later.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 3,946

Good morning, Bobby.

*Last edited by phrontister (2013-04-18 11:05:31)*

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,654

Hi;

You said: "Close to the exact answer of 514.0874001..."

Isn't that an 'exact' approximation?

It is accurate to all the digits displayed. The exact answer is a big fraction.

This is what I came up with but it is not faster ( it might be slower ) than yours.

```
cars=Table[0,{800}];
numbers=Range[800];
fubar[n_]:=cars[[n]]=1;
Table[cars=0*cars;
Table[pcks=RandomSample[numbers,35];fubar/@pcks,{23}];
Count[cars,1],{10}]//Mean
```

**In mathematics, you don't understand things. You just get used to them.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 3,946

Hi Bobby,

Thanks for doing that code for me - I'll have a closer look at it tonight to try and understand it.

I ran it just now, and, as you thought, it's slower than mine. Your code for 1 million iterations ran for 2241 seconds, and mine for 1014 seconds.

My M code basically follows the path I took with Excel, but is much briefer than that of course.

I just found an error in my Excel approach to do with multiple automatic iterations, but I think that my basic idea there is sound...just HUGELY slower now.

*Last edited by phrontister (2013-04-18 18:50:39)*

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,654

Hi;

The procedural style seems to be beating the functional one here. Why that is, I do not know.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 3,946

I wondered about that too but have no answer for it.

I think we should suggest to M that he package the nuts and bolts of my procedure into a super-fast function called PhroSim to encourage sales of M in used-car yards.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,654

I will ask him the next time I see him but he is an obstinate guy.

Try this:

```
Table[
DeleteDuplicates[Table[RandomSample[Range[800],35],{23}]//Flatten]//Length,{100000}]//Mean
```

It uses many of your ideas but eliminates some of the procedural constructs.

Takes 41 seconds to do 100000 on my machine, a doggy dual core.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 3,946

Wow! Had to get the fire extinguisher out to cool down my cpu for that one! BobSim runs 4 times faster than PhroSim. But I know why...your code is only 2/3rds the length of mine.

Took 25 seconds on my old dual core, so it would put wings onto a modern cpu.

Excellent!

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,654

Your dual core would blow the doors off of mine as we used to say.

We could try to compile it to make it faster.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 3,946

I don't know how to compile, other than in LB.

I'll have to start thinking more in functional mode than in procedural, now that I've seen the benefit of it. But it's gonna be hard to convert that which is set in concrete.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,654

They say once you learn procedural it is very hard to rewire your mind. It is very difficult for me too.

**In mathematics, you don't understand things. You just get used to them.**

Offline