
E ricorda…

il blog di Biagio Raucci


There are many techniques to prove various statements. The simplest ones are direct proof, where you show that if the first statement (P) is true then the second statement (Q) is also true; the proof by contrapositive, where you assume that the negation of the second statement (~Q) is true and show that this forces the negation of the first statement (~P) to be true as well. Mathematical induction is a technique used to prove that an all statements of an infinite list of statements (instead of just two like in the first two techniques mentioned) are all true.
To motivate the discussion, let’s first examine the kinds of statements that induction is used to prove.
Consider the following statement.
Conjecture. The sum of the first odd natural numbers equals
.
The following table illustrates what this conjecture says. Each row is headed by a natural number , followed by the sum of the first
odd
natural numbers, followed by .

Note that in the first five lines of the table, the sum of the first odd numbers really does add up to
. Notice also that these first five lines indicate that the
th odd natural number (the last number in each sum)
is . (For instance, when
, the second odd natural number is
; when
, the third odd natural number is
, etc.)
The table raises a question. Does the sum really always equal
? In other words, is the conjecture true?
Let’s rephrase this as follows. For each natural number (i.e., for each
line of the table), we have a statement , as follows:

Our question is: Are all of these statements true?
Mathematical induction is designed to answer just this kind of question.
It is used when we have a set of statements , and weneed to prove that they are all true. The method is really quite simple.

In this setup, the first step (1) is called the basis step. Because is usually a very simple statement, the basis step is often quite easy to do.
The second step (2) is called the inductive step. In the inductive step direct proof is most often used to prove , so this step is usually carried out by assuming
is true and showing this forces
to be true.
The assumption that is true is called the inductive hypothesis.
Now let’s apply this technique to our original conjecture that the sum of the first odd natural numbers equals
. Our goal is to show that for each
, the statement
is true. Before getting started, observe that
is obtained from
by plugging
in for
.
Thus is the statement
. Also, we get
by plugging in
for
, so that
.

More:


la lettera…
“Anni fa – non molti, è bene saperlo in anticipo – un carteggio di raro tenore s’intrecciò tra due coniugi siciliani, lui emigrato per lavoro in Germania, lei rimasta in paese ad accudire la vecchia suocera e la giovanissima prole. Analfabeti entrambi e riluttanti a dividere con uno scrivano estraneo e venale i segreti della propria intimità (fossero effusioni d’affetto o notizie di spicciola economia domestica), i due sposi ricorsero, per corrispondere, ad un linguaggio di convenzione, un sistema di pittografie in sequenza, il cui senso risultasse intelligibile al destinatario. “Amore mio caro, il mio cuore è trafitto dal tuo pensiero lontano, e ti tendo le braccia insieme ai tre figli. Tutti in buona salute, io e i due grandicelli, indisposto, ma non gravemente, il piccino. La precedente lettera che t’ho spedito non ha ricevuto risposta e ne soffro. Tua madre, colpita da un male, si trova in ospedale, dove mi reco a trovarla. Non temere che ci vada a mani vuote; né sola, dando esca a malelingue: m’accompagna il figlio mezzano, mentre il maggiore rimane a guardare il minore. Il nostro poderetto, ho provveduto che fosse arato e seminato. Ai due “giornalieri” ho dato 150.000 lire. Si son fatte le elezioni per il Comune. Ho votato Democrazia Cristiana, come il parroco m’ha suggerito. Per la Falce e Martello la sconfitta è stata grande: come fossero morti, in un cataletto.
Ma che vincano gli uni o gli altri, è tutt’una. Nulla cambia per noi poveretti: abbiamo zappato ieri, zapperemo ancora domani. Molte ulive quest’anno, dai nostri ulivi. L’uomo e i due ragazzi che ho assunto, l’uno per bacchiarle, gli altri per raccoglierle a terra, mi sono costati 27.000 lire. Altre 12.000 lire le ho spese per il frantoio. Ne ho ricavato tant’olio da riempire una giara grande e una piccola. Posso ricavarne il prezzo corrente che è di 1.300 lire al litro.
Amore lontano, il mio cuore ti pensa. Ora, soprattutto, che viene Natale e vorrei essere insieme a te, cuore a cuore. Un abbraccio, dunque, da me e dai tre figliolini. Arrivederci, amore caro, il mio cuore è tuo e ti sono fedele, unita a te come i nostri due anelli”.
– Gesualdo Bufalino, La luce e il lutto

The calendar module in python enables us to print calendars on the terminal and other cool functions with the calendar.
Import the calendar module to access all these functions.

