# Why all the math?

Most of you readers know that my main focus in this column has been on the use of fairly high-powered math to solve practical problems. Over the years, we've covered topics ranging from fundamental functions to vector and matrix calculus to Fourier transforms to numerical calculus to control systems to digital filters, and lots of stuff in between.

Every once in awhile I get e-mail asking me, "Why are you focusing on these things, and what do they have to do with embedded systems?" Another perennial favorite is, "Why are you writing software for that, when it's already available in <Matlab | Mathematica | Mathcad | Maple | APL|>?"

Jack Crenshaw's Estimation SeriesPart 1: Why all the math? Part 2: Can you give me an estimate? Part 3: Estimation interruptus Part 4: The normal distribution |

*Embedded Systems Design*. It's supposed to be about implementing embedded systems, and it's not likely that you're ever going to build an embedded system that has Matlab or another proprietary product built in. I'm not going to say it can't be done; it can, given a fast enough processor and enough money to pay the royalty fees. But the company who can get the same algorithms working in their own software, royalty-free, are going to be able to sell their product at a lower cost, and thereby eat your lunch.

As for the first question, it's true that embedded systems aren't what they used to be. The original embedded systems were missile guidance systems and were all about steering those missiles to targets, based on math models of their dynamics. Today, such embedded systems are in the minority. These days, embedded software is in cellphones, PDAs, set-top boxes--even microwave ovens and simple thermostats. Not exactly things requiring heavy-duty math.

Fine. If that's the kind of embedded system you're involved with, I can't help you. My focus has been, and always will be, on those embedded systems that *do* need the high-powered math.

Can it be possible that all the math algorithms I've covered in lo these seventeen years, have really been used in embedded systems. Yup, it can. I've not shown you one single algorithm that I've not applied myself, in one embedded system or another.

'Nuff said.

**The least squares fit**

This month, I want to talk about yet another math technique, called the* Least Squares Fit*. This won't be my first time to talk about it. I first covered the topic in 1993 ("The Least Squares Fit," *Embedded Systems Programming*, April 1993, p. 36). In that article, I used a very different, and more academic, approach. I began with the most general and powerful derivation, then specialized to more practical cases. Such an approach feels very comfortable for an old college professor, but perhaps not so comfortable for the student, who has no idea where the prof is going.

This time, I'll still talk about the elegant math and the more general cases, but I'll begin with a very simple, practical, and useful special case, postponing the fancy math for later.

At its core, the least squares fit is all about drawing graphs. In particular, the two-dimensional, *x*-*y* graph sometimes called a scatter plot. I have a process in which I know or suspect that one parameter--the *dependent variable*--seems to depend on the value of another one, the* independent variable*. We can, of course, assign any names we like to these variables, but in this study I'll follow the usual convention and call the independent variable *x* and the dependent variable *y*.

## Loading comments... Write a comment