Welcome to OmegaMath’s documentation!

🥠 Bayes Theorem

In the calculation of probabilities we can use Bayes’ Theorem by applying the following formula:

_images/formula.pngformula

Being B the event for which we have previous information An represents the different conditioned events The denominator of the formula simulates the total probability The numerator symbolizes the conditional probability Now, we will use a certain example to demonstrate how the Bayes Theorem formula applies, but instead of using, A1, A2 y A3 we will change them to A, B and C.

➖ Exercise 1

Suppose that a factory has three machines that produce containers where the orange juice they produce is poured, we will call these three machines A, B and C.

_images/photo.pngphoto

We are aware that machine A is capable of producing 50% of the total amount of packages, while machine B produces 30% and machine C only 20%. On the other hand, we also know that each of the machines produces defective packaging. As we know that machine A is the most efficient of all, it only produces 2% of the defective containers, machine B 3% of the total of imperfect containers and finally machine C that generates 5% of this type of containers.

P(A) = 0,50      P(D/A) = 0,02
P(B) = 0,30      P(D/B) = 0,03
P(C) = 0,20      P(D/C) = 0,05

Now let’s see how we can calculate the probability that a container produced by this juice factory is defective and we will apply the total probability formula. Being P (D) the probability that a container is defective.

P[D] =[ P(A) x P(D/A) ] + [ P(B) x P(D/B) ] + [ P(C) x P(D/C) ] = [ 0,5 x 0,02 ] + [ 0,3 x 0,03 ] + [ 0,2 x 0,05 ] = 0,029

If we express the result in percentages, we can say that the probability of a package being defective is 2.9%. Now, if we want to know when we obtain a defective container, what probabilities we have that it has been manufactured specifically by machine A, by machine B or by C. This is when we use Bayes’ Theorem, since knowing that a container is defective, we already have prior information. Now we only have to calculate the probability that it has been produced by which of the machines that exist in the factory.

P[A/D] = (P[A].P[D/A])/(P[D])=  [0,50 x 0,02] / 0,029 = 0,345
P[B/D] = (P[B].P[D/B])/(P[D])= [0,30 x  0,03] / 0,029 = 0,31
P[C/D] = (P[C].P[D/C])/(P[D])= [0,20 x 0.05] / 0,029 = 0,344

When adding all the results we should obtain the unit, representing all the defective containers, but we realize that when adding 0.345 + 0.31 + 0.344 = 0.999, which as we observe is almost equal to 1, we then understand that there is a minimum loss per the rest of the decimals not used in the summation.

On the other hand, when interpreting the results, we can conclude that the defective packaging has a 34.5% probability of having been produced in machine A, 31% of having been produced in machine B and 34.4% that it was produced on machine C.

It is important to emphasize that the summation term that exists in the denominator of Bayes’ Theorem, we calculate it in advance and call it P[D].

➖ Exercise 2

Let’s assume that 15% of the employees of a company are engineers, while 25% of the employees are economists. But 75% of engineering employees hold some managerial position, with respect to economists, 50% of them also have a managerial position. On the other hand, the rest of the managers who are neither engineers nor economists represent 20%. If we want to know the probability that a manager is an engineer, economist or any other profession, it is advisable to use Bayes’ Theorem.

_images/photo2.pngphoto2

To understand a little better we are going to make a tree diagram

_images/photo3.pngphoto3

P[Engineer / Executive] = (0,15 .0,75)/(0,15 .0,75 + 0,25 .0,5+ 0,6 .0,2) = 0,314
P[Engineer / Executive] = (0,25 .0,5)/(0,15 .0,75 + 0,25 .0,5+ 0,6 .0,2) = 0,349
P[Other / Executive] = (0,6 .0,2)/(0,15 .0,75 + 0,25 .0,5+ 0,6 .0,2) = 0,336

➖ Exercise 3

A certain factory has an alarm to alert about accidents and has only a 0.1 probability that an incident of this type will occur. Now, if an accident occurs, it has a probability of 0.97 that the alarm will sound and with a probability of 0.02 that the alarm will be activated even without any incident having occurred.

Suppose the alarm goes off at some point, what is the probability that the alarm has been activated without an accident occurring?

Let’s now determine the variables involved:

A = An accident occurs
NA = No accident occurs
S = Sound Alarm
NS = Do not sound alarm

Again we will make an enlightening diagram

_images/photo4.pngphoto4

P[NA/S] = (0,9 .0,02)/(0,1 .0,97 + 0,9 .0,02) = 0,157

As we can see, the probability that the alarm sounds without an accident having occurred is 15.7% As we can see, applying Bayes’ Theorem does not have major complications. But if after seeing each and every one of these exercises you have any concerns, please do not hesitate to ask, which I will gladly try to answer as soon as possible.

🧮 The Gauss-Jordan method to solve Systems of Linear Equations

Carl Friedrich Gauss was a mathematician and physicist born in Germany at 1777 and developed such a huge body of works in so many different fields, that any science student will find his name many times, within different subjects, up to a point of believing Gauss is just everywhere.

_images/gauss.jpgCarl Friedrich Gauss

Among all the contributions of Gauss to mathematics, we find a method for solving Systems of Linear Equations that is widely used now that computers can be programmed to do all the hard work. This method has the advantage of being easily programmable because it uses a sequence of repetitive operations once the equations are stored on the computer memory as an array of terms similar to a matrix containing the coefficients of each equation in one row.

The way Gauss solved the problem was by using some properties of Systems of Linear Equations to make changes in the matrix, changing the coefficients by getting equivalent equations which won´t alter the System. These changes can be:

  • A) Swap two of the rows, putting each one in the position of the other

  • B) Multiply every term in one of the rows (equations) by the same number different from zero.

  • C) Add or subtract each term in one of the rows (equations) from the corresponding term from another row, resulting in a new row which also belongs to the same equations system.

You can do any of these operations and the equation´s system remains the same, the solutions will be the same. Gauss thought a way to use this to convert the initial group of equations into one which would be easier to solve.

The Gauss method

The method is very ingenious and very straightforward too. Let´s show how he did it with one example; a 4 equation´s system with 4 unknowns (w, x, y, z):

_images/gauss01.jpgEquation 1

The matrix has as many columns as equations (and unknowns) as the system, plus one column because of the constant terms, so in this case, the matrix has 5 columns X 4 rows.

Gauss thought a good way of solving these systems was by “getting rid” of some terms, by making them zero, until he could get an equation with only zeroes except for one unknown and the constant term, making it very easy to find then the unknown. How to accomplish this?

We must remember the operations (A, B, C) we can perform without changing the system. Now let´s focus on the second equation:

w-4x-2y+2z=-5

The first unknown (w) is multiplied by the coefficient 1, not written. That´s why the first term on the second row of the matrix is 1.

How can I get rid of this unknown by making changes to this second equation? How can I turn this 1 into a zero so that the w just disappears from the equation?

