Finding a,b,c,etc in Quadratic/Cubic Equations I have been developing an RPG and I finally want to program a better development curve. I have decided to use the following equations
Linear, Quadratic and Cubic
The Linear one is easy. I have no problems with that. But I'm stuck with the other 2.
Quadratic
The formula for this equation is $y = ax^2 + bx + c$
What I want to do is find out what $a$ and $b$ are. Given that I know what $y$, $x$ and $c$ are. How would I figure out what this is?
Cubic
The formula for this equation is $y = ax^3 + bx^2 + cx + d$ 
What I want to do is find out what $a, b$ and $c$ are. Given that I know what $y, x$ and $d$ are. How would I figure out what this is?
Can anyone help me with this? This is the first time learning about curves and I am falling flat.
Bonus Question
In the Cubic equation, there is a part that looks like the middle of an S. How would I extend that middle in the equation?
Bonus Question 2
I'd love to know about more graph based curves built using equations. Do you know of any?
Thanks for any help!
 A: For the quadratic case all you need is two pairs of x and y. Let these be $(x_1, y_1) ,(x_2,y_2)$. On putting these values in your equation we get:
$$ax_1^2+bx_1=y_1-c$$
$$ax_2^2+bx_2=y_2-c$$
$$\implies \left[{\begin{array}{cc}
      x_1^2 & x_1\\
      x_2^2 & x_2\\
\end{array}}\right]
\left[{\begin{array}{c}
      a\\
      b\\
\end{array}}\right]=
\left[{\begin{array}{c}
      y_1-c\\
      y_2-c\\
\end{array}}\right]$$
It is now easy to solve for a and b.
In case of the cubic equation the only difference is that you need atleast 3 pairs of x and y. The rest is the same.
The middle part of the S is actually the part between the roots of the derivative of the cubic. To increase that distance you need to increase this distance between the roots.
Consider a cubic $ax^3+bx^2+cx+d$. Its derivative is $3ax^2+2bx+c$. Let the roots of the quadratic be $\alpha$ and $\beta$.
$$ \alpha + \beta = -\frac{2b}{3a} $$
$$ \alpha\beta = \frac{c}{3a} $$
$$ (\alpha-\beta)^2 = (\alpha+\beta)^2 - 4\alpha\beta $$
$$ (\alpha-\beta)^2 = \frac{4b^2-c^2}{9a^2} $$
To increase the middle portion of the S you need to increase the value of $\frac{4b^2-c^2}{9a^2}$.
Added after Jeremy's request:
$$ax_1^2+bx_1=y_1-c$$
$$ax_2^2+bx_2=y_2-c$$
Multiply the equation above by $x_2$ and below by $x_1$
$$ax_1^2x_2+bx_1x_2=(y_1-c)x_2$$
$$ax_2^2x_1+bx_2x_1=(y_2-c)x_1$$
Subtract the two equations
$$a(x_1^2x_2-x_2^2x_1) = (y_1-c)x_2-(y_2-c)x_1$$
$$\implies a = \frac{(y_1-c)x_2-(y_2-c)x_1}{x_1^2x_2-x_2^2x_1}$$
Finding $b$ is now easy.
Learning about matrices will help you in finding the unknown coefficients for curves of even higher degree.
A: There are two aspects of your questions:


*

*How to do it in an abstract, ideal setting.

*How to do it in practice.


First, if you have $n$ unknowns, you need $n$ data points (modulo special cases), like pairs $(x,y)$. Then you get a system of linear equations, which you can easily solve.
I would start with Wikipedia, but there are libraries which would solve them for you (however, please do start with some theory, it would be much easier for you later, as for the software, start with what BLAS is).
To give a concrete example, suppose that you would like your model to have the following formula $$y = ax^2+bx+c.$$
There are three unknowns, namely $a,b,c$, so you need three independent data points. Let's make it $(0,1), (2,4), (8,16)$ where the pair means $(x,y)$.
We put this into some engine, e.g. Wolfram Alpha and obtain $a = \frac{1}{16}$, $b = \frac{11}{8}$ and $c = 1$.
Now, how to do it practice is a whole other question. In particular you will often have multiple data points which contain some noise, and you would like to model the general behavior. Some relevant topics are curve fitting and regression analysis. Be aware that this area is huge and there are whole courses that consider only a small part of it. If you want to dwell more on this, I would recommend machine learning first to gain a wider perspective (e.g. there are some great online resources on this). If you are serious, but want to stick to only a few methods, I would recommend processing your data with Kalman filters (probably an overkill).
Finally, if this is not a system-critical part, some trail-and-error might give you better results than using some mathematical approach you have no experience with.
I hope this helps $\ddot\smile$
