How Hard Is It To Write A Calculator App?

How hard can it be to write a simple four-function calculator program? After all, computers are good at math, and making a calculator isn’t exactly blazing a new trail, right? But [Chad Nauseam] will tell you that it is harder than you probably think. His post starts with a screenshot of the iOS calculator app with a mildly complex equation. The app’s answer is wrong. Android’s calculator does better on the same problem.

What follows is a bit of a history lesson and a bit of a math lesson combined. As you might realize, the inherent problem with computers and math isn’t that they aren’t good at it. Floating point numbers have a finite precision and this leads to problems, especially when you do operations that combine large and small numbers together.

Indeed, any floating point representation has a bigger infinity of numbers that it can’t represent than those that it can. But the same is true of a calculator. Think about how many digits you are willing to type in, and how many digits you want out. All you want is for each of them to be correct, and that’s a much smaller set of numbers.

Continue reading “How Hard Is It To Write A Calculator App?”

The Helicone: Toy Or Mathematical Oddity?

We always enjoy videos from the [Mathologer], but we especially liked the recent video on the Helicone, a toy with a surprising connection to mathematics. The toy is cool all by itself, but the video shows how a sufficiently large heliocone models many “natural numbers” and acts, as [Mathologer] puts it, acts as “microscope to probe the nature of numbers.”

The chief number of interest is the so-called golden ratio. A virtual model of the toy allows easy experimentation and even some things that aren’t easily possible in the real world. The virtual helicone also allows you to make a crazy number of layers, which can show certain mathematical ideas that would be hard to do in a 3D print or a wooden toy.

Apparently, the helicone was [John Edmark’s] sculpture inspired by DNA spirals, so it is no surprise it closely models nature. You can 3D print a real one.

Of course, the constant π makes an appearance. Like fractals, you can dive into the math or just enjoy the pretty patterns. We won’t judge either way.

We’ve seen math sequences in clocks that remind us of [Piet Mondrian]. In fact, we’ve seen more than one of those.

Continue reading “The Helicone: Toy Or Mathematical Oddity?”

Ramsey Numbers And The Appearance Of Order In Random Numbers

Proof without words of the two-color case of Ramsey's theorem. (Credit: CMG Lee, Wikimedia)
Proof without words of the two-color case of Ramsey’s theorem. (Credit: CMG Lee, Wikimedia)

Generally when assuming a chaotic (i.e. random) system like an undirected graph, we assume that if we start coloring these (i.e. assign values) with two colors no real pattern emerges. Yet it’s been proven that if you have a graph with a certain set of vertices, coloring the resulting lines in this manner will always result in a clique forming. This phenomenon has been investigated for nearly a century now after its discovery by British mathematician [Frank P. Ramsey].

The initial discovery concerned a graph with 6 vertices, providing the lowest number of vertices required. Formally this is written as R(3, 3), with subsequent cases of these Ramsey numbers discovered. They are part of Ramsey theory, which concerns itself with the question of what the underlying properties are that cause this apparent order to appear, which requires us to discover more cases.

Finding the number for a particular instance of R(m, n) can be done the traditional way, or brute-forcing it computationally. Over the decades more advanced algorithms have been developed to help with the search, and people from different fields are mingling as they are drawn to this problem. So far the pay-off of this search are these algorithms, the friendships created and perhaps one day a deep insight in the causes behind this phenomenon that may have implications for physics, chemistry and other fields.

Hackaday Links Column Banner

Hackaday Links: October 13, 2024

