# More on Simultaneous Equations

The previous post dealt with solving three equations in three unknowns, however, one equation was trivial leaving two equations in two unknowns. This problem is similar and my guess is that the person emailing it to me is trying to fit an equation to some data. So, I’ll solve the requested problem, then comment on its application.

The person submitting the problem wanted to find the coefficients of a cubic polynomial satisfying the following conditions. Let p(x) = a + bx + cx2 + dx3.

p(0) = 0
p(1/4) = ∏/2
p'(0) = m1
p'(1/4) = m2

Instead of fitting a cubic polynomial to four points, this person wants to find the polynomial interpolating two points with specified slope at those two values. Seems to me this should really be a cubic Hermite curve, but more on that later. At the least, it’s a good exercise in setting up and solving a system of equations.

Now, p'(x) = b + 2cx + 3dx2, so

p(0) = 0 means that a = 0. This makes things quite a bit easier 😉

p(1/4) = ∏/2 -> b/4 + c/16 + d/64 = ∏/2 or b/2 + c/8 + d/32 = ∏ or 16b + 4c + d = 32∏ .

p'(0) = m1 -> b = m1 . Fortunately, the easy initial conditions leave us with two equations in the remaining two unknowns c and d.

p'(1/4) = m2 -> m1 + c/2 + 3d/16 = m2 – m1 or 8c + 3d = 16(m2 – m1) .

Substitute the value of b into the equation for p(1/4) to obtain 4c + d = 16(2∏ – m1) = c1

Let c2 = 16(m2 – m1) = 8c + 3d. Solve the above equation for d and substitute into the second to yield

8c + 3(c1 – 4c) = c2 or 4c = c2 – 3c1 or c = (c2 – 3c1)/4 .

Since d = c1 – 4c, we have d = c1 – (c2 – 3c1) = 4c1 – c2 .

Given the coefficients, the polynomial can be evaluated efficiently in nested form.  I think the issue with these problems is getting overwhelmed with all the conditions.  Once you write it out and take it one step at a time, things become much easier, especially with the friendly conditions. It can often be easier to introduce additional temporary variables such as the c1 and c2 above instead of writing everything out in terms of initial variables and conditions.

My belief is that the person asking this question wanted to ‘fit’ a table of data with a cubic polynomial.  The conditions were designed to force the polynomial to take a certain direction ‘out of’ the initial point and ‘in to’ the final point.  The problem with polynomials of this form is that they want to oscillate.  The higher the degree, the greater the tendency to oscillate.  Just setting the derivative value at the endpoints does not guarantee the polynomial will follow that direction more closely as the derivative value increases.  That’s essentially what a cubic Hermite curve does.  The polynomial derived here may do a good job close to the endpoints, but don’t assume that means a good fit anywhere else.

In the previous post on parabolic scaling, we presumed that a quadratic polynomial was a reasonable model for the problem at hand.  I hope this post helps some people with setting up and solving simultaneous equations and provides some insight into the thinking process regarding whether or not such a polynomial is a good model for a given problem.