Decimal Digits of PI
This example shows how to use variable-precision arithmetic to investigate the decimal digits of pi using Symbolic Math Toolbox™.
Joke: What do you get when you take the sun and divide its circumference by its diameter?
Answer: in the sky!
It is an old game to search for one's birthday or telephone number in the decimal digits of . The precision of the built-in datatypes suffices to obtain a few digits only:
vpa uses variable-precision to convert symbolic expressions into symbolic floating-point numbers. Convert
pi to a floating-point number using
vpa. Increase the precision of
a = vpa(pi)
To convert a variable-precision number into a string, use the function
Search for your phone number in the digits of
It is common belief that all digits occur asymptotically equally often in the decimal expansion of , but no proof exists yet. Find the decimal point:
Convert the decimal digits to numbers, and plot a histogram of their frequency:
d = arrayfun(@str2num, c(pos+1:end));
title('Frequency of the decimal digits of \pi');