Thursday, May 15, 2008

Cubic Funcion Discovery

Today I have another question from Yahoo Answers (super math tips people, send some questions too!). The question is simple, but its answer is very, very long.

There is a cubic function that passes through the following points: (-2, -24) (3, -4) (5, 18) (6, 56). Find out what the function is.

(The original question had a point different than (6,56), but it makes it shorter, so the fun is gone).

At first, it seems impossible. But then, you remember that a cubic function has the following form:
y = ax3 + bx2 + cx + d

We have x and y, so we can plug them in to find a, b, c, and d! All we have to do now is set up a system of four equations and solve them. All of them (here comes the long part):

I -8a + 4b - 2c + d = -24
II 27a + 9b + 3c + d = -4
III 125a + 25b + 5c + d = 18
IV 216a + 36b + 6c + d = 56

Now we need to get three equations out of those four. We do that be subtracting the equations from each other and getting rid of d. If done smart, it can even simplify the process in the future (if we can get small enough coefficient). There are six possible outcomes, and the smartest thing to do is to choose the best ones:

A. 91a + 11b + c = 38 (IV - III)
B. 98a + 16b + 2c = 22 (III - II)
C. 35a + 5b + 5c = 20 (II - I)

Now we need to eliminate another variable and create two equations. The chosen one is c. First, we multiply equation A by 2:
A2: 182a + 22b + 2c = 76
B2: 98a + 16b + 2c = 22

After we subtract the two equations we get:
84a + 6b = 54
Divide by 6 to simplify:
14a + b = 9

Now multiply equation A by 5:
A5: 455a + 55b + 5c = 190
C5: 35a + 5b + 5c = 20

Subtract them to get:
420a + 50b = 170
Divide by 10:
42a + 5b = 17

Now we have two more equations:
i. 42a + 5b = 17
ii. 14a + b = 9

Multiply equation ii by 5:
70a + 5b = 45

So now we have:
i21: 42a + 5b = 17
ii21: 70a + 5b = 45

Subtract the two equations:
28a = 28
a = 1

Now everything is going to be super fast. We just need to plug in the numbers we get, this time in equation ii (14a + b = 9):
14 * 1 + b = 9
14 + b = 9
b = -5

Another coefficient! They go down like flies! Now let's use equation A, since it has c with a coefficient of 1:
91a + 11b + c = 38
91 - 55 + c = 38
c = 2

So tiny, with so many problems. One coefficient to go, d, the y-intercept. Let's plug it in equation II, where all coefficients are positive but small:
27a + 9b + 3c + d = -4
27 - 45 + 6 + d = -4
d - 12 = -4
d = 8

THE END!

We now have all coefficients for this cubic function, and we can proudly say that it is:
y = x3 - 5x2 + 2x + 8

Who said cubics are hard?

Nadav


nadavs

2 comments:

Anonymous said...

Or you could make a matrix. :)

Yash Mehta said...

Please could you explain why you do the abcd thing and what it means?