Menu

Category Archives: Misc

It happens that I quite like scientific calculators, and lately I’ve been adding a few to my collection. Several calculators are CAS (“Computer Algebra System”)-capable, meaning they are powerful enough to do symbolic / algebraic processing, and thus are able to understand and manipulate algebraic expressions containing any mix of unknowns, operators and numbers, and simplify, expand, and solve those in a general form. They normally can also do symbolic differentiation and integration, computing the general derivative/integral “function” from a expression first, before you can evaluate them at given points, if desired.

But I’ve always found quite fascinating that some less advanced calculators still offer the possibility of doing numerical integration and differentiation. They don’t know for instance that the derivative function of 3⋅x² is 6⋅x, but they can still tell you that when x = 2 the derivative is 12.

Before you ask; I got into this rabbit hole because numerical differentiation and integration are kinda standard features nowadays of any decent calculator. It doesn’t need to be a high end or an expensive calc. In fact, I noticed that even my fx-570MS “entry level” scientific calculator I purchased like 10 years ago can do both operations, while three of my “high end” vintage programmable Casio calculators can’t. As they were “programmable” I think Casio kinda expected users to write their own programs for whatever “advanced” feature they needed. So I started wondering what is the method/algorithm used by current scientific calculators to compute these functions, so I could add the same functionality to my vintage calcs.

Now, I’ll focus on differentiation here because it’s way easier to deconstruct and understand how that works. A post about integration may follow, if this doesn’t turn out to be a massive borefest.

The concept of derivative

So if you go back to the formal definition of a derivative;

You’ll see that it basically attempts to find the “slope” of the function f(x) at a point x by evaluating the expression at x and (x+h) (as you would do with a straight line), and trying to reduce the difference in the X-axis between those two points (h) to a tiny fraction. In fact, it uses the concept of limit to find out where that expression converges when h approaches 0 (It never really gets there though, because the whole expression goes to hell at that point). Read More →

If you are using your Arduino’s PRNG (Pseudo-Random Number Generator) for anything more serious than flashing random lights for your Christmas decorations, there’s a chance you might run into some unexpected issues, as the random() function in Arduino seems to be somewhat broken.

Why? Let me explain.

Background

Most basic random number generators in programming libraries and platforms are based on what is called a “Linear Congruential Generator” (LCG), and I have discussed them before here in my blog. As with any PRNG, the output of the algorithm ends up being a sequence of numbers “seemingly” selected at random, starting from a “seed”.

Given the basic structure of an LCG, after you have drawn X numbers from the generator, you’ll start getting the same sequence again. This is called the “period” of the LCG, and is one of the things you should know about the PRNG you are using (again, if you are serious about your random numbers, or you need a controlled, predictable and stable behavior).

Arguably, you should always know the weakness and strengths of the PRNG you are going to use, before even using it, as to avoid any potential pitfall and/or limitation (and that’s why it’s normally not a good idea to use the default implementation of a random generator in any language; For the most of it you don’t know what you are getting).

I have a very simple “audio/video” setup in my room. My main computer display doubles as my “TV” for playing videogames and watching movies. Technically speaking is just a 22″ HDTV with a bunch of input options, which I have connected to all of my devices, mostly through an HDMI hub, so I use the same screen for my computer, and my various consoles and audio/video devices.

Now, I’m not an audiophile, but as you normally get to expect, its integrated speakers are kinda too terrible to actually listen to anything through them for more than 10 seconds, so I have a couple of entry-level PC speakers connected to the TV audio output, which give relatively decent sound, or at least, better than with the monitor alone. Now, as all my gaming consoles and A/V devices go to the same TV, this is a pretty centralized setup, which is great for most of what I do, and has worked really well for years, but stops being great when I want to listen to something not physically connected to my system, like my phone, laptop, tablet, or whatever. So I thought of adding a bluetooth receiver somewhere in between.

After an online search I ended up buying this nice little module, which is essentially a BT 4.0 receiver that works with 5V. By default it will redirect whatever it receives through its physical “AUX IN” port to the output connector, but when a device connects to it over BT, it will ignore the physical input and play the audio it receives wirelessly instead.

The BT Audio module. As seen on most popular auction/e-commerce sites.