Not the obvious idea, multiplying the whole equation by zero. If we read again the operation B as explained before, we find there it´s very clearly stated that we cannot multiply by zero. The other way would by adding -1 to the first term. The third operation we talked about before, C, states that we can add two equations belonging to the system, term by term, and the resulting equation belongs to the system too. So, if there would only be another equation in the system with -1 as first coefficient, we would only add this equation, term by term, to the second one and the first term would become just a zero, it would go away. But of course there is not this desired equation with a -1 multiplying w. Life is never so easy.

What was the solution Gauss found? Well, he thought of multiplying any other equation by a number which would turn it´s first coefficient into a -1. If we multiply every term of a linear equation by the same number, the resulting equation is equivalent to the original, just as stated on B.

If we do this with the first equation (3w - 2x + 3y + z = 12), the coefficient multiplying the unknown w, the first one, is 3 so, in this case, we would need to multiply the whole first equation, term by term, by a number which would turn a 3 into a -1. That number would be -1/3 so that the operation would go like this:

_images/gauss02.jpgEquation 2

Where the desired -1 is the first coefficient. We can add now this equation to the second equation of the system in order to turn it´s first coefficient into a zero.

_images/gauss03.jpgEquation 3

We can see that the first coefficient in the second equation is now zero, so it has now one less term.

The system of equations and the matrix of coefficients would now look like this:

_images/gauss04.jpgEquation 4

Now we are one step closer to get the solution for the system, since we have one equation with only three unknowns instead of four. Can we go on doing the same with more equations? Of course we can, and Gauss did exactly this for the third and fourth equations. His method gets rid of all the first terms except in the case of the first equation; you will always need at least one equation with the first term so that the value of w can be calculated.

Repeating the steps going down

So, after doing similar operations on the third and fourth equations, we get:

_images/gauss05.jpgEquation 5

Now the system, if we ignore the first equation, has only three unknowns (x, y, z) and three equations (second, third and fourth equations).

Once we grasp what we have done here, we can understand the whole method Gauss devised so smartly, because if we forget about the first equation and we repeat the previous process, leaving now the second equation untouched, and we modify the third and the fourth equations so that their first term (the coefficient for x) is zero, we will get a smaller system of equations with only two unknowns and two equations.

The Gauss method keeps shrinking the size of the equation´s system into smaller systems which are easier to solve. This is how the system of equations looks once it´s reduced to just two equations:

_images/gauss06.jpgEquation 6

This way we can keep reducing the size of the system until we get only one equation and one unknown, which is directly solved:

_images/gauss07.jpgEquation 7

Getting results and turning the tide to move upwards

So from the fourth equation we can get directly the value for z, our first result:

z=4

Up to this moment, the method works from top to bottom, getting our first result from the last equation but now the flow is reversed and we start moving upwards. Having the value for z, we can use it on the third equation (z=4 then 3z=12) getting:

-10y + 12 = -18

From where we can get directly the next result, the value for y:

y = (-18-12) / (-10) = 3

Then, having z=4 and y=3, we can continue upwards and use these values in the second equation in order to get the next unknown, x, and finally, we use these three results (x, y, z) in the first equation to get the last result, the unknown w.

Following this procedure, we have calculated all the results:

w=1 x=2 y=3 z=4

And this method can be used for any linear equation´s system no matter how big it is, how many equations it has, thanks to Carl Friedrich Gauss.

Some details to keep in mind when programming this method

When we were operating to turn the first column into zeroes, we left the first equation untouched, it was used to modify the other equations focusing on the first term of the first equation; this term we use is known as the “pivot”. Once we changed all the coefficients below this first term into zeroes, we moved down and used the second equation, leaving it untouched, to change third and fourth equation. We used the first non-zero term to change into zeroes all the coefficients below (second column) so in this case, this second term is the pivot. When we repeat the procedure using the third equation, the third term is the pivot, and so on.

_images/gauss08.jpgEquation 8

The matrix we have been showing on the right side of the system is a representation of how the coefficients can be stored on a computer to make all these operations digitally, by using a programmable version of this method, an algorithm. There are some details to keep in mind when designing this algorithm.

The element we use as a pivot cannot be a zero. To prevent this from happening, the usual procedure is using the equation which has the larger number as it´s first coefficient as the pivotal equation. We must remember that we can swap two equations from the system without altering the system, so before using the first equation to modify the others, we look for the equation with a larger first coefficient and swap it to the first row, then we proceed. The same happens when we will use the second equation, we compare it´s second coefficient (because the first one has been changed into a zero) with the corresponding coefficients on the third and fourth equations, and then swapping the one with the largest coefficient to the second row.

This same swapping should be done until all the lower-left triangle is full of zeroes, so that the last equation is ready to be directly solved. It´s a way to guarantee that each pivot will not be a zero.

The Jordan improvement

Wilhelm Jordan was a German geodesist born at 1842, and he was also a writer with an interest in mathematics and geometry. He worked on the method developed by Gauss and improved it while he was trying to use it on some surveying data. Later, he published his technique in his book Textbook of Geodesy.

_images/jordan.jpgWilhelm Jordan

To understand the work of Jordan, we must remember that the Gauss method turns into zeroes all the low-left triangle of the matrix. Jordan had the idea of keep using the same procedure on the top-right triangle, turning all these coefficients into zeroes as well, keeping only the terms in the diagonal, the pivots, so that each equation would have only one unknown, and then operating on those terms so that they would be changed into ones (1) and each equation would bring directly one result. We can better understand all this by looking at the system after the upper-right triangle has been changed into zeroes and the pivots in the diagonal turned into ones.

_images/gauss09.jpgEquation 9

In the equation´s system, we left the zeroed terms in order to make evident the correspondence of the equations with the matrix, but the usual way to write these equations would be simpler, not writing the null terms and not writing the number 1 when it is multiplying the unknowns, like this:

_images/gauss10.jpgEquation 10

By watching at the simplified equations, it´s really obvious why Jordan wanted to add these steps to the method of Gauss. Each equation is just the result for each unknown. Very elegant.

Though these methods were developed a long time before computers, it´s evident the authors wanted to develop an algorithm with simple and repetitive steps that would work even for large equation´s systems; it´s perfect for computers, the iterative process can be programmed and executed digitally in a very precise way just by introducing the coefficient´s matrix. As a matter of fact, this is how computers solve linear equation´s systems in the present, sometimes running the Gauss method and some other times the Gauss-Jordan variation.

We can only feel admiration for this kind of minds which, by sending their intelligence and wisdom through the centuries, can help us solve our problems today.

About The Author

Jorge Araica is a Graphic Designer with technical background, an old school pro with some knowledge in the engineering and programming fields and also a promotor of critical and rational thinking as a way to spread a scientific attitude towards knowledge. Freedom is his other passion, and he will stand for it at every opportunity he gets.

➗ Fermat’s Theorem And More Than Three Centuries Of History

In 1607, an illustrious jurist and mathematician named Pierre de Fermat was born in Beaumont de Lomagne (France).

Eric Temple Bell, a Scottish-born mathematics historian, dubbed Fermat “Prince of the amateurs.”

_images/fermat.jpgPierre de Fermat

Fermat was educated at the University of Orleans and made great contributions in the field of mathematics. One of the most famous tells the story is that the mathematical genius had in his possession a bilingual edition of the book “Arithmetica de Diofanto” (Latin and Greek), on whose pages and apart from each problem, Fermat wrote comments or more good math puzzles.

