Monday, December 1, 2014

Picking marbels from a jar - rigorous proof

Hurray! I have returned :)


Let's start from an easy one:
The following is a well known puzzle. I have encountered it several times in my life.

(cited from:
http://www.techinterview.org/post/526363745/red-marbles-blue-marbles/)

"You have two jars, 50 red marbles, 50 blue marbles. you need to place all the marbles into the jars such that when you blindly pick one marble out of one jar, you maximize the chances that it will be red."


Solution:
The solution to this puzzle is to throw one red marble to one of the jars (say, w.l.o.g, jar A) and to throw all other marbles (49 reds and 50 blues) to the other jar (jar B). If we do so the probability to pick a red marble is:
 
\(P(picking\, a\, red\, marble)=\)
\(P(picking\, a\, red\, marble|choosing\, jar\, A)\cdot P(choosing\, jar\, A)+\)
\(P(picking\, a\, red\, marble|choosing\, jar\, B)\cdot P(choosing\, jar\, B)=\)
\(1\cdot\frac{1}{2}+\frac{49}{99}\cdot\frac{1}{2}\sim0.74\)

This solution is also well known and easy to come up with, however most of the places and web sites that solve this puzzle fail to post a convincing proof for this solution. Indeed trying to find a rigorous explanation for it might be seem a little  tedious, but it is essential -from my experience facts that seem 'obviously true' can fall apart easily with close inspection. 


Proof of Solution
The method of the proof is the following:
We start with any  ordering of the marbles in the jars (we call this ordering 'ordering 1'( and show that the probability to draw a red marble in this ordering will always be smaller or equal than the probability to draw a red marble with the ordering of the solution (we call this ordering- 'ordering 2').

We use the following notations:
(These notation are all with respect to ordering 1)
The number of blue marbles in jar A - \(\textrm{N}_{blue}^{A}\)

The number of red marbles in jar A - \(\textrm{N}_{red}^{A}\)

The number of blue marbles in jar B - \(\textrm{N}_{blue}^{B}\)

The number of red marbles in jar B - \(\textrm{N}_{red}^{B}\)

W.l.og - we assume that \(\textrm{N}_{red}^{A}\leq \textrm{N}_{red}^{B}\).
We also need to assume that \(0<\textrm{N}_{red}^{A}\). Because if one of the jar doesn't have any red marbles then the probability of getting a red marble is \(\frac{1}{2}\cdot\frac{50}{50+\textrm{N}_{blue}^{B}}\leq\frac{1}{2}\) which is smaller than the probability of our solution.

Now let us move all the blue marbles from jar A to jar B. We call this new ordering - 'ordering 3'.

Lemma 1
First I will show that :
\(\frac{\textrm{N}_{red}^{B}+\textrm{N}_{blue}^{A}}{\textrm{N}_{red}^{B}+\textrm{N}_{blue}^{B}+\textrm{N}_{blue}^{A}}\geq\frac{\textrm{N}_{red}^{B}}{\textrm{N}_{red}^{B}+\textrm{N}_{blue}^{B}}\)   (1)

Proof of Lemma 1
This inequally is valid  if and only if both the l.h.s and the r.hs.  complementaries to 1 will satisfy the opposite inequallity:

\(\frac{\textrm{N}_{blue}^{B}}{\textrm{N}_{blue}^{B}+\textrm{N}_{blue}^{B}+\textrm{N}_{blue}^{A}}\leq\frac{\textrm{N}_{blue}^{B}}{\textrm{N}_{red}^{B}+\textrm{N}_{blue}^{B}}\).

Note that the denominator of the l.h.s is greater than the denominator of the r.h.s- hence this inequality holds.



We will show that:

\(P(picking\, a\, red\, marble\, with\, ordering\, 1)\leq P(picking\, a\, red\, marble\, with\, ordering\, 3)\)
Proof:


\(P(picking\, a\, red\, marble\, with\, ordering\,1)=P_{1}=\)
\(\frac{1}{2}\cdot\frac{\textrm{N}_{red}^{A}}{\textrm{N}_{red}^{A}+\textrm{N}_{blue}^{A}}+\frac{1}{2}\cdot\frac{\textrm{N}_{red}^{B}}{\textrm{N}_{red}^{B}+\textrm{N}_{blue}^{B}}\)

\(P(picking\, a\, red\, marble\, with\, ordering\,3)=P_{3}=\) 
\(\frac{1}{2}\cdot1+\frac{1}{2}\cdot\frac{\textrm{N}_{red}^{B}}{\textrm{N}_{red}^{B}+\textrm{N}_{blue}^{B}+\textrm{N}_{blue}^{A}}\) 

We take the difference between \(P_{3}\) and \(P_{1}\) and get :
\(P_{3}-P_{1}=\)
\(\frac{1}{2}\cdot\left(1-\frac{\textrm{N}_{red}^{A}}{\textrm{N}_{red}^{A}+\textrm{N}_{blue}^{A}}\right)+\frac{1}{2}\cdot\left(\frac{\textrm{N}_{red}^{B}}{\textrm{N}_{red}^{B}+\textrm{N}_{blue}^{B}+\textrm{N}_{blue}^{A}}-\frac{\textrm{N}_{red}^{B}}{\textrm{N}_{red}^{B}+\textrm{N}_{blue}^{B}}\right)\)
\(=\frac{1}{2}\cdot\left(\frac{\textrm{N}_{red}^{A}+\textrm{N}_{blue}^{A}}{\textrm{N}_{red}^{A}+\textrm{N}_{blue}^{A}}-\frac{\textrm{N}_{red}^{A}}{\textrm{N}_{red}^{A}+\textrm{N}_{blue}^{A}}\right)+\frac{1}{2}\cdot\left(\frac{\textrm{N}_{red}^{B}}{\textrm{N}_{red}^{B}+\textrm{N}_{blue}^{B}+\textrm{N}_{blue}^{A}}-\frac{\textrm{N}_{red}^{B}}{\textrm{N}_{red}^{B}+\textrm{N}_{blue}^{B}}\right)\)
\(=\frac{1}{2}\cdot\left(\frac{\textrm{N}_{blue}^{A}}{\textrm{N}_{red}^{A}+\textrm{N}_{blue}^{A}}\right)+\frac{1}{2}\cdot\left(\frac{\textrm{N}_{red}^{B}}{\textrm{N}_{red}^{B}+\textrm{N}_{blue}^{B}+\textrm{N}_{blue}^{A}}-\frac{\textrm{N}_{red}^{B}}{\textrm{N}_{red}^{B}+\textrm{N}_{blue}^{B}}\right)\)
\(\geq\frac{1}{2}\cdot\left(\frac{\textrm{N}_{blue}^{A}}{\textrm{N}_{red}^{A}+\textrm{N}_{blue}^{A}}\right)+\frac{1}{2}\cdot\left(\frac{\textrm{N}_{red}^{B}}{\textrm{N}_{red}^{B}+\textrm{N}_{blue}^{B}+\textrm{N}_{blue}^{A}}-\frac{\textrm{N}_{red}^{B}+\textrm{N}_{blue}^{A}}{\textrm{N}_{red}^{B}+\textrm{N}_{blue}^{B}+\textrm{N}_{blue}^{A}}\right)\)
Where the last inequality holds because of Lemma 1 ( we subtract a smaller  quantity). Carring on :
\(=\frac{1}{2}\cdot\left(\frac{\textrm{N}_{blue}^{A}}{\textrm{N}_{red}^{A}+\textrm{N}_{blue}^{A}}\right)-\frac{1}{2}\cdot\left(\frac{\textrm{N}_{blue}^{A}}{\textrm{N}_{red}^{B}+\textrm{N}_{blue}^{B}+\textrm{N}_{blue}^{A}}\right)\).
Now all we need to show is that :\(\left(\frac{\textrm{N}_{blue}^{A}}{\textrm{N}_{red}^{A}+\textrm{N}_{blue}^{A}}\right)\geq\left(\frac{\textrm{N}_{blue}^{A}}{\textrm{N}_{red}^{B}+\textrm{N}_{blue}^{B}+\textrm{N}_{blue}^{A}}\right)\).
but this inequality holds since \(\textrm{N}_{blue}^{B}+\textrm{N}_{blue}^{A}\geq\textrm{N}_{blue}^{A}\), and \(\textrm{N}_{red}^{B}\geq \textrm{N}_{red}^{A}\) because of our assumption. Therefore the denominator of the l.h.s is smaller than the denominator of the r.h.s.


We have proven the 'hard part'. We are only left with the relatively easy part of proving that moving from ordering 3 to ordering 2 can only increase the odds of getting a red marble. I leave this proof for the reader.

  

 

Thursday, October 20, 2011

משולש

Universal Mind / The Doors

I was doing time
In the universal mind,
I was feeling fine.
I was turning keys,
I was setting people free,
I was doing alright.

אני חושב שאני יכול בהחלט להעיד על עצמי שאני לא מבין גדול במוזיקה. 
 אף על פי כן, היא לוותה אותי במשך חיי, יש שירים שפשוט מייצגים את התקופה.
אז פעם לפני הצבא הייתי מכור לImagine של לנון ולא יכולתי שלא להקשיב לו כל איזה חצי שעה.
זה השיר היחידי שאני זוכר את המילים שלו בעל פה (ויש לי זכרון מאוד גרוע למילים של שירים) 
בגלל שאני חושב שהקשבתי לו  (נטו בזמן אוויר) איזה שבוע  מהחיים שלי.
יש פשוט משהו מאוד מהפנט בדרך שלנון שר את ה"יואו-הו-או-הווו" לפני שהוא מתחיל הפזמון.
( בדיוק כמו שאלטון ג'ון מענטז עם הקול שלו  בסוף כל בית בשיר "goodbye yellow brick road" )


Then you came along,
With a suitcase and a song,
Turned my head around.
Now I'm so alone,
Just looking for a home
In every place I see.


קורה שבאמצע נסיעה ברכב אתה שומע איזה שיר מסקרן ואז מגיע איזה סולו או אקורד או צליל של משולש*
ובעצם אתה מוצא את עצמך מקשיב באמת למילים שלו. הוא נכנס אליך ואתה מבין שהשיר הזה הוא כבר בכרומוזומים שלך.

יש לי כבר כל כך הרבה שירים כאלה.

I'm the freedom man,
I'm the freedom man,
I'm the freedom man,
That's how lucky I am.







*  בשיר "Good old fashioned lover boy"  מסתתר צליל של משולש, ויש לי חבר שחושב שאי אפשר לעשות קאבר לשיר בלי הצליל הזה. צודק!

Sunday, October 16, 2011

מה נשמע?

במסגרת הפרוייקט האישי שלי להעלות  לאינטרנט דברים שחיפשתי במשך שנים ולא מצאתי
אני מביא לכם מאמר של מאיר שלו שפעם נגע מאוד לליבי:


 מאיר שלו- מה נשמע? 

( 8.2.2002.  המוסף לשבת)



אני משער שהקוראים כבר שמו את ליבם לתופעה הלשונית
המעניינת שמתחוללת כאן באחרונה.  פעם כשהיית שואל
מישהו "מה נשמע?" או "מה שלומך?".  היית מקבל תשובה
פשוטה ? "טוב" "רע" "בסדר" "ככה ככה".  אבל היום כל
מי שנשאל לשלומו עונה בהתחכמויות ובהתפתלויות שמעידות
על תערובת של גישה בריאה לחיים עם מנה נאה של דאגה ומבוכה.

כיוון שכך ערכתי מחקר קצר וחובבני שאלתי ודרשתי ואף
הטיתי אוזן לשיחות לא לי והרי לפניכם הלקט המעודכן של
תשובות שאנשים משיבים ל"מה נשמע?"

קבוצת התשובות הראשונה מעידה על תחושה של ניכור והפרדה מן הכלל:

 "אני בסדר, אבל המדינה בזבל"

 "אתה שואל בספציפיות או בכלליות?"

"מה נשמע אצלי או מה נשמע אצל כולנו?"
 "אישית על הכיפאק"

 "הרוב בסדר"

לכך מצטרפת עוד תשובה חדשנית : "במיקרו על הכיפאק
במאקרו על הפנים" 

( את התשובה הזאת אפשר ורצוי להפוך
בייחוד אם אתה תרנגולת בשלב ההפשרה)

הקבוצה השנייה היא של שימושים מחודשים בביטויים ישנים.

"חרא-גיל" .  תשובה זו ל"מה נשמע? " היא הכלאה של המילה "חרא"
עם המילה "כרגיל" והיתה נפוצה מאוד בשנות החמישים והשישים
אחר כך נעלמה מן השוק ובימים אלה שבה והתחדשה ( מעניין למה?)
"וואלה?"( כאן חשובה מאוד האינטונציה שעל הנייר קשה
להעבירה( אין זו ה"וואלה" של תימהון ושל סימן שאלה ולא
ה"וואלה" של "הבנתי אותך" אלא "וואלה" שנאמרת בנמיכות
מסוימת, ואפילו במונוטוניות של חוסר-ברירה. כיוון שאיני יכול
לומר "סבבה" או "אחלה" אומר "וואלה" שמשמעותה מאיכשהו
נסחבים או "זה מה יש"
 "סוף הדרך"

( ביטוי זה שבדרך כלל מביע שבחים והתפעלות
התחיל להיאמר כ"סוף הדרך" פשוטו כמשמעו )

"המצב בטטה" 
( מטאפורה וגטטיבית קצרה. ייתכן שהומצאה על ידי שונא בטטות
או כנגזרת פונטית של "המצב בתחת")


הקבוצה השלישית של תשובות ל"מה שלומך?" מציגה חדירת
נוסחים דתיים לפה החילוני. אולי הדבר קשור לצורך הדחוף
שאנו חשים בסיעתא דשמייא ?, אבל עובדה היא, שגם בועלי
טריפות ואוכלי נידות התחילו משיבים ל"מה שלומך?" במלים
כמו " ישתבח שמו"  "השם יעזור" ו"ברוך השם"  לתשובה האחרונה 
התפתחה גם וריאציה חביבה  "בְרוֹך השם".

לקבוצה הרביעית מצטרף המימד הכרונולוגי,
התשובה המקובלת "יהיה טוב" התחלפה באחרונה 
ב"היה טוב". כמו כן אומרים "נכון לרגע זה, בסדר" או
"חיים, עד הפיגוע הבא".
יש גם תשובה עם מלכודת:  "יותר טוב" השואל מגיב בתמיהה:  "ממה יותר טוב? 
ואז עונים לו:  "היום יותר טוב ממחר".

בקבוצה החמישית של התשובות ל,מה שלומך?" משתלבים
תיאורי אופן מצב ופעולה. כאן נמצאות תשובות לאומיות גאות
כמו "מכניסים להם" ו"מראים להם" ובצידן תשובות מהסוג של
"מורידים את הראש ומחכים" ( חשוב לציין שלשון הרבים של
התשובות האלה מעידה על כך שהמשיבים בניגוד לאנשי הקבוצה 
הראשונה עדיין רואים עצמם חלק מן הציבור).

הקבוצה השישית היא של אלה שמשיבים בשאלה נגדית: 

"בתור מה אתה שואל אותי?"
"מה אתה רוצה לשמוע בתור תשובה?"

ותשובה נוגעת ללב ל"מה שלומך?" :"מה זה חשוב?" או
"מה זה משנה?"

לכך מצטרפות גם כמה תשובות מתריסות:
"מה שלומי? אין לי מושג, עוד לא קראתי עיתון"

"אתה רוצה תשובה דובר-צה"ל או תשובה את האמת?"

וכן "עזוב אותי מהשמאלנים" ולחלופין:  "עזוב אותי משרון"

והקבוצה האחרונה היא של מי שיש להם גם כושר המצאה. על
השאלה "מה שלומך" הם ענו בתשובות הבאות:

 "תשאל את ההנהלה"

 "בסדר גמור, עם דגש על הגמור"

 "הכל בסדר, רק חסר קצת מלח בפצעים"

ואחד מחברי שזה שנים היה משיב על "מה שלומך" ב"תודה, רע" 

התחיל באחרונה לענות: "סביר מינוס, נא להתקשר שוב
שעה לפני הנחיתה"

את כל התשובות הנ"ל שמעתי בהיאמרן לי או לאחרים.

למותר לציין שאשמח לקבל ולפרסם עדכונים ותוספות.





בפעם הבאה במסגרת הפרוייקט: קטעים מ"המעופפים הנועזים" בעברית.



אהובתי

אהובתי לא צריכה לדעת שום דבר במתמטיקה,
רק מה הנגזרת  של .

זה עניין עקרוני

Sunday, October 9, 2011

On Terrorists and Ultrafilters

One of the coolest puzzles ever:

Three Big-Endian terrorists have plated a bomb somewhere in Lilliput's Little-Endian quarter.
The police was able to capture them however they refuse to cooperate and deliver the location of the bomb.

The police chief decided ti separate them to three cells and every day to chose one to be electroshocked.

The terrorists are not able to control when the bomb will be detonated, however it's still can be exploded by other members of the terrorist organization or by chance.

If the bomb explodes the authorities will punish the terrorists by electrifying  two of them every day.

After infinity days (this is were it gets abstract) the terrorist die and go to heaven. Each of them
is brought before God separately and is asked whether the bomb has exploded or not.

If at least two terrorists answer rightfully they all go to heaven.
otherwise: hell it is!

Before entering the jail rooms the terrorists are given some time to plan a strategy to
go to heaven, after which they don't see one another and don't communicated.
(i.e each terrorist know only what happened to him after infinite days.)

Can they devise a winning strategy?

Formal Defenition


It is a little boring to convert this problem, but it usually makes problem brighter :

We are given three binary sequences . We know that excluding finitely many n; There are two possibilities:

1.          for all n.
2.          for all n.

Is it possible to find a function   such that

A. If case 1 occurs then at least two of the numbers are 0.

B. If case 2 occurs then at least two of the numbers  are 1 ?

We want to say that if we are terrorist we "see" a sequence of zeros and one
(0 represent a day without show and 1 otherwise) and we see "a lot" of 1s then we should say that the bomb has exploded.

This function exists but how can we prove it mathematically?


To understand it we must know a basic idea from Set Theory:
 Every binary sequence is equivalent to a subset of the natural numbers:



Therefore the first thing for the prisoners to do is to convert the sequence to a subset of the natural numbers.

Theorem:

There exist a function that satisfy to following properties:

A.
B. .
C.

Those two properties remind us the properties of the measure function, but two major differences:
there is no sigma-additivity (only finite sums) and the values are only 0,1.


We can conclude from (A-C) the following  properties:


Properties:

1.

From property (A)  the fact that only 0,1 value are allowed.

2.

3.

4.

( from (1) (from (3) (De-Morgan law)

First we show  how the existence of this function helps the terrorists to go to heaven:
Lets assume that the bomb didn't explode. we can prove that at least two of the terrorist have said no. (the terrorist say no if the function value is 0 on his subset)

since only one of them was electroshock everyday it means that the subset representing
their sequences are mutually disjoint! :

therefore at least two of them must say no!.

Lets assume that the bomb had exploded, them because of property (B) we can assume that is has exploded on the first day. Pick any two of the terrorists.
Every day, at least one of them was electroshock, therefore:


at least one of them must say yes !
because we picked any two terrorists it must mean that at least two of them said yes!


Why such function exists?- Axiom of Choice FTW!

Once again, we think of the function a little differently. We think of it as a collection of subsets of the natural numbers by :

What are the properties of this subset (we can conclude it from properties of the function)

i. (this means it is close to supersets)
ii.
iii.
iv.

Definition: 
A non empty collection of subsets that not contains the empty set satisfying properties i and ii is called filterIf it satisfy property iii as well it is called ultra-filter.

Ultra-filter do exists: for example is an ultra-filter however this
ultra-filter don't satisfy property iv.

Ultra-filters that do satisfy property iv are called non-principal or free ultra-filter, their existence must be assumed or be proven with AC.


Theorem:
Let be an infinite set, then there exist an free ultra-filter on .

Proof:
Every filter is contained in a maximal filter. (Zorn's Lemma)

We show that every maximal filter is an ultrafilter: Denote our maximal filter ; Notice that contains the all set since we can add it to the filter without interfering with the filter propertyies.

Because that it not contains the empty set, we know :
Else it could be shown with property (ii) that it contains the empty set.
Now we prove property (iii); Let us assume that , then because of the maximality :   (because the r.h.s is also a filter)
since contains , . This proves is an ultra-filter.

Now we can define the filter: (it is indeed a filter because is infinite)

This filter is contained in an ultrafilter .

The ultra-filter contains no finite subset - assume is finite, this means because of property iii of the ultra-filters. but which is a contradiction.

Quite remarkable, isn't it?

Wednesday, September 28, 2011

Extending the p-adic norm to the field of real numbers


One of the most beautiful problems that I've encountered was the famous Monsky theorem that asserts that one can not tile a rectangle by an odd number of equal area triangles.


This problem is wildly discussed in the forums, yet it is highly sophisticated and requires a wide algebra knowledge.
Among thing required is the fact that one can extend the p-adic absolute from the rational field to the real field, I would like to present this extension here.
I will assume that the reader is familiar with some basic algebra materials that one ought to learn in a second year of undergraduate studies, such as:
Linear algebra,group theory , determinant map, field extension, set theory.
The p-adic norm on the rationals:
As an application of the fundamental theorem of arithmatics every rational number can be written: where .
the p-adic absolute value of is define to be:
basic facts:
1.
2. (ultrametric inequality)
Proof of (2) : assume
then

we have :
. but is an integer, so
altogether , and the proof is finished.
(because of property 1)

actually one can prove







Our goal now is to construct an new absolute value on , such that it will still have properties 1 and 2 (on the real numbers )and Will be an extension of our absolute value on the rationals for all
. .

first step: extending to finite extensions. The Norm
let us assume we have two fields where is a finite extension of .
given an element , considering as a vector space over multiplying by
is a linear transformation! so we can note it as . being a finite dimensional linear transformation
its have a well define determinant. the norm of is defined to be .

practically one can calculate this norm by considering what multiplying by does to basis elements.

Example: let us consider the quadratic extension every element can be written as . let see what happens when multiplying with the basis element
.

writing it as a matrix we have:

which means :
consider the case !

because of the multiplicative nature of the determinant it is not hard to show that :

.
also note .


now we can advance one little step towards our destination.
suppose we have where is a finite extension of , and that somehow
we managed to extend the p-adic valuation on , and we would like to further extend it to
the field , we define it to be:


it is easy to see that this absolute value is still the same if , and still have the multiplicative nature that the absolute value should have.

the hard part is to show that the new absolute value still satisfy the ultrametric inequality, but
i will not give it here, i refer you to (*)
second step: extending the norm to transcendental extension

assume where we managed to define the p-adic absolute value on and we want to extend it to , but this time and is a transcendental element over ,
what can we do?
this time it turns out that we have a lot of freedom. first pick some , it is known that
every element can be uniquely written as

.
we define
.
this is a little complicated but one can check this to be an extension of the p-adic valuation.


so far we have managed to extended the p-adic valuation a 'little further' than we had,
how can we be sure that we can do this procedure for until we reach the whole real numbers

the magic words are Zorn's lemma!

we define a partial order on the set of all p-adic absolute values that are defined on some subfield of the real numbers much similar to how we use Zorn's lemma in the Hahn-Banach Theorem


it is easy to see that every totally ordered subset have an upper bound and that we have a maximal element.



Claim: this maximal element is defined over all the real numbers.

Proof: assume not , we have and it is defined on then one can extend by adding to
an element , can be algebraic or transcendental extension
but we still know how to extend the absolute value on it! contradiction to the maximality.


(*) for further information I advise you to read Cassel's local Fields book chapter 6-7



Remark 1: There is of course lots of ways to extend the norm and the absolute value!
Remark 2: The use of the axiom of choice is seem to be very needed, for example:no one can prove the existence of nontrivial automorphisms of the complex field with out it.

Nice problem:
Try proving that you can not tile a rectangle with odd number of - right triangles
without Monsky Theorem