Review: Calculator Kit Is Just A Few Hacks From Greatness

While most people are satisfied with a calculator application on their smartphone these days, there’s still something to be said for the old fashioned desk calculator. Maybe it’s the fact the batteries last long enough that you can’t remember the last time you changed them, or the feel of physical buttons under your fingers. It could even be the fact that it keeps your expensive smartphone from needing to sit out on the workbench. Whatever the reason, it’s not uncommon to see a real-life calculator (or two) wherever solder smoke tends to congregate.

Which is precisely the idea behind this DIY calculator kit. Available from the usual overseas retailers for about $15 USD, it has some hobbyist-oriented features such as the ability to decode resistor color bands, convert hexadecimal numbers, and calculate resistor values for driving LEDs. If you’re going to keep a knock-around calculator on your bench, why not build the thing yourself?

Given the dual nature of this product, a DIY electronics kit and a functional desk calculator for electronic hobbyists, it seems only appropriate to review both aspects of it individually. Which is good, since there may be more to this product than just the sum of its parts.

Continue reading “Review: Calculator Kit Is Just A Few Hacks From Greatness”

Implementing The Exponential Function

Ask ordinary software developers how to code an exponential function (that is, ex) and most will tell you to simply write an expression in their favorite high level language. But a significant slice of Hackaday readers will program tiny machines down to the bare metal or need more speed or precision than available with a customary implementation. [Pseduorandom] knows quite a few ways to do the calculation, and while it isn’t light reading for the math-phobic, it is an interesting tour.

The paper covers a variety of ways to calculate the function ranging from various Taylor series approximations, Lagrange interpolation, and Chebyshev interpolation. The paper is somewhat abstract, but there are Python and C++ examples to help make it concrete.

Continue reading “Implementing The Exponential Function”

Looking For Pi In The 8087 Math Coprocessor Chip

Even with ten fingers to work with, math can be hard. Microprocessors, with the silicon equivalent of just two fingers, can have an even harder time with calculations, often taking multiple machine cycles to figure out something as simple as pi. And so 40 years ago, Intel decided to give its fledgling microprocessors a break by introducing the 8087 floating-point coprocessor.

If you’ve ever wondered what was going on inside the 8087, wonder no more. [Ken Shirriff] has decapped an 8087 to reveal its inner structure, which turns out to be closely related to its function. After a quick tour of the general layout of the die, including locating the microcode engine and ROM, and a quick review of the NMOS architecture of the four-decade-old technology, [Ken] dug into the meat of the coprocessor and the reason it could speed up certain floating-point calculations by up to 100-fold. A generous portion of the complex die is devoted to a ROM that does nothing but store constants needed for its calculation algorithms. By carefully examining the pattern of NMOS transistors in the ROM area and making some educated guesses, he was able to see the binary representation of constants such as pi and the square root of two. There’s also an extensive series of arctangent and log2 constants, used for the CORDIC algorithm, which reduces otherwise complex transcendental calculations to a few quick and easy bitwise shifts and adds.

[Ken] has popped the hood on a lot of chips before, finding butterflies in an op-amp and reverse-engineering a Sinclair scientific calculator. But there’s something about seeing constants hard-coded in silicon that really fascinates us.

Mathematical Proof The Eagle In The USPS Logo Is FAST!

The logo for the United States Postal Service is a mean-looking eagle. But a true fluid dynamics geek might look at it and realize that eagle is moving so fast it’s causing a shock wave. But just how fast is it moving? [Andrew Higgins] asked and answered this question, posting his analysis of the logo’s supersonic travel. He claims it’s Mach 4.9, but, how do we know? Science!

It turns out if something is going fast enough, you can tell just how fast with a simple picture! We’ve all seen pictures of jets breaking the sound barrier, this gives us information about the jet’s speed.

Mach Lines

How does it work?

