Calculus Made Easy In The Car

If you had the traditional engineering education, you’ve made your peace with calculus. If you haven’t, you may have learned it on your own, but for many people, calculus has a reputation for being super difficult. While some of the details can be very tricky, the core concepts are actually simple and [Mathologer] has a very simple explanation along with some good graphics that can help you get started on calculus mastery if you’ve been putting it off. Using a car on the highway as the prototypical example, he covers quite a bit of ground in the 30 minute video that you can see below.

Of course, this isn’t a unique idea that calculus is actually simple. The video credits the great book “Calculus Made Easy” that we’ve talked about before. That 100-year-old (and then some) book has a similar approach to the topic.

Continue reading “Calculus Made Easy In The Car”

Book Teaches Gaming Math

If we knew how much math goes into writing a video game, we might have paid more attention in math class. If you need a refresher, [Fletcher Dunn] and [Ian Parbery] have their book “3D Math Primer for Graphics and Game Development” available free online. The book was originally a paper book from 2011 with a 2002 first edition but those are out of print now. However, math is math, so regardless of the age of the book, it is worth a look. For now, the online version is a bunch of web pages, but we hear a PDF or E-reader version is forthcoming.

There’s quite a bit of discussion about vectors, matrices, linear transformations, and 3D graphics. The last part of the book covers calculus, kinematics, and parametric curves. Some of these topics will be of interest even if you don’t care about graphics but do want to learn some math with practical examples.

Continue reading “Book Teaches Gaming Math”

Rubber Band “Slide Rule” Doesn’t Slide, But Rotates

Around here we mostly enjoy slide rules. We even have our own collections including some cylindrical and circular ones. But [Mathologer] discusses a recent Reddit post that explains a circular slide rule-like device using a wheel and a stretchable rubber band. While it probably would be difficult to build the actual device using a rubber band, it can do wonders for your understanding of logarithms which still show up in our lives when, for example, you are calculating decibels. [Dimitri] did simulate the rubber band for you in software.

The idea is that a perfect rubber band has numbers from 0 to 10 evenly marked on it. As you rotate a wheel attached at the 10 mark, the rubber band stretches more and more. So the 10 and the 9 have relatively little space between them, but the 1 and the 2 are much further apart. The wheel’s circumference is set so that the 1 will exactly overlay the 10. What this means is that each spot on the wheel can represent any number that differs only by a decimal point. So you could have 3 mean 0.03, 300, or — of course — 3. Of course, you don’t need to build the wheel with a rubber band — you could just mark the wheel like a regular circular slide rule.

Continue reading “Rubber Band “Slide Rule” Doesn’t Slide, But Rotates”

Our Favorite Things: Binary Search

You might not think that it would be possible to have a favorite optimization algorithm, but I do. And if you’re well-versed in the mathematical art of hill climbing, you might be surprised that my choice doesn’t even involve taking any derivatives. That’s not to say that I don’t love Newton’s method, because I do, but it’s just not as widely applicable as the good old binary search. And this is definitely a tool you should have in your toolbox, too.

Those of you out there who slept through calculus class probably already have drooping eyelids, so I’ll give you a real-world binary search example. Suppose you’re cropping an image for publication on Hackaday. To find the best width for the particular image, you start off with a crop that’s too thin and one that’s too wide. Start with an initial guess that’s halfway between the edges. If this first guess is too wide, you split the difference again between the current guess and the thinnest width. Updated to this new guess, you split the differences again.

But let’s make this even more concrete: an image that’s 1200 pixels wide. It can’t get wider than 1200 or thinner than 0. So our first guess is 600. That’s too thin, so we guess 900 — halfway between 600 and the upper limit of 1200. That ends up too wide, so we next guess 750, halfway between 600 and 900. A couple more iterations get us to 675, then 638, and then finally 619. In this case, we got down to the pixel level pretty darn fast, and we’re done. In general, you can stop when you’re happy, or have reached any precision goal.

[Ed note: I messed up the math when writing this, which is silly. But also brought out the point that I usually round the 50% mark when doing the math in my head, and as long as you’re close, it’s good enough.]

What’s fantastic about binary search is how little it demands of you. Unlike fancier optimization methods, you don’t need any derivatives. Heck, you don’t even really need to evaluate the function any more precisely than “too little, too much”, and that’s really helpful for the kind of Goldilocks-y photograph cropping example above, but it’s also extremely useful in the digital world as well. Comparators make exactly these kinds of decisions in the analog voltage world, and you’ve probably noticed the word “binary” in binary search. But binary search isn’t just useful inside silicon. Continue reading “Our Favorite Things: Binary Search”

Apple Falling Division

[Paul Curtis] over at Segger has an interesting series of blog posts about calculating division. This used to be a hotter topic, but nowadays many computers or computer languages have support for multiplication and division built-in. But some processors lack the instructions and a library to do it might be less than ideal. Knowing how to roll your own might allow you to optimize for speed or space. The current installment covers using Newton’s algorithm to do division.

Steve Martin had a famous bit about how to be a millionaire and never pay taxes. He started out by saying, “First… get a million dollar. Then…” This method is a bit like that since you first have to know how to multiply before you can divide. The basic premise is twofold: Newton’s method let you refine an estimate of a reciprocal by successive multiplications and then multiplying a number a reciprocal is the same as dividing. In other words, if we need to divide 34 by 6, you could rewrite 34/6 to 34 * 1/6 and the answer is the same.

Continue reading “Apple Falling Division”

Hacking Multiplication With Karatsuba’s Algorithm

People tend to obsess over making computer software faster. You can, of course, just crank up the clock speed and add more processors, but often the most powerful way to make something faster is to find a better way to do it. Sometimes those methods are very different from how a human being would do the same task, but it suits the computer’s capabilities. [Nemean] has a video explaining a better multiplication algorithm known as Karatsuba’s algorithm and it is actually quite clever. You can see the video below.

To help you understand the algorithm, the video shows a simple two-digit by two-digit multiplication. You can see that the first and last digits are essentially the result of one multiplication. It is all the intermediate digits that add together. The only thing that might change the first digit is a carry.

Continue reading “Hacking Multiplication With Karatsuba’s Algorithm”

Web Assembly, Music Synthesis, And The Beauty Of Math

The electronics hobby has changed a lot since the advent of the microprocessor. Before that — and with the lack of large-scale integrated circuits — projects in magazines tended to be either super simple or ultra complex. However, one popular type of project dealt with music synthesis. Fairly simple circuits could combine to make a complex synthesizer so it was sort of the best of both worlds. Nowadays, you are more likely to tackle a music synthesizer in software like [Tim] did when he created Abelton in Web Assembly and C++. Along the way, he learned a lot about the relationship between math and music.

[Tim] covers what he learned about the Nyquist theorem and how to keep synthesis data flowing in real time with buffers. However, there are some problems trying to do all this in a cross-browser context. The AudioWorklet class appears to have widespread support, though, and [Tim] managed to get that working.

Continue reading “Web Assembly, Music Synthesis, And The Beauty Of Math”