Random Number Generation By Brain

If you want to start an argument in certain circles, claim to have a random number generation algorithm. Turns out that producing real random numbers is hard, which is why people often turn to strange methods and still, sometimes, don’t get it right. [Hillel Wayne] wanted to get a “good enough” method that could be done without a computer and found the answer in an old Usenet post from random number guru [George Marsaglia].

The algorithm is simple. Pick a two-digit number — ahem — at random. OK, so you still have to pick a starting number. To get the next number, take the top digit, add six, and then multiply by the bottom digit. So in C:  n1=(n/10+6)*(n%10). Then use the last digit as your random number from 0 to 9. Why does it work? To answer that, the post shows some Raku code to investigate the behavior.

In particular, where does the magic number 6 come into play? The computer program notes that not any number works well there. For example, if you used 4 instead of 6 and then started with 13, all your random digits would be 3. Not really all that random! However, 6 is just a handy number. If you don’t mind a little extra math, there are better choices, like 50.

If you think humans are good at picking random numbers, ask someone to pick a number between 1 and 4 and press them to do it quickly. Nearly always (nearly) they will pick 2. However, don’t be surprised when some people pick 141. Not everyone does well under pressure.

If you want super random numbers, try a lava lamp. Or grab some 555s and a few Nixie tubes.

50-Year-Old Program Gets Speed Boost

At first glance, getting a computer program to run faster than the first electronic computers might seem trivial. After all, most of us carry enormously powerful processors in our pockets every day as if that’s normal. But [Mark] isn’t trying to beat computers like the ENIAC with a mobile ARM processor or other modern device. He’s now programming with the successor to the original Intel integrated circuit processor, the 4040, but beating the ENIAC is still little more complicated than you might think with a processor from 1974.

For this project, the goal was to best the 70-hour time set by ENIAC for computing the first 2035 digits of pi. There are a number of algorithms for performing this calculation, but using a 4-bit processor and an extremely limited memory of only 1280 bytes makes a number of these methods impossible, especially with the self-imposed time limit. The limited instruction set is a potential bottleneck as well with these early processors. [Mark] decided to use [Fabrice Bellard]’s algorithm given these limitations. He goes into great detail about the mathematics behind this method before coding it in JavaScript. Generating assembly language from a working JavaScript was found to be fairly straightforward.

[Mark] is also doing a lot of work on the 4040 to get this program running as well, including upgrades to the 40xx tool stack, the compiler and linker, and an emulator he’s using to test his program before sending it to physical hardware. The project is remarkably well-documented, including all of the optimizations needed to get these antique processors running fast enough to beat the ENIAC. We won’t spoil the results for you, but as a hint to how it worked out, he started this project using the 4040 since his original attempt using a 4004 wasn’t quite fast enough.

Math Book Gets Real With Complex

The [Math Sorcerer] loves books. His latest acquisition is the famous Real and Complex Analysis, which is a very stout math book.  How stout? Well, there are several chapters on holomorphic functions, including how to do a Fourier transform on such a function. There’s also an appendix about Hausdorff’s maximality theorem. What are those? Beats us; read the book. You can also watch the short video review of the text below.

The author asserts right up front that the exponential function is “undoubtedly the most important function in mathematics.” Undoubtedly. [The Math Sorcerer’s] videos remind us of browsing a bookstore or a library. You don’t get a book summary as much as a preview of what’s in it, so you can decide if you want to read it.

Continue reading “Math Book Gets Real With Complex”

Native Alaskan Language Reshapes Mathematics

The languages we speak influence the way that we see the world, in ways most of us may never recognize. For example, researchers report seeing higher savings rates among people whose native language has limited capacity for a future tense, and one Aboriginal Australian language requires precise knowledge of cardinal directions in order to speak at all. And one Alaskan Inuit language called Iñupiaq is using its inherent visual nature to reshape the way children learn and use mathematics, among other things.

Arabic numerals are widespread and near universal in the modern world, but except perhaps for the number “1”, are simply symbols representing ideas. They require users to understand these quantities before being able to engage with the underlying mathematical structure of this base-10 system. But not only are there other bases, but other ways of writing numbers. In the case of the Iñupiaq language, which is a base-20 system, the characters for the numbers are expressed in a way in which information about the numbers themselves can be extracted from their visual representation.