In the course of time, each of these riddles have been solved by personalities such as Newton, Leibniz, etc. but one of them remained unsolved and is the one that was written, around the content embodied in problem VIII.

Fermat’s note stated: “It is impossible to find a way to convert a cube into the sum of two cubes, a fourth power into the sum of two fourth powers, or in general any power beyond the square, into the sum of two powers. of the same class … “He also completed it with the following sentence:” … I have discovered for the fact an excellent demonstration. But this margin is too small to fit in it.”

_images/newspaper.pngNewspaper article

This puzzle was about the result of a number to “n” NO SE DICE ASI, as the addition of two numbers raised to “n”. In summary, what Fermat affirmed was that since “n” is an integer equal to or greater than 3, there would be no positive integers in this formula, where “x”, “y” and “z” fulfill this equality:

_images/equality.pngEquality

Nowadays, a large part of us and at some point in our lives, have used the Pythagorean Theorem, that famous formula that relates the length of the hypotenuse with that of the legs in a right triangle and where Fermat’s Theorem is applied for n = 2.

_images/right-triangle.pngRight Triangle

It is no secret to anyone that this equality is al reves, is equally true for all possible combinations and different numbers. But if we go further and ask ourselves what happens when n = 3? Will there be a numerical combination that by raising two numbers to the cube to the third power and adding them, we will obtain the cube of a third number as a result?

Suppose for a moment that we manage to demonstrate the above. What will happen to exponents greater than 3?

On the other hand, this annotation by Fermat was kept anonymous? for a long time and a great number of leading mathematicians have tried to solve this theorem without success. Reasons why, a lot of intrigue was generated around this riddle and for more than three centuries it was a true mystery.

GREAT MATHEMATICS PROVEN FERMAT’S THEOREM FOR SOME CASES

The first to make progress in this regard was Fermat himself, who managed to show that his theorem did work for the case n = 4 and for this, he used a certain variant of the principle of induction with the infinite descent technique.

Another important mathematician who made a great contribution was Leonhard Euler when he was able to prove Fermat’s Theorem for the case n = 3, although it is true that an error was later found in this proof. Other contributions pre-established by Euler himself, allowed to find the correct solution and that is why, it was considered in mathematical circles, that Euler had proved the theorem for this case.

Even by this failed proof, the certainty arose that some complex numbers behave differently from integers.

Sophie Germain

The next step was taken by mathematician Sophie Germain. Where she established Fermat’s conjecture for a specific case that expresses: If “p” and also “2p + 1” are both prime numbers. The Fermat expression determined for a power “p” would be fulfilled when none of the “x”, “y” or “z” were divisible by “p”.

Sophie Germain managed to prove the conjecture for every number “p” less than 100 and another mathematician named Adrien Marie Legendre, proved this case for all numbers less than 197.

But in 1825 it was when Legendre together with Peter Gustav, were able to generalize the proof from Euler, only for the case n = 5. Later LamĂŠ manages to prove the theorem in 1839 for when n = 7.

Many years later (1955), two Japanese mathematicians argued that all elliptical curves, although they were of different shapes, could be considered as camouflaged modular shapesm?. They were called: Goro Shimura and Yutaka Tamiyama.

But they ran into the problem that to confirm or disprove this conjecture, there are an infinite number of different elliptic curves, so proving that every possible elliptical curve has a similarity to some modular shape was simply an impossible task.

It was not until 1982 when a mathematician named Gerhard Frey came up with the idea of ​​comparing elliptic curves as a solution to Fermat’s Theorem, by means of the following formula:

y ^ 2 y2?= x (x-ap) (x + bp)

However, in theory, this elliptical curve did not have an associated modular shape and therefore, only one of the two conjectures could be true, since they contradicted each other. So if there was an elliptical curve that corresponded to Fermat’s Theorem, we could assume that all elliptic curves would not necessarily have an associated modular shape.

Discovering which of the two propositions was the correct one would indirectly lead to solving whether Fermat’s Theorem was true or not, since if a way was found to know if for each possible elliptic curve there was an associated modular form, as had been proposed by the Japanese Tamiyama and Shimura. There would then be no elliptical curve that would correspond to Fermat’s Theorem.

Andrew Wiles

This mathematician born in 1953, encountered Fermat’s Theorem for the first time at the age of 10, in a book that dealt with this dilemma, in a bookstore that was on the way home from school. The theorem shocked him since despite its simplicity, even he could understand it at such a young age, but at the same time it was so complex that no one had been able to solve it three centuries after its promulgation. Even a large number of illustrious mathematicians claimed that it could not be solved.

At that time, Wiles had full knowledge that his mathematical abilities and skills were not enough to try to solve the riddle, so he forgot it to return to it in 1986.

_images/fermat-equation.pngFermat's equation

Credit: Charles Rex Arbogast / AP

Andrew believed that the secret to solving this conjecture was in geometry and specifically in achieving a mathematical representation of all elliptic curves. In addition to comparing them with their associated modular forms, but he also knew that these are abstract and symmetric functions, found in the plane that represents imaginary numbers.

Following his belief, Wiles developed a mathematical method that allowed him to compare each of the infinite elliptical curves, with the also infinite modular shapes, but obviously without the need to compare them one by one. This titanic work took him 7 years of work.

During these 7 years, Andrew Wiles did not tell anyone about his secret project, because he thought that no one would take it seriously and after this period of time, the persevering mathematician showed his colleagues the solution to Fermat’s conjecture. Thus he managed to summarize in numbers and letters, more than 350 years of attempts to solve the mystery.

He presented his proof in 1993 and had to go through the usual review process, to check his theory. However, in August of that year they realized that their hypothesis contained an error that was in one of its sections, which of course, greatly disappointed the poor mathematician.

Only he failed to daunt him and spent the next year trying to fix the flaw and just when he was about to abandon the search, he managed to solve it.

For the month of September 1994, Wiles managed to finish the last test and was able to confirm what Fermat said, whose validity had not been demonstrated since his proposal in 1642. This heroic feat led him to win the Abel prize for mathematics and together with he got nothing more and nothing less than $ 700,000.

If we reflect on the path of the immense effort and the complicated mathematical tools that important specialists in the area have used, to demonstrate this conjecture raised by Fermat. Also comparing them with the small note written in 1642 by the illustrious mathematician in the margin of a book, where he clearly stated that he did not have enough space there to prove it. We cannot help but wonder if Fermat had proposed a very elegant and simple solution to his theorem, in which he outlined that there should be no exponent greater than n = 2, for the equality to be fulfilled.

Although it is true, that Fermat himself tested his conjecture for the specific case when n = 4. It is no less irrefutable than the theorem at that time, it was not verified for all the remaining values greater than 2 and this fact is so relevant that Fermat never wrote about it again, in his remaining 30 years of life.

This incredible story has permeated even TO the general public, even those unfamiliar with mathematics. To such an extent that from time to time, references to the theorem appear in popular culture.

One of the most curious examples is a scene that appears in the series “The Simpsons”, in which Homer is in front of a blackboard, where we can appreciate the following equality:

