Posts

Analyzing 1 billion digits of Pi

Image
The number pi, which always reminds of pie, happens to be one of the most widely used symbol in mathematics, both in high school and university. As you know, it is nothing more than an irrational number (it can't be written as a fraction) which starts with 3.14159 and it is the heart of all geometry and trigonometry. Many have calculated billions of digits of pi, the record (last I checked) is at 105 trillion digits, but it is all done just for the sake of curiosity, there is no practical application since you only need the know the first few dozens of digits in order to perform any calculation in the universe. However I'm sure you've seen on Facebook that famous post in which they explain the digits of pi are non-repeating, meaning any possible number combination may be found if you keep digging deep enough, therefore you may run into a combination of numbers which are your birthday, another combination of numbers which spell your name in ASCII format and maybe

Decimal system math

Image
Computers are awesome! But have you ever tried to use them for scientific math? Have you ever made a computer software that performs a long list of mathematical operations and later returns a result which must be precise? If you have tried any of the endeavors above then you must be frustrated with the fact that computers are not reliable when you need high precision, or when you need to perform many operations sequentially. Most programmers have sometimes encountered the common floating point problem, when the result is not what you expected, you spend hours trying to discover where the bug is, only to discover the floating point variables were slowly suffering a distortion in their values over the course of the program, all thanks to the binary number system. That is because computers work with the binary number system, not the decimal system. A computer can understand number such as 0.5 or 0.25, because they are the result of a division by a denominator which is a power

Is it possible to erase a Hard Disk Drive with magnets?

Image
It is possible, but not with the magnets you have at home, and here is why: you would need a super strong magnet for that because it turns out HDDs are built to resist the influence of magnetic fields. Do you want proof? Here it is: I've tested it myself with an electric motor full of magnets inside, they are very strong magnets. I rubbed the HDDs on it for minutes, then I tested them and they were intact, the data was all in there, so disapointing.   But then I had another idea: I microwaved the HDDs for 30 seconds, and it worked! They were not even recognized by the BIOS anymore, however I still don't know if the microwave damaged the disk inside it or only the chip which allows it to communicate with the BIOS, perhaps the data is still in there, I just couldn't access it with the SATA cable.   I used 2 very old HDDs which would end up in the garbage one way or another. If you know a better way then please write it in the comments below.

Cryptography introduction and cheatsheet

Image
Cryptography, an interesting word most people do not understand. It is nothing more than the art of sending messages which are protected from spies, you convert them into a secret code with the use of an algorithm called "cipher". It has altered the course of history because it has been decisive during war times. There are many ciphers out there, some of which have been used for centuries, some which are still being used today, specially when you use the internet, after all it is necessary to make sure you can access your bank account, send Whatsapp messages and shop online with security, we can't allow some hacker to tap into your internet transmission and steal all your data, therefore everything must be encrypted before it leaves your computer, and it must be decrypted as soon as it arrives at its destination, which could be someone else's computer or some data center. Although it seems complex, the principles are actually simple, all you need

Computational art

Image
Are you a mathematician? A computer scientist? A programmer? An engineer? Or maybe just someone who really likes exact sciences? In this case you are reading the right article, here you will discover the hidden artist who lives inside you. If you are a member of any category mentioned above, then chances are you haven't been fond of art during your life and probably doesn't have talent for it. After all, you must think "what problems of the world would be solved by paintings and sculptures?", you are partially right, arts do not do much good in leveraging the resources of the planet for the betterment of humankind, nor can they help you answer questions such as "what is the shortest route between my house and my favorite pub?". However art is a part of human nature and culture, it is the demonstration of our creativity, which in turn is what allowed us to come up with each and every form of science and technology, which basically mea

Graphs cheatsheet

Image
Here is a list with some of the most basic forms of graphs and how to implement them. Graphs are useful when implementing search algorithms. Edge list Create an array with sub arrays. Each sub array will contain 2 numbers which represent the vertices that form the edge. It may contain a 3 rd number to represent the weight. It doesn't use much memory but the search time is long. Adjacency matrix Create a matrix with all the vertices x vertices . The indices of the rows and columns of the matrix will be the vertices. Add the number 1 when 2 vertices form an edge. Add the number 0 otherwise. It uses a lot of memory but the search time is super fast. Adjacency list Create an array with sub arrays. Each sub array's index will represent a vertex. Fill each sub array with the vertices it forms edges with. This one doesn't use much memory and the search time is short. Notes Adjacency matr

Computer graphics introduction

Image
Today we will be learning about how your computer can make all of those beautiful and stunning images appear before your eyes every time you play a game or watch a video . First of all, h ow does the human eye work? The back of the human eye is called the retina, it contains thousands of cells to receive light, there is a nerve that passes through this wall , therefore one spot of your retina doesn't receive light because it is covered by a nerve , this is your blind spot. Your brain can process images in a speed of approximately 13 FPS, which means you should have at least that many FPS for a proper animation experience . Less than that and the film will be glitchy, a lot more than than and the film will look strange, it won't look like a natural movement . Unless you are working with VR goggles, your peripheral vision can process frames faster, unlike a movie where you only use your central vision, with VR goggles you use your peripheral vision as well, meaning the

Algorithms cheatsheet

Image
Here goes a list of useful and common algorithms explained in a way that is easy to understand and beside their names I have written their average case runtimes. Reading this article should give you insights about which algorithm to use and how to implement it.   Binary search (O(log2(n)), works in place) Let n = size of the array. Let min = 0 and max = n - 1 . If max < min then stop , the target is not present in the array , r eturn -1 . Calculate guess as floor(( max + min ) / 2) . If array[guess] equals the target then stop , y ou found it , r eturn guess . If array[guess] < the target then set min = guess + 1 and jump to step 8. if array[guess] > the target then s et max = guess - 1 . Go back to step 3. Uniform binary search (O(log2(n)), works in place) Let sizeA rray be the size of the array we will se