So far, food for astronauts hasn’t exactly been haute cuisine. Freeze-dried cereal cubes, squeezable tubes filled with what amounts to baby food, and meals reconstituted with water from a fuel cell don’t seem like meals to write home about. And from the sound of research into turning asteroids into astronaut food, things aren’t going to get better with space food anytime soon. The work comes from Western University in Canada and proposes that carbonaceous asteroids like the recently explored Bennu be converted into edible biomass by bacteria. The exact bugs go unmentioned, but when fed simulated asteroid bits are said to produce a material similar in texture and appearance to a “caramel milkshake.” Having grown hundreds of liters of bacterial cultures in the lab, we agree that liquid cultures spun down in a centrifuge look tasty, but if the smell is any indication, the taste probably won’t live up to expectations. Still, when a 500-meter-wide chunk of asteroid can produce enough nutritionally complete food to sustain between 600 and 17,000 astronauts for a year without having to ship it up the gravity well, concessions will likely be made. We expect that this won’t apply to the nascent space tourism industry, which for the foreseeable future will probably build its customer base on deep-pocketed thrill-seekers, a group that’s not known for its ability to compromise on creature comforts.

Continue reading “Hackaday Links: October 13, 2024”

Print Yourself Penrose Wave Tiles As An Excellent Conversation Starter

Ah, tiles. You can get square ones, and do a grid, or you can get fancier shapes and do something altogether more complex. By and large though, whatever pattern you choose, it will normally end up repeating on some scale or other. That is, unless you go with something like a Penrose Wave Tile. Discovered by mathematician Roger Penrose, they never exactly repeat, no matter how you lay them out.

[carterhoefling14] decided to try and create Penrose tiles at home—with a 3D printer being the perfect route to do it. Creating the tiles was simple—the first step was to find a Penrose pattern image online, which could then be used as the basis to design the 3D part in Fusion 360. From there, the parts were also given an inner wave structure to add further visual interest. The tiles were then printed to create a real-world Penrose tile form.

You could certainly use these Penrose tiles as decor, though we’d make some recommendations if you’re going that path. For one, you’ll want to print them in a way that optimizes for surface quality, as post-processing is time consuming and laborious. If you’re printing in plastic, probably don’t bother using these as floor tiles, as they won’t hold up. Wall tiles, though? Go nuts, just not as a splashback or anything. Keep it decorative only.

You can learn plenty more about Penrose tiling if you please. We do love a bit of maths around these parts, too. If you’ve been making your own topological creation, don’t hesitate to drop us a line. 

Ask Hackaday: How Can We Leverage Tech For Education?

If you’re like us, you’ve studied the mathematician [Euler], but all you really remember is that you pronounce his name like “oiler” and not much else. [Welch Labs], on the other hand, not only remembers what he learned about logarithms and imaginary numbers but also has a beautiful video with helpful 3D graphics to explain the concepts.

This post, however, isn’t about that video. If you are interested in math, definitely watch it. It’s great. But it also got us thinking. What would it be like to be a high school math student today? In our day, we were lucky to have some simple 2D graph to explain concepts. Then it hit us: it probably is exactly the same.

Continue reading “Ask Hackaday: How Can We Leverage Tech For Education?”

Manually Computing Logarithms To Grok Calculators

Logarithms are everywhere in mathematics and derived fields, but we rarely think about how trigonometric functions, exponentials, square roots and others are calculated after we punch the numbers into a calculator of some description and hit ‘calculate’. How do we even know that the answer which it returns is remotely correct? This was the basic question that [Zachary Chartrand] set out to answer for [3Blue1Brown]’s Summer of Math Exposition 3 (SoME-3). Inspired by learning to script Python, he dug into how such calculations are implemented by the scripting language, which naturally led to the standard C library. Here he found an interesting implementation for the natural algorithm and the way geometric series convergence is sped up.

The short answer is that fundamental properties of these series are used to decrease the number of terms and thus calculations required to get a result. One example provided in the article reduces the naïve approach from 36 terms down to 12 with some optimization, while the versions used in the standard C library are even more optimized. This not only reduces the time needed, but also the memory required, both of which makes many types of calculations more feasible on less powerful systems.

Even if most of us are probably more than happy to just keep mashing that ‘calculate’ button and (rightfully) assume that the answer is correct, such a glimpse at the internals of the calculations involved definitely provides a measure of confidence and understanding, if not the utmost appreciation for those who did the hard work to make all of this possible.