# What are the steps to function design?

So I'm trying to write a program, and I want to use math functions to help it. In this example, I'm trying to change the color of a line based on the position of each pixel on the line.

Anyway, I wanted to make a function with certain aspects, and I have no idea how to go about doing it. For this function, I wanted it to have:

1. A global maximum at (0, 1)
2. A horizontal asymptote on the x axis
3. Symmetric over the y axis
4. And for it to dip below the x axis before approaching the asymptote

Just thinking about it, I figured I needed a couple things, like it should be something like x^4, since it has 3 extremes, and it probably needs to be a rational function since it has an asymptote. But I don't know how to go any further than that, without guessing and checking to an extreme (I tried that, it didn't work out well). I just wanted to know what sorts of things people do to design a function. I figure you start with picking the type of function (polynomial, logistic, exponential, etc.) and there will be different steps for each, but I don't really know what to do past that.

• First of all, what do want the domain and range of your function to be? It sounds like you want a function from the plane $\mathbb{R}^2$ (or maybe 3-space,$\mathbb{R}^3$) to the reals $\mathbb{R}$. Is that right? – Rob Arthan Apr 11 '15 at 23:47
Assuming you've had a little calculus, you could start by describing the derivative. If you want the function to have a global max at $x=0$, then $f^{\prime}(x)=x \cdot g(x)$, so that when you plug in $x=0$ you get $0$ in the derivative (the $g(x)$ is just short-hand for "something else in addition"). To make it symmetric about the $y$-axis, just make sure you have an even function. If you want a horizontal asymptote, then you cannot simply have a polynomial. You could have a fraction of polynomials (if the largest power in the denominator is bigger than the largest power on top, you'll have horizontal asymptotes being the $x$-axis). Making sure it dips below the axis is trickier, but one way you could do it is to have local minima at $x=\pm 1$. To do this add $(x-1)(x+1)$ into the derivative. When you integrate, you'll get a constant of integration. To make sure that you hit $(0, 1)$ you can multiply your function by a constant to adjust heights (this works provided that, before adjusting, the $y$-value isn't 0).
All that said, one example that comes to mind (is not quite what I described above), but try $f(x)=\frac{\cos(x)}{x^2+1}$. At $x=0$ you hit $y=1$, the function is even--so it is symmetric. And it bounces above and below the $x$-axis but has $y=0$ as a horizontal asymptote.