This leads to some surprising consequences, largely that certain operations like addition and subtraction and even long division can be strikingly easy to do since the visual nature of the characters makes it obvious what each answer should be. Often the operations can be seen as being done to the characters themselves, instead of in the Arabic system where the idea of each number must be known before it can be manipulated in this way.

This project was originally started as a way to make sure that the Iñupiaq language and culture wasn’t completely lost after centuries of efforts to eradicate it and other native North American cultures. But now it may eventually get its own set of Unicode characters, meaning that it could easily be printed in textbooks and used in computer programming, opening up a lot of doors not only for native speakers of the language but for those looking to utilize its unique characteristics to help students understand mathematics rather than just learn it.

Understanding Wavelets

Mathematical transforms can be a great help in understanding signals. Imaging trying to look at a complex waveform and figuring out the frequency components without the Fourier transform. [Artem Kirsanov] calls the wavelet transform a “mathematical microscope” and his video gives you a great introduction to the topic. You can see the video below.

The video starts with a discussion about how the time domain and frequency domain have a dual relationship — not big news if you’ve dealt with Fourier transforms and — in fact — that’s the next topic in the video. However, there are limitations to the transformation — you lose time domain information in the process.

Continue reading “Understanding Wavelets”

A Math Based Personality For Games

We make no apologies for being hardware focused here at Hackaday, but that doesn’t mean we aren’t occasionally impressed by a particularly inspired feat of bit wrangling. For example, [t3ssel8r] has taken a break from his game to discuss his procedural animation system and the beautiful math behind it.

Sometimes, rather than having specific keyframes, games will instead use procedural animation. This means that the position is determined on the fly rather than a predetermined set of positions. Developers can use the combination of IK or FK (inverse or forward kinematics) to solve for rotation and positions of the joints that will place the end at a specific position. Particularly with crawling multi-limb things, it’s pretty easy to put a limb on the ground and keep it there until it’s too far away, pick a new spot, and move it there. It’s simple code to write and looks convincing. It can handle complex terrain and situations with different limb positions.

However, it doesn’t offer the chance to inject some life or personality into the movement as keyframes do. [t3ssel8r] goes through the equations and reasoning behind his semi-implicit Euler solver-based system. There are some fantastic explanations in the video, but the short version is that he has three parameters to control the system’s frequency, dampening, and initial response. This allows him to tweak the behavior in a somewhat intuitive manner. One problem is stability; if the timesteps get too large, the position quickly explodes outwards. Using eigenvalues (who ever thought you’d use those) to determine the minimum timestep allows the system to remain stable and take multiple smaller steps when needed or just bound the change temporarily.

If you’re looking for more animation, this blender plugin renders your PCB traces in a new light.

Continue reading “A Math Based Personality For Games”

Thermal printer with a loop of thermochromic foil inserted in it, printing digits of Pi on the loop.The digits gradually disappear from the foil as it exits the printer.

Celebrating The Infinity Of Pi Day With Thermochromic Foil

It might take you some time to understand what’s happening in the video that Hackaday alum [Moritz Sivers] shared with us. This is [Moritz]’s contribution for this year’s Pi Day – a machine that shows digits of Pi in a (technically, not quite) infinite loop, and shows us a neat trick we wouldn’t have thought of.

The two main elements of this machine are a looped piece of thermochromic foil and a thermal printer. As digits are marked on the foil by the printer’s heating element, they’re visible for a few seconds until the foil disappears from the view, only to be eventually looped back and thermally embossed anew. The “Pi digits calculation” part is offloaded to Google’s pi.delivery service, a π-as-a-Service endpoint that will stream up to 50 trillion first digits of Pi in case you ever need them – an ESP8266 dutifully fetches the digits and sends them off to the thermal printer.

This machine could print the digits until something breaks or the trillions of digits available run out, and is an appropriate tribute to the infinite nature of Pi, a number we all have no choice but to fundamentally respect. A few days ago, we’ve shown a similar Pi Day tribute, albeit a more self-sufficient one – an Arduino calculating and printing digits of Pi on a character display! We could’ve been celebrating this day for millennia, if Archimedes could just count a little better.

Continue reading “Celebrating The Infinity Of Pi Day With Thermochromic Foil”