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.


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?


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!

  • $\begingroup$ The quadratic is one equation with two unknowns; there are an infinite number of solutions. The cubic is even worse, there are three unknowns in one equation. $\endgroup$
    – Eff
    Mar 27, 2014 at 12:03
  • $\begingroup$ If you only have one set of value, this will not be enough to find what $a$ and $b$ are. Same goes for the cubic equation. To find $n$ constants of an equation, you will generally need $n$ points therefore $n$ $(x,y)$. $\endgroup$
    – user88595
    Mar 27, 2014 at 12:04
  • $\begingroup$ When you say unknown, do you mean they could be any value and it could match y? $\endgroup$ Mar 27, 2014 at 12:04
  • $\begingroup$ Well, $a$ and $b$ are unknowns in the quadratic case. Generally you need (at least) 2 equations to solve for 2 unknowns. $\endgroup$
    – Eff
    Mar 27, 2014 at 12:06
  • $\begingroup$ Hmm. I guess this is an impossible feat then for me. Are there any good programs I can use to plot out curves on? The ones I find go up to -50 to 50 on the x/y axis? $\endgroup$ Mar 27, 2014 at 12:06

2 Answers 2


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.

  • $\begingroup$ Well that makes more sense but I am still confused. Could you go through solving a and b a bit more? I haven't seen that sort of bracketing before. $\endgroup$ Mar 27, 2014 at 12:27
  • $\begingroup$ @JeremyBeare. Those are matrices. Forget the matrices. to get a and b you could just solve the two equations above it. $\endgroup$
    – lakshayg
    Mar 27, 2014 at 12:30
  • $\begingroup$ Ok I'll do it with a real life scenario. This is for Armour development Level 1 Armour : (a * (1 * 1)) + (b * 1) = 2 - 1, Level 11 Armour : (a * (11 * 11)) + (b * 11) = 64 - 1 $\endgroup$ Mar 27, 2014 at 12:32

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$

  • $\begingroup$ Well that makes it easier! Now I have a new problem. I did it with 3 points. The first point was with x being 1 (Where I want the curve up to start). The last 2 points being where I the last values of Y. Now the equation does indeed work for all points, the points between 1 and the last 2 points for the majority bring a negative y. I guessed this was because one of the points need to be in the middle of the curve. But then this causes a problem because I want to use the graph to find the points between the beginning and the end. What do I do? $\endgroup$ Mar 27, 2014 at 13:07
  • $\begingroup$ @JeremyBeare It's hard to say when I don't know your data. However, maybe the quadratic equation is not the one you are looking for, how would the ideal curve look like? $\endgroup$
    – dtldarek
    Mar 27, 2014 at 13:10
  • $\begingroup$ I think you are completely right. Everything I have done doesn't work. i114.photobucket.com/albums/n260/danielkin09/Curves.png rpg.net/news+reviews/columns/RFF_045.gif rpg.net/news+reviews/columns/RFF_044.gif These are the types of curves I want to achieve. Whenever X increases, Y must always increase $\endgroup$ Mar 27, 2014 at 13:13
  • $\begingroup$ @JeremyBeare Take a look at S-function, also at exponential function and logarithms. Maybe something like $y = a\cdot \exp{(b\cdot x+c)}$ or $y = a\cdot \log{(1+b\cdot x)}$ or $y = a\cdot \tanh{(b\cdot x+c)}$ would work better for you. $\endgroup$
    – dtldarek
    Mar 27, 2014 at 13:53

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.