Pi Day
Many things are small, but important. The mathematical constant π (Pi) is one of those cornerstones. It is used in many places in mathematics, physics, and more. The constant has never ending digits (“infinite”). Some kids, mine included, have fun memorizing 100, sometimes 200, or even more of those digits by singing along songs like the following:
To celebrate π, fans started to observe a Pi Day on March 14th (3.14). According to Wikipedia, the first larger Pi Day was celebrated in 1988. People eat pies, recite π and its digits, or have other fun with π.
Pi Day with Db2
While reading over the “What’s new in Db2” sections for Db2 12.1 and its fixpacks, I stumbled over SQL Enhancements in Db2 12.1.1:
New numeric scalar function PI() The PI function returns the value of π 3.141592653589793. For more information, see PI scalar function.
Let’s celebrate Pi Day with Db2 by returning π (Pi) in different ways. The first is by utilizing the new Pi function, followed by functions like acos, asin, atan, radians, or just a float literal.
db2 => values(pi())
1
------------------------
+3.14159265358979E+000
1 record(s) selected.
db2 => values(acos(-1))
1
------------------------
+3.14159265358979E+000
1 record(s) selected.
db2 => values(2*asin(1))
1
------------------------
+3.14159265358979E+000
1 record(s) selected.
db2 => values(4*atan(1))
1
------------------------
+3.14159265358979E+000
1 record(s) selected.
db2 => values(radians(180))
1
------------------------
+3.14159265358979E+000
1 record(s) selected.
db2 => values (float(3.14159265358979))
1
------------------------
+3.14159265358979E+000
1 record(s) selected.
Conclusions
That was fun. Enjoy Pi Day on next Saturday, March 14th.
If you have feedback, suggestions, or questions about this post, please reach out to me on Mastodon (@data_henrik@mastodon.social) or LinkedIn.