398712 + 436512 = 447212

If we realize it, this formula coincides with the case n = 12 of Fermat’s Theorem:

x ^ 12 + y ^ 12 = z ^ 12

_images/fermat-homer.pngHomer Equality

The curious thing is that if we do the test in any calculator, we will realize that the equality is fulfilled. So Homer could have found a perfect example, capable of contradicting Fermat’s conjecture and Andrew Wiles’s later proof, right?

The reality is that this formula that appears in the series is nothing more than a mere illusion. Since in this case, the numbers are so immensely large that they do not usually fit on the screens of common calculators and the difference is so small, that somehow they are hidden, precisely those numbers that cannot be shown on the screen. In fact, the Gaussians can demonstrate the calculations in detail and we will be able to realize that in effect, the formula is not fulfilled and therefore, Fermat effectively continues to be right in the statement of his theorem.

🆚 Frequentist versus Bayesian statistics

For the nineteenth century the main entertainment of the members who represented high society, were games of chance. Among them was an expert gambler named Antonie Gombaud, known as the Knight of MerĂŠ, and he approached Blais Pascal (a French philosopher and writer born in 1623) to pose two problems that were on his mind, regarding gambling.

Both Pascal and Pierre Fermat were maintaining a great and fluid correspondence around both problems. Thanks to the solutions found by these great characters in history, the foundations were laid on game theory and the calculation of probabilities. From there came a myriad of applications that are used today.

_images/pascal.pngpascal

_images/fermat.pngfermat

Without knowing it, between the two of them they had created a very powerful tool of interpretation, organization and information for making optimal decisions and from that moment on, the expectations of rolling the dice again have never been the same. Finally, through the beginning of probability, the outcome of the bets could be predicted with a greater degree of accuracy and thus be able to get more out of them.

_images/dice.pngdice

For example, if we have two dice, one white and one black, what are the probabilities of obtaining the result of the sum of the points of both dice?

_images/dice2.jpgdice2

As we can see we can obtain a minimum of 2 points, therefore we can never have 1 point or less and we will have a maximum of 12 points, we will never have 13 points. After counting each and every probability, we can obtain the following distribution table.

_images/table.jpgtable

Later Thomas Bayes, a Presbyterian minister and English mathematician born in 1702, creates a theorem that bears his name “Bayes Theorem” where he introduces the probability that an event occurs, but taking into account another event that occurred in advance. For example, if, in general, every time we have the flu, we get a headache, we may come to think that if we have a headache, it is likely that we have the flu.

_images/formula.jpgformula

As we can see, it is to understand the probability of obtaining a result, according to the observation of the causes that generated it. This is called “inverse probability”, since the direct probability based on classical or frequentist statistics, measures the probability through the frequency with which the expected events occur, based on the amount of results obtained when applying a certain procedure.

The followers of Bayesian analysis affirm that the importance of this tendency lies in drawing general conclusions, but from what has been observed previously and not vice versa. Bayes raises the vision of probability by entering the subjectivity of the observer and how he can change his judgment according to new information or additional evidence that is presented in the way of the investigation.

However, statistics evolved in the most empirical way and based on measurements where subjectivity and intuition were put aside, therefore, the most used statistic throughout the 20th century has been the frequentist. Of course, it became much more established with the appearance of software and computers, where this type of process could be carried out in a more expeditious manner.

As we all know “statistics don’t lie”, but something was actually missing: For example, suppose that two people want to share a roast chicken, the common thing is to think that each of the diners gets half a chicken; but that does not necessarily imply that both have been satiated, since it may be that each one has not eaten exactly half, it is even probable that one of them has eaten the whole chicken, while the other only dedicates it to observe.

On the other hand, when we talk about the probability of contracting AIDS or cancer, we can understand that population statistics are not very useful to us, since we must take into account not only lifestyle habits, but also genetic parameters. For this reason, it is becoming increasingly evident to use Bayesian analyzes that are adapted to reality.

In fact, this type of statistics has been shown to be much more effective when it comes to dealing with the social sciences and some matters of econometrics, where certain less scientific parameters such as feelings, philosophy and human behavior must be taken into account.

Another advantage that Bayesian statistics offers is that it does not necessarily depend on the size of the sample, although for obvious reasons, the larger this sample, the more accurately we can assess the conclusions we have regarding reality.

The other diatribe posed to frequentists is that their tests focus on affirming or refuting their hypothesis, instead of emphasizing the belief in their hypothesis and the correlation that exists with the empirically analyzed reality. While Bayesians do emphasize precisely the credibility of their hypothesis and are not forced to choose between black and white.

Due to the aforementioned, Bayesian statistics can work in a study where we cannot obtain a large sample, without distorting the results, since not only the previous data are taken into account, but also the new events that are taking place; in addition to the subjectivity of the researchers themselves with respect to how reality can behave according to their analysis.

Giving a much more enriching framework and leaving a greater degree of freedom to the researcher, so that with his knowledge, he can get to assess the probability that the results determined in advance will occur.

However, a hypothesis is required to be able to interpret the results to be obtained and an estimated probability must be established before carrying out the study. Subsequently, the Bayes factor is used, which is nothing more than a measure capable of comparing the data obtained in the investigation, with respect to the proposed hypothesis.

The Bayes factor is applied to the set of probabilities that are established in advance according to the hypothesis, to calculate the highest probability of the data that is expected to be obtained, after the investigation is carried out. It is important to propose the hypothesis that has the highest degree of certainty, in order to verify the data obtained with the greatest possible measure of correctness.

We will then show 3 types of hypotheses to be verified: Association, correlation and mean difference.

We can show that the Bayesian hypothesis is more acceptable than the classical one, based on a study that was done in this regard. For this, the 3 types of hypotheses mentioned above were used and studies were simulated with respect to the contrast between the association, the difference of means and the correlation.

For each of these hypotheses, it is demonstrated how both the Bayes factor and the posterior probability can be interpreted, including how authentic the hypotheses are according to the results obtained in an investigation. Of course, taking into account whether the previous expectations regarding the results obtained after the study are met.

Suppose that we are going to start with a medical investigation, as it happens in any other scientific field, the idea is to compare the different relationships that can be proved, whether causal or not, taking into account the proposed hypothesis. For this, the results of the data that we cannot take as a sample are extrapolated with those data that we do obtain from the participating population.

One of the most frequent examples in this field is to demonstrate whether a drug is more effective than those on the market, either to cure a disease or ailment. In order to verify this hypothesis, empirical data is required from those participants, who have been treated with one of the two options that have been considered in the evaluation.

The evidence will show which of the two drugs is more effective for the treatment in question. But the data obtained can be extrapolated to treat other patients who have not participated in the aforementioned study, this is what we call inference. It is no secret to anyone that no investigation can take into account each and every one of the factors involved and therefore, the predictions of the results cannot be exact. Reasons why, the results should be shown as estimates based on probabilities and using extrapolation, which in turn will depend on the assumptions chosen and the measurements thrown during the study.

Of course, the science that supports the purpose of the research is statistics and from time immemorial, two proposals were established to generate these inferences, which are Bayesian and frequentist statistics.

