top of page

# Measuring Pi with Smartphone Sensors: A Fun and Educational Challenge

By Christophe Chazot and Guillaume Lefranc - Update 15 March 2023

Today is Pi Day !! The occasion to celebrate Pi, this mathematical constant which has fascinated the whole world for millennia and which, somewhat by magic, pops-up in various fields such as mathematics or physics.

In this article, we propose to take up the following challenge: “Measure Pi with the sensors of your smartphone”. In fact a useful excuse to develop the creativity of student, review the main concepts of physics and deepen notions on the precision of the measurements!

## Why measure Pi with a smartphone?

Does it make sense to try to calculate Pi with smartphone sensors? After all Pi is a mathematical constant whose value can be very precisely calculated with various widely proven methods. According toWikipedia, the precision record set in June 2022 is more than 100 trillion (or 100,000 billion) decimal places!

Why then would you want to calculate Pi with physical instruments whose precision is necessarily muchlower than what would be necessary to estimate this quantity with precision?

We propose to take up this challenge because in addition to its playful side it presents many very interesting aspects from the educational point of view:

• stimulate students' creativity and experimental skills,

• work on the notion of precision and error,

• Reflect on the concept of constant.

Everyone is familiar with Niels Bohr's famous anecdote about measuring the height of a building. In the same way, through this challenge, we ask students to analyze the formulas they use and to be creative about the means of verifying them. What sensors can I use? Which physical quantities to study? What system should be put in place to be as precise as possible in the measurements? This research is of course the basis of the method of investigation and a fun way to interest students.

The precision for the calculation of Pi will depend on that of sensors. Although smartphone sensors are high quality measuring instruments, their precision is however rarely better than one percent. This raisesquestions : what accuracy can students expect to achieve? does this precision depend on the type of analysis? how to improve the measurement?

Finally, this exercise is an opportunity to reflect on the notion of constant. What is a constant? Whatdifferentiates a physical constant from a mathematical constant?

Calculating Pi with a smartphone is a very stimulating intellectual and manual exercise and we hope you and your students will have as much fun doing it as we did. We present below five experiments that we have imagined and carried out… your students and yourself will surely find many others!

## Pi in physics

Pi defined first in Euclidean plane geometry as the ratio of the circumference of a circle to its diameter.This property of circles was known from antiquity and already at that time several numericalapproximations of this number had been made.

Present in most mathematical formulas, Pi is also very present in all branches of science and in particular in physics. The reason is simple: many physical phenomena involve circular or spherical shapes, such as the orbital movements of planets, the oscillations of pendulums, sound waves, ... The equations that describe these phenomena will include terms that refer to circular geometry, and therefore to Pi.

For example, the formula which describes the period of rotation T of an object in orbit around a more massive body is given by T = 2π√(r³/GM), or the period of a pendulum for weak oscillations , T = 2π√(L/g), or finally Coulomb's law which describes the electrical interaction between two electric charges, F = (q1 * q2) / (4πer²).

In a general, Pi appears in all the formulas which use the concept of circle or sphere but also in theformulas of physics which describe the propagation of waves. Wave equations often use trigonometricfunctions, and naturally show the number pi.

In high school and college, students use many physics formulas that involve Pi. Before the course theteacher can make an inventory to determine which ones could be used using mobile phone sensors.

In the rest of this article, we detail four methods that use smartphone sensors. There are many othersand we are listening to your solutions!

## Vitruvius Pollio's odometer

Method : In the 1st century BC, the Roman engineer Marcus Vitruvius Pollio had developed a precursorto the odometer. Its system, linked to the wheel, caused small stones to fall into a receptacle with each turn of the wheel. At the end of the course, it was enough to multiply the number of stones by the circumference of the wheel to obtain the precise distance covered.

Experience : Let's use this ingenious idea to calculate Pi. We cycle a certain distance and count thenumber of revolutions the wheel makes. We deduce pi from the ratio of the distance to the diameter ofthe wheel.

To calculate the distance traveled, we use the GPS sensor of the smartphone. Some apps like FizziQ measures latitude and longitude variations independently, we use a straight line route oriented north/south or east/west. The point of arrival and departure are at the same longitude (latitude), so the distance traveled is simply the radius of the earth multiplied by the difference in radians between the latitude (longitude) of departure and that of arrival.

To count the number of revolutions the wheel has traveled, place a plastic card between the spokes of the front wheel and fold it at a right angle so that it rubs against the fork of the front wheel. This producesan easily identifiable 'clack' sound with each turn of the wheel. By recording the sound level during the race, we identify the sudden variations in sound intensity that correspond to each new revolution of the wheel. A modern equivalent to the Vitruvius Polio system.

With FizziQ, the ‘duo sensor’ mode is used to simultaneously record the sound level in db and the latitude. You can also use the trigger so that data recording starts 5 seconds after pressing the button and stops automatically after 20s.

Results : To carry out this experiment we walked along the avenue de la Reine in the Bois de Vincennes facing north/south. We counted 18 laps for a latitude difference of 0.35 milli-degrees, which gives a distance traveled of 38.9 m (0.35/1000*40,000,000/360). The wheel is French type 700, theoretically a diameter of 70 cm. In practice, with the compaction due to the cyclist's weight, we can consider a slightly smaller diameter of 69 cm. We obtain an approximation of the value of Pi of 3.13, i.e. an error of less than 0.5%. The GPS has an accuracy of the order of 1m, so this estimate is very satisfactory.

## Newton's pendulum

Method : the pendulum is an ideal experimental tool for studying gravity and energy because for small movements, the period T of the oscillation only depends on the length L of the pendulum and the gravitational constant g: T = 2π √(L/g). By measuring the length and the period and knowing g locally, wecan deduce Pi.