import calendar
The prmonth() method helps us to print a month’s calendar. It requires the year and the month in the form of integers as arguments.
import calendar calendar.prmonth(2001,9)
We can check whether a given year is a leap year by using the isleap() method of the calendar. This method takes a year as an argument and returns “True” or “False”.
If you think only dividing the year by 4 gives you a leap year, then you are absolutely wrong. A year is a leap year only if it satisfies the following three conditions:
So, instead of writing all these conditions, we can just use this method.

If we wish to know what day a particular date is we can use the weekday() method. This method takes a day, month, and a year as arguments. This will return an integer value from 0–6. 0 -Monday, 1 — Tuesday, … 6 — Sunday, and so on.
It receives arguments in the format of (year, month, day).

It returns 2 for April 4th, 2021 which is Wednesday.
We can print an entire year using the prcal() method. This method takes the year as an argument. We can also specify the column width and spacing in the arguments.


Data Visualization helps in understanding different patterns, associations, visual insights from the data, etc. It is important because it uncovers the mystery behind the data tables in form of charts, graphs, and plots. There are tons of python libraries that help in visualizing the data like Matplotlib, Seaborn, etc.
AnimatPlot is an open-source python library that is built on top of Matplotlib and is used for creating highly interactive animated plots. Now, we will explore some of the functionalities that AnimatPlot provides.
We will start by installing AnimatPlot using pip. The command given below will do that.
pip install animatplot

Animatplot is built on the concept of blocks. We’ll start by animating a Line block.
First we need some imports.
Interactivity is not available in the static docs. Run the code locally to get interactivity.
So, we will use JupyterLab for our simulations.
We will import the required libraries for creating animated plots.

We will animate the function:
Let’s generate the data:

In order to tell animatplot how to animate the data, we must pass it into a block. By default, the Line block will consider each of the rows in a 2D array to be a line at a different point in time.
We then pass a list of all our blocks into an Animation, and show the animation.


We’ll use the same data to make a new animation with interactive controls.
block = amp.blocks.Line(X, Y)
anim = amp.Animation([block])
anim.controls() # creates a timeline_slider and a play/pause toggle
anim.save_gif('images/line2') # save animation for docs
plt.show()

The above animation didn’t display the time properly because we didn’t tell animatplot what the values of time are. Instead it displayed the frame number. We can simply pass our values of time into our call to Animation.
block = amp.blocks.Line(X, Y)
anim = amp.Animation([block], t) # pass in the time values
anim.controls()
anim.save_gif('line3') # save animation for docs
plt.show()
Similarly, now we will add more data and create multiple plots in a single chart.


and once again:



L’insieme di Mandelbrot o frattale di Mandelbrot è l’insieme dei numeri complessi per i quali la successione definita da:
è limitata.
Nonostante la semplicità della definizione, l’insieme ha una forma complessa il cui contorno è un frattale.
Qui, la funzione per la costruzione della matrice da diagrammare:
def plotter(n, vallim, itlim, xi,xs,yi,ys):
image = np.full((n,n),0)
Xp = np.linspace(xi,xs,n)
Yp = np.linspace(yi,ys,n)
for x in range(n):
for y in range(n):
image[y][x] = divergetest(complex(Xp[x],Yp[y]),vallim, itlim)
return image
Di seguito, invece, la routine per verificare la convergenza della successione:
def divergetest(c, vallim, itlim):
z = c
i = 0
while i < itlim and np.sqrt((z.real)**2 + (z.imag)**2)< vallim:
z = z**2 + c
i = i + 1
return i
Il programma principale:
n = 5000
xi,xs,yi,ys = -3,1,-2,2
vallim = 5
itlim = 30
mandelbrot = plotter(n,vallim,itlim,xi,xs,yi,ys)
plt.figure(1,figsize=[8,8])
plt.title('Mandelbrot Set')
plt.imshow(mandelbrot,extent=[-3,1,-2,2])
plt.xlabel('Real')
plt.ylabel('Complex')
plt.show()
Di seguito, l’output del programma:

That is the problem:

We can solve the problem by writing a Python code.
Let’s start with a function that checks if the three numbers , with
, are a Pythagorean triplet.
def is_triplet(a,b,c): if (a**2 + b**2) == c**2: return(True) else: return(False)
Now, let’s move on to defining the main function:
def main(sum_value): for c in range(sum_value): for b in range(c): for a in range (b): if (a+b+c) == sum_value: if is_triplet(a,b,c): print(a,b,c) print(a*b*c)
and then, the main program:
sum_total = 1000 main(sum_total)
This is the answer:


Per un individuo abietto come Morisi, la droga potrebbe essere un’attenuante.

Guardommi, e mi rispose: “O mia sorella,
Vado a morir per la mia patria bella”.
Io poi buttai i miei occhi un po’ da fora,
né potei dirgli: “Che culo, oh mia Signora!”
[*]