To establish the difference between both methods, in classical or frequentist statistics, the probability is measured through the frequency with which the expected events occur, based on the number of results obtained when applying a certain procedure.

For example, if we obtain 0.5 as a result, we can conclude that 50% of the time the expected event was obtained. While in Bayesian statistics, the probability has to do with the degree of belief of the result that can be obtained in reality, for example, for the same value of 0.5 it is interpreted as 50% of the certainty that was obtained with respect to something.

Hypothesis testing

A hypothesis is a presumption about reality and is usually presented as a feasible forecast, that is, based on the theoretical arguments that we have before conducting our research. Now, when we speak of statistical hypotheses, we refer to those that can be verified by mathematical methods, specifically we refer to probabilities.

Although it is true that when conducting both medical and other research, we may find ourselves with the need to contrast more than two hypotheses; It is advisable to consider only two, in order to facilitate the study of a single assumption and not lose ourselves in a compendium of multiple unknowns. In general, a null hypothesis and an alternate hypothesis are established.

When we refer to the null hypothesis, it is to establish a conjecture capable of predicting that there is no difference between the analyzed variables; while the alternate hypothesis does predict a difference between them.

The way to test these hypotheses will depend on the type of statistics that we intend to use. In case of applying the frequentist statistic, only the null hypothesis is checked and for this, random distribution models are developed taking that null hypothesis as true, so that the aforementioned distribution is centered on the null value as its highest probability.

From there comes the value of “p” defined by Fisher, which is responsible for determining the compatibility between the estimated value that can be observed in a study, with the null value.

_images/fisher.jpgfisher

In other words, “p” is the probability that a previously measured statistical value will be taken as possible, but taking into account a certain null hypothesis.

This value summarizes the probability of seeing a data with its most extreme values and therefore, as the probability of being equated with “p” decreases, the less compatibility it will have with the null value and the variables that influence can be deduced, for that this result is so different from “p”.

However, until the contributions of Pearson and Neyman, a limit value had not been established to know if the difference between the values was large enough to deny the hypothesis.

_images/neyman.jpgneyman

That is why both introduced the PSEHN value, where they established that a null hypothesis can be rejected if “p” is less than the error set at 5%, that is, if p <0.05. This way of establishing a maximum value of “p” helps us to differentiate those sampling results that are a product of chance, from those that are statistically significant.

_images/distribution.jpgdist

Although it is true that frequentist statistics has predominated throughout history, in more recent years Bayesian statistics have been taken up again, since many errors have been made when interpreting the value of “p”. They have even inappropriately used the statistical meaning of the null hypothesis, that is, the PSEHN value and that without naming other multiple advantages that Bayesian statistics can offer you.

🥇 Fibonacci series

The Fibonacci series, the Phi number and how they manage to describe the universal proportions, which are part of the world around us

Leonardo de Pisa was an Italian mathematician, who has been better known throughout the world as Fibonacci. This mathematician discovered a sequence commonly known as “The Fibonacci series”; he came up with this idea when calculating the number of rabbits that could be obtained over the period of several months, after inducing them to breed.

Suppose that at the beginning of the first month we have a pair of newborn rabbits. Therefore, we have one (1) pair of rabbits that will take a month to develop enough to be able to pair. So at the end of the first month, we can already cross this pair of rabbits, and we will have 1 + 0 = 1 couples, the same pair of rabbits, because they have not yet procreated.

Now, at the end of the second month the first couple gives birth to a second pair of rabbits, and the first pair pairs again, but (of course) they have not yet sired them and in this case we will already have 1 + 1 = 2, to a couple of pairs rabbits.

By the end of the third month, the first pair of rabbits gives birth to a third pair, while the second pair is turning one month old, and they come together to pair, only that the first pair crosses again. In this case, the first pair already had two pairs of rabbits. Therefore, the number of rabbit pairs for this month will be: 2 + 1 = 3

If we follow the succession, at the end of the fourth month, the first pair of rabbits will have already produced three pairs of rabbits, while the second pair will already have had their first pair of rabbits. We would then have that the number of rabbit pairs would be: 3 + 2 = 5.

If we continue doing these calculations, we would have that, if we start with the numbers 1 and 1 + 0 = 1 and add them both, it would give us the number 2 as a result, so that:

  • 1 + 1 = 2

  • 1 + 2 = 3

  • 2 + 3 = 5

If we continue adding the last result with the previous one, we can obtain the rest of the series. So we can continue building the sequence, always with the sum of the two previous results:

  • 5 + 3 = 8

  • 8 + 5 = 13

  • 13 + 8 = 21 and so on

_images/fibonacci1.jpgFibonacci sequence

How this sequence influences the explanation of certain proportions in nature

This type of mathematical pattern is found in countless examples within nature. For example, the number of petals a flower has almost always matches a number in the Fibonacci series. While it is true that some flowers have 3 petals, you will find others that have 5 petals, while some will have 8 and you can even find flowers with up to 13 petals. But in very few exceptions, you will find a flower with a number of petals that does not match a Fibonacci number. That is, with 4, 6, 7, 9, 10 or 11 petals.

The numbers that belong to this series are presented in a big part of the world that surround us.

In the year 1753 a Scottish mathematician named Robert Simson discovered that the quotient of two consecutive numbers in the Fibonacci series always tends to be closer to 1.6180339. The result will always be alternatively, a number somewhat above and later, another a little below 1.6180339, but yes, without reaching it absolutely.

The number to which the relationship between two successive numbers of this same series converges, was called the golden number, which in addition to being irrational, is denoted by the Greek letter Phi.

If you notice how the seeds that are in the center of any sunflower are arranged, you will notice that each seed is at a certain angle with respect to the previous one, which corresponds to approximately 137.5Âş.

You can obtain this same angle by multiplying the decimals of the Phi number by 360Âş, and you will obtain an angle greater than 180Âş. If we take the complement of this angle, it will give us as a result 137.5Âş which coincides with what we call the golden angle.

This allows the seeds to have the optimal filling, that is, the same space between one seed and another. Resulting in a distribution of seeds from the center to the periphery and completely covering the area, in the most suitable way possible. This is how the new leaves that are generated in the sunflower do not block the sun from the previous leaves and also cover the maximum of the surface, thus managing to receive as much rain as possible. This same phenomenon occurs with the leaves of an artichoke.

But, this does not end there, if you count the spirals that form in the center of a sunflower, you will realize that there are 89 spirals in one direction and 55 in the other; they can also have 144 and 89, where again these three numbers belong to the illustrious succession.

Trees do not escape this analogy, since if you look closely at the angle that is formed between two consecutive branches, you will realize that they have an angle of approximately 137.5Âş between them.

The succession created by Leonardo de Pisa is also related to the so-called golden spiral, which is generated by drawing a series of adjacent squares, the sides of which are made up of the terms of the Fibonacci series. The spiral is formed by the arcs of circumference, which are formed by the radii of the sides of these squares.

_images/fibonacci2.jpgcephalopod mollusk