Think about it like this: sound moves at roughly 330 m/s on Earth at sea level. If an object moves through air at that velocity, the air disturbances are transmitted as sound waves. If it’s moving faster than sound, those waves get distributed downstream, behind the moving object. The distance of these waves behind the moving object is dependent on the object’s speed.

This creates a line of these interactions known as a “Mach line.” Find the angle difference of the Mach line and the direction of travel and you have the “Mach angle” (denoted by α or µ).

There is a simple formula for determining the speed of an object using the Mach angle, the speed of sound (a), and an object’s velocity (v): sin(µ) = a / v.  The ratio of to a is known as the Mach number, (M). If an object is going exactly the speed of sound, it’s going Mach 1 (because v = a).

Since Mach number (M) is v / a, we can plug it into the formula from above as 1 / M and use [Andrew]’s calculation shown in the image at the top of the article for a Mach angle (µ) of ~11.7°:

\bf \sin ( \mu ) = \frac{1}{M} \\ \\ M = \frac{1}{\sin(\mu)} \\ \\ M = \frac{1}{\sin(11.7)} \\ \\ M = \frac{1}{0.202787295357} \\ \\ M = 4.9312753949380048

The real question is, did the USPS chose Mach 4.93 as a hint to some secret government postal project? Or, was it simply a 1993 logo designer’s attempt to “capture the ethos of a modern era which continues today”?

Hands-On: Smarty Cat Is Junior’s First Slide Rule

You may remember that I collect slide rules. If you don’t, it probably doesn’t surprise you. I have a large number of what I think of as normal slide rules. I also have the less common circular and cylindrical slide rules. But I recently picked up a real oddity that I had to share: the Smarty Cat. It isn’t exactly a slide rule but it sort of is if you stretch the definition a bit.

Real Slide Rules

A regular slide rule takes advantage of the fact that you can multiply and divide by adding logarithms. Imagine having two rulers marked in inches or centimeters — it doesn’t matter (see the adjoining image). Suppose you want to add 5 and 3. You count off 5 marks on one ruler and line it with up the zero inch mark on the other ruler. Now you count off 3 marks on the second ruler and that position on the first ruler will indicate the result. Here it lines up with the 8 mark, which is, of course, the correct answer.

That’s a simple addition. But if you can convert your numbers into logarithms, add the logarithms, and then back out to a regular number, you can multiply.

Continue reading “Hands-On: Smarty Cat Is Junior’s First Slide Rule”

Hacking Multiplication: Binary Multiply On Paper

We’ve often noted that whether had ancient man known binary, we could all count to 1023 on our fingers. We thought about that while watching [Numberphile’s] latest video about “Russian” multiplication (see below). Apparently, the method dates back quite a way, sometimes known as Ethiopian or peasant multiplication. Even the ancient Egyptians did a form of it.

If you’ve ever written long multiplication code for a microcontroller, you can probably tell how this works. Each halving of the number amounts to a right shift. Each doubling is a left shift. Throwing out the even numbers means you only take the values when the least-significant bit is zero. Booth’s algorithm is more efficient, but the “Russian” method is simple to do on paper.

Continue reading “Hacking Multiplication: Binary Multiply On Paper”

Tensors Explained

You can do a lot of electronics without ever touching a tensor, but there are some situations in which tensors are absolutely essential. The problem is that most math texts give you a very dry description that is difficult to internalize. That’s where [The Science Asylum] comes in. Their recent video (see below) starts with the dry definition and then shows you what it means and why.

According to the video, the textbook definition is:

A rank-n tensor in m-dimensions is a mathematical object that has n indices and mn components and obeys certain transformational rules.

That sounds a lot like an array but we are not sure what “certain transformational rules” really means to anyone.

Wikipedia does a little better:

[A]n algebraic object that describes a linear mapping from one set of algebraic objects to another.

These constructs are key to anything electromagnetic (including antennas) and show up a lot in stress calculations and quantum mechanics. Even Einstien’s theory of relativity uses tensors.

Continue reading “Tensors Explained”