First non-introductory post! I wanted to mark my geekiness, truth to be told.
LaTeX markup is available for all equations on this page; click on an equation to get its code if you're not viewing this in an RSS reader. LaTeX rendering courtesy of Texify, graphing thanks to this utility.
The idea came up as a challenge for me — most students in my classroom now know about my "DNA" function, which looks like this:

Which is basically the function:

But limited by these two functions:
Fair enough, that's DNA, alright. The thing is that it uses the function min() and max() to constrain the function into a reserved space. The max() function returns the largest number out of two given numbers, and min() does the opposite. These are what I unscientifically call conditional functions: they return a certain value in one case, another value in another case. It reminded me of the abs() function, which returns the positive value of a given number. abs(x) can be replaced by simple arithmetic operations:

Simple as that, really. This way, I could rewrite my DNA function using only basic math.
But then I thought about min() and max(). What about them? Could they be written in such a manner? Using only these three operations:
- Addition/substraction (+, -)
- Multiplication/division (×, ÷)
- Exponents (ab)
And I managed to do it, albeit with some limitations (more on that later). Here's the logic I used:
The max() function
max(a,b) is a when a > b, or b when b > a. It's also a×1 + b×0 when a > b, or a×0 + b×1 when b > a. In other words, max(a,b) is a(a > b) + b(b > a), with (a > b) and (b > a) being booleans (1 when true, 0 when false).
All good up to now, but using boolean is also "conditional". So my next worry was: how to write (a > b) or (b > a) using simple arithmetic operations?
In order to compare two numbers, a and b, you can compare their difference, a - b, and look at its sign, given using the signum (sgn) function. In other words:
is either 1 if a > b, either -1 if b > a.
That's great, we got 1 or -1. How do we convert that to a boolean (0 or 1)? Why, all that's needed is to add one and to divide by 2:

Indeed, (1+1)÷2 = 1 (if a > b), and (-1+1)÷2 = 0 (if b > a).
This way, the max() function can be rewritten like so:


That's some progress. But there's still the sgn function here which troubles the whole thing. How exactly do you get the sign of a number?
Well, here's a pretty obvious way to do it:

Which uses the abs() function, which can be replaced as described earlier in this post:

Awesome! Here's the final result:

Which gives the following curve for a(x)=2cos(x) and b(x)=sin(2x):

The min() function
You can apply the same reasoning here as well. You only have to switch around the a and b coefficient. Here's the result:

And the curve, with the same a and b:

The DNA function - rewritten
It had to be done. Sorry guys. Here's the mighty DNA function again, in "simple arithmetic" form! (Hover to fancy-ly enlarge! If you're not viewing this in an RSS reader, that is)

LaTeX code:
\text{dna}(x)=\frac{-\sqrt{\sin^2(x)}.(\frac{\sqrt{(-\sqrt{\sin^2(x)}-\frac{9001.\cos(\frac{5x}{2}+\frac{\pi}{2}).(\frac{\sqrt{(\sqrt{\sin^2 x}-9001.\cos(\frac{5x}{2}+\frac{\pi}{2}))^2}}{\sqrt{\sin^2 x}-9001.\cos(\frac{5x}{2}+\frac{\pi}{2})}+1)+\sqrt{\sin^2 x}.(\frac{\sqrt{(9001.\cos(\frac{5x}{2}+\frac{\pi}{2})-\sqrt{\sin^2 x})^2}}{9001.\cos(\frac{5x}{2}+\frac{\pi}{2})-\sqrt{\sin^2 x}}+1)}{2})^2}}{-\sqrt{\sin^2(x)}-\frac{9001.\cos(\frac{5x}{2}+\frac{\pi}{2}).(\frac{\sqrt{(\sqrt{\sin^2 x}-9001.\cos(\frac{5x}{2}+\frac{\pi}{2}))^2}}{\sqrt{\sin^2 x}-9001.\cos(\frac{5x}{2}+\frac{\pi}{2})}+1)+\sqrt{\sin^2 x}.(\frac{\sqrt{(9001.\cos(\frac{5x}{2}+\frac{\pi}{2})-\sqrt{\sin^2 x})^2}}{9001.\cos(\frac{5x}{2}+\frac{\pi}{2})-\sqrt{\sin^2 x}}+1)}{2}}+1)+\frac{9001.\cos(\frac{5x}{2}+\frac{\pi}{2}).(\frac{\sqrt{(\sqrt{\sin^2 x}-9001.\cos(\frac{5x}{2}+\frac{\pi}{2}))^2}}{\sqrt{\sin^2 x}-9001.\cos(\frac{5x}{2}+\frac{\pi}{2})}+1)+\sqrt{\sin^2 x}.(\frac{\sqrt{(9001.\cos(\frac{5x}{2}+\frac{\pi}{2})-\sqrt{\sin^2 x})^2}}{9001.\cos(\frac{5x}{2}+\frac{\pi}{2})-\sqrt{\sin^2 x}}+1)}{2}.(\frac{\sqrt{(\frac{9001.\cos(\frac{5x}{2}+\frac{\pi}{2}).(\frac{\sqrt{(\sqrt{\sin^2 x}-9001.\cos(\frac{5x}{2}+\frac{\pi}{2}))^2}}{\sqrt{\sin^2 x}-9001.\cos(\frac{5x}{2}+\frac{\pi}{2})}+1)+\sqrt{\sin^2 x}.(\frac{\sqrt{(9001.\cos(\frac{5x}{2}+\frac{\pi}{2})-\sqrt{\sin^2 x})^2}}{9001.\cos(\frac{5x}{2}+\frac{\pi}{2})-\sqrt{\sin^2 x}}+1)}{2}+\sqrt{\sin^2(x)})^2}}{\frac{9001.\cos(\frac{5x}{2}+\frac{\pi}{2}).(\frac{\sqrt{(\sqrt{\sin^2 x}-9001.\cos(\frac{5x}{2}+\frac{\pi}{2}))^2}}{\sqrt{\sin^2 x}-9001.\cos(\frac{5x}{2}+\frac{\pi}{2})}+1)+\sqrt{\sin^2 x}.(\frac{\sqrt{(9001.\cos(\frac{5x}{2}+\frac{\pi}{2})-\sqrt{\sin^2 x})^2}}{9001.\cos(\frac{5x}{2}+\frac{\pi}{2})-\sqrt{\sin^2 x}}+1)}{2}+\sqrt{\sin^2(x)}}+1)}{2}
Limitations
Evidently, the formula takes a lot longer to process and calculate on a standard graphing calculator. But the main limitation of such a formula probably seem evident to most of you guys that have been reading until this point: The function fails if a = b. Yes, and it's pretty obvious (division by (a - b)). If anyone has a suggestion on how to fix this, feel free to share!


