0
$\begingroup$

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.

Thank you for your time.

$\endgroup$
  • $\begingroup$ 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? $\endgroup$ – Rob Arthan Apr 11 '15 at 23:47
  • $\begingroup$ @RobArthan Yeah, I do want it to be R^2, not R^3, and domain to be all reals. Range should be something like [w, 1]. Where w is some number -1<w<0. Just to give a concrete number, I'd go with .25 $\endgroup$ – awenonian Apr 12 '15 at 4:54
0
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ This was really helpful, I didn't think about using the derivative. I'll probably mess around more with that new info in the morning and see what I can come up with. Thank you. $\endgroup$ – awenonian Apr 12 '15 at 5:00
  • $\begingroup$ @awenonian, the derivative is a really easy way to do it provided that you don't have the asymptote condition (if you just want to specify maxima/minima and points on the curve). If you make the derivative a fraction, it can be tricky to integrate, and tricky to guarantee you get an even function in the end. $\endgroup$ – TravisJ Apr 12 '15 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.