Category Archives: Julia

Representing pi in Julia

By: Hexecontahedron

Re-posted from: http://hexecontahedron.com/hexecontahedron.com/hexecontahedron.com/2016/09/20/representing-pi-in-julia.html

Julia excels as a numeric computation language. It is even faster than C for certain tasks, but has a syntax almost as simple as that of python.
Although, at the beginning, Julia syntax might seem similar to python, things start to change when you want the best performance, or specific numerical functionalities.
This is the case of precision specification. When it comes to numerical computing you must be able to have as much precession as you want. Let’s say you have the geeky goal of memorizing the first hundred digits of pi. Just printing it to the console won’t cut it, since pi is an irrational number (represented in julia by the type ::Irrational{:π}):

π
π = 3.1415926535897...

If you want to print pi with more precession you have to unse it’s BigFloat representation:

BigFloat(π)
3.141592653589793238462643383279502884197169399375105820974944592307816406286198

Notice that it’s no longer an irrational representation (no dots at the end). This new representation of pi has a specific precession. Default precision is 256 bits:

precision(BigFloat)
256

This is the equivalent of four double values. Let’s try printing pi as represented by 1024 bits. This is done with the setprecision() function within a do block.

setprecision(2^10) do
    println(precision(BigFloat))
    println(BigFloat(π))
end
1024
3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724586997

As you can see, high precision floating numbers are a powerful tool in Julia. I suggest you try playing around with φ, the golden ratio.

Julia Enters Top 50 Programming Languages

Julia has taken its place among the top 50 computer programming languages, according to the TIOBE Programming Community Index, an index of the world’s most popular programming languages:

Julia Enters Top 50 for the First Time

It was a matter of time until Julia would hit the top 50. This month it did so. The Julia programming language is meant for numerical computing. It combines functional programming paradigms with high speed. In other words, readable and stable code that performs. Chances are high that Julia will gain even more popularity [during] the next few months.

TIOBE Index for September 2016

About Julia

Julia is the simplest, fastest and most powerful numerical computing language available today. Julia combines the functionality of quantitative environments such as Python, R, MATLAB, SAS, SPSS and Stata, with the speed of production programming languages like Java and C++ to solve big data and analytics problems. Julia delivers dramatic improvements in simplicity, speed, capacity, and productivity for data scientists, algorithmic traders, quants, scientists, and engineers who need to solve massive computational problems quickly and accurately.

Julia offers an unbeatable combination of simplicity and productivity with speed that is thousands of times faster than other mathematical, scientific and statistical computing languages.

Partners and users include: Intel, The Federal Reserve Bank of New York, Lincoln Laboratory (MIT), The Moore Foundation and a number of private sector finance and industry leaders, including several of the world’s leading hedge funds, investment banks, asset managers and insurers.

About the TIOBE Programming Community Index

The TIOBE Programming Community Index is an indicator of the popularity of programming languages. The index is updated once a month. The ratings are based on the number of skilled engineers world-wide, courses and third party vendors. Popular search engines such as Google, Bing, Yahoo!, Wikipedia, Amazon, YouTube and Baidu are used to calculate the ratings. For more information, please visit www.tiobe.com.