# Find, programmatically, equation of quartic curve with three points, two of which are turning.

I have a curve which passes through the origin with gradient zero, and also through the point (d,1) with gradient zero. It also passes through the point (m,n) between the two. I believe this is a quartic with an equation of the form y = ax^4 + bx^3 + cx^2. I need to be able to programmatically find the equation for different m, n, and d. So I need expressions for a, b, and c in terms of m, n, and d.

I have found these three equations:

(1) ad^4 + bd^3 + cd^2 = 1 (from point (d,1))

(2) 4ad^2 + 3bd + 2c = 0 (from gradient at (d,1), divided by d as I know d to be non-zero)

(3) am^4 + bm^3 + cm^2 = n

Can a, b, and c be found programmatically? If not is there another curve which fits my purposes (flat at origin and (d,1), passes through (m,n) somewhere between the two, I must be able to change d, m, and n)?

Many thanks in advance for the help.

• It's a linear system, very standard to solve. What do you mean by "programmatically"? – Aretino Sep 2 '16 at 13:31
• Well, I need a computer to be able to do it for any m, n, and d. So I can't be doing factorizations that depend on actually having the numbers. I'm not saying it isn't easy, but I have been trying for a few hours and it's too hard for my tiny brain. – Gabriel Sep 2 '16 at 13:57
• I eventually got to something that looks like this (you can see my equations for a, b, and c in the bottom left). Either I've gone at it from completely the wrong angle or made a stupid mistake. I'm going back through my working now but can't shake the feeling I'm missing something really simple. jsfiddle.net/themusicroob/fqwmu943/6 – Gabriel Sep 2 '16 at 14:00
• Do you know how to solve a linear $3\times3$ system of equations. There are a lot of different ways to do that, it all depends on what kind of tools you have at your disposal and on how much linear algebra you know. – Aretino Sep 2 '16 at 14:00
• I think I probably know somewhere in the back of my mind, but I left university almost three years ago and it's all gone. And I was so excited to have a real-world application for maths too... :( – Gabriel Sep 2 '16 at 14:03

You have three linear equations with three unknowns so it will solve in a few steps. While doing the calculations remember that $d$, $m$ and $n$ represent values while $a$, $b$ and $c$ are variables you want to find.

The working out will depend upon what techniques you know to solve systems of linear equations. I'll add something if you want but without knowing if you know matrices it's pretty ugly looking.

$$a= \frac{d^3n-3 d m^2+2 m^3}{d^3 m^2 (d-m)^2}$$
$$b= \frac{2\left(-d^4 n+2 d^2 m^2-m^4\right)}{d^3 m^2 (d-m)^2}$$
$$c= \frac{d^4n-4 dm^3+3 m^4}{d^2 m^2 (d-m)^2}$$
• You didn't state that the curve can't go below $0$ or above $1$. That is why you are getting the odd non-smooth behaviour with the line when you move your point close to either end. – Ian Miller Sep 2 '16 at 14:33
• Maybe you can solidify/clarify your actual requirements for the graph then ask that in a new question (link back to this one and to your solution so far). I'm guessing you want a curve which is flat at $(0,0)$ and $(d,1)$ and increasing smoothly and monotonically from $x=0$ to $x=d$ and also passes through the point $(m,n)$. – Ian Miller Sep 2 '16 at 14:44