Experience : We use a Newton's pendulum to precisely measure the period by timing the time differences between the sound of the balls hitting. Other methods of measuring period can be used with simple pendulums such as magnetic sensing or by light intensity.

Many apps can be used to conduct this analysis, we have used FizziQ to measure the sound intensityover a period corresponding to several collisions, then by positioning the cursors we calculate theaverage period of the oscillations.

Results : in this experiment, we calculate the length of the pendulum by trigonometry. The length of a wire is 14 cm, the diameter of a ball 2 cm and the spacing 8.5 cm, i.e. a pendulum length of 14.35 cm. The frequency measured on the graph is 0.755s, which gives an approximation of Pi at 3.121.

The advantage of this method is twofold: the precision of the period is good since the frequency of acquisition of the sound level is 200 hertz; it is less sensitive to length determination than the previous method. An error of 10% on the length leads to an error for Pi of 3% against 10% for an error on the diameter of the wheel with the previous method. It will be in our interest to work with large pendulums.

## Time for a spin !

Method : centripetal acceleration is the acceleration that keeps an object in uniform circular motion on acircular path. For a uniform circular motion, the centripetal acceleration a is given by the formula a = 4π²oh²R, Oroh is the speed of the rotating object and R is the radius of the circle being described. By measuring the acceleration and rotational speed of a bicycle wheel, the number Pi can be deduced from the formula.

Experience : To achieve the most regular rotations possible, we will use a bicycle wheel mounted on one side to be stable. The smartphone is fixed on the wheel with a rubber band. Most smartphones are equipped with accelerometer sensors and can measure centripetal acceleration.

The rotation speed will be detected using the gyroscope in dual recording mode.

Results: the recording graph on the FizziQ application of the transverse acceleration and the magnetic field gives us information on the centripetal acceleration and the speed of rotation. In our test, the rotation speed is 0.481 rotation/s. The wheel diameter is 34 cm and the average acceleration is 3.20 m/s². We obtain an estimate for Pi of 3.18.

This result is ultimately relatively accurate given that we use two instruments for this calculation.

## The Doppler Effect

Method: the previous measurement requires knowing the radius of the wheel. It is possible to avoid using a meter by measuring the speed of a moving object attached to the periphery of the wheel by measuring the Doppler effect. The tangential speed of the mobile is v = cΔf/f and on the other hand v = 2πRω with ω being the speed of rotation. On the other hand the centripetal acceleration is a = v²/R. Hence a = 2πωcΔf/f

Experiment: we attach a wheel horizontally on a workbench to do the experiments. With a rubber band we attach a smartphone to the wheel which will record the centripetal acceleration. This mobile also outputs 680 hertz sound from the sound library. Under the wheel we place a second smartphone which measures the frequency. In FizziQ we activate the "Fast calculation of frequencies" option in the Settings > Sampling tab. This option allows the fundamental frequencies to be recorded with a sampling of 40 hertz. We start the recordings of the centripetal acceleration and the frequency then we spin the wheel vigorously.

Results: The attached graphs give the values ​​of the acceleration and the frequency measurement. We have a shift of Δf = 4 hertz, and an average acceleration of 13.1m/s². The rotation period of the wheel is measured on the frequency graph, ie 0.98 s. We obtain a value of Pi: π = 3.23. It can be seen that this measurement is very sensitive to the determination of the frequency shift due to the Doppler effect. On the other hand, it does not use the notion of length measurement!

## A probabilistic trip to Monte-Carlo

Method : The calculation of π by the Monte-Carlo method consists of randomly drawing numbers x and y in the interval [0;1]. The probability that a point of coordinates (x,y) has a norm less than 1 is π / 4. We use the sensors as random number generators to estimate Pi.

Experience : when we study the data produced by the accelerometer or the gyroscope of a smartphone, we find that they have a large number of digits after the decimal point, often more than 10. These figures are of course not significant and are the result noise in the sensor. They are random. We use this property to generate random numbers and using the Monte Carlo method, give an estimate of Pi.

We use the duo mode to simultaneously record the horizontal acceleration and the vertical acceleration on FizziQ. We put the smartphone on a table, then we record the data for 15 seconds. After recording the data in the experiment notebook, the notebook is exported in CSV form.

In a spreadsheet, we create for two new columns that capture 3 digits in the middle of the data string. For example, if the cell that contains the acceleration x is A1, we will use the following formula to create a number between 0 and 1000 made up of characters in the 4th, 5th and 6th position:

“ =VALUE(MID(A1,5,1)&MID(A1,6,1)&MID(A1,7,1))“

We create a column for each acceleration, then we calculate the square root of the sum of the squares.Finally we count the number of occurrences, n1 less than 1000.

Pi = 4*n1/N where N is the total number of observations.

Results : we performed this experiment with 2430 data corresponding to a recording of about 20 seconds. We obtain for Pi the value 3.164. Can we do better? Unfortunately this algorithm converges very slowly: to obtain a precision of 0.001 with a confidence interval of 95% it would take about 1 million draws, so we are far from the mark!

## To conclude

We have presented five methods for measuring pi, but there are many others using other sensors or other notions. By appealing to the creativity of the students and using a simple smartphone, we see that we can quickly set up extremely interesting experiments and open up many educational avenues. The measurement of Pi is an excuse to approach other notions such as that of constants, precision or consistency of data, and to have your students carry out experimentation sessions that they can continue with their own smartphones. It's up to them now!

Ancre 1
Ancre 2
Ancre 3
Ancre 4
Ancre 5
Ancre 6
Ancre 7
bottom of page