If we look at the shell of the nautilus (cephalopod mollusk) we can see the similarity with the golden spiral, only that instead of forming the spiral with the sides of a square, it is formed with equilateral triangles. Both spirals differ in the opening, but in both cases they have the same length to generate the first polygon.

_images/fibonacci3.jpgShell _images/fibonacci4.jpgSpiral Drawing

Not satisfied with the similarities described in advance, we can also note that equivalent spirals are present in certain galaxies and hurricanes.

_images/fibonacci5.jpgGalaxia final _images/fibonacci6.jpgHurricane

The Fibonacci series and the golden ratio in art

Great music composers in the 20th century, such as Olivier Messiaen, Delia Derbyshire, BĂŠla BartĂłk, and the band Tool, used this famous succession to invent new structures for their musical chords.

This Phi number has been directly involved in art for thousands of years. Since it also interferes with the ideal proportions of certain ancient architectural structures.

This is because again the Phi number is also obtained when we divide a line into two certain unequal parts. If we take the quotient of the longest part and the smallest part, it will end up being equal to the total length of the line divided by its longest part. That is to say:

a / b = (a + b) / a

Where “a” is the longest part of the line and “b”, the shortest. We can see that the Pyramid of Giza has a length of 230 meters on each side of its base and its height is 146 meters. The relationship between the two measures is approximately 1.575, which, as we can see, is quite close to the golden number.

Those numbers can be applied to the proportions of a rectangle, called the golden rectangle, considered one of the most visually satisfying geometric shapes.

Even the famous mathematician and sculptor Phidias, born in 500 BC, is believed to have applied the Phi number to the design of the sculptures in the Parthenon.

On the other hand, a Franciscan friar named Luca Bartolomeo de Pacioli was an economist, accountant, mathematician and highly recognized for being one of the forerunners of probability calculus. This friar published a book on mathematics in 1509 called “De divina proportione”, which was illustrated by none other than Leonardo da Vinci. There he claimed that “Without mathematics there is no art” and this compendium of writings, only intended to reveal the secret to the artists about harmonic forms, using the golden ratio as the main tool.

In fact, Leonardo da Vinci himself, through what he called the “sectio aurea”, defined the ideal symmetry in his paintings such as “The Mona Lisa”, “The Last Supper” and “The Vitruvian Man”.

_images/fibonacci7.jpgLeonardo Da Vinci

Da Vinci claimed that the ideal proportion of a person is closely linked to the quotient between the measurement of his height and the distance from the ground to his navel, since for a harmonious human being this relationship tended to Phi. In the same way, this number was repeated in an approximate way with the relationship between the distance between his fingers to his shoulder and the measurement from the elbow to his fingers. In fact, “The Vitruvian Man” was designed with these proportions.

As if that weren’t enough, this sequence has multiple applications in mathematics, computer science, and even game theory. A mathematical curiosity is to add ten consecutive numbers chosen at random from the famous series; You will notice that the result of the sum will always be a multiple of 11. As we can see, that the Fibonacci series is full of mathematical anecdotes, which can fascinate anyone who delights in this type of event.

🪙 Numeral Systems

Before the invention of writing, humans spent a good deal of time developing the first attempts of civilization by settling in convenient places, selected because of water sources, good soils for agriculture, abundance of animals for hunting or climate. These small human groups started growing and relationships changed from tribal societies to small town complexities, making it necessary to develop some ways to control quantities. They needed to count people, food, animals, days, distances etc.

No doubt, the first ways used to count (after the obvious use of the fingers) involved small pebbles. As a matter of fact, the word “calculus” originally means “small rock”. The first approach to this way of representing quantities was probably a “one-to-one” relationship between the rocks and the numbers, so to register the number 50 you needed 50 small rocks. Not very practical but thinking about this from our advantage position in the XXI century is not fair. To develop a better numeral system requires a good deal of ingenuity, to a point that some humans groups never did it.

Even in the present days, there are some isolated tribes which have not numeral systems. The Piraha tribe from Brazil just don´t have any word for the numbers, they just have concepts for small or large (one bird is a small bird, several birds are a large bird), and they just reject the possibility to learn about quantities, they say then don´t need such a thing. The Vedda tribe, at Sri Lanka, and the Caquinte tribe at Peru, have only numbers for one and two. For greater quantities the use something like “one more” or “many”. The Munduruku people, an Amazonian tribe, has numbers only up to five, so let´s not assume that it´s an easy task to develop a practical numeral system.

Humans started counting by using their fingers. The word “digit” has its origin in the Latin for finger, “digitus”, and that´s the reason why so many cultures developed numeral systems with a basis on the number ten. Nevertheless, 10 can only be divided by 2 and by 5, so it´s not a good number when it comes to divisions into smaller parts. Twelve is better in this department, so it´s frequent to use dozens, and when more divisions are useful, 60 and 360 are great; 60 can be divided by 2, 3, 4, 5, 6, 10, 12, 15 and 30, and when large quantities are involved 360 has all the same divisors as 60 and many more, and it has another advantage: 360 is very close to the number of days in a year, so it can even be used as the basis for a primitive calendar. Primitive Persians had a 360 days calendar, 12 months of 30 days, and every six years they would add a ritual additional month to keep the years synchronized with the stars and the change of seasons. The ancient Egyptians had a similar calendar. Obviously, they liked the 360 number because how easy it was to get exact subdivisions.

A hard decision

The first numeral system we find at the dawn of history is the Sumerian, just like the first samples of writing were found on the same area. Sumerian civilization was very advanced for it´s time, so it´s no surprise they had a sophisticated development of mathematics and astronomy. What numeral system did they embrace?

Well, apparently the decision was so hard they just didn´t decide. They used both the 10 and the 60 in a very convenient fashion. They represented the numbers in an additive way (much like the Roman numeral system, centuries later). It means they added numbers to represent quantities, and these numbers they used were only 1, 10, 60, 600, 3600, each represented by a different “token”, like small pebbles made with clay. Number 1 was represented by a small cone of clay, number 10 by a little ball, 60 by a large cone, 600 was represented by a large cone with a hole on it, 3600 by a large ball and when the large ball had a hole it represented 36.000.

_images/numeral-1.jpgSumerian Tokens

We can see that this system can represent a number like 683 without the need of 683 tokens; they just needed 7 tokens. It was a great improvement over direct relation, a magnificent idea, to assign different values to different tokens and, to represent any number without an assigned token, you just add as many tokens as needed. This system is known as an additive system and it was used by most civilizations for the longest part of our history. Europe used the Roman system until the XIV or XV centuries.

The Roman numeral system

The Roman numeral system is derived from the Etruscan system. Etruscan people inhabited the Italian peninsula before the VIII century B.C. and around 750 B.C. Rome was founded. Romans developed the Latin alphabet and adapted the Etruscan numerals using these characters. They assigned the “I” to number one, “V” to number five, X to number ten, “L” to number 50, “C” to number 100, “D” to number 500 and “M” to number 1.000. These symbols worked in an additive way, and the bigger number should always be written to the left; the smaller numbers should go to the right, and when a smaller number was written to the left of a bigger number, it was not to be added but subtracted. So “VI” means six, but “IV” means four.

This Roman system was very useful, but it had the inconvenience that arithmetic operations were too complex, and large numbers required too many symbols to be written. This fact can be observed in the present because Roman numerals are still in use for some specific applications, like in classic style clocks, chapter numbers in some books or when they register the year when a movie was made. Usually when we watch a movie, at the end of the credits list, the year makes its appearance in Roman numerals, and we can see how hard it is to make this large list of letters into a number. For instance, the 1988 classic, “Who Framed Roger Rabbit” shows this at the end of the credits: MCMLXXXVIII. When you have figured out the first 4 characters, the credits scrolling is over.

What kind of advance in the conception of the numeral systems was necessary to represent large quantities with just a few characters, and on the other hand, to make arithmetic operations easy and straightforward? Additive numbers were not enough, more consistency was needed. If you were to add two numbers, you would need to put one on top of the other and operate one character at a time, but when using Roman numerals, this way of adding up produced confusing results, not consistent with the inherent rules of Roman numerals. The same happened when subtracting, and if we tried to multiply or complete a division, operations became a nightmare.

The solution had been in use since around the V or VI century at India, possibly inspired by an older Chinese system. Two important advances made the difference.

A) Positional numeral values: It means the value of a character is not always the same, it depends on its position. The basis of the positional numeral system is the number of different characters or digits the system uses (like 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 in our decimal system which has its basis on ten and have ten different digits), and the positions of the digits means they will be multiplied by different powers of the base number.

B) The invention of zero: The positional system cannot work properly without some way to fill positions which should not be added. The first character used at India to fill positions which didn´t represent any quantity was just a dot. It was the first character for zero.

What does it all means? Let´s see it in more detail.

The power of Powers

Using increasing powers on the base number has the advantage that powers grow very fast when you raise them.

  • 100=1

  • 101=10

  • 102=100

  • 103=1.000

  • 104=10.000

  • 105=100.000

  • 106=1.000.000

Only by reaching the sixth power of ten, we are in the zone of millions, not bad. Can we use these powers to represent any number? Yes, of course we can, this is when the other digits enter the ballroom. Remember we used 7 clay pebbles to write down the number 683? We can see that our decimal system only needs 3 digits to write it down: 6-8-3. Let´s see how it works.

_images/numeral-2.jpgPositional Values

This is how we use powers of ten to represent any number in our positional system; the exponents for each position grow from right to left (2, 1, 0), this is why the digit 8, second position, multiplies 10. Ten is the second power of 10 (101) since the first one is 1 (100). It means the numeral 683 contains 8 tens. The complete meaning for 683 would be 6 hundreds + 8 tens + 3 units.

This way we can write down any number, no matter how big. If we need to represent the population of India (1.380.004.385 people), we do it like this:

_images/numeral-3.jpgPositional Values

Where again, the numbers in the first row, going backwards from 9 to 0, are the exponents, and in the second row we have the base number, ten, raised to the exponents.

The third row shows the digits which represent the number, the population of India, and the fourth row shows the results of multiplying these digits and the powers of ten. By adding up all the numbers on the fourth row we get the total number.

1.380.004.385 = 1.000.000.000 + 300.000.000 + 80.000.000 + 0 + 0 + 0 + 4.000 + 300 + 80 + 5

The importance of Zero

In the previous example, we can notice the total number has three zeroes in the positions for tens of thousands, hundreds of thousands and millions. It means these powers of ten are not needed to represent our total number, the population of India so these positions should be “empty” but, if we had no zero to be used in these positions, the number would look like this:

1.384.385

Only 1.38 millions instead of 1.38 thousand of millions!!

So, the zeroes are important to keep track of the positional value of each digit. This idea of a digit representing “nothing” is what the Romans didn´t think, it would have helped them develop a better numeral system. Zero was in the first place used at China by the 4th century B.C. and one century later at India, but to develop a complete positional system including zero the Indians took as far as the fifth century A.C., the beginning of western middle ages.

All through this time, western civilization had been using Roman numerals. By 813, a Persian astronomer published some astronomical tables using zero, and by 976, an Iranian author explained how to use zero when doing arithmetic operations. This way, he said, the rows can be kept in order.

The decimal system reached Europe through Spain, which was occupied by Arab people by 11th century. This is why we know the decimal digits as “Arabic numerals”. An Italian mathematician, Fibonacci, did his best to make the Arab system known and by the 15th century it was commonly used by mathematicians, but regular people didn´t embrace the system until one century later.

Other numeral systems

We are so much used to live with the decimal system that it´s very easy to think it´s the only numeral system, we count with our 10 fingers, and we operate with the 10 Arabic digits. Nevertheless, when we study mathematics it´s common to have some lessons on numeral systems and how any number can be used as a base, not only ten; but even in this case, we hardly come back to this subject, a simple curiosity.

We use other numeral systems as well, without giving it too much thinking, when we count time (hours, minutes, seconds) with roughly a base 60, or when we measure angles (360 degrees, base 360). But it was the invention of computers which gave a huge importance to other numeral systems. Computers don´t use 10 digits, not at their very core. Computers use electronic components which only can have 2 possible states: On-Off or 1-0. So the whole arithmetic system inside computers needs to have only two digits, a base 2 system which we know as the binary system. It works exactly in the same way as the decimal system, but the base is 2, and we work with powers of 2, and only 2 digits: 0 and 1.

Let´s see how it would work when applied to the number we used before, 683.

_images/numeral-4.jpgPositional Values

We can see that the binary (base 2) digits for this number are 1010101011, and this is how a computer ultimately stores numbers. Number 2 is the lowest one which can be used for a numeral system, and a memory position inside a computer which stores a 0, or a 1 is the smallest piece of information, and it has received the name Bit.

Usually, computers use groups of 8 bits to define characters or instructions, so these groups of 8 bits are known as Bytes.

Octal and Hexadecimal

There are two more important numeral systems related with computers. Back in the 1960´s there were some primitive computers, like Univac or the IBM Mainframe which used for some operations a base 8 numeral system (Octal system) because of the way they packaged groups of bits. Since Octal system has base 8, it only uses 8 numerical symbols: 0, 1, 2, 3, 4, 5, 6, 7

In the present days, computer programmers use another numeral system, Hexadecimal (base 16). This system was selected because 16 is a power of 2 so in a way, Hexadecimal keeps a relation with binary system. Groups of 4 bits correspond to one Hexadecimal digit so, in certain cases, using Hexadecimals can make it easier to read information than a long list of ones and zeroes.

Being the base 16, we need 16 different numerical symbols, and the convention dictates we use numbers from 0 to 9 plus A, B, C, D, E, F.

Any number below 10 is represented the same in decimal or Hex, but if we want to write down ten in Hexadecimal, we use A. B is for eleven, C is for twelve, D is for thirteen, E for fourteen and F for fifteen.

Sixteen is represented as 10 in Hex system. Let´s see how the same number we used before can be represented in Hexadecimal system.

_images/numeral-5.jpgPositional Values

Then, we can represent 683 with only 3 digits: 2AB

Hexadecimal system is one we will find frequently in programming literature because it´s a very short way to write down long binary numbers or lists of bits. Memory locations, media access control addresses, codes for error messages are some examples of information expressed in hexadecimal; also colors on the screen or all the different characters that can be displayed or printed.

As we have seen, there are countless ways to count but the more efficient, coherent and useful for arithmetic operations are the positional systems which include zero. This number we all take for granted, it looks so obvious today that we forget it took about 20 centuries to evolve and travel from ancient China and India to the Western civilization.

Next time you buy a wristwatch, don´t bee fooled by the idea that watch spheres with Roman numerals are more elegant. There is nothing more elegant than the clean efficiency of positional systems, and the use of zero.

About The Author

Jorge Araica is a Graphic Designer with technical background, an old school pro with some knowledge in the engineering and programming fields and also a promotor of critical and rational thinking as a way to spread a scientific attitude towards knowledge. Freedom is his other passion, and he will stand for it at every opportunity he gets.

🖥️ 🔢 PYTHON AND MATH

Throughout contemporary history and since the birth of technology as we know it, it has provided education with innovative tools, which has made it possible to significantly improve teaching processes. Despite the fact that some mathematicians were antagonistic to the use of programming languages, because according to them “the pure essence of mathematics is lost”; In the last 20 years, the mathematical society has proven the great help that the use of computational tools supposes for its work. In addition to this, the use of programming languages such as Python has proven to be beneficial when carrying out specific applications in areas of science such as Physics, Chemistry or Biology; since, the capabilities of Python allow to perfectly model mathematical behaviors in the aforementioned sciences.

Additionally, many researchers have carried out scientific studies to verify how programming affects the teaching of mathematics; where it has been concluded that the use of a programming language such as Python would result in an essentially positive stimulus in the basic stage of education since it would provide the following benefits:

  1. Development of reasoning, facilitates the learning of mathematics and the ability to solve problems. It even helps with language-related subjects.

  2. It favors the creative process since, imagining a project, investigating how to carry it out and structuring it so that it works, inherently involves the development of the imagination.

  3. Increase self-confidence and self-esteem by seeing how what you work on is paying off.

  4. Stay focused. Helps in the development of skills such as logic.

  5. promotes teamwork. By seeking help from colleagues and forming support groups to solve the problems raised.

But how much math do I need to know to learn programming? This disturbing question arises in the consciousness of most people and despite popular conception, mathematics is not used much in programming. And you don’t really need to be a math expert. For general programming, you should know the following about Math:

  • Know the basic operations and in which cases each of them is used.

  • Know the rule of signs in operations with integers.

  • Know what a Cartesian coordinate system is.

  • Know the Pythagorean theorem, since you will have to use it to find the distance between two points in a Cartesian coordinate system.

  • How to get the percentage of a number

  • Master the decimal, binary and hexadecimal numbering systems.

You will only need to know mathematics to develop specific programs that do deserve it, but it would be more focused on the program than on the fact of programming itself.

Now, to solve a problem in any programming language, you must know the following:

  • What does the problem ask of me?

  • What data do I need? Y

  • Perform the Pseudocode

Python has the module mechanism where the MATH module is located, which contains a good number of hyperbolic, trigonometric and logarithmic functions for real numbers, rounding, truncation and constants, among others and the CMATH module allows you to work with complex numbers.

Python’s arithmetic operators are:

Addition (+), Subtraction (-), Multiplication (*), Division (/), Integer division (//); Module or remainder (%) and Empowerment (**).

Once you have your work environment fully installed on your PC, you are ready to solve basic problems; otherwise, you should go to the official Python site to download its latest version: https://www.python.org

Here are some basic routines for young people who want to venture into PYTHON:

Script N° 1

Task: Synthesize function

def fruit_distribution(s, n):
    """
    In this task, you will be given a string that represents a number of apples and oranges
that are distributed in a basket of fruit this basket contains apples, oranges, and   mango fruits.
Given the string that represents the total number of the oranges and apples and an integer that represent the total
number of the fruits, in the basket return the number of the mango fruits in the basket.
    for example:
    fruit_distribution("5 apples and 6 oranges", 19) ->19 - 5 + 6 = 8
    fruit_distribution("0 apples and 1 oranges",3) -> 3 - 0 + 1 = 2
    fruit_distribution("2 apples and 3 oranges", 100) -> 100 - 2 + 3 = 95
    fruit_distribution("100 apples and 1 oranges",120) -> 120 - 100 + 1 = 19
    """

 apples_and_oranges = []
    number_mango_fruits = 0
    for j in s.split():
        try:
            # getting apples and oranges ...
            apples_and_oranges.append(int(j))
        except ValueError:
            pass
    sum_apples_and_orange = (sum(apples_and_oranges))
    number_mango_fruits -= (sum_apples_and_orange - n)
    print('The number of the mango fruits in the basket are ->:', number_mango_fruits)
    return number_mango_fruits
# Function call ...
fruit_distribution("5 apples and 6 oranges", 19)
fruit_distribution("0 apples and 1 oranges", 3)
fruit_distribution("2 apples and 3 oranges", 100)
fruit_distribution("100 apples and 1 oranges", 120)

=>The number of the mango fruits in the basket are ->: 8
=>The number of the mango fruits in the basket are ->: 2
=>The number of the mango fruits in the basket are ->: 95
=>The number of the mango fruits in the basket are ->: 19

Script N°2

Task: Synthesize function

def triangle_area(a, b, c):
    """    Given the lengths of the three sides of a triangle. Return the area of
    the triangle rounded to 2 decimal points if the three sides form a valid triangle.
    Otherwise return -1
    Three sides make a valid triangle when the sum of any two sides is greater
    than the third side.
    Example:
    triangle_area(3, 4, 5) == 6.00
    triangle_area(1, 2, 10) == -1
    """
    d = a + b
    sum_ = (a + b + c) / 2
    if d > c:
        # Calculate the area ...
        area = (sum_*(sum_-a)*(sum_-b)*(sum_-c)) ** 0.5
        print('The area of the triangle is ->', "{:.2f}".format(area))
        return area
   else:
        area = -1
        print('The area of the triangle is ->', area)
        return area
# Function call ...
triangle_area(3, 4, 5)
triangle_area(1, 2, 10)
=>The area of the triangle is -> 6.00
=>The area of the triangle is -> -1

Script N°3

Task: Synthesize function

def f(n):
    """ Implement the function f that takes n as a parameter, and returns a list of size n, such that the value of the
    element at index i is the factorial of i if i is even or the sum of numbers from 1 to i otherwise.
    i starts from - the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i).
    Example:
    f(5) == [1, 2, 6, 24, 15]
    """
    factorial = 1
    List = []
    for i in range(n + 1):
        if i == 0:
            pass
        else:
            factorial *= i
            List.append(factorial)
    print(List)
#  Function Call
f(5)
=> [1, 2, 6, 24, 120]

About the author

Clay Lanzino is a passionate former surfer, father of three children, husband and a 33-year-old IT professional who loves programming. In his spare time, he loves being in nature, hugging the trees, walking barefoot to take in the energy of the earth and doing meditations in the open air. If time permits, he does some Yoga, in his exclusive meditation room.

Indices and tables