[Quanto ho lavorato su questa rubrica]

La prova del nove

Un sistema rapido e veloce per controllare i risultati di un'operazione

Come ho già menzionato, ho scoperto con non poca sorpresa che a scuola non insegnano piú la prova del nove, e benché la pagina Wikipedia dica già tutto quello che c'è da dire, ho deciso di inaugurare proprio con questa la mia serie sulla “scuola dimendicata”.

Nota: questo articolo fa uso di MathML, lo standard XML per le formule matematiche. Purtroppo, questo non è supportato correttamente in alcuni browser sedicenti ‘moderni’ o ‘ricchi di funzionalità’. Se le formule non hanno senso nel tuo browser, segnala il problema agli sviluppatori (del browser), o passa ad un browser che supporti questi standard.

Cos'è

Cos'è quindi la prova del nove? È un meccanismo semplice e veloce per verificare la correttezza di un'operazione. La verifica non è completa (nel senso che non coglie alcuni errori: ha falsi positivi), ma se fallisce siamo sicuri di aver commesso uno sbaglio (non ha falsi negativi).

Come funziona

La prova del nove funziona sommando tra loro le cifre di ciascun operando, eliminando i 9, fino ad ottenere due numeri ad una cifra (riduzione che rappresenteremo con il simbolo ). Se l'operazione tra questi operandi ridotti dà un risultato diverso dalla riduzione del risultato originale, abbiamo commesso un errore, altrimenti il risultato è probabilmente giusto (ma potrebbe essere comunque sbagliato).

Esempio

Abbiamo provato a calcolare 1024×768 e ci è venuto 785432.

Come prima cosa, riduciamo gli operandi ed il risultato.

Riduzione di 1024:

10241+0+2+4=1+2+4=3+4=7.

Riduzione di 768 (qui sfruttiamo il fatto che possiamo fare riduzioni parziali intermedie, trasformando il 13 in 1+3=4):

768(7+6)+8=13+84+8=123.

Riduzione di 785432 (qui sfruttiamo il fatto che nelle riduzioni parziali possiamo direttamente eliminare 0 e 9):

785432(7+8)+5+4+(3+2)=15+5+(4+5)=20+92.

(Notate come avremmo potuto anche continuare 20+9=29112, facendo però piú operazioni.)

Se moltiplichiamo i nostri operandi ridotti otteniamo 7×3=21, che ridotto ulteriormente viene 3: sappiamo quindi che abbiamo commesso un errore, perché la riduzione del risultato (2) è diversa dal risultato applicato agli operandi ridotti (3). La prova ci dice anzi qualcosa di piú: probabilmente l'errore che abbiamo commesso è una sottostima di una delle cifre, poiché 2<3. (Il risultato corretto della moltiplicazione è infatti 786432, non 785432.)

Rappresentazione

Nota: questo articolo mette alla prova il supporto per SVG. Purtroppo, alcune funzionalità non sembrano essere correttamente supportate in alcuni browser sedicenti ‘moderni’ o ‘ricchi di funzionalità’. Alcune delle immagini potrebbero quindi risultare vuote o altrimenti errare nel vostro browser. In tal caso, segnalate il problema agli sviluppatori, e/o passate ad un browser con un support migliore per questi standard.

Convenzionalmente, la prova del nove viene rappresentata in uno schemino con quattro numeri “in croce”: si traccia una croce (+), nelle caselle superiori si mettono le riduzioni degli operandi, in quella in basso a sinistra la riduzione del risultato, ed in quella in basso a destra il risultato ottenuto operando sulle riduzioni:

Sulla destra, la moltiplicazione in colonna. Al centro, le operazioni di riduzione.
A sinistra, lo schemino con la prova del nove.

Una rappresentazione grafica della prova del nove per la moltiplicazione (corretta) di 1024 per 768. Normalmente le operazioni di riduzione verrebbero fatte a mente, ma in questo caso sono rappresentate per mostrare come vengono riempite le caselle dello schema della prova del nove (a sinistra nel diagramma).

Alle quattro operazioni

La prova del nove può essere applicata ad addizione, moltiplicazione, sottrazione e divisione. Per le due operazioni inverse (sottrazione e divisione) conviene però applicarla al contrario.

Invece di verificare una sottrazione, verificate se la somma della riduzione di differenza e sottraendo vi dà la riduzione del minuendo. Ad esempio per verificare se 1024-768=256 (ridotti: 7-3=4) controllate se 256+768=1024 (ridotti: 4+3=7).

Questo è particolarmente importante per la divisione con resto. Abbiamo infatti che 2048:768=2 con resto 512, ma se facciamo l'operazione sulle riduzioni degli operandi (5:3) otteniamo 1 con resto di 2, che sembrerebbe indicare un errore1, mentre se verifichiamo che 768×2+512=2048 in forma ridotta abbiamo

3×2+8=6+8=14=5,

che corrisponde alla riduzione del dividendo 2048.

Nessuno è perfetto

Si può sbagliare anche nella prova del nove. Errare è umano, e anche sommando tanti numeri piccoli si può sbagliare. Ad esempio, mentre scrivevo il paragrafo di esempio sulla moltiplicazione avevo inizialmente sbagliato a fare la riduzione del risultato, ed ero arrivato ad una riduzione di 5: in questo caso avrei comunque osservato una discrepanza, ma sarebbe stato un caso (e mi sono accorto dell'errore perché avendo costruito io l'esempio sapevo già che la riduzione del risultato errato doveva darmi 2, avendo intenzionalmente cambiato una cifra in difetto).

Quindi in caso di discrepanza, come prima cosa ricontrollate le riduzioni! Sono piú facili da ricontrollare dell'operazione originale (soprattutto nel caso della moltiplicazione).

Ma soprattutto, ricordatevi che la prova del nove non trova tutti gli errori. Se avessimo sbagliato la nostra moltiplicazione ottenendo 768432 invece del risultato corretto 786432, non ci saremmo accorti di aver sbagliato, poiché:

7+6+8+4+3+2=7+8+6+4+3+2,

per la proprietà commutativa dell'addizione.

BONUS: la prova dell'undici

Esiste una prova simile alla prova del nove, e che non insegnavano a scuola nemmeno ai miei tempi, che è la prova dell'11.

Se vi ricordate il criterio di divisibilità per 9, questo consisteva nel sommare tutte le cifre, ripetutamente, fino ad ottenere un numero che fosse un multiplo di 9, o per il quale fosse facile verificare che non era un multiplo di 9. Il parallelo tra il criterio di divisibilità per 9 e la riduzione dei numeri nella prova del nove non è un caso, ed è legata all'aritmetica modulare, che sta alla base della prova e che non andrò qui a spiegare.

Piuttosto, se vi ricordate, esiste anche un criterio di divisibilità per 11, che consiste nell'alternare somme e differenze, partendo dalla cifra meno significativa: bene, sulla stessa falsariga si può fare una prova dell'undici.

Torniamo al nostro esempio di 1024×768. In questo caso le nostre riduzioni vanno fatte in questa maniera alternata, e bisogna ricordarsi, nel caso in cui un numero venga negativo, di prendere il suo complementare con (ovvero aggiungere) 11.

La riduzione di 1024 è 4-2+0-1=4-3=1.

La riduzione di 768 è 8-6+7=2+7=9.

Il prodotto dei numeri ridotti è 1×9=9.

La riduzione di 785432 è2:

7854322-3+4-5+8-7=14-15=-110,

dove abbiamo applicato la correzione per il numero negativo. Sapevamo già che questo risultato era sbagliato dalla prova del nove, e questo lo conferma.

La riduzione del risultato corretto 786432 è:

7864322-3+4-6+8-7=14-16=-29,

che corrisponde al prodotto dei fattori ridotti.

Infine, se controlliamo la riduzione del risultato errato 768432, che la prova del nove dava come falso positivo, abbiamo:

7684322-3+4-8+6-7=12-18=-65,

che è diverso dal prodotto dei fattori ridotti: la prova dell'undici riconosce un errore che la prova del nove non può riconoscere.

Quale prova?

Esistono errori che la prova del nove trova e la prova dell'undici non trova?

Tecnicamente è possibile: può succedere ad esempio se sbagliamo due cifre consecutive (o comunque una di posto pari ed una di posto dispari) della stessa quantità. Un esempio di risultato errato che il 9 trova e l'11 no è il seguente, costruito “ad arte”:

Prendiamo 11×171=1771 invece del corretto 1881.

Nella prova del nove abbiamo: 2×0=0 e 1771 riduce a 7, quindi sappiamo che è sbagliato.

Nella prova dell'undici, la riduzione di 11 è 0, e la riduzione di 171 è 1-7+1=-56, quindi abbiamo: 0×6=0, ma la riduzione di 1771 è 1-7+7-1=0: la prova dell'undici non trova l'errore.

Detto questo, è molto difficile che errori simili si verifichino in calcolo manuali, per cui alcuni considerano la prova del nove “superflua” avendo a disposizione la prova dell'undici, che trova piú errori “comuni” di quella del nove.

D'altra parte, è anche vero che la prova del nove è molto piú semplice (tutte somme, non bisogna alternare con il segno, non bisogna “correggere” eventuali risultati negativi, è facile eliminare i 9); e questo è il motivo per cui la prova del nove veniva insegnata a scuola, ai miei tempi fin dalle elementari, senza dovercisi preoccupare di spiegare i numeri negativi o l'aritmetica modulare.


  1. In realtà anche 5:3 funziona, se consideriamo che 5:3=2 con resto -1, essendo -1==8(mod9), ed essendo l'aritmetica modulare con modulo 9 la base matematica della prova del nove. ↩

  2. quando si usa il simbolo andrebbe sempre specificata la base del modulo per cui si sta facendo la riduzione; qui per semplicità la omettiamo, sperando che sia comunque chiaro che in questo paragrafo si parla di riduzioni modulo 11, e per questo le operazioni sono diverse da quelle dei paragrafi precedenti, in cui le riduzioni erano modulo 9, nonostante si stia usando lo stesso simbolo. ↩

Primus inter pares

Un piccolo gioco di parole linguistico-matematico

Quesito

Primus inter pares

Risposta

Il numero due

Spiegazione

Il “primo tra i pari” è il numero due poiché esso è l'unico numero primo che è anche un numero pari.

In realtà, esiste anche una seconda motivazione, che vede il numero due come il primo dei numeri pari nel senso dell'ordine, ma questo richiede di escludere lo zero dai numeri naturali, e questo non è universalmente accettata.

(Non mi interessa qui discutere se sia giusto includerlo o meno, la risposta basata sulla primalità è quella che mi ha dato l'idea, la seconda è un bonus che mi è venuto in mente dopo.)

Venti venti (e piú)

Quanti venti conosci?

Note: this article makes use of MathML, the standard XML markup for math formulas. Sadly, this is not properly supported on some allegedly ‘modern’ and ‘feature-rich’ browsers. If the formulas don't make sense in your browser, consider reporting the issue to the respective developers and/or switching to a standard-compliant browser.

Introduzione

In risposta ad un sondaggio semiserio che chiedeva quanti venti si conoscessero, ho fatto un mio sondaggio ancora meno serio su quanti “venti” si conoscessero; per limiti della piattaforma () su cui ho il mio account, il sondaggio prevedeva solo quattro possibili risposte, a cui ho poi aggiunto altri due “pezzi” del sondaggio (a risposta multipla), portando il numero di possibili risposte a dodici:

  • 14
  • 20
  • 24
  • XX
  • 10100
  • 202
  • 1T1T
  • 1000010.010001
  • 40
  • 1T0
  • 26
  • 3T

Di queste, tutte hanno ricevuto almeno una risposta, con l'eccezione di 1000010.010001 e 3T. In molti hanno “capito” il gioco, e qualcuno ha anche “svelato” il segreto (dietro opportuna copertura), ma ritengo sia opportuna una mia spiegazione.

Il gioco consisteva nello scrivere il numero venti in tanti modi diversi, e capire come fosse scritto. I modi proposti possono essere grossolanamente raccolti in quattro gruppi, che richiedono ciascuno la sua spiegazione:

  1. il primo gruppo ha come unico membro la forma: XX
  2. il secondo gruppo ha come membri: 14, 20, 24, 10100, 202, 40, 26
  3. il terzo gruppo ha come membri: 1T1T, 1T0, 3T
  4. il quarto gruppo ha come unico mebro: 1000010.010001

Andiamoli dunque a vederli in dettaglio.

Primo gruppo: i numeri romani

Immagino che per il mio pubblico italiano non avrò particolare bisogno di “spendermi” sul sistema di numerazione romano.

Brevemente, ricordo che esso è composto dai simboli

I, V, X, L, C, D, M

o piú propriamente

Ⅰ, Ⅴ, Ⅹ, Ⅼ, Ⅽ, Ⅾ, Ⅿ

se avete un font che supporta abbastanza Unicode (ed è possibile che non vediate la differenza), del valore rispettivamente di uno, cinque, dieci, cinquanta, cento, cinquecento, mille.

Gli altri numeri sono composti per “accostamento”, con fino a 3 simboli uguali consecutivi (in realtà, si trovano anche scritte con 4 simboli consecutivi uguali) i cui valori vanno sommati; un singolo simbolo di valore inferiore viene invece premesso per indicare che il valore va sottratto. Abbiamo cosí che i numeri da uno a dodici sono scritti come:

I, II, III, IV, V, VI, VII, VIII, IX, X, XI, XII

ovvero

Ⅰ, Ⅱ,Ⅲ, Ⅳ, Ⅴ, Ⅵ, Ⅶ, Ⅷ, Ⅸ, Ⅹ, Ⅺ, Ⅻ

usando Unicode (curiosità: lo Unicode ha codici per i numeri romani da uno a dodici, e poi per cinquanta, cento, cinquecento e mille, piú qualche variante, ma non per altre combinazioni, come quella per il venti).

Il numero venti, di nostro interesse, sarà quindi scritto come

XX

ovvero

ⅩⅩ

al solito (ma ora basta perdere tempo con i numerali romani Unicode perché mi pesa scriverli, e la maggior parte dei miei lettori non vedrà la differenza).

Secondo gruppo: una questione di base

Il lettore attento avrà notato che finora, parlando di numeri, ho preferito scriverne il valore in lettere. Il motivo —abbastanza ovviamente— è che affidarmi alla comune grafia “in cifre” avrebbe completamente fatto saltare il banco per questo secondo gruppo, dove il gioco è proprio il fatto che lo stesso valore può essere rappresentato con combinazioni di cifre diverse a seconda della base di numerazione.

L'idea del sistema di numerazione arabo è quello di adottare dieci simboli, che nell'era moderna sono per il mondo occidentale

0, 1, 2, 3, 4, 5, 6, 7, 8, 9

con valore crescente da zero a nove. Queste cifre possono essere combinate in sequenze come ad esempio 1234 che noi leggiamo «mille duecento trenta quattro»: il valore di una cifra in un numero dipende dalla sua posizione, ed in questo esempio abbiamo quattro unità (4 nella posizione meno significativa), tre decine (3 nella posizione successiva, da destra verso sinistra, in ordine di valore), due centinaia (ovvero decine di decine, nella posizione successiva), ed infine un migliaio (ovvero decina di centinaia, nella posizione piú significativa).

Il motivo per cui si parla di decine (e decine di decine, etc) è che il sistema di numerazione arabo è un sistema decimale, con dieci cifre, che quindi richiede uno spostamento di posizione ogni dieci.

Nello stesso modo si possono avere sistemi di numerazione in qualunque base intera maggiore di uno (esiste il sistema numerico unario ma non è posizionale, quindi non ne parliamo).

L'idea è che data una base b (con b un qualunque intero maggiore di uno) e date b cifre, una combinazione di cifre andrà letta da destra verso sinistra considerando unità, multipli della base, multipli del quadrato della base, multipli del cubo della base, e cosí via. Se la base b è non superiore a dieci, per convenzione si usano i simboli da 0 alla cifra precedente il valore della base; per basi maggiori di dieci (le piú comuni sono sedici e dodici) si usano spesso delle lettere; nell'esadecimale, ad esempio, i simboli

A, B, C, D, E, F

rappresentano le cifre con valori da dieci a quindici; per le possibili scelte adottate nel sistema dozzinale, rimando alla relativa pagina Wikipedia.

Facendo un esempio concreto, in un sistema di numerazione in base cinque, con i soliti simboli (0, 1, 2, 3, 4), il numero 1234 rappresenta quattro unità, tre cinquine, due venticinquine ed una centoventicinquina, rappresentando in numeri romani il numero:

IV + III × V + II × XXV + CXXV = CXCIV

ovvero il numero centonovantaquattro. Se indichiamo la base in pedice, come consuetudine, ma rappresentandola con i numeri romani per evitare confusione sui simboli, abbiamo quindi

1234V=194X

Il nostro “gioco del venti” sarà quello di indovinare in quale base ciascuna delle combinazioni di cifre proposte rappresenta il numero venti (due decine).

Ricordiamo che a questo gruppo appartengono le combinazioni:

14, 20, 24, 10100, 202, 40, 26

e che la seconda è ovviamente quella con cui abbiamo tutti familiarità (20 è il numero venti in base dieci).

Anche chi non ha troppa dimestichezza con il binario (sistema di numerazione in base due, che ha come unici simboli 0, 1) può facilmente sospettare che 10100 possa essere il venti in base due. La cosa può essere confermata ricordando che venti si può scomporre in sedici piú quattro, dove sedici è la quarta potenza di due, e quattro la seconda potenza: nel sistema binario, avremo quindi “una quarta potenza di due” (un 1 in quinta posizione da destra, perché la prima posizione rappresenta le unità, ovvero la potenza zero della base), ed “una seconda potenza di due” (un 1 in terza posizione da destra), ovvero proprio 10100.

Per la base di rappresentazione delle altre potremmo andare cosí a tentativi, ricordandoci che se il numero sembra piú “piccolo” la base è maggiore, e viceversa. Possiamo quindi ipotizzare che il 14 sia in una base maggiore di dieci, e tutti gli altri in una base minore.

C'è in verità un trucchetto che può tornarci utile per capire qual è la base, poiché sappiamo qual è il valore: scomporre il numero nelle sue componenti posizionali e risolvere l'equazione che pone il tutto uguale a venti.

Applichiamo per cominciare (e come esempio) la procedura al 14. Usando i numeri romani per indicare i valori senza confonderci con le basi:

14=XXI×b+IV=XXb=XX-IVb=XVI

ovvero: 14 è venti in base sedici. Analogamente:

24=XXII×b+IV=XXII×b=XX-IVb=XVIII=VIII

ovvero: 24 è venti in base otto.

Per quanto riguarda il 202, dobbiamo considerare che qui abbiamo cifre in terza posizione, che rappresentano la base al quadrato. Quindi:

202=XXII×bII+II=XXbII+I=XbII=IXb=III

ovvero: 202 è venti in base tre.

È cosí molto facile vedere che 40 è venti in base cinque (quattro volte la base dà venti, quindi la base è un quarto di venti, cioè cinque), ed infine il 26 non può che essere venti in base sette (metà di quattordici, che è venti meno sei).

Una tabella riepilogativa, ordinata per base ed aggiungendo qualche base mancante che potrebbe comunque essere interessante abbiamo quindi che:

In base Venti si scrive
II 10100
III 202
IV 110
V 40
VI 32
VII 26
VIII 24
IX 22
X 20
XI 19
XII 18
XIII 17
XIV 16
XV 15
XVI 14
XVII 13
XVIII 12
XIX 11
XX 10

Per ovvie ragioni non continuiamo con basi maggiori di venti, dove vi sarebbe una cifra dedicata specificamente a questo valore.

Una curiosità: in tutte le basi da due a venti, il numero venti può essere rappresentato con le sole cifre decimali, anche in basi maggiori di dieci. Ed interpretando il numero come se fosse un numero decimale si vede come questo scenda inizialmente molto velocemente (da 10100 a 202 è un fattore cinquanta), poi piú lentamente (un fattore circa due fino a 40), poi di un semplice otto, poi di un sei, e poi ripetutamente di un due fino a 20 (in base dieci), e poi ancora di uno per base fino al 10 in base venti.

Terzo gruppo: bilanciamoci

Per introdurre il terzo gruppo, i cui membri sono —ricordiamo—

1T1T, 1T0, 3T

bisognerebbe capire cosa rappresenta quel simbolo T.

Abbiamo osservato come per i sistemi posizionali in una data base b siano necessari b simboli. Tipicamente, questi hanno valori che vanno da zero (0) al valore immediatamente precedente la base (ad esempio, in base dieci da zero a nove, in base tre da zero a due). Tuttavia, nel caso in cui la base sia dispari, oltre allo zero abbiamo un numero pari di simboli. Cosa succede allora se invece di distribuirli tutti “dallo stesso lato” (rispetto allo zero) li distribuiamo “metà prima e metà dopo”?

Si ottiene cosí una rappresentazione in una base detta “bilanciata”, e la peculiarità è che in questo caso metà dei simboli avranno valori negativi. Cosí ad esempio nel sistema numerico ternario bilanciato avremo simboli che rappresentano i valori “da meno uno a piú uno”, nel sistema quinario bilanciato avremo simboli che rappresentano i valori “da meno due a piú due” in quello undecimale (base undici) bilanciato avremo simboli che rappresentano i valori “da meno cinque a piú cinque” e cosí via.

Il problema grosso diventa qui di tipo tipografico: come rappresentare facilmente le cifre con valore negativo? Alcune convenzioni sono di utilizzare le medesime cifre positive, ma riflesse verticalmente o ruotate “a testa in giú”, oppure con una barra sopra (integrandovi cosí il segno meno). Nel caso specifico del sistema ternario bilanciato, la convenzione piú comune è di utilizzare il simbolo T per rappresentare “meno uno”.

Come si dovrebbe quindi scrivere venti in ternario bilanciato? Ricordiamo che nel sistema ternario “normale” (non bilanciato) il numero venti si scrive 202 (due unità, piú due quadrati di tre). Ma il simbolo 2 non esiste nel ternario bilanciato: invece di avere due unità, avremo una terzina meno una unità: 1T. Allo stesso modo, non potremo avere due nove (quadrati di tre): avremo invece un cubo di tre meno un quadrato di tre: 1T00 (ventisette meno nove fa infatti diciotto). Il nostro 202 in ternario non bilanciato diventa 1T1T in ternario bilanciato: laddove il non bilanciato scompone il venti in diciotto piú due, il bilanciato lo scompone in ventisette meno nove piú tre meno uno.

Sembra strano? È ventisette meno sette, dove sette è sei piú uno, dove sei è nove meno tre:

1000-((100-10)+1)=1000-100+10-1

e nel ternario bilanciato, l'opposto si ottiene semplicemente scambiando 1 e T.

Cosa succede nelle altre basi dispari? Vediamo ad esempio in base cinque bilanciata: ricordiamo che in questo caso non possiamo avere piú di due di qualcosa. Il nostro venti dovrebbe essere quattro cinquine, ma questo non è possibile: dovremo quindi partire da una venticinquina (cinque al quadrato) e poi togliere una cinquina: possiamo ancora riciclare la T per rappresentare “meno uno”, ed il nostro venti diventa 1T0.

Ed in base sette? Stavolta non possiamo avere piú di tre di qualcosa, quindi non possiamo scomporre il venti in due volte sette piú sei: dovremo scomporlo in tre volte sette (ventuno) meno uno: 3T.

Curiosamente, in base nove bilanciata la rappresentazione rimane 22, poiché sono entrambe cifre presenti nella versione bilanciata.

La questione si fa piú spinosa nel caso della base undici: nel caso bilanciato, le cifre avranno valori “da meno cinque a piú cinque”, quindi non potremo rappresentare il venti come “undici piú nove”: dovremmo rappresentarlo come due volte undici meno due. E non esiste una convenzione grafica normale per la cifra con valore meno due. Potremmo però inventarne una sul momento, adottando la Z per rappresentare “meno due”, sicché venti diventerebbe 2Z.

L'unica vera rogna è la base tredici: in base bilanciata avremo cifre con valori da meno a piú sei, sicché il venti dovrebbe essere scritto come due volte tredici meno sei, ma che simbolo adottare per la cifra “meno sei”? Per questo motivo, nella tabella seguente ci affideremo invece alla convenzione di soprasegnare le cifre negative:

In base bilanciata Venti si scrive
III 11¯11¯
V 11¯0
VII 31¯
IX 22
XI 22¯
XIII 26¯
XV 15
XVII 13
XIX 11

(non mi è chiaro perché vengono formattati in maniera diversa i blocchi con cifre negative, ma questo non è un problema da risolvere alle 11 di sera, quindi sarà per un'altra volta).

Quarto gruppo: il mistero del punto

L'ultimo venti da studiare (per oggi) è lo stranissimo

1000010.010001

che in Italia ed altri paesi dove si predilige l'uso della virgola come separatore “decimale”, sarebbe meglio scritto come

1000010,010001

o ancor meglio come

1 000 010,010 001

per aumentarne la leggibilità.

Ma cos'è questa follia? Come può un numero intero richiedere una parte frazionaria per essere rappresentato?

Il segreto è nella “magica” sezione aurea. Vi ricordate “il medio proporzionale tra il tutto e la parte rimanente”? Dalla proporzione

1:Φ=Φ:(1-Φ)

si ottiene l'equazione

Φ2=1-Φ

che ha soluzione, espressa in base dieci:

Φ=5-12.

La sezione aurea è proprio il rapporto ϕ=1:Φ (il valore Phi è detto coniugato della sezione aurea) e vale (ancora espressa in base dieci):

ϕ=25-1=2(5+1)5-1=5+12=1+Φ.

L'aspetto particolare di ϕ è che soddisfa l'equazione

ϕ2=1+ϕ

da cui, piú in generale

ϕn+1=ϕn+ϕn-1

ovvero: la somma di due potenze consecutive di ϕ equivalgono alla potenza successiva (proprietà di normalizzazione).

Una delle tante peculiarità di ϕ è che è possibile esprimere ogni numero intero come somma di sue potenze positive e negative (ovvero potenze di ϕ e potenze di 1ϕ=Φ).

Come? Facciamo qualche esempio.

Abbiamo ovviamente ϕ0=1 (è vero per ogni numero diverso da zero, e quindi anche per ϕ).

Per le proprietà di ϕ e Φ=1ϕ abbiamo

ϕ2=1+ϕ

Φ2=1-Φ

e quindi

ϕ2+Φ2=2+ϕ-Φ

da cui

2=ϕ2-ϕ+Φ+Φ2=1+Φ+Φ2=ϕ0+ϕ-1+ϕ-2=ϕ+ϕ-2

dove l'ultima uguaglianza viene dalla proprietà di normalizzazione applicata alla potenza n=0.

Cosí procedendo possiamo continuare per i successivi numeri naturali:

3=2+1=ϕ+ϕ-2+1=ϕ1+ϕ0+ϕ-2=ϕ2+ϕ-24=22=ϕ2+2ϕϕ-2+ϕ-4=ϕ2+(ϕ+ϕ-2)ϕ-1+ϕ-4==ϕ2+1+ϕ-3+ϕ-4=ϕ2+ϕ0+ϕ-25=4+1=ϕ2+1+ϕ-2+1=ϕ2+2+ϕ-2=ϕ2+ϕ+ϕ-2+ϕ-2==ϕ3+2ϕ-2=ϕ3+(ϕ+ϕ-2)ϕ-2=ϕ3+ϕ-1+ϕ-4

e cosí via.

Questa particolarissima proprietà della sezione aurea permette di definire quella che si chiama la base aurea, un sistema di numerazione posizionale in cui la base è ϕ e i simboli ammessi sono solo 0 (come coefficiente delle potenze della base che mancano nella rappresentazione) e 1 (dove invece la base è presente), con il separatore decimale a separare le potenze positive da quelle negative.

Dall'espansione in somme di potenze di ϕ dei primi cinque numeri abbiamo quindi la loro rappresentazione aurea (permettetemi qui di usare il punto come separatore decimale, e la virgola come separatore della successione):

1, 10.01, 100.01, 101.01, 1000.1001

Abbiamo ora tutti gli elementi per calcolarci la rappresentazione aurea del venti. Abbiamo infatti:

20=45=(ϕ2+ϕ0+ϕ-2)(ϕ3+ϕ-1+ϕ-4)==ϕ5+ϕ+ϕ-2+ϕ3+ϕ-1+ϕ-4+ϕ+ϕ-3+ϕ-6==ϕ5+ϕ3+2ϕ+ϕ-1+ϕ-2+ϕ-3+ϕ-4+ϕ-6==ϕ5+ϕ3+2ϕ+ϕ0+ϕ-2+ϕ-6==ϕ5+ϕ3+ϕ2+ϕ-1+ϕ0+ϕ-2+ϕ-6==ϕ5+ϕ4+ϕ+ϕ-2+ϕ-6==ϕ6+ϕ+ϕ-2+ϕ-6

da cui la rappresentazione aurea 1000010.010001 con la sua affascinante quasi simmetria.

(Non) finisce qui

Ovviamente quelli presentati qui sono solo una misera frazione di tutte le rappresentazioni possibili per il numero venti. Esistono dopo tutto una miriade di sistemi di numerazioni e di simbologie per la rappresentazione delle cifre (anche già solo i famosi numeri arabi hanno una controparte “orientale” le cui cifre, pur avendo lo stesso valore, hanno una diversa veste grafica (٠١٢٣٤٥٦٧٨٩). A questi possiamo aggiungere i sistemi di numerazione passati e presenti di ogni parte del globo, dal greco antico all'ebraico, dal glagolitico al cinese, dal cistercense al giapponese.

Ma s'è fatta una certa, e qui si rischia di non finire piú.

Mentally multiply by π

Quirks about π that make it easy to build successive approximation

Note: this article makes use of MathML, the standard XML markup for math formulas. Sadly, this is not properly supported on some allegedly ‘modern’ and ‘feature-rich’ browsers. If the formulas don't make sense in your browser, consider reporting the issue to the respective developers and/or switching to a standard-compliant browser.

I recently came across this interesting article (blog post?) from the Fediverse showing a nifty trick to compute multiples of π by relying on only two products: by 3, and by 14. I encourage you to read the article if you're interested in the method because it's crystal clear, whereas I'm going to muddy the waters a bit, throwing my considerations at it.

The reason why the proposed idea works is that the first digits of the fractional part of the decimal expansion of π can be expressed as multiples of 14. Indeed, the fractional part of π=3.14159265359...

0.141592 14 14 14 7 -21

This effectively means that

π=3.14159265359...=3+1410-2+1410-4+1410-5+...

and thus

kπ=3k+14k(10-2+10-4+10-5+...)

which is interesting because 10-x means “shifting your results right by x digits”, which is particularly nice if k is an integer up to 7, and thus 7k has two digits, and the first two terms in the expansion are shifted by two and four digits (no need to take any actual summation).

Let's make the example with k=7, and try to compute

7π=21.991148575...

This may seem to be an arbitrary divergence from Cook's example, but is actually needed to discuss one of the limitations of the approach: spillover. We have 3k=21, 14k=98, and thus the first terms (up to what Cook's calls the simplest approach) are:

7π21.9898

(relative error is <6.210-5 —note that this is the same found by Cook, even though he discusses the absolute error instead)

Things get a bit hairier on the first refinement, because the value of 14k now needs to be shifted by one more digit, not two. And while in Cook's example with k=4 he has 14k=56 and 560+56=616 (remove the last two digits, replace with the new three digits) in our case there's a bit of a spillover: 980+98=1078, so this refinement doesn't lend itself to a simple substitution of the last two digits:

7π21.99078

(relative error <1.710-5.)

The next refinement is a bit more involved, because (you may notice the 7 in the tableau at the top of this article) it involves halving our 14k —which, coincidentally, is always possible because 14 is even— and adding it in the same place. In our case, this means adding another 49 to the last two digits, and once again we have a small spillover (luckily into a 0):

7π=21.99127.

The relative error is now <5.610-6, more than order of magnitude better than the initial result, and —interestingly— it is now an overestimation.

Alternatives

If you go read the Fediverse thread, you'll notice that I raised the question of the comparison with approximations compute from the well-known rational approximations of π, i.e.

227=3+17

and

355113=3+16113=3+17-1791

Aside from the somewhat contrived case of k=7 I'm using here an example, multiples of these fractions would be harder to compute, as observed by Bill Ricker, although the multiple of 355/113 would still be more accurate.

What is interesting is that the second refinement presented by Cook can be further refined, e.g. by replacing the last “half 14k” contribution with a “3/8th of 14k” contribution. This is less trivial to compute, unless we consider that 3/8=1/2-1/8, so we can correct Cook's refinement by subtracting the “half 14k divided by 4”, which in our case is 49/4=12.25.

Even if we truncate this to 12, the fixup gives us

7π21.99115

with a relative error that is now <6.510-8, which is now two orders of magnitude lower. (The actual correction would be 7π21.9911475 with a relative error <510-8.)

What is impressive about this particular result is that the relative error is not only of the same order as the one given by the 355/113 approximation, but actually slightly better (the relative error for 355/113 is closer to 8.510-8).

A summary

To get a good approximation of a multiple of π:

  1. multiply by 3 (call this u);
  2. multiply by 14 (call this f);
  3. add: u,
    f shifted by 2 digits,
    f shifted by 4 digits,
    f shifted by 5 digits;
  4. bonus: add
    f/2 shifted by 5 digits;
  5. extra: subtract
    f/8 shifted by 5 digits
    (note that f/8 can be computed as (f2)/4).

An alternative to the last two points, getting to the same results, would be to add f/4+f/8 (this time computing f/8 as half of f/4) shifted by 5 digits.

Let's apply to this to Cook's example for 4π:

  1. 4×3=12;
  2. 4×14=56;
  3. 12+0.56+0.0056+0.00056=12.56616;
  4. bonus: 56/2=2812.56644
    (note that Cook's post has a couple of typos in this line; absolute error is still <710-5);
  5. extra: 28/4=712.56637
    (absolute error is now <6.210-7; note that the extra division by 4 is particularly easy to do in Cook's example).

with the possibility to replace 4. and 5. with

564=14,142=712.56616+0.00014+0.00007=12.56630+0.00007=12.56637.

Note however that 12.5663 is slightly worse than 12.56644 as an approximation (error 7.110-5 rather than <710-5, in addition of being of the opposite sign.) Note also that the best approximation we've discussed so far (12.56637) is also the midpoint of these two.

Smallest doesn't mean easier to handle

I believe that one of the most important discoveries to which this trick has led me is the importance of the difference between the compactness of the (approximating) fraction and how easy it is to handle.

This isn't something entirely new to me (I've always known that in computing there are several series that help find out new digits of π faster), but what I learned this time is how this maps to “human computing”.

If we write the full mathematical expression of the π approximant that leads to the algorithm we just described we have:

π3+14100(1+1100+11000(1+12(1-14)))  ()

which is considerably more complex than the expressions we have from the continued fraction expansion,

π227=3+17

or even my beloved Milü

π355113=3+16113=3+17-1791=3+17(1-1113).

Yet, except for particular cases, the divisions by 7 and 113 involved in the latter expressions are likely to be more complex than the “multiply by 14, divide by 100”, because the division by 100 in the decimal system is a simple shift by two digits.

To wit, if we have computed 1/7 for the 22/7 approximation, it would be simpler to approximate π as

2199700=3+17-1700=3+17(1-1100)

than with the 355/113 expansion, since the last term is obtained simply by shifting by two digits the already computed division by 7. Even 3+1/7-1/800 (more accurate, but still not as much as 355/113) would be faster than the full 355/113 contribution.

Sevenths

Incidentally, here's an interesting fact:

17=0.(142857)=14100+2141002+4141003+8141004+...

and if we factor 14/100 (recognize it yet?)

17=14100(1+2100+41002+81003+)=14100i=02i100i.

Now, if we compute 1/7(1-1/100) as discussed above, we get

17(1-1100)=14100(1+1100+21002+41003+)

and you may notice that the first two terms are the same as the ones in the mind trick formula (). Where they start to diverge is on the third term, which is 2/10000=1/5000 here, but (after simplifications) 11/8000 in the mind trick formula.

This divergence should not surprise, since 1/7-1/700 is actually a pretty poor approximation for π-3. If we try 1/7-1/800, the first terms are a bit more complex to compute:

17-1800=17(1-781100)=14100(1+981100+25811002+...)

but we can make it easier to compare with () by rearranging the terms as

17-1800=14100(1+1100+181100+25811002+...)

so that the third term would be:

100811002+25811002=125810000=1880=1640

(compare 125/80000 to the mind trick's 110/80000.)

Speed versus accuracy

One of the key point in determining the approach to use to find approximate values to multiples of π is to take into account the accuracy of the multiplier.

As an example, assume we want to compute the circumference of the Earth, knowing that the radius is approximately r=6500 km. We want to compute 2πr or 13000π.

One would be tempted to use the magic algorithm that has been the main topic of discussion of this article, but that would actually be a waste of brainpower in this case, since the approximation for the radius is quite large already: there's no need to compute 13000π to particularly high accuracy, and in fact in this case the 3+1/7 approximation of π is sufficient: the first part is trivial, 3×13000=39000, and the rest is

130007=140007-100072000-140

(the next term from 1/7 would be 140/100, already too precise) which gives us a circumference of some 40960 km.

The attentive reader who remembers when the meter was defined as the 40-millionth part of the circumference of the Earth, will have noticed that we're way over the expected 40000 km, which is due to the fact that the (average) Earth radius is actually less than 6400. If we want to redo these computations, this time with 12800π, we have:

3×12800=38400

and leveraging the approximation 200/728:

1280071828

giving us a circumference of 38400+1828=40228, which is still too large (and for the curious: no, using a more accurate approximation wouldn't solve the issue, dropping it only to around 40212.)

Reciprocal problem

Maybe it would be better to work things the other way: assuming we know that circumference is 40000 km, can we work out a more accurate value of the radius? This means computing 20000/π. This is actually another one of those cases where the simpler, harder to manipulate fractions are easier to use, since their reciprocal is 1/π.

In our case

20000π20000722=70000116364

(the division by 11 is easy to do in mind: 66 from 70 is 4, 33 from 40 is 7, and then it repeats). This is actually a pretty good approximation to the actual Earth radius, that is closer to 6371 km. (Note also that using actual π here would only give marginally better results with an integer part of 6366: our approximation is accurate enough.)

So this got me wondering: could we build an approximant to 1π that is as easy to handle as () and the corresponding algorithm? From a quick look, the answer seems to be … “ish”. We have

1π=0.318309886...

so from a cursory look the best candidate to replace the 14/100 in () is 318/1000, and our shifts will be of three rather than two digits:

1π3181000(1+11000(1-3100))

which is considerably less manageable than (), especially after the second term, because of the three-digit numbers, although it does give us pretty low relative errors right from the start, approximately 9.7410-4,2.5510-5,4.4810-6 at the first, second and third term.

A more manageable candidate may seem like 32/100, since

1π32100(1-121100-311002+21011002)

with relative errors of approximately 5.410-3,2.810-4,1.810-5,1.610-6 respectively for the first, second, third term, and fourth term. The big nuisance of this building block is that it seems to be built primarily around subtraction rather than addition, something which is harder to manage mentally compared to the “add by shift” of ().

To compare let's try to compute the same 20000/π with the two approximations.

We have 2318=636, so the first two terms of using the 318/1000

20000π=100002π100000.636636=6366.36

(compare with actual result 6366.19772... to show the excellent result of this approximation.)

For 32/100, we have 232=64 and 3×64=252, but:

20000π=100002π10000(0.64-0.0032-0.000252+0.0000128)

that is:

20000π=10000(0.64-0.003452+0.0000128)

and finally:

20000π=6400-34.52+0.128=6365.48+0.128=6365.608

Ultimately, the fact that the expressions in this case are uglier and less manageable may just be the sign that computing the reciprocal of π is an inverse problem. Or that I suck at these kind of things, especially at this hour.

The A4 paper puzzle

Note: this article makes use of MathML, the standard XML markup for math formulas. Sadly, this is not properly supported on some allegedly ‘modern’ and ‘feature-rich’ browsers. If the formulas don't make sense in your browser, consider reporting the issue to the respective developers and/or switching to a standard-compliant browser.

Introduction

I first heard about this problem from the Stand-up Maths video on the topic and I found it utterly fascinating. I'm going to present here the problem, the solution, and finally discuss a more general version.

The problem

The problem is quite simple. Find the length of the perimeter of the following plane figure:

A kite-shaped figure where the side corners are marked as being right angles
The shape for which we want to find the perimeter

The shape is obtained by folding an A4 piece of paper (whose sides have lengths in a ratio of 1:2) two times: on one corner until the short side reaches the adjacent long side, and then again on the corner of the leftover rectangle, until the leftover on the long side touches the folded short side. Check Matt's video if you're confused, or consider the following picture: from the initial rectangle, fold diagonally to bring U to H and then V to K:

Same shape as above, but with auxiliary lines showing how it can be obtained from a rectangle with 1:√2
How to obtain the shape from an A4 sheet of paper, with reference points for clarity in the solution

The solution

The solution to the problem is quite straightforward: we simply need to add up the lengths of the segments composing the perimeter of our figure.

We'll take as reference for the length the short side of the sheet of A4 paper, so the bottom segment AD, which is the long side of the sheet, has length AD¯=2.

The long diagonal segment AB is the diagonal of a square AUBH, whose side is the short side of the sheet: the side has length AU¯=UB¯=BH¯=AH¯=1, and therefore the diagonal length is AB¯=12=2.

The short diagonal BC was obtained folding the V angle of the leftover rectangle HBVD, so let's focus for a moment on this rectangle. The long side of HBVD is the short side of the original A4 paper sheet, and is thus of length BH¯=VD¯=1; the length of the short side of this rectangle, on the other hand, is equal to the difference in length between the long and short sides of the A4 paper sheet, and is thus BV¯=HD¯=AD¯-AH¯=2-1.

By folding the corner of this rectangle, the resulting side is the diagonal of the BVCK square, whose side is the short side of HBVD, and its length is thus

BC¯=(2-1)2=2-2.

The last segment CD is the long side of the rectangle KCDH, which is the “leftover of the leftover” after the second fold: its length is thus the difference between the long and short sides of the leftover rectangle HBVD:

CD¯=VD¯-VC¯=VD¯-BV¯=1-(2-1)=2-2.

(Notice how, curiously, this last segment is equal in length to the previous, diagonal segment! We have $\bar{BC} = \bar{CD}, which will come in handy next.)

We now have the lengths of all the segments:

The kite shape, with the side lengths written in
Side lengths of our figure

and the length of our perimeter can then be computed as:

AB¯+BC¯+CD¯+AD¯=2+2+(2-2)+(2-2)=2+2=4.

Generalization

The beauty of the problem obviously comes from the fact that the cancelling square roots give us a nice and clean integer despite the original piece of paper having an irrational aspect ratio, thus resulting in irrational lengths for all sides. But what happens if we don't start from an A4 (or more in general, from an A-series) sheet? What if the original rectangle has a different aspect ratio?

So let's assume now that we're starting from a rectangle with aspect ratio 1:a with a1.

The bottom segment now has length AD¯=a.

The long diagonal segment still has length AB¯=2, since the short side of the original rectangle still has length 1.

Let's now look at the leftover rectangle. The long side still has length 1, and the other has length a-1.

We must now be careful, since the second fold gives us the behavior we have already seen for the A4 sheet only as long as the short side of the leftover rectangle is not longer than the other side, i.e. only if BV¯VD¯, i.e. if a-11, i.e. only if a2.

In this case, the second fold thus gives us a short diagonal of length

BC¯=(a-1)2,

and the remaining segment has length

BC¯=1-(a-1)=2-a.

We have lost the beautiful relationship between the last two segments, but we can still compute the final perimeter, with length

AB¯+BC¯+CD¯+AD¯=a+2+(a-1)2+2-a=2+a2.

We can thus see that the only case where we can a nice integer value for the length of the perimeter is when a2 is an integer, which can only happen when a=n2 for some integer n, but since it must be 1a2, the case n=1,a=2 is the only possible case.

In the extreme case where a=1, the second fold produces a diagonal of length 0, and we get an isosceles triangle obtained by halving the square, with length 2+2.

In the extreme case where a=2, the second fold matches the first one, and we get another isosceles triangle, this time with two sides of length 2, and the other with length 2, and thus a perimeter of length 2+22=2(1+2).

Thin stripe case

We can, in fact, also do the case a>2, i.e. the case when the original rectangle is a “thin stripe” (long side more than twice longer than short side). In this case, the second fold would stop when the (now short) right side VD of the leftover rectangle HBVD meets the base, giving us a trapezium:

The trapezium created by folding the two short sides of a long stripe
The “thin stripe” case

We still have AD¯=a, AB¯=2, and this time also CD¯=2. Finally, the short base BC is obtained subtracting from the long base the short sides of the original rectangle (due to the folds), and thus BC¯=a-2.

The perimeter of the figure is therefore

AD¯+BC¯+CD¯+AD¯=a+a-2+22=2(a-1+2).

(Note that for the extreme case a=2 we obtain again 2(1+2).)

If we want the perimeter of the new figure to be an integer n, we need first of all that a+2-1 to be rational, and thus a=q-2 for some rational q. Then n=2(a-1+2)=2(q-1), hence q=1+n2, and thus finally

a=1+n2-2.

Observe that since this was done under the hypothesis a2, from this we also get n21+2 whence n2+22, and since n must be integer, n2+3=5.

The smallest integer perimeter we can get for the “thin stripe” case is 5, achieved with a=72-2 (for the curious, this is barely more than 2, as a=2.0857864376... —and yes, it's the trapezium in the figure). Subsequent integer perimeters are obtained by incrementing a in steps of 12.

Risolvere un quizzino della domenica (5)

.mau. propone per oggi un quizzino della domenica di stampo geometrico: calcolare l'area del quadrato blu in figura, sapendo che prolungando i lati questi intersecano l'asse delle ascisse a 3, 5, 7, 13:

Un quadrato blu sul piano xy, ruotato rispetto agli assi cartesiani.
Prolungando i lati, questi toccano l'asse delle ascisse a 3, 5, 7 13.
Lo schema proposto

Per risolverlo, chiamiamo l il lato del quadrato. Se trasliamo il quadrato finché il vertice inferiore si trova al punto (5,0), ci ritroveremo con un triangolo rettangolo (rosso in figura) la cui ipotenusa è lunga 2 (dal punto (3,0) al punto (5,0)), ed il cateto maggiore è lungo l:

La figura di prima, con il quadrato traslato in modo che il vertice inferiore sia in (5, 0).
Con il quadrato spostato in (5, 0)

Effettuando invece la traslazione dall'altro lato, portando il medesimo vertice al punto (7,0), ci ritroveremo con un triangolo rettangolo (verde in figura) la cui ipotenusa è lunga 6 (dal punto (7,0) al punto (13,0)), ed il cateto minore è lungo l:

La figura di prima, con il quadrato traslato in modo che il vertice inferiore sia in (7, 0).
Con il quadrato spostato in (7, 0)

Osserviamo infine che i due triangoli in questione sono simili (essendo creati da rette rispettivamente parallele), per cui il cateto maggiore del triangolo verde è lungo 3l (essendo la sua ipotenusa lunga 3 volte l'ipotenusa del triangolo rosso, ed avendosi la medesima proporzione tra i cateti maggiori).

Il triangolo verde ha quindi lati l,3l,6, da cui segue, per il teorema di Pitagora, che l2+9l2=36 ovvero 10l2=36 e quindi l2=3610 che è l'area del quadrato.

Number substrings

Given a target integer, what's the fewest digits needed for an integer in a given base to contain all integers from 0 to the target as substring?

Here's an interesting question: given a target integer n, what's the smallest number of (significant) digits an integer must have in a given base so that it contains as substrings all integers from 0 to n?

Let's clarify with some examples, and assume for simplicity that we're working in base 10.

Obviously, for n<10, the minimum number of digits to have all numbers from 0 to n is n+1, since all numbers from 0 to n are (distinct) single-digit numbers, so, for example, for n=9 you need a 10-digit number at least (9876543210 would do, but so would 1023456789; the actual number doesn't matter, we only care about the number of digits).

With two-digit numbers, things become more interesting. For example, the same 9876543210 also has 10 as a substring, so it works for n=10 too. It doesn't work for n=11 though —and for that you can prove that you need at least an 11-digit number because you need a repeated digit (for example, 98765432110). With n=12 you want to have substrings 10,11,12, and while the 11 can share its final digit with either the 10 or the 12, it can't do both, so it will need to be something like 987654312110, a 12-digit number.

The same argument can be repeated up to n=19 (1918171615141312110), a 19-digit number, and even for n=20 you'll need to at least add a 0 after the existing 2 (19181716151413120110) since you can't share the 0 used for 0 and 10 … which is a pity, because this splits the 2 from the 1 that could be otherwise be used for n=21, so we need an extra digit (191817161514131202110). Similarly, we can't easily recycle the two 2s we have to get to n=22 (we need 20, 21 and 22), so we'll need another digit (1918171615141312022110, a 22-digit number), but then for n=23 we can't just add one digit, because we need both another 2 and another 3: n=23 needs a 24-digit number, and the same “+2” growth is needed for all numbers up to n=29, leading to the monstrous 36-digit number 191817161514131202211023242526272829.

Things then slow down again: for n=30 we just need to add a single digit, 1918171615141312022110230242526272829, and this same number works for n=31, but not for n=32 because we split the 3 from the 2 again …

How does the pattern flow then as n grows larger? On the one hand, there should be more opportunities to use digits for multiple purposes: on the other, you need more combinations.

Is there some kind of law that can describe the pattern? Are there more opportunities to find numbers with less digits if they are rebuilt from scratch for the target n, or if they are built with small changes from the previous one(s)?

UPDATE #1: a discussion thread on the Fediverse with @mau@frenfiverse.net mentions that the number of digits needed is monotonic non-decreasing. This is obvious, but just in case here's a short proof.

Let σb be the function that maps the target number n to the minimum number of digits needed in bases b. This means that if k=σb(n) then there is an integer with k (significant) digits in base b that includes as substrings all integers from 0 to n. Let's call such a number a k-digit representative of the target n in base b. (Note that as exemplified in the beginning, there may be multiple representatives.)

Now consider k1=σb(n+1). If must be k1k because by definition of σ there is an integer with k1 significant digits in base b that includes as substrings all integers from 0 to n+1, which includes all integers from 0 to n: if k1 was strictly less than k, we could use the k1-digit representative of n+1 also for n.

@mau also provides an example sequence of representatives in base 2, but I think it can be improved a little. Remember that the integers in base 2 go: 0, 1, 10, 11, 100, 101, 110, 111, 1000, … and a sequence of representatives could be: 0, 10, 10, 110, 1100, 101100 (@mau proposes 110100) 101100 (ditto), 1011100, 10111000, …

It doesn't look like OEIS has anything like this, so it might be really worth exploring this better.

The one thing that seems to emerge at least with small numbers and bases 2 and  10 is that σ(n)n. Does this hold for larger targets? Does it all in all bases? (I'm particularly curious about the latter for odd balanced bases.)

And for those that enjoy pure math the most when it doesn't seem to have any applications, I strongly doubt somebody will ever find a practical application to this, other than in the game I play with my kids to avoid car boredom.

UPDATE #2: new discussion thread on the Fediverse. @wqferr@mathstodon.xyz points out that this problem may be related to (generalized) superpermutations, especially when b=2, and @mrdk@mathstodon.xyz relates it to de Bruijn sequences. There are are still some significant differences in the rules that the representative should follow that have a significant impact on the number of digits, but we seem to be getting somewhere.

Risolvere un quizzino della domenica (4)

.mau. propone per oggi un quizzino della domenica di stampo geometrico: è piú lunga la linea blu o quella rossa nel disegno seguente?

Quattro quadrati affiancati.
Il rettangolo risultate ha il bordo superiore e quello destro
coperti da una spezzata blu.
Una spezzata rossa formata da tre segmenti obliqui attraversa il rettangolo
dal vertice in alto a sinistra a quello in basso a destra.
Lo schema proposto

La spezzata blu seguete il bordo superiore del rettangolo ed il lato destro, mentre la spezzata rossa è formata da tre segmenti uguali. Essendo il rettangolo formato da quattro quadrati, la spezzata blu ha lunghezza (4+1)l=5l dove l è il lato del quadrato. La domanda quindi è: quanto è lunga la spezzata rossa? La risposta è ovviamente 3s dove s è la lunghezza del singolo segmento.

Osserviamo che i segmenti da cui è composta la spezzata rossa sono le diagonali di altrettanti rettangoli (uguali poiché uguali sono i segmenti) la cui unione è il rettangolo originario.

La figura precedente, con aggiunte due linee trattegiate ad indicare
i confini dei sotto-rettangoli in cui la spezzata ripartisce il rettangolo complessivo.
I sotto-rettangoli della spezzata rossa

Prendiamo uno di questi sotto-rettangoli ed osserviamo che per costruzione il lato lungo è 43 di l, e per evitare di lavorare con le frazioni, poniamo l=3u.

Abbiamo quindi che la spezzata blu ha lunghezza 5l=15u, mentre un singolo segmento s della spezzata rossa è la diagonale di un rettangolo di lati 3u (lato corto) e 4u (lato lungo). Per il Teorema di Pitagora (o semplicemente ricordando che (3,4,5) è una terna pitagorica) ne segue che s ha lunghezza 5u, e quindi la spezzata rossa ha lunghezza 3×5u=15u.

Le due spezzate hanno la medesima lunghezza.

(Curiosità: siamo abituati a “tagliare in diagonale” per accorciare la strada, questo è un curioso esempio di un modo di farlo lasciando invariata la lunghezza complessiva del percorso.)

An answer to the legendary “Question six”

Some simple algebra to answer one of the hardest questions in the history of the International Mathematical Olympiad

Note: this article makes use of MathML, the standard XML markup for math formulas. Sadly, this is not properly supported on some allegedly ‘modern’ and ‘feature-rich’ browsers. If the formulas don't make sense in your browser, consider reporting the issue to the respective developers and/or switching to a standard-compliant browser.

Introduction

You can find an introduction to the legendary “Question Six” in this Numberphile video. This article is my attempt at providing a “simple” answer to the problem, sketched from the hints provided in this more detailed insights video.

To be clear this isn't my personal “best effort” at trying to solve the problem (I did give it a quick try, starting from an intuition that induction would be the key, but I didn't get very far in). I also have no idea if this is how it was solved by any of the candidates that did provide the correct answer to the problem.

No, this is just a formalization into an actual proof of the hints provided by Simon Pampena in the second video. The proof should still be easy to follow even with only a basic knowledge of algebra.

The problem

Let a and b be positive integers such that ab+1 divides a2+b2. Show that

a2+b2ab+1

is the square of an integer.

The solution

Let

f(x,y)=x2+y2xy+1.

We want to show that if a,b are positive integers and f(a,b) is an integer, then f(a,b) is a square.

Observe first that if a,b are non-negative integers, and one of them is 0, then the statement is trivially true, since f(a,0)=a2 and f(0,b)=b2.

Assume now that a0,b integers with 0<a0<b are such that f(a0,b) is an integer. We want to show that there exist a non-negative integer a1<a0 such that f(a1,a0)=f(a0,b). Note that with this proven, we can apply the result iteratively, constructing a sequence {ai} with 0ai+1<ai and such that f(ai+i,ai)=f(a0,b). Given the strictly decreasing nature of the sequence and the non-negativity of the values, the sequence will terminate in k<a0 steps, with ak=0, leading to f(a0,b)=f(0,ak-1)=ak-12, proving that f(a0,b) is the square of an integer.

Let us then prove the existence of a1. Let N=f(a0,b). By hypothesis, N is an integer and we have

a02+b2a0b+1=N

that with simple algebra can be rearranged into

b2-Na0b+a02-N=0.  ()

This implies that the quadratic equation

x2-Na0x+a02-N=0

has the solution x=b. Dividing the polynomial

x2-Na0x+a02-N

by x-b gives us1 the second root, a1=Na0-b, which again is an integer.

We need to show that a1<a0, i.e.

Na0-b<a0

or equivalently

Na0b-b2<a0b.

Note that by bringing the leftmost two terms in the right-hand side of equation () to the left-hand side and flipping the equation, we have

Na0b-b2=a02-N

but since a0<b, this implies:

Na0b-b2=a02-N<a0b-N<a0b

and thus

Na0b-b2<a0b,

quod erat demonstrandum.


  1. E.g. using Ruffini:

    1 -Na0 a02-N b b b2-Nba0 1 b-Na0 b2-Nba0+a02-N=0

    where the reminder is known to be 0 because of equation (). ↩

Risolvere un quizzino della domenica (3)

xmau propone per oggi un quizzino della domenica che consiste nel “risolvere” una semplice somma espressa utilizzando i numerali romani (I, V, X) in maniera impropria: invece di rappresentare addendi e risultato semplicemente esprimendo i numeri con il meccanismo romano, i numeri sono espressi nel sistema decimale posizionale che ci è familiare, ma ciascuna delle cifre è espressa con i numerali romani1: I per 1, II per 2, III per 3, IV per 4, V per 5, VI per 6, VII per 6, VIII per 8, IX per 9, con l'aggiunta difficoltà dell'assenza di spazi tra le cifre.

L'esposto del problema è il seguente:

IVIIIIIVIII +
IIVIIIII    =
-------------
VIIXIVI

L'assenza di spazi è proprio ciò che rende questa una “crittosomma”: è infatti impossibile, con un semplice colpo d'occhio, capire ad esempio se una sequenza come III rappresenta la cifra 3 o una delle coppie di cifre 21 e 12.

L'unica “sequenza” di cui possiamo essere sicuri è IX, giacché X rappresenta il valore 10 secondo il sistema di numerazione romano, e nel sistema posizionale da noi adottato non esiste una cifra con questo valore, per cui IX è sicuramente 9. Possiamo quindi “semplificare” la nostra crittosomma in:

IVIIIIIVIII +
IIVIIIII    =
-------------
VI9IVI

Rimangono da interpretare le due sequenze di numerali romani nella somma finale: VI, che può essere 6 o 51, e IVI che può essere interpretata in tre modi diversi: 151, 41, e 16.

Un dubbio

Un problema aperto (che speriamo non sia determinante per la soluzione) è la lettura delle cifre: le piú significative saranno scitte a destra, come vuole la convenzione che abbiamo ereditato dagli arabi, o saranno scritte a sinistra, come sembra suggerire l'allineamento?

Alla prova del 9

Per cercare di limitare le possibili interpretazioni possiamo osservare che non tutte le interpretazioni hanno la stessa congruità modulo 9. Specificamente, mentre le sequenze “additive” (simbolo di valore maggiore seguito da simboli di valori non inferiori) hanno tutte lo stesso valore modulo 9, quelle potenzialmente sottrattive (simbolo di valore inferiore seguito da simbolo di valore maggiore) possono avere due possibili interpretazioni, con valori modulo 9 che differiscono di un valore pari alla differenza tra il valore additivo e quello sottrattivo del simbolo di valore inferiore.

Nel nostro caso, le uniche coppie ambigue sono IV per cui la differenza di valore sarà 2. Come esempio, vediamo che VI alla “prova” del 9 darà sempre 6 (sia che venga letto come 6, sia che venga letto come 51), per IV abbiamo due valori diversi a seconda che IV abbia valore “additivo” (15 = 6) o “sottrattivo” (4).

Per la somma finale, alla prova del 9 abbiamo quindi due possibili valori: 4 (interpretazione additiva di IV) oppure 2 (intepretazione “sottrattiva” di IV).

Il secondo addendo ha pure un'unica sequenza IV, e quindi due interpretazioni: 3 (additiva) e 1 (sottrattiva).

Il primo degli addendi ha invece due sequenze IV , e quindi ha tre possibili valori (a seconda che le due sequenze siano entrambe additive, entrambe sottrattive, o una additiva ed una sottrattiva, indipendentemente da quale sia quale): i valori associati sono 1 (additive), 6 (sottrattive) e 8 (mista).

Alla prova del nove, le possibili combinazioni dei due addendi sono: 1+1=2, 1+3=4, 6+1=7, 6+3=8+1=0, 8+3=2. Poiché la somma è congrua 4 o 2 modulo, possiamo scartare per il primo addendo l'interpretazione sottrattiva: quindi o entrambe le sequenze del primo addendo vanno lette additivamente, oppure la lettura del primo addendo è mista, e quella del secondo è additiva (caso 8+3=2).

La cifra piú a sinistra

La cifra piú a sinistra della somma è 5 o 6, e quindi le cifre piú a sinistra dei due addendi devono arrivare almeno a 4 o 5, piú un opzionale riporto dalle due cifre successive (supponendo che la notazione metta a sinistra le cifre piú significative).

Osserviamo subito che questo non è possibile se per il primo addendo si utilizza la lettura puramente additiva: in tal caso infatti la cifra piú a sinistra del primo addendo è 1, mentre quella del secondo è al piú 2, arrivando a 3, che è insufficiente.

Ne segue che per il primo addendo si deve usare la lettura mista, con la prima sequenza IV interpretata sottrattivamente (ed a fortiori la seconda interpretata additivamente). Questo ci porta quindi nel caso 8+3=2 della prova del9, che implica un'interpretazione additiva del secondo addendo, e sottrattiva della somma: la sequenza IVI con cui termina quest'ultima può pertanto essere letta solo come 41.

Possiamo quindi ulteriorimente semplificare la nostra crittosomma in

4IIIIIVIII +
IIVIIIII   =
------------
VI941

Dei rimanenti simboli V sappiamo che vanno interpretati additivamente, e quindi o avranno valore 5 (a sé stanti) o saranno parte di sequenze per 6, 7 oppure 8.

Il lungo problema dell'1

Un terzo aiuto nel vincolare le interpretazioni ci viene dal possibile numero di cifre. Per la somma abbiamo solo due possibili interpretazioni: 6941 e 51941, di lunghezza rispettivamente 4 e 5. Nessuno dei due addendi può avere una lunghezza superiore (potrebbero avere una lunghezza inferiore se le cifre meno significative fossero a sinistra ed avessimo un riporto tra quelle piú significative, a destra).

Questo vincolo risulta particolarmente potente in congiunzione con il problema dell'1: un interessante corollario dell'uso del sistema numerico romano per la rappresentazione delle cifre è l'assenza di un modo per rappresentare lo 0: questo ci aiuta perché, non potendovi essere 0 negli addendi, l'unica cosa che può fare spuntare la cifra 1 nella somma è una coppia di cifre con riporto.

Guardando alla somma, abbiamo due possibili interpretazioni rimaste: 6941, e 51941. La seconda, in particolare, ha un 1 in seconda posizione (non sappiamo ancora se per le decine o per le migliaia), e questo non è ottenibile in alcun modo.

Supponiamo infatti che la lettura corretta della somma sia 51941. La cifra piú a sinistra del secondo addendo dovrà quindi essere 1, poiché se dovessimo leggere la sequenza iniziale II come 2, avremmo 4+2=6. (L'alternativa per arrivare a 5 come cifra piú a sinistra piú significativa richiederebbe un riporto dalle cifre precedenti, che però possono essere lette al massimo come 5+2=7, e non potremo mai avere un riporto di 4 dalle cifre ancora precedenti per arrivare ad un riporto dalle seconde.)

Saremmo quindi a

4IIIIIVIII +
11VIIIII   =
------------
51941

ma diventa a questo punto impossibile ottenere un 1 in seconda posizione, non potendo esserci uno zero nel primo addendo, o un riporto tale da lasciare un 1.

L'unica lettura possibile per la somma è quindi 6941, e questo richiede (sempre per una questione di riporti) che la cifra piú a sinistra del secondo addendo sia un 2: la nostra crittosomma è ora parzialmente risolta come

4IIIIIVIII +
2VIIIII    =
------------
6941

e possiamo affermare che tutti e tre i termini sono composti da 4 cifre: potrebbero essere 3 con un opportuno riporto dalla somma delle cifre piú significative, ma il primo addendo non può avere solo 3 cifre.

Il vincolo sulle lunghezze è particolarmente importante per l'interpretazione del secondo addendo, per il quale rimangono 6 simboli per 3 cifre, con poche letture possibili: 811; 721 o 712; 631, 622 o 613, ed infine 532 o 523.

Anche qui ci viene in aiuto la questione dell'1 (terminale, stavolta), che risolve, insieme al vincolo delle lunghezze, anche la questione dell'ordine delle cifre: l'unico modo per ottenere un 1 come cifra piú significativa sarebbe un riporto da due addenti con tre cifre, e come già detto il primo addendo non può avere solo 3 cifre.

Da questo si deducono due fatti importanti: le cifre meno significative sono a destra (quindi alla fine otterremo numeri con le cifre ordinate secondo la convenzione cui siamo abituati), e per gli addendi queste sono rispettivamente 8 e 3, le uniche letture possibili per ottenere un riporto che ci lasci indietro l'1 della somma:

4IIIII8 +
2VII3   =
---------
6941

che lascia come possibili letture per il secondo addendo solo 2613 o 2523. E poiché dobbiamo arrivare a 9 come seconda cifra da sinistra, ed abbiamo al piú 3 dal primo addendo, e nessun riporto, la cifra dopo il 2 deve essere un 6, con un 3 in sua corrispondenza sul primo addendo, che ci permette una completa risoluzione del problema:

4328 +
2613 =
------
6941

  1. non è esplicitamente enunciato nel testo, ma stiamo supponendo che si utilizzi solo la grafia che non prevede piú di 3 simboli uguali consecutivi, benché in realtà la forma additiva con quattro I sia storicamente attestata. ↩

Risolvere un quizzino della domenica (2)

xmau propone per oggi un quizzino della domenica che consiste nel trovare la singola cifra (di quelle da 1 a 9) che rimane fuori inserendo nelle caselle del seguente schema le altre otto:

Un anello di caselle collegate da operazioni ed operatori di equivalenza.
Partendo in alto a sinistra e procedendo in senso oraro: ÷ = × = = + = -
Lo schema proposto

Il quiz chiede di trovare la cifra “in piú”, e per farlo è sufficiente (ma, come vedremo, non necessario) risolvere lo schema.

Nota: questo articolo fa uso di MathML, lo standard XML per le formule matematiche. Purtroppo, questo non è supportato correttamente in alcuni browser sedicenti ‘moderni’ o ‘ricchi di funzionalità’. Se le formule non hanno senso nel tuo browser, segnala il problema agli sviluppatori (del browser), o passa ad un browser che supporti questi standard.

Cominciamo dalla riga superiore: abbiamo una divisione a:b=c in cui i tre numeri a,b,c devono essere tutti distinti tra loro e compresi tra 1 e 9. Questo ci aiuta ad escludere, come valori possibili di a, sia l'1, sia i numeri primi (2, 3, 5, 7) sia i quadrati (4, 9), ciascuna con motivazioni diverse:

  • se a=1, allora deve essere b=c=1, e quindi abbiamo ripetizioni;
  • se a è primo, dovendo essere ba dovrebbe essere b=1 (poiché a non ha altri divisori, essendo primo), e quindi c=a (ripetizione);
  • se a è un quadrato, come divisori ha solo 1,a (esclusi), o un terzo valore ba per cui a:b=b, nuovamente una ripetizione.

Gli unici valori possibili per a, ovvero per la casella in alto a sinistra dello schema, sono quindi 6 oppure 8, per cui gli unici valori possibili per le altre due caselle della prima riga sono 2, 3 oppure 4.

Osserviamo ora che la colonna di destra di fatto è analoga alla riga superiore, poiché a:b=c è equivalente a c×b=a: la casella in basso a destra vale quindi 6 oppure 8, e la casella centrale della colonna vale pure 2, 3 oppure 4.

Quindi o la casella in alto a sinistra vale 6, e quella in basso a destra vale 8, oppure è al contrario. In entrambi i casi, possiamo osservare che la casella in alto a destra deve essere il divisore comune a 6 ed 8, e quindi deve essere 2.

Usando una notazione simil-sudoku possiamo scrivere:

Soluzione parziale: 6 8 ÷ 3 4 = 2 × 3 4 = 6 8
Soluzione parziale con notazone in stile sudoku

e la presenza delle coppie 3/4 e 6/8 ci permette di escludere questi 4 valori dalle tre caselle mancanti, che possono quindi solo contenere i valori 1, 5, 7 e 9.

Soluzione del quiz

Osserviamo che già ora, senza completare lo schema, possiamo dire quale valore sarà escluso: nessuna delle tre caselle rimanenti, infatti, può avere valore 9, giacché questo renderebbe impossibili le operazioni necessarie per arrivare rispettivamente a 6 o 8.

La risposta al quiz è quindi: il 9 è la cifra mancante.

Completamento dello schema

Come per il lato superiore e quello destro, possiamo osservare che il lato sinistro e quello inferiore presentano la medesima simmetria: la sottrazione sul lato sinistro è equivalente alla somma sul lato inferiore. Ragionando analogamente a quanto visto per la divisione e la moltiplicazione, possiamo quindi dire che la casella inferiore sinistra prenderà l'addendo comune (in questo caso, 1) e le altre due caselle avranno rispettivamente 5 e 7, a seconda di dove saranno 6 ed 8.

Per completezza, possiamo quindi osservare che lo schema ha due possibili soluzioni, rivelate passando il cursore del mouse sull'immagine seguente (a sinistra e a destra per risultati diversi):

SVG interattivo con le due soluzioni complete dello schema

The product logarithm

On Lambert's W function aka the product logarithm

Note: this article makes use of MathML, the standard XML markup for math formulas. Sadly, this is not properly supported on some allegedly ‘modern’ and ‘feature-rich’ browsers. If the formulas don't make sense in your browser, consider reporting the issue to the respective developers and/or switching to a standard-compliant browser.

There is something I learned today that, as a mathematician, I should have probably learned some time ago: the name of the function that solves the equation

xex=y

where e is Napier's constant. I did know that the equation didn't have an elementary solution, but that didn't really help me solving the problem I wanted to solve, which was to find a solution to the equation:

x2ekx=c

for positive k,c (and x too, for what it's worth).

Apparently the non-elementary function we're interested in is called Lambert's W or ω function, or the product logarithm. It is the (multi-valued, in fact) function such that

x=W(y)y=xex.

The name product logarithm comes from the analogy with the (natural) logarithm

x=ln(y)y=ex

and the fact that there's an extra x multiplying the exponential on the right hand side of the equation we want to invert (solve for x).

I'm not going to discuss the properties of the function (I mean, what would the Wikipedia link above be here for, otherwise), but I will show how it can be used to solve the equation we're interested in, something that is not shown on Wikipedia and actually had me thinking for a while —mostly about the fact that I was obvioulsy missing something trivial, as it often happens in mathematics.

The general idea, to use the product logarithm in solving an equation, is to bring it in the form

f(x)ef(x)=c

which then leads to

f(x)=W(c)

and finally, assuming f is invertible, to x=f-1(W(c)). Of course, how to get to the form we want is not always obvious.

Let us take for example the equation I wanted to solve:

x2ekx=c.

Making sure k appears both as power of e and outside of it is trivial: simply multiply by k both sides. However, how to make sure we have the same power of x muliplying the exponential and as a power is not: the most obvious ideas (divide by x both sides, or multiply and divide by x the power and then try to juggle things around) don't really take you anywhere.

We'd have to be able to take the square root … wait, that might actually work!1 If we take the square root on both sides, then we get two equations (with the only difference being the sign, so we'll write it as one):

xek2x=±c.

Now we can balance the constants:

k2xek2x=±k2c

and apply the definition of W to get

k2x=W(±k2c)

and finally

x=2kW(±k2c).

As mentioned, W is a multi-valued function. However, for the specific application we derived the equation for we needed the largest positive value, meaning we need specifically the W0 branch (which is the only one that gives positive value), and since W0 is monotone increasing, we want the solution with the largest argument, that is, ultimately:

x=2kW0(k2c),

a surprisingly elegant formula —for which there is no built-in function in the C++ standard library.

(Surprisingly, making the latter discovery wasn't enough to reduce my enthusiasm and satisfaction in finding the answer and discovering the function, although it will be a problem I'll have to solve in the next few days —I'm not really looking forward to having to include the GSL or Boost libraries just for this.)


  1. this is actually more or less how it went. ↩

6cm per flag

Note: this article makes use of MathML, the standard XML markup for math formulas. Sadly, this is not properly supported on some allegedly ‘modern’ and ‘feature-rich’ browsers. If the formulas don't make sense in your browser, consider reporting the issue to the respective developers and/or switching to a standard-compliant browser.

Nation, flags and memory card games

One of the “portable” games offered by Flying Tiger is a memory card game with national flags as a theme. The game has 68 cards (34 national flags) and I like it not only because it's one of the largest memory games I've seen, if not the largest (about 50 cards or fewer being the norm, for what I can see), but also because of its educational side-effect, as each card features not only the flag, but also (in the “native” language as well as in English) the name of the nation and the name of the capital city.

After the first play, my first consideration was that Mexico was missing from the flags/nations (why Mexico? personal reasons). The next thing I noticed was that the selection of nations is essentially centered around Europe, with only a handful of extra-European nations included. This is when I realized how small the selection is: 34 nations is less than a fifth of the nations of the world, even if you consider the smallest possible set (the 190 states whose sovereignity is undisputed).

So obviously, my next thought was: how large would such a memory card game be? 190 states (at least) means 190 pairs, or 380 cards. The Flying Tiger cards are squares (with rounded corners) with a side length of 55mm, and I don't think it's reasonable to go much smaller. In fact, considering the padding between cards that is needed for practical reasons when laying them down for playing, we can assume square tiles with a 6cm side. That's 36cm², or 0.0036m² per tile. 380 such tiles would cover an area of 1.368m².

Curiously, 380 is very close 19.562, which means that if the 190 pairs were laid out in a square, they would take up a square area with a side of almost exactly 117cm, or 1.17m. Even I would have troubles reaching the cards on the opposite side of the table. Of course, you can't actually do that, because 380 is not a perfect square, so you cannot tile the cards on a square: you would have to either have to do a 19×20 rectangle (with sides of length 1.14m and 1.2m respectively), or a 20×20 square with an empty diagonal.

The issue of placing the memory cards in a pleasing pattern has always fascinated me. My daughter has a 48-cards game, which I like because the card can be laid out in a 7×7 square with a hole in the center. My son has a 32-cards game that can be laid out as a 6×6 square with missing corners.

In fact, the 68-cards game that spurred these consideration is a bit annoying because 68=8×8+4, but the 4 extra cards cannot be placed in a nice symmetric way with good alignment because the sides of the square are even, not odd. Possible placemets are the “wheel” pattern (extending each of the sides with one card), the “shifted” pattern (place each extra card on the middle of each side, spanning the gap between the two central cards of the side), or the “versus” pattern, good when playing 1v1 games, with two extra cards on each of two opposing sides.

Obviously, the next question is: how many nations would you have to include to be able to tile out the cards in a “good” pattern?

Perfect squares

this solution can be achieved with 20×20=400 cards, or 200 states (note that without holes or extra cards, the square must be even); problem is, Wikipedia lists 206 states when including the ones with disputed sovereignity; we'd have to cherry-pick some, leaving out six of them;

The hole

an odd square can be made even by taking out a central hole;

a possible solution would be 19×19-1=360, but this would require removing 10 nations from the “uncontroversial” list;

the next one would be 21×21-1=440, which would require 220 states: can we find 14 other territories to add to the 206 states currently listed by Wikipedia?

Give or take more

good patterns can be obtained by removing the 4 corners, or by having 4 extra cards —particularly with an odd square;

20×20-4=396 would require 198 states, which could be assembled from the 193 UN member states, the 2 observer states, plus more (decisions, decisions);

21×21-1-4=436 would require 218 states: we'd only need to find 12 more than the ones listed by Wikipedia.

19×19-1+4=364 would require 182 states: still too little;

As it turns out, 380 isn't even that bad: since 19×19-1+4×5=361-1+20=380, a decent tiling can be found with a 19×19 square, without the center, plus 5 cards centered on each side.

And a long stick to pick the cards on the other side of the table.

But I want more

Revision 6.0 of the Unicode standard introduced Regional Indicator Symbols and their ligatures mapping to «emoji flag sequences». Of the 26×26=676 possible combinations, only 270 are considered valid, and if we ignore the 12 «deprecated region sequences», this leaves us with 256+2=258 “current” region sequences. We could use this as the basis for our memory card game!

With 258 regions we have 258×2=516 cards. What would be a good pattern? We have 516=22×22+32=22×22+4×8 which actually lends itself to a decent layout: a 22×22 square, plus 8 cards centered on each side.

How large would such a memory game be? At 6cm per tile, the main square wold be 1.32m wide. The extra cards on each side would make it 1.44m wide, which is actually a pretty nice number1 —if unwieldy in practice. Still, if we're basing our choice on what Unicode supports, why not build such a game around computers? You'd need lots of players to make sense of it anyway.


  1. anybody familiar with TEX would recognize 1.44 as “magnification step 2”, per Knuth's recommendation of scaling sizes by a geometric progression of ratio 1.2. ↩

How far can you see?

Note: this article makes use of MathML, the standard XML markup for math formulas. Sadly, this is not properly supported on some allegedly ‘modern’ and ‘feature-rich’ browsers. If the formulas don't make sense in your browser, consider reporting the issue to the respective developers and/or switching to a standard-compliant browser.

Something that everybody (but the staunchiest believer in a Flat Earth) can agree on is that you can see farther by climbing higher. Indeed, getting to a higher place not only helps you see beyond any obstacles that might be in your line of sight, but it actually helps you see farther along the surface of the Earth even if there are no other obstacles than Earth's own curvature: it's the reason why ships have a Crow's nest.

So the obvious question is: how much farther can you see by climbing higher? And people that follow me will surely have already caught on: yes, we're trying to solve the inverse problem to how high do you have to go. In fact, we'll recycle the figure:

P and S are points on a circular arc. d is arc connecting them.
They are both connected to the circle center C by radii of length r,
at an angle α. the CP radis is extended by a segment h to another point H
such that HS is tangent to the arc on S.
The lengths and points of interest for our analysis

Again, we assume we're dealing with a spherical Earth of known radius r. This time, however, we assume h known (how far high we are), and we want to know d, the distance along the geodetic to the farthest point we can see1. Equivalently, we want to know the angle α subtending the geodetic, since by definition of radian its amplitude in radians is just dr, hence d=rα. And again, of course, we know that it will be for sure 0α<π2, i.e. 2d<πr.

In fact, from our study on the direct problem we know that the relationship between h and α can be expressed as

h=r(1cosα-1)

which we can invert rather easily; divide by r:

hr=1cosα-1

add 1 on both sides:

hr+1=1cosα

and take the reciprocals, swapping the two sides:

cosα=1hr+1.

Given our range of existence for α, we can use the inverse function of the cosine, arccos, to get the final formula for α

α=arccos(1hr+1)

and from this get

d=rα=rarccos(1hr+1).

As a quick check, for h=0 we have α=arccos1=0, while for h growing to infinity we get α=arccos0=π2, as we would expect.

Approximation?

As with the previous problem we would like to devise a formula that can be applied easily under the assumption that the angle is small. The most obvious approach would be to use the first term(s) of the Taylor expansion of the arc cosine, as it's usually done for small-angle approximations. However, Taylor series for these functions are usually developed around 0, whereas we would like to develop them around 1, since a small angle, in our case, leads to an argument of 1 for the arc cosine.

(In fact, we can see that better if we focus on the argument to the arc cosine:

1hr+1=1-(hr)+(hr)2-(hr)3+...

assuming h<r.)

From a mathematical perspective, writing a Taylor expansion of arccos around 1 is not recommended, since some assumptions needed to ensure good convergence behavior for the series cannot be guaranteed (in particular, the fact that 1 is at the boundary of the domain of the arc cosine rather than inside it is a no-no).

Worse, if we opt to disrergard the warning, we find out that we can't even do what we want, since the derivative of the arc cosine is

-11-x2

which isn't even defined for x=1.

We could try leveraging the nice relationship between the arc cosine and the arc secant:

arccos(1hr+1)=arcsec(hr+1),

but that barely helps us, since the arc secant's first derivative is

1xx2-1

for x>1 so that again, for h=0, we would have a degenerate case.

Look ma, no inverse functions!

To work around this conundrum, let's take a step back, to:

cosα=1hr+1,

and let's use the small-angle approximation for the cosine; we get

1-α22=1hr+1

or

α22=1-1hr+1=hrhr+1=hh+r

which gives us a much more approachable

α2=2hh+r

and finally, with an ugly square root,

α=2hh+r.

In fact, there's two horrible things in this formula: the division of a (potentially) very small number by a very large number, and a square root.

For the ratio, we can rewrite things with our friend q=rh under the assumption that h0 (sensible, since otherwise α=0, which isn't very interesting):

α=21+q

with q large (in fact, potentially tending to +).

As it turns out, ignoring for a moment the 2 factor, the rest has a power series expansion, in the form of a Puiseux series that can be written in an acceptable form in terms of p=1q=hr:

α=2(p-(12)p3+(38)p5-(516)p7+).

Curiously (but unsurprisingly) the first order term is what we get if we just ignore the 1 in the non-expanded formula.

More in general, we shouldn't be surprised by the need to compute p with a square root, given that in the other direction we used s=2q2. But then again, if we have to compute a square root, why even bother doing it for p when we can do it directly for α?

So, shall we just stop at

d=rα=r21+q

or can we do something more interesting?

(Aside for local manipulations, such as:

d=r2hh+r

of course.)

Another rollback

To find a better formula, let's roll back to

1-α22=1hr+1

and work on the right-hand side, which we can write as (1+hr)-1. For small h (compared to r) this has a curiously nice expansion:

1-hr+(hr)2-(hr)3+

so that our equation for α becomes:

α22=hr-(hr)2+

and truncating:

α22=hr(1-hr),

but also

α22=(hr)2(rh-1).

The nice thing about these formulas is that we can rewrite the right-hand side in terms of q, giving us

α22=1q(1-1q)=q-1q2

which comes in very handy if we don't stop at α, but actually go and compute d:

d=rα=r2(q-1)q=h2(q-1)=h2r-hh

that is interesting since it expresses the distance in terms of “the height, multiplied by something” rather than “the radius of the planet, multiplied by something”.

In fact, in this case we can even try pulling out the 2 from under the square root:

d=2hr-h2h

(well, sort of; but at least it has some symmetry to it).

A different approach

Remember that we could also express h as the exterior secant, that could be expressed in terms of the tangent function, giving us

h=rtan(α)tan(α2).

Can we try inverting this instead? Let us proceed by expressing the tangent in terms of t=tan(α2):

h=r2t1-t2t=r2t21-t2

and let's solve for t:

h(1-t2)=2rt2

(2r+h)t2=h

t2=h2r+h.

We can go for a direct solution now, with

α2=arctan(h2r+h).

The good news is that, in contrast to the situation with the arc cosine, we would need to go now for the expansion of the arc tangent for small values of the tangent, which is just its argument, giving us the following approximation:

α2=h2r+h,

or

α=2h2r+h,

If instead we wanted to use small-angle approximation for t, giving us t2=α24, we'd get

α2=4h2r+h,

or finally

α=2h2r+h.

Would you look at that, it's the same formula! That's good news, like the fact that the 2 is already out of the square root (well, at least one of them!) and when we go for d:

d=2rh2r+h

we have the same nice symmetry that we had with the previous approach —but no h outside of the square root.

Going crazy

As an alternative, we could leverage that fact that 0α<π2, so that we are in the range where

tan(α2)=tanα1+1+tan2α

which would give us

h=rtan2α1+1+tan2α

that we can manipulate to

1+1+tan2α=rtan2αh

1+tan2α=rtan2αh-1

1+tan2α=(rtan2αh-1)2

h2+h2tan2α=(rtan2α-h)2

h2+h2tan2α=r2tan4α-2hrtan2α+h2

r2tan4α-(h2+2hr)tan2α=0

And assuming α0 (which for us would only be the case if h=0) we can actually simplify this to

tan2α=h2+2hrr2.

Going for the small-angle approximation (that, as we've seen, gives us the same result regardless if we go first for the arc tangent), we finally get:

α=h2+2hrr

and for the distance that we're interested in:

d=rα=h2+2hr=h1+2rh=h1+2q,

with an amazing similarity to the h2(q-1) we had found before. (Of course, for small enough h i.e. large enough q, the extra term, be it +1 or -2, doesn't really matter, 2q prevails.)

(As someone might have noticed, this approximation is nothing more than the length of the HS segment, i.e. the distance from the observation point «as the crow flies» rather than along the geodetic1.)

TL;DR

Pick your poison (as usual, q=rh). The exact formula is:

d=rarccos(1hr+1)=rarccos(rh+r)=rarccos(q1+q).

And several possible approximations:

d=r2hh+r

d=h2(q-1)

d=2hr-h2h

d=2rh2r+h

d=h1+2q

d=h1+2rh

Oh, and do you know how you can tell that this is the inverse problem? Because the formulas are uglier.

Example

How far can a human being with their eyes 2 meters from the ground (yes, it's a tall human being) see? Let's pretend that r is 6,400 km (yes, it's a larger-than-ours planet). We have 2q=6,400,000 (how convenient, the 2 simplifies with h!), so its square root is marginally (less than 0.2) smaller than 2530 (damn, one would hope that with that nice 64 … but no, we went and had an odd number of zeroes!). We multiply that by the 2 meters of height, and it turns out that the tall man can see over 5 km in the distance, marginally less than 5,060 m. The exact solution would be 5,059.64… m —not bad, not bad at all!

Let's say you managed to climb up to the top of Mt Everest: then 2q would be something less than 1,500, and its square root around 38. If not for the weather and the mountains and everything else, you could se things nearly 340 km away —336 km and counting, which is still just as good as the exact solution, within less than a meter.

It's interesting to see what happens if we push the boundaries of these approximations: assume h equal to r, i.e. q=1. Then the exact formula gives us d=rπ3, i.e. around 1.05r. What about the rest?

Formula Result for h=r i.e. q=1 Quality
d=r2hh+r d=r Not that bad
d=2rh2r+h d=23r1.15r Could be better
d=h1+2q d=3r1.73r Losing it …
d=h2(q-1) d=0 Oh, come on!

Overall, the situation isn't even that bad: only one formula completely misses the target, and for two out of three of the others the error is relatively small (5% to 10%). Sadly, but unsurprisingly, the worst behaving approximations are the ones expressed for h rather than r: the extra benefit in their simplification comes more strongly from the “small h” assumptions, and that's why they fail the hardest.

The extra mile

A slightly different question that we might be interested in is: how much more can you see by going to higher ground? In other words, if we have two different heights h1 and h2 (say, h1<h2), and the corresponding distances d1 and d2 (for which it will still be d1<d2, since the arc cosine is nondecreasing), what would be, for example, the ratio d2d1 compared to the ratio h2h1, or the difference compared to the difference?

For the ratio, I'm not aware of a formula, but for the difference there's actually a way to express the difference of the arc cosines, giving us

d2-d1=rarccos(q1q2(1+q1)(1+q2)+(1-(q11+q1)2)(1-(q21+q2)2))

which is quite the mouthful that offers only a little bit of possibility for simplification, if it can be called that way:

d2-d1=rarccos(q1q2(1+q1)(1+q2)+1+2q1(1+q1)21+2q2(1+q2)2)

or possibly even

d2-d1=rarccos(q1q2+(1+2q1)(1+2q2)(1+q1)(1+q2)).

Of course, if we couldn't easily reason (or simplify) the analytical formula for the geodetic distance visible from a certain height, much less so we can hope to do derive any interesting information from the present formula.

A bit of insight on the other hand can be derived by looking at the derivative of d as a function of h, in particular using the expression for the arc secant.

From

d=rarcsec(hr+1)

and the arc secant derivative for positive arguments, we get

dh=1(hr+1)(hr+1)2-1

(interestingly enough, the r on the numerator cancels with the r coming from the derivative of hr+1). We can work on simplifying this

dh=r2(h+r)(h+r)2-r2

and finally

dh=r2(h+r)h2+2hr

(and we can rejoyce in the knowledge that even well-known software tools with strong analytical capbilities have issues trying to integrate that, while we know the result from the previously computed d2-d1) that tells us pretty clearly how quickly the rate of growth decreases as h increases.

We can still massage the expression to give

dh=r2(h+r)h1+2q

or even

dh=q1+qq1+2q,

which is a bit improper (we're expressing a derivative with respect to h using q), but it makes life easier for us if we want to know how small variations in height affect how far you can see.

Let's pretend for example that humans, on average have their eyes about 1.6 m from the ground; then q=4106 assuming our usual r, and the rate of change of d with respect to h is about 1,414: a centimeter of difference alters your perspective by about 14 m.

Let's linearize this too!

Of course, the expression we have for the derivative isn't that nice either. It would be better if we could approximate that one with something more manageable. And there is, in fact an expansion for the formula assuming h small (or q large):

dh=q2(1-54q+4332q2-177128q3+)

and our previous example works perfectly if we stop at the first order, since q2=21061414.

And now that we have it easy, we can see what happens around 2 m of baseline (yes, we can still use the first-order approximation for the derivative): q2=1.61061264: a centimeter of difference alters your perspective by less than 13 m.

(Notice how moving our baseline up by 40 cm has reduced the effect of fluctuations by over 1 m per cm.)


  1. we're picking the distance along the geodetic because we're looking at this issue as the inverse to the previous problem, but we could also look at this in a slightly different manner, i.e. considering the distance «as the crow flies»: this is in fact different, since we'd be talking about the HS distance instead of the PS arc.

    Curiously, the formula for the crow's flight interpretation is actually simpler, since we're looking at a leg of the right triangle with hypothenuse r+h and other leg r: the crow's flight is then (r+h)2-r2=h2+2hr=h1+2q, which is, in fact, one of the approximations we'll find for d. ↩  ↩

How high do you have to go?

Note: this article makes use of MathML, the standard XML markup for math formulas. Sadly, this is not properly supported on some allegedly ‘modern’ and ‘feature-rich’ browsers. If the formulas don't make sense in your browser, consider reporting the issue to the respective developers and/or switching to a standard-compliant browser.

You are standing on the beach of a great lake, and realize that the other side is far enough to not be visible. You'd have to get to a higher place. But how much higher?

To simplify things a little bit, let us assume that the Earth is spherical, so that the geodetic (shortest path on the surface) connecting any two points on the surface is the arc of a great circle, and let as denote the radius of this sphere by r (which is something less of 6,400 km).

Let us denote by d the distance (along the geodetic) between the place P where we are and the place S we want to see. Let h be the distance above the Earth surface our eyes have to be to be able to see S due to the curvature of the Earth.

P and S are points on a circular arc. d is arc connecting them.
They are both connected to the circle center C by radii of length r,
at an angle α. the CP radis is extended by a segment h to another point H
such that HS is tangent to the arc on S.
The lengths and points of interest for our analysis

Observe that the center of the earth C, the place S we want to see and the place H we have to be at to see it represent a right triangle with hypothenuse CH and legs CS and SH. We also have CH=CP+PH=r+h, CS=r and the arc PS=d.

By definition of radian, the angle PCS has amplitude α=dr (radians). As a side note, we remark that this whole construction only makes sense if α<π2, or 2d<πr (we will discuss this more later).

We also have that cosα=CSCH, and thus CH=CScosα, that is r+h=rcosα and finally:

h=r(1cosα-1)

or

h=r1-cosαcosα.

Approximation

To proceed further, let us assume that d is very small compared to r, so that the cosine of the angle is very close to 1. We can then make use of the small-angle approximation cosx=1-x22, which brings us to

h=rα221-α22

or

h=rα22-α2

and rememering that α=dr,

h=rd22r2-d2.

Taking advantage of the fact that rd is probably easier to compute than dr for us, we can rewrite the previous expression as

h=r2(rd)2-1.

A different formula

Let's go back to

h=r(1cosα-1)

and remember that, with t=tan(α2), we can write cosα=1-t21+t2, so:

h=r(1+t21-t2-1)

or

h=r1+t2-1+t21-t2

simplifying to

h=r2t21-t2

or still again, dividing numerator and denomitator by t2,

h=2r1t2-1

For small α we can approximate t=d2r and 1t=2rd. This gives us

h=2r4(rd)2-1=r2(rd)2-12

The only difference is that we're subtracting 12 instead of 1 at the denominator. In fact, in most cases (small d) we can completely disregard the subtracting costant.

A historical note

When computers were not as common as they are today, and time-consuming accurate computations were optimized by the use of look-up tables, several derived trigonometric functions were in common usage. The one we care about is the exterior secant (exsec for short), that represents exactly the ratio of the length we are interested in to the radius of the circle:

h=rexsecα.

The interesting thing about exsec is that you can express it in terms of the tangent simply as

exsecα=tanαtan(α2).

The first terms of the Taylor expansion around 0 for this function are:

α22+5α424+61α6720+

as usual with α=dr.

If we stop at the first term (the same we would get from our knowledge of the first-order approximation of the tangent), we get an approximation of h as

h=r2(dr)2=d22r

which, while written differently, is in fact the same expression that we've seen already, but with a null constant —as anticipated.

Knowing additional terms allows us to write higher order approximation (if we would ever need it):

h=r(12(dr)2+524(dr)4)=d22r(1+512(dr)2).

If we wanted to express this in terms of the easier-to-compute-and-square q=rd, we would get:

h=r2(1q2+512q4)=r2q2(1+562q2).

Finally, since we know the next term in the series, let's do that (and stop there, since coefficients start becoming very large afterwards): expanding α we get

h=r(12(dr)2+524(dr)4+61720(dr)6)

and expressing this in terms of q:

h=r2(1q2+512q4+61360q6)=r2q2(1+162q2(5+61152q2)).

TL;DR summary

If you want to know how high you have to go over the surface of a sphere of radius r to see a point which is at distance d along the surface of the sphere, compute q=rd and then your height can be computed as

h=r2q2.

For higher-order terms, set s=2q2. The second term then gives us

h=rs(1+56s),

and if we want to push it further

h=rs(1+16s(5+6115s)).

(The formulas are in Horner's form, which makes for quicker computation and express elegantly the “extra contribution” from each new term.)

An example

As an example, let's say that d is about 160 km, which puts rd at around 40, squared to 1,600, doubled to 3,200. Disregarding the subtracting constant (i.e. using the exsecant expansion), the final result is h=64003200=2 km. The correct value would be 2.00052..., so our approximation is good within half a meter out of 2km, a relative error of about 2.6%.

Limitations

You can't see further than a quarter circle in each direction, and that's only at infinite distance from the sphere surface; so we must have dr=α<π2 or 2d<πr. (Using the approximation π227, which is a slight overestimation, we get the easier condition 7d<11r).

On the Earth, this would mean distances up to about 10,000km, which means you wouldn't be able to see Cape Town from Reykjavik (over 11,400km), but you could see Hong Kong from Rome (9,280km).

However, the formulas we presented aren't accurate in the whole domain: the error term for the higher order approximation is of order 6, and in the highest order we presented is of order 8, which is very good as long as your angles are less than 1 radian, but actually gets really bad really fast after that.

(Intuitively, you can tell that the formula doesn't work when the distance approaches its maximum because the exact formula diverges, while the ones we have proposed don't.)

To see this in action, consider the Rome to Hong Kong case. We have q=1.45, squared to 2.1025, doubled to s=4.205.

Our lower-order estimate for h is 1,522km. Our higher-order estimate for h is 1,824km. Our highest-order estimate is 2,160km. The correct answer is 46,711km, over 20 times higher!

So, how far can you push the formula? How large can the angle be before the error you commit is too large? What would be a possible workaround? (Aside from the obvious: use the exact formula.)

The anarchist curve

Note: this article makes use of MathML, the standard XML markup for math formulas. Sadly, this is not properly supported on some allegedly ‘modern’ and ‘feature-rich’ browsers. If the formulas don't make sense in your browser, consider reporting the issue to the respective developers and/or switching to a standard-compliant browser.

As visually discussed here, a set of equations has recently been popping up as graffiti in Belgium. The equations define five functions of one variable, namely:

f(x) = 2+ -(x-2)2 + 1 g(x) = 2- -(x-2)2 + 1 h(x) = 3x-3 i(x) = -3x+9 j(x) = 0,2x+1,7

Plotting the five functions with x[1,3] (the domain of existence of f and g) gives the well-known anarchist logo

Anarchy symbol, composed of two semi-circles and three straight lines, all of different colors.
Anarchy symbol

As mathematicians, we can take this a step further and define an Anarchist curve, by finding the implicit form of the plot of each of the function, and then bringing them together.

In this case, f,g together define the circle, with equation

(x-2)2+(y-2)2=1

or rather (fully implicit):

(x-2)2+(y-2)2-1=0.

The three functions h,i,j describe the ‘A’ shape. We first rewrite j in a nice form as

j(x)=x/5+17/10,

and then write the implicit equation for each of them, multiplying the one for j by 10 to get rid of the fractions:

h : y-3x+3 =0 i : y+3x-9 =0 j : 10y-2x -17 =0

We can now multiply all the left hands together, obtaining:

(y-3x+3)(y+3x-9)(10y-2x-17)=0

which is the equation for the ‘A’.

If we then multiply this for the left-hand side of the implicit equation for the circle, we have the Anarchist curve

((x-2)2+(y-2)2-1)(y-3x+3)(y+3x-9)(10y-2x-17)=0

(which, for the record, is currently missing from the list of known curves in the Wolfram Alpha database.)

(There's a few more we could draw similarly, but that's for another time.)

Pi Day

Why March 14 (Einstein's birthday) is the wrong day to celebrate π, the mathematical constant

Note: this article makes use of MathML, the standard XML markup for math formulas. Sadly, this is not properly supported on some allegedly ‘modern’ and ‘feature-rich’ browsers. If the formulas don't make sense in your browser, consider reporting the issue to the respective developers and/or switching to a standard-compliant browser.

Today's date, March 14th, is considered Pi Day, since written in the North American (and a few other places') convention of putting the month before the day, 3/14 can be read as the three most significant digit of

π=3.1415926535897932384626433832795...

I personally disagree with this choice, mainly for two reasons:

  1. it depends on the decimal representation of π; in hexadecimal, we have π=3.243F... so that the correct day would be March 2nd (hexadecimal 24 is decimal 36, and no month is that long);

  2. it depends on the (IMO barbaric) convention of putting the month before the day in numerical date representations, which is far from being international (day/month/year being much more common) or standard (the ISO standard goes for year-month-day).

While the second point is debatable (I'm not aware of ISO standard recommendations for dates without years, which might be used as a resolution), the first point is easily fixed by going for a fractional representation of π instead; and a well-known fractional approximation of π is given by 227, that dates as far back as Archimedes at least. Of course, 22/7 is not really possible in the month/day representation, but it makes perfect sense as July 22nd.

Mathematically speaking, July 22nd is preferable to March 14th as Pi Day also because the relative error introduced by approximating π as 227 is 0.04%, while the 3.14 truncation has a relative error of 0.05%, so July 22nd is a better approximation to π than March 14th.

The best Pi Day

Arguably, in the year 2015, the “American way” has another benefit: writing the year in the short (two-digit) form, we get an even better approximation of π as 3.1415, and by further appending the time we have an actual instant in which π is presented exactly.

The argument fails miserably when taking into account that the time to be considered (9:26:53) would need to be padded by a 0 before “appending” it to the date, and there's always the decimal representation issue, and the fact that the time is sexagesimal …

If the year is to be considered, better dates can be chosen, with the following argument. Consider the continued fraction expansion of π:

[3;7,15,1,292,...]

Side note: the afore­men­tio­ned 227 is exactly the continued fraction [3;7].

Taking only the first three terms, corresponding to the date 3/7/15, we get [3;7,15]=333106, which is accurate to 0.0026% (better than the 0.0029% of 3.1415, even). So, March 7th 2015 (resp. July 3th 2015, depending on date notation) are both better approximations than March 14th (resp. June 22nd) for π this year.

But as it happens, we can do better: if we take the first four terms of the continued fraction, we get [3;7,15,1]=[3,7,16]=355113 which is an excellent approximation to π, with an error of less than one in ten million (a hint to this is the following huge 292 number).

The best date-fractional approximation of π will happen next year, on March 7th in North America, Belize and whichever other country prefers month before day, and on July 3rd in the rest of the world.

Going beyond π

As a mathematician, one gets to think: we stop at π day, aside from the obvious pi/pie pun? There are so many other interesting numbers to look into!

Tau Day and the τ manifesto

For example, there are people that believe that π is wrong, and τ=2π should be considered the fundamental constant of the circle, and

τ=6.283185307179586476925286766559...

The proposed Tau Day (in the manifesto linked above) is thus on June 28th, following the North American tradition. We obviously disagree, and would rather look for a fractional date choice. We thus go and look at the continued fraction representation of τ,

[6;3,1,1,7,2,146,...]

And taking the first three terms we get [6;3,1]=[6;4]=254 which approximates τ to 0.5% (May 25th). Sadly, in this case the fractional approximation is worse than the truncation (0.05%), due to the fact that the next continued fraction term [6;3,1,1]=[6;3,2]=447, which approximates τ to 0.04%, is not a good date (although it was on 6/3/2). Is this a hint that π is, in fact, better than τ?

e, ϕ, what else?

Similarly, we can go looking for the best date for Napier's number e, for which we can choose 197, accurate to 0.15% and dating to July 19th. For the golden ratio Φ the best candidate is 119, with an error of 0.21% and dating to either September 11th (oops), or November 9th, depending on convention.

(It should be mentioned that the continued fraction representation of e and ϕ is not interesting enough to give us something useful for the year.)

For anybody interested in exploring rational approximating dates, I've also cooked up a quick'n'dirty Ruby script that does the finding for you.

Have fun.

I biscotti di Wythoff

Il problema

Nota: questo articolo fa uso di MathML, lo standard XML per le formule matematiche. Purtroppo, questo non è supportato correttamente in alcuni browser sedicenti ‘moderni’ o ‘ricchi di funzionalità’. Se le formule non hanno senso nel tuo browser, segnala il problema agli sviluppatori (del browser), o passa ad un browser che supporti questi standard.

Si pone il seguente problema, derivato da questo articolo su G+: determinare la formula esplicita della successione di numeri naturali1 (ovvero della funzione F:) che soddisfa le due seguenti condizioni:

  1. è strettamente crescente;
  2. l'i-esimo elemento non appartenente all'immagine di F è F(F(i))+1.

Vediamo innanzi tutto di capire bene il secondo punto, cominciando con l'osservare che l'unica successione strettamente crescente che ha come immagine l'intero è la successione a(n)=n. Per dimostrarlo, prendiamo una qualunque (altra) successione strettamente crescente b e sia k il primo indice per cui b(k)k; risulterà anzi necessariamente2 b(k)>k, ed avremo quini b(n)=n<kn<k e b(n)b(k)>knk, da cui risulta che k non è immagine di alcun numero naturale secondo b.

Ora, se ogni successione strettamente crescente non banale ha come immagine un sottoinsieme stretto di , possiamo considerare il complementare della sua immagine in , H=\F(), che sarà un insieme non vuoto e quindi (in quanto sottoinsieme di ) totalmente ordinato e numerabile; in soldoni, in tale complementare possiamo considerare il primo elemento (inteso come il minimo), il secondo elemento (il più piccolo elemento di H maggiore del primo elemento), etc.

La seconda condizione su F ci dice quindi che il primo elemento di H è esattamente F(F(1))+1, che il secondo elemento di H è F(F(2))+1, etc. Volendo, la cosa si può riformulare dicendo che H è l'immagine della successione h(n)=F(F(n))+1.

La domanda a questo punto è se effettivamente esiste (almeno) una successione F che soddisfi i requisiti prescritti, e (in caso affermativo) se tale successione sia unica. Vi sono vari approcci per trovare risposta alla domanda, ed uno dei più immediati è sicuramente quello costruttivo: dimostriamo che F esiste ed è unica determinando i valori di F per ogni n e mostrando come essi siano univocamente determinati.

Nel procedimento, ci serviremo di due ulteriori osservazioni. La prima è che in una successione strettamente crescente di numeri naturali a si ha sempre3 a(n)n; la seconda è che nel complementare H del codominio di F non possono esservi mai due interi consecutivi (infatti, se kH, avremo k-1=F(F(n)) per un opportuno n, e quindi k-1, essendo nell'immagine di F, non starà in H).

Costruiamo dunque la nostra F, e vedremo come nel farlo costruiremo di necessità anche H (ovvero, come visto, equivalentemente, la successione h dei valori non assunti da F).

Abbiamo innanzi tutto che F(1)=1. Se così non fosse, infatti, sarebbe 1H; di più, 1 sarebbe il primo elemento di H (non possono infatti esservi in H numeri più piccoli), e quindi dovrebbe essere (per la seconda proprietà di F) 1=F(F(1))+1, da cui risulterebbe 0=F(F(1))F(1)1 (dove le due disuguaglianze sono ottenute dalla precedente osservazione su valori e indici delle successioni crescenti).

Da F(1)=1 segue che F(F(1))=F(1)=1 e quindi h(1)=2: il primo elemento di H è 2, e quindi F(2)3 (per la crescenza di F abbiamo F(2)2, ma 2HF(2)2).

Possiamo anzi dire che F(2)=3: se infatti fosse F(2)>3, dalla crescenza di F seguirebbe che F(n)>3n>1, che in congiunzione con il fatto che F(1)=1<3 ci direbbe che 3 non è immagine di alcun elemento, e quindi 3H, ma ciò è impossibile, essendo 2H e non potendosi avere, come osservato, numeri consecutivi in H.

Quindi F(2)=3, da cui segue che F(3)4 (stretta crescenza di F), e quindi il secondo elemento di H sarà h(2)=F(F(2))+1=F(3)+15 e quindi h(n)5n>1, per cui 4H e, per complementareità 4F(); sarà quindi4 F(3)=4, da cui infine h(2)=5.

Così procedendo possiamo calcolare manualmente ciascun valore di F e di h, ottenendo qualcosa come la seguente (l'idea, in soldoni, è di ‘riempire’ i valori di F finché possibile, e quindi quelli di h secondo la formula della seconda condizione):

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
F 1 3 4 6 8 9 11 12 14 16 17 19 21 22 24
h 2 5 7 10 13 15 18 20 23 26 28 31 34 36 39

Se questa tecnica costruttiva ci può servire come prova dell'esistenza (ed unicità) della F (e della relativa h), non sembra dirci molto sulla sua forma chiusa.

Possiamo però studiare i primi termini delle due successioni F ed h e notare ad esempio che —almeno nella sequenza iniziale— esibiscono questo tipo di comportamento:

  • per F, valori successivi differiscono tra loro di 1 o 2 (più spesso 2 che 1) unità;
  • per h, invece, i ‘passi’ tra un valore e il successivo sono di 2 o 3 (più spesso 3 che 2) unità.

Le successioni di Beatty

Il comportamento in questione è tipico delle successioni di Beatty, una classe di successioni il cui termine generico ha la forma nϑ per un fissato ϑ numero reale positivo irrazionale (il simbolo rappresenta la funzione ‘parte intera’). Se ϑ>1, la successione è strettamente crescente, e la differenza tra due termini consecutivi è sempre compresa tra ϑ e ϑ+1.

Una interessante proprietà delle successioni di Beatty è che se α e β sono irrazionali positivi tali che 1α+1β=1, allora le rispettive successioni di Beatty partizionano i numeri naturali (ovvero, sono complementari e la loro unione è data dall'intero insieme ).

Vi sono forti indizi che le nostre successioni F e h siano successioni di Beatty complementari. Per risolvere il nostro problema basterebbe quindi trovare una coppia di numeri irrazionali α,β che soddisfino 1α+1β=1 e che generino rispettivamente F,h soddisfacenti la famosa seconda proprietà, scrivibile come h(n)=F(F(n))+1n.

Per trovare i generatori in questione cominciamo con l'osservare che, secondo quanto osservato finora, il generatore α di F dovrebbe essere compreso tra 1 e 2, mentre il generatore β di h sarebbe compreso tra 2 e 3. Da 2<β<3 e 1α+1β=1 seguirebbe anzi che 32<α<2 (da cui si potrebbe già intuire chi possa essere α, essendovi un famosissimo numero irrazionale proprio in quell'intervallo —ma noi cercheremo di essere più formali).

Partiamo quindi dalla famosa seconda proprietà, che scritta in forma esplicita nel caso di F,h successioni di Beatty ci dice che per ogni positivo n risulta nβ=nαα+1, ovvero nβ=nαα+1, e quindi -1<nβ-(nαα+1)<1, da cui ancora 0<nβ-nαα<2.

Essendo α irrazionale e positivo possiamo scrivere (n-1)α<nα<nα, e quindi spezzare l'ultima catena di diseguaglianze in nβ-(n-1)α2>nβ-nαα>0 e nβ-nα2<nβ-nαα<2. Dividendo per n ovunque e portando un α2n a minorare nella prima diseguaglianza otteniamo infine la relazione α2n<β-α2<2n vera per ogni n, da cui in definitiva β-α2=0 e quindi β=α2.

Abbiamo quindi che α,β devono soddisfare 1α+1β=1 e β=α2. Sostituendo nella prima abbiamo 1α+1α2=1 o α+1=α2, la cui unica soluzione positiva è la famosa sezione aurea φ=1+52.

In definitiva, abbiamo dimostrato che se una coppia di successioni di Beatty complementari soddisfa le condizioni richieste, allora dovrebbe avere come generatori φ e φ2. Per concludere che le successioni di Beatty con questi generatori sono effettivamente quelle che cercavamo rimane ora da verificare che esse soddisfano i due criteri5.

La crescenza di F è immediata conseguenza del fatto che il generatore è maggiore di 1, quindi rimane da provare la famosa seconda condizione, che vista la complementareità delle successioni possiamo esprimere così: dimostrare che per ogni n risulta nφ2=nφφ+1.

Osserviamo innanzi tutto che, posto k(n)=nφ-(n-1)φ, risulta nφ2-(n-1)φ2=k(n)+1. Infatti, essendo φ2=φ+1, possiamo scrivere nφ2=nφ+n e (n-1)φ2=(n-1)φ+n-1; sottraendo membro a membro otteniamo nφ2-(n-1)φ2=nφ-(n-1)φ+1=k(n)+1.

Abbiamo quindi che nφ2=(n-1)φ2+k(n)+1, e per provare la nostra tesi basta dimostrare che nφφ=(n-1)φ2+k(n), eguaglianza che possiamo riscrivere nφ(1+1φ)=(n-1)(φ+1)+k(n), ovvero nφ+nφφ=(n-1)φ+n-1+k(n). Essendo nφ=(n-1)φ+k(n) la nostra tesi si semplifica nel dover dimostrare che nφφ=n-1 o equivalentemente6 n-1nφφ<n che possiamo riscrivere (n-1)φnφ<nφ.

La diseguaglianza di destra è immediata essendo φ irrazionale, rimane quindi da provare che (n-1)φnφ. Supponiamo per assurdo che sia vero il contrario, ovvero (n-1)φ>nφ, da cui seguirebbe (n-1)φnφ; ma (n-1)φ<nφ, quindi (n-1)φnφ, e pertanto (n-1)φ=nφ, che implica nφ-(n-1)φ<1, ovvero φ<1, assurdo7.

Abbiamo così completato la nostra dimostrazione e verificato che le successioni di Beatty con generatori φ e φ2 sono effettivamente quelle cercate.

Le successioni di Wythoff

Queste due successioni sono meglio note come la successione inferiore (F) e superiore (h) di Wythoff. Queste due successioni sono state scoperte appunto dall'eponimo matematico nello studiare un famoso problema di teoria dei giochi che prende vari nomi (problema di Wythoff, il gioco delle scatole dei biscotti, etc).

Il gioco ha la seguente forma: ci sono due scatole di biscotti, e due giocatori si alternano scegliendo quanti biscotti vogliono da una sola delle due scatole, oppure lo stesso numero di biscotti da entrambe le scatole. Vince il giocatore che prende l'ultimo biscotto.

È evidente che se una delle due scatole è vuota, o se ambo le scatole hanno lo stesso numero di biscotti, il primo giocatore vince. Il gioco si fa più interessante se entrambe le scatole sono piene ed il numero di biscotti non è equamente distribuito.

Ad esempio, se le scatole hanno rispettivamente 1 biscotto e 2 biscotti, è evidente che il secondo giocatore vincerà, qualunque sia la scelta fatta dal primo giocatore. Ovviamente, partendo da un'altra configurazione, un giocatore dovrebbe quindi cercare di arrivare alla distribuzione 1/2 per aver garantita la vittoria. La domanda è: quali altre configurazioni hanno tale proprietà? Ovvero, quali coppie di numeri (a,b) sono tali che, qualunque sia la mossa del primo giocatore, il secondo si può garantire la vittoria?

Con un poco di calcoli si scopre che le coppie (ordinate, con a<b) che garantiscono la vittoria al giocatore che le raggiunge sono

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
a 1 3 4 6 8 9 11 12 14 16 17 19 21 22 24
b 2 5 7 10 13 15 18 20 23 26 28 31 34 36 39

e se la tabella vi ricorda qualcosa è perché i valori sono esattamente gli stessi visti nella precedente tabella: le coppie (F(n),h(n)) sono le configurazioni vincenti nel problema di Wythoff.

Una nota finale

Concludiamo questa nostra rapida escursione sulla questione osservando che h(n) ha una forma ben più semplice della già vista F(F(n))+1, e questa è h(n)=F(n)+n. La cosa, chiaramente visibile dai valori in tabella e facilmente dimostrabile8, ci permette di leggere le successioni di Wythoff in questo modo: ogni coppia (F(n),h(n)) è la coppia vincente in cui la differenza di contenuto tra le due scatole di biscotti è pari ad n.

Questo, combinato con la proprietà di partizionamento di di cui godono le due successioni (ogni intero sta in una ed una sola delle successioni, e quindi anche in una ed una sola coppia) e con il fatto che il gioco è puramente ‘sottrattivo’ (da una configurazione all'altra si passa solo diminuendo uno o entrambi dei contenuti) è sufficiente a definire la strategia vincente, che viene lasciata come esercizio per il lettore.


  1. si intende qui l'insieme dei numeri interi strettamente positivi. ↩  ↩

  2. l'affermazione è ovvia nel caso k=1, poiché non vi sono numeri naturali1 minori di 1; se invece k>1, posto l=b(k) e supponiamo per assurdo l<k: essendo b(n)=nn<k per la scelta di k, avremmo, b(k)=l=b(l), e quindi b(l)=b(k) con l<k, che viola la stretta crescenza di b. ↩

  3. si dimostra ad esempio per induzione. Come base induttiva abbiamo che a(1)a(1)1. Supponiamo ora che a(n)n e dimostriamo che da questo segue a(n+1)n+1: per la stretta crescenza della successione abbiamo a(n+1)>a(n)n, ovvero a(n+1)>n, e non essendovi numeri naturali tra n ed n+1 questo equivale ad a(n+1)n+1. ↩

  4. se fosse F(3)>4, per la crescenza di F si avrebbe F(n)>4n>3, da cui, sapendo che F(1)<4 ed F(2)<4, seguirebbe che 4F(). ↩

  5. tale verifica è necessaria perché l'ipotesi da noi fatta (ovvero che F ed h siano successioni di Beatty complementari) potrebbe condurre ad un assurdo, da cui seguirebbe che in realtà esse non sono successioni di Beatty. ↩

  6. si ha x=m se e solo se mx<m+1, da applicare nel nostro caso con x=nφφ,m=n-1 ↩

  7. osserviamo che per un arbitrario numero reale positivo α la diseguaglianza (n-1)αnα non è in genere verificata, come si vede prendendo ad esempio α=1K per un fissato K naturale ed osservando che per ogni 1<n<K si ha nα=nK=0<n-1K=(n-1)α; la diseguaglianza è però verificata per tutti i numeri reali α1. ↩

  8. essendo nota la forma esplicita delle due successioni, ci basta provare che nφ2=nφ+n; partiamo quindi dall'equazione che definisce la sezione aurea: da φ2=φ+1 segue, per ogni n, nφ2=n(φ+1) e quindi anche nφ2=nφ+n, o equivalentemente nφ2=nφ+n, ciò che volevamo dimostrare. ↩

Matematica aliena/1: numerali

Se è vero che la matematica è concettualmente un linguaggio ‘universale’, lo stesso non può dirsi dei sistemi di numerazione. Ad esempio, siamo ormai abituati a considerare ‘universale’ il sistema posizionale basato sulle cosiddette cifre arabe, ma abbiamo dimestichezza anche con il ben diverso sistema simbolico in uso nell'antica Roma. E questi sono solo due dei sistemi che sul nostro pianeta sono (o sono stati) usati.

Supponiamo di entrare in contatto con una civiltà aliena, magari ormai estinta, ma che ci abbia lasciato documenti ed iscrizioni su cui poterla studiare. Anche ammesso che, per la sua universalità, la loro matematica sia ‘isomorfa’ alla nostra, possiamo essere sicuri di riuscire a non dico leggere, ma almeno identificare la loro rappresentazione della stessa?


Propongo un esercizio di riscaldamento. Supponiamo di sapere che gli alieni scrivano, come noi, da sinistra verso destra e poi dall'alto verso il basso. Supponiamo anche di aver identificato gli otto simboli con cui vengono scritti i numeri, e che trascriveremo con le prime otto lettere dell'alfabeto latino: A B C D E F G H.

Supponiamo inoltre che nei documenti che ci sono pervenuti compaia un solo simbolo di operazione, che trascriveremo con ˆ. Supponiamo che nei frammenti arrivati fino a noi, gli esempi più semplici che si riescano a trovare siano questi:

  • AA ˆ AA = BB
  • AA ˆ BB = CC
  • HA ˆ HA = HAB

Ovviamente, si trovano esempi più complicati, come CCFDAC ˆ FEEGHC = AADDBAF.

Siamo in grado di cominciare a interpretare i numeri (e capire di quale operazione si tratta) semplicemente da questo?

Spoiler Alert!

Il sistema numerico presentato è biiettivo in base 8, con alcune modifiche. Come nei sistemi di numerazione biiettiva, le otto cifre rappresentano i numeri da 1 a 8, e non si fa quindi uso dello zero. In aggiunta, gli alieni scrivono i numeri nella direzione di scrittura, partendo dalle cifre meno significative, e chiudendo con la cifra data dal numero modulo 7.

Vediamo alcune ragioni perché un siffatto sistema ha senso.

L'uso della base 8 invece che della base 10 è facilmente giustificabile, ad esempio, supponendo che gli alieni abbiano solo 8 dita invece delle nostre 10.

Scrivere le cifre meno significative prima di quelle più significative semplifica la scrittura in riga dei risultati delle operazioni (non è necessario sapere in anticipo quanto saranno lunghi e lasciare spazio a sufficienza).

L'uso della cifra supplementare facilita la determinazione di eventuali errori. Nel nostro usuale sistema numerale, questo punto si applicherebbe aggiungendo alla normale sequenza di cifre il valore modulo 9 dello stesso numero.

Il valore della cifra di controllo non è nemmeno difficile da calcolare, ricordando la buona vecchia ‘prova del nove’ che un tempo si insegnava alle elementari: basta sommare le cifre del numero, ripetutamente, fino ad ottenere una sola cifra. Volendo separare con una barra verticale il numero dalla cifra di controllo, scriveremmo 12|3 o 15|6, o 125678|2 (adottando, a parte la base, il sistema alieno, avremmo invece 213, 516, 8765212 rispettivamente).

L'unico inconveniente (come ai tempi della prova del 9) è che bisogna ricordarsi che 0 e 9, come cifre di controllo, sono equivalenti. È qui che interviene infine l'utilità del sistema biiettivo, che rende univoca la rappresentazione, mancando di una cifra per indicare lo 0.

Risolvere un quizzino della domenica (1)

Il .mau. propone per oggi un quizzino della domenica dal seguente testo:

In un articolo apparso il secolo scorso sul bollettino parrocchiale di Villar Perosa, si racconta che il senatore Giovanni Agnelli in persona premiò un contadino che aveva nove figli per una curiosa proprietà aritmetica. Tutti i figli erano infatti nati allo stesso numero di anni di distanza l'uno dal successivo; ma soprattutto la somma dei quadrati delle loro età in quell'anno era pari al quadrato dell'età del contadino. Quali erano queste età?

Vediamo di risolverlo.

Ratio e definizioni

Nota: questo articolo fa uso di MathML, lo standard XML per le formule matematiche. Purtroppo, questo non è supportato correttamente in alcuni browser sedicenti ‘moderni’ o ‘ricchi di funzionalità’. Se le formule non hanno senso nel tuo browser, segnala il problema agli sviluppatori (del browser), o passa ad un browser che supporti questi standard.

Sia A l'età del figlio minore e sia D la cadenza con cui sono nati i figli: avremo allora che il penultimo ha A+D anni, e così via fino al maggiorenne, di età B=A+8D anni. La somma dei quadrati di queste età, dopo un po' di semplice aritmetica, si può scrivere così:

S=9A2+72AD+204D2

ed il problema si riduce quindi a trovare A,D,C interi tali che

C2=9A2+72AD+204D2

con alcune condizioni al contorno, del tipo D>0, A>0, C>A+8D etc.

Procedimento

In generale, trovare interi tali che loro combinazioni algebriche diano quadrati perfetti non è banale, ma nel nostro caso possiamo aiutarci osservando che l'espressione che vorremmo ridurre ad un quadrato perfetto è molto simile all'espansione del quadrato di una somma, il cui primo quadrato è 9A2, il doppio prodotto è ‘vicino’ a 72AD ed il secondo quadrato è ‘vicino’ a 204D2.

L'idea è quindi quella di trasformare questa espressione nel quadrato di una somma di interi, ‘trasformando’ opportunamente il secondo e il terzo addendo senza ovviamente alterare il valore numerico dell'espressione stessa.

A tal fine, osserviamo che 204 (il coefficiente numerico del secondo quadrato) non è un quadrato perfetto, ma è compreso tra 196=142 e 225=152: è quindi legittimo sperare che l'espressione si possa trasformare in un quadrato con uno di questi due coefficienti. A tal fine, calcoliamo:

(3A+14D)2-S

e

(3A+15D)2-S,

ottenendo rispettivamente

4(3A-2D)D

e

3(6A+7D)D,

termini che noi vogliamo siano nulli, nell'ambito sempre delle condizioni enunciate alla fine del precedente paragrafo. Questo comporta in particolare che il secondo caso non ammette soluzione, poiché annullarlo ci dà come condizioni o D=0 (impossibile) o 6A+7D=0, che ammette soluzioni solo se A e D hanno segno opposto (o sono entrambi nulli), mentre noi vogliamo che sia A che D siano strettamente positivi.

Ne consegue che l'espressione da noi cercata è la prima, che si annulla per 3A=2D. Sostituendo quindi ad esempio A=2D3 nell'espressione per S otteniamo

S=256D2

e quindi C=16D.

Sappiamo anche che D deve essere multiplo di 3, poiché altrimenti A non sarebbe intero, ed abbiamo quindi almeno due soluzioni possibili:

Spoiler Alert!

  • per D=3 si ha A=2,B=26 e C=48;
  • per D=6 si ha A=4,B=52 e C=72;

e ci fermiamo qui perché per il successivo valore D=9 avremmo C=144 e non siamo più ai tempi dei matusalemmi. È probabile che come soluzione si debba in realtà prendere la prima, perché un contadino 72enne con un figlio di 4 anni è poco credibile, benché non impossibile.

Postilla

Il testo del problema è stato emendato per rendere univoca la soluzione aggiungendo questa nota:

mentre la somma degli anni dei figli era uguale al triplo degli anni della moglie

e intendendo che la moglie del contadino sia anche la madre di tutti i suoi figli, questo porta la moglie ad avere un'età M che soddisfi

3M=9(A+4D)

da cui, semplificando e introducendo le nostre condizioni su A e D,

M=3(A+4D)=14D

che per D=3,6 ci restituisce M=42,84 rispettivamente; questo permette di scartare la soluzione D=6 essendo praticamente impossibile che una donna abbia un figlio ad 80 anni. È però interessante notare che con questa condizione la donna aveva 16 anni quando ha partorito il primo figlio.

Il problema dei portatori di pizza

Tre coppie decidono di prendere per cena pizza da asporto. Arrivati alla pizzeria, ordinano rispettivamente due margherite senza olio, una caprese e una bresaola, una caprese e una vulcano. Quando le pizze sono pronte, la commessa le fornisce impilate in ordine ignoto. Ciascuno dei tre cavalieri prende due delle pizze per distribuire equamente il carico durante il trasporto verso casa.

Supponendo che l'ordine in cui le pizze sono state distribuite sia perfettamente casuale, qual è la probabilità che ciascun cavaliere trasporti le due pizze ordinate dalla rispettiva coppia?

Soluzione

Nel seguito, indicheremo con B la pizza Bresaola, con C la Caprese, con M la Margherita (senza olio) e con V la Vulcano. Il pizzaiolo fornisce le pizze in un ordine casuale (ad esempio MCCBMV), che per comodità i tre cavalieri prenderanno in ordine (nell'esempio, il primo prenderà MC, il secondo CB, il terzo MV).

La probabilità che i cavalieri portino il paio giusto di pizze è quindi il numero delle permutazioni che assegnano a ciascun cavaliere le pizze giuste diviso il numero totale di permutazioni (distinte) possibili.

Le permutazioni valide sono quattro, per le seguenti condizioni: il primo cavaliere deve prendere le margherite (una sola possibilità: MM), il secondo cavaliere deve prende la bresaola e una caprese (due possibilità: BC, CB), il terzo cavaliere prende la vulcano e una caprese (ancora due possibilità: VC, CV). Le permutazioni in questione possono anche essere enumerate per esteso:

  • MM BC VC
  • MM CB VC
  • MM BC CV
  • MM CB CV

Quante sono invece le permutazioni distinte possibili1? Se le pizze fossero tutte diverse, si avrebbero 6! = 720 permutazioni, ma poiché vi sono due margherite, e tutte le permutazioni in cui le due margherite si scambiano di posto sono equivalenti, il numero di permutazioni va dimezzato; analogamente per le capresi, ottenendo infine 720/4 = 180 permutazioni distinte.

La probabilità che ciascun cavaliere porti le pizze della propria coppia è quindi di 4/180, ovvero 2/90 o 1/45, il 2.(2)%.

{ Costruire un albero delle 180 combinazioni distinte. }


  1. si ringrazia il proponente del gioco per aver anche determinato il modo più rapido per calcolare le permutazioni distinte. ↩

Lavorare per, lavorare con

Versione tl;dr (e conclusioni di tutto il discorso): lavorare per qualcuno e lavorare con qualcuno sono due tipi di relazioni indipendenti: si può quindi lavorare per qualcuno, ma non con loro; si può lavorare per qualcuno e con loro; si può lavorare con qualcuno, ma non per loro. Sono quindi due insiemi con intersezione non vuota.

Motivazione: una delle tipiche discussioni inutili che si fanno per passare tempo in palestra.


Nota: questo articolo fa uso di MathML, lo standard XML per le formule matematiche. Purtroppo, questo non è supportato correttamente in alcuni browser sedicenti ‘moderni’ o ‘ricchi di funzionalità’. Se le formule non hanno senso nel tuo browser, segnala il problema agli sviluppatori (del browser), o passa ad un browser che supporti questi standard.

Per una comprensione più dettagliata del discorso, cominciamo con un breve ripasso di teoria degli insiemi (solo quello che serve).

Sia X un insieme. Una relazione (binaria) tra gli elementi di X è un sottoinsieme del prodotto cartesiano di X con sé stesso. Se RX×X è una relazione ed x,yX, diremo che x è in relazione con y (secondo R) se (x,y)R, ed in tal caso scriveremo per semplicità xRy.

Su uno stesso insieme X si possono definire più relazioni. Alcuni tipi di relazione sono particolarmente diffusi e/o importanti. Tra questi ricordiamo:

relazioni d'ordine

una relazione RX×X si dice d'ordine se essa gode delle proprietà riflessiva (xRx per ogni xX), antisimmetrica (se xRy e yRx allora x=y) e transitiva (se xRy e yRz allora xRz); un esempio classico di relazione d'ordine è la relazione di minore o uguale definita sui numeri (naturali, razionali, reali);

relazioni d'ordine stretto

una relazione RX×X si dice d'ordine stretto se essa gode delle proprietà irriflessiva (xRx per nessun xX), asimmetrica (se xRy allora non può aversi yRx) e transitiva (se xRy e yRz allora xRz); un esempio classico di relazione d'ordine stretto è la relazione di minore definita sui numeri (naturali, razionali, reali);

relazioni di equivalenza

una relazione RX×X si dice di equivalenza se essa gode delle proprietà riflessiva (xRx per ogni xX), simmetrica (se xRy allora yRx) e transitiva (se xRy e yRz allora xRz); un esempio classico di relazione d'ordine è la relazione di similitudine definita sull'insieme dei triangoli del piano.


Veniamo ora alla nostra questione: prendiamo l'insieme X delle persone che lavorano, e definiamo su questo insieme due relazioni.

La prima relazione, che indicheremo con C, è la relazione del ‘lavorare con’. Se x,y sono persone ed x lavora con y, scriveremo xCy. Questa relazione gode sicuramente della proprietà riflessiva (nel senso che ciascuno lavora con sé stesso) e di quella simmetrica (se uno lavoro con un altro, è anche vero che l'altro lavora con l'uno); se quando uno lavora con un altro e questo lavori con una terza persona è sempre vero che il primo lavori con il terzo, allora sarà anche vera la proprietà transitiva e quindi la relazione C potrà essere considerata una relazione d'equivalenza.

La seconda relazione, che indicheremo con P, è la relazione del ‘lavorare per’. Se x lavora per y, scriveremo xPy. A seconda se si ammette che si lavori per sé stessi o meno, la relazione P è abbastanza ovviamente una relazione di ordine semplice o in senso stretto.

Siccome si ha C,PX×X, possiamo calcolare l'intersezione delle due relazioni (ovvero lavorare per e con qualcuno) e questa sarà ancora una relazione tra gli elementi di X (CPX×X). Se essa è vuota, non vuota, uguale alla diagonale (ovvero se ogni elemento è in relazione ‘per e con’ solo con sé stesso) o altro dipende ovviamente dalle relazioni C e P.

Facciamo un esempio. Sia dato un insieme X i cui elementi sono a,b,c,d e supponiamo che le relazioni C e P siano così definite:

  • b lavora con a e con d; considerando la simmetria e riflessività di C, avremo le relazioni aCa,bCb,cCc,dCd,aCb,bCa,bCd,dCb (in questo caso stiamo supponendo che non valga la proprietà transitiva, ed in particolare che anche se b lavora con a e con d, a non lavora con d)
  • a e b lavorano per c, e b lavora anche per d; senza considerare la riflessività per P, avremo aPc, bPc, bPd (questa relazione P è una relazione d'ordine in senso stretto)

In tal caso, la relazione lavorare per e con lega soltanto b e d essendo (b,d) l'unico elemento dell'intersezione CP (relazioni bCd e bPd)

Se nella relazione P si avesse pure bPa, gli elementi di CP sarebbero (b,d) e (b,a).

Se invece in P considerassimo anche la riflessività (cioè che ciascuno lavora per sé stesso), allora a lavorare per e con qualcuno saranno: ciascuno con sé stesso, b per e con d: (a,a),(b,b),(c,c),(d,d),(b,d).