# Parabola attributes - custom curve?

UPDATE: I feel like my original question was too vague and didn't provide enough information (as others have mentioned). So I'm going to restate it.

Purpose: I want to find an equation in order to provide a smooth slope for an animation that I am creating. My animation consists of a lever and a set of numbers on a horizontal line. As you move the lever up and down the numbers will slide down and up the line (opposite of the lever). I want to create a smooth curve so that the user can "feel" the speed increasing the further they get away from the center. Most of the time, the user will stay within the main part of the screen, therefore I want the sliding numbers to go slowly for that space. But once they get closer to the top or bottom I want the increase in speed to be relatively quick.

Requirements: The variables are the distance from center that the lever is, $x$, and the distance that the numbers should move, $y$. I need $x=y=0$ so there is no movement at the center. $y$ should be positive when $x$ is positive, but $y$ can be positive or negative when $x$ is negative. The graph just needs to be symmetric for $x=0$ or $x=y$.

Right now I'm using a simple parabola $y = (0.03*x)^2$ but I would like the middle space to be "stretched out." Therefore, is there a function that I can use that would have some constants (maybe some points) to define what kind of slope is found for, lets say $x=0$ to $x=100$ and then it curving to another point at $x=160$.

I don't want to use piecewise because unless I use a lot of pieces, the user will be able to "feel" the positions where the equation changes. I think Quadratic Bézier curve might do the trick, but if it can, I would need help in understanding how to use it.

Question: is the Quadratic Bézier curve what I should be looking into, if not, what do you suggest? If it is, do you have a suggestion of what equation I should use or at least a reference were I can relearn it.

Old question: I need to come up with an equation for a curve but I have forgotten most of my calculus by this point. What I need very close to a parabola that opens up. I'm currently using y = (0.03*x)^2 but this does not have a fast enough slope on the ends.

I need the slope in the middle to be very gradual, and then near the ends to increase faster.

I'm guessing this won't be a standard parabola, but I'm not just sure what I should be looking for.

UPDATE: Attempting to be more detailed with my "requirements." This is for a computer animation and a user is sliding a "lever" up and down. As they do so a set of numbers are scrolling the opposite direction on the side. The further away the lever is from center, the faster the numbers should go. Thus, I want the edges (top and bottom) to make the numbers go much faster. But for most of the main section of the screen, they shouldn't go so fast. But I want the transition from slow to fast to be noticeable so that it feels intuitive to the user.

Thus, I need a function that has a high value for y as x gets larger, but I want the edges to have a greater slope. Bézier curve looks like it might work? But it has been a long time since I've used it. Anyone have suggestions for how to use it in this context?

-
You have not given enough information for this to be answered well, and there are a number of ways to do this. For example, $y=cx^4$ or $y=c_1x^2+c_2x^4$ will have gradual increase for small $x$, and much greater increase for larger $x$. Even higher degree even powers will make it increase even faster. Or how about $y=e^{cx^2}-1$, or $y=c\cosh(x)-1$? – Jonas Meyer Oct 25 '10 at 21:02
What do you need it for? If it's for a computer program (for use in, say, an animation), there's no need for it to be described exactly by one formula. You might get away with defining it piecewise with small straight line segments, and then you can design it as you wish without any need for fancy formulas. – Samuel Oct 25 '10 at 21:06
(I had a typo: I meant $y=\cosh(cx)-1$.) – Jonas Meyer Oct 25 '10 at 21:08
Then all you need it is a twice differentiable curve. This is what a bézier curve is for. – Samuel Oct 25 '10 at 22:01
@Ryan: Anything that is more specific about what your curve is supposed to do would be nice. Is it modeling a concrete physical situation? Or do you only have a vague idea of what you want the shape to do with no desire for precision? – Jonas Meyer Oct 25 '10 at 22:05

I think the easiest way may be piecewise—not piecewise-linear, but a piecewise-defined function that is relatively smooth, so there isn't a point where the speed suddenly changes. Let's say that you want slope $m$ for $-a\le x\le a$ (and $y=0$ when $x=0$), then curving up to the point $(b,c)$. $$y=\begin{cases} \frac{-a^2 c+a^2 b m}{(a-b)^2}-\frac{\left(2 a c-a^2 m-b^2 m\right) x}{(a-b)^2}+\frac{(-c+b m) x^2}{(a-b)^2} & \text{ if } x<-a \\ mx & \text{ if } -a\le x\le a \\ -\frac{-a^2 c+a^2 b m}{(a-b)^2}-\frac{\left(2 a c-a^2 m-b^2 m\right) x}{(a-b)^2}-\frac{(-c+b m) x^2}{(a-b)^2} & \text{ if } x>a \end{cases}$$ (I arrived at this formula by having Mathematica solve for the coefficients of the quadratic polynomial that would go through the point at the end of the linear segment and the other given point and have the same slope as the linear segment at the splice point: a1 x^2 + a2 x + a3 /. Solve[a1 a^2 + a2 a + a3 == a m && 2 a1 a + a2 == m && a1 b^2 + a2 b + a3 == c, {a1, a2, a3}].)

For example, if you wanted a slope of $\frac{1}{4}$ from -100 to 100, then curving up to (180,150), $a=100$, $m=\frac{1}{4}$, $b=180$, $c=150$, and $$y=\begin{cases} -\frac{2625}{16}-\frac{97 x}{32}-\frac{21 x^2}{1280} & \text{ if } x<-100 \\ \frac{1}{4}x & \text{ if } -100\le x\le 100 \\ \frac{2625}{16}-\frac{97 x}{32}+\frac{21 x^2}{1280} & \text{ if } x>100 \end{cases}$$

edit: even smoother would be to use a cubic polynomial for the end parts and force it to match the first and second derivatives at the splice points (a1 x^3 + a2 x^2 + a3 x + a4 /. Solve[a1 a^3 + a2 a^2 + a3 a + a4 == a m && 3 a1 a^2 + 2 a2 a + a3 == m && 6 a1 a + 2 a2 == 0 && a1 b^3 + a2 b^2 + a3 b + a4 == c, {a1, a2, a3, a4}]):

$\begin{cases} \frac{-a^3 c+a^3 b m}{(a-b)^3}-\frac{\left(3 a^2 c-a^3 m-3 a b^2 m+b^3 m\right) x}{(a-b)^3}+\frac{3 a (-c+b m) x^2}{(a-b)^3}-\frac{(c-b m) x^3}{(a-b)^3} & x<-a \\ m x & -a\leq x\leq a \\ -\frac{-a^3 c+a^3 b m}{(a-b)^3}-\frac{\left(3 a^2 c-a^3 m-3 a b^2 m+b^3 m\right) x}{(a-b)^3}-\frac{3 a (-c+b m) x^2}{(a-b)^3}-\frac{(c-b m) x^3}{(a-b)^3} & x>a \end{cases}$

For example, if you wanted a slope of $\frac{1}{4}$ from -100 to 100, then curving up to (180,150), as above, $a=100$, $m=\frac{1}{4}$, $b=180$, $c=150$, and

$y=\begin{cases} \frac{13125}{64}+\frac{1639 x}{256}+\frac{63 x^2}{1024}+\frac{21 x^3}{102400} & x<-100 \\ \frac{x}{4} & -100\leq x\leq 100 \\ -\frac{13125}{64}+\frac{1639 x}{256}-\frac{63 x^2}{1024}+\frac{21 x^3}{102400} & x>100 \end{cases}$.

original answer: Would $y=\cot(3x+0.07)$ for $0\le x\le 1$ work? Or $y=-\frac{x-0.5}{(x+0.1)(x-1.1)}$?

-
I need the graph to be symmetric about the y-axis or at least x=y. With x=y=0. – RyanJM Oct 26 '10 at 16:27
For Mathematica users: Note that InterpolatingPolynomial[] allows you to do a Hermite interpolation; that is, it allows you to generate the cubic whose values and derivatives are specified values. For instance, Expand[InterpolatingPolynomial[{{0, {-1,2}}, {1, {3,-1}}}, x]] gives the cubic polynomial $p(x)$ such that $p(0)=-1$, $p^{\prime}(0)=2$, $p(1)=3$, $p^{\prime}(1)=-1$. – J. M. Oct 26 '10 at 23:14
@J.M.: I have a tendency to forget about that. It did occur to me right after I posted, but I was on my way out the door. – Isaac Oct 27 '10 at 1:06
Sorry for my delay getting around to accepting this. I finally implemented it today and it works really well. Thank you very much. – RyanJM Nov 4 '10 at 18:45
@RyanJM: No problem; I'm glad it worked. Did the reasoning make sense? – Isaac Nov 4 '10 at 19:06