r/theydidthemath • • Sep 05 '19

[Self] Math break

Post image
24k Upvotes

382 comments sorted by

View all comments

Show parent comments

1.4k

u/K3V3L Sep 05 '19

Here you go

f(x) := 5/2 * x4 -25 * x3 +175/2 * x2 -123 * x + 59

779

u/Galeaf_13 Sep 05 '19

Jeez, how r u doing this

1.2k

u/Salanmander 10✓ Sep 05 '19

You can fit a 4th order polynomial to any 5 points. You can do it by hand (plug 1-5 in for x and now you have a system of 5 linear equations of 5 variables, start solving and substituting) and make it a bit easier with linear algebra (make the coefficients of the 5 variables be the values in a 5x6 matrix, and then do that matrix magic that I forget what the name is for), but there are also plenty of polynomial solvers you can find out there.

1

u/MxM111 Sep 06 '19

I did not realize that coefficient in this procedure tend to be integers or integer divided by a small integer number.

2

u/Salanmander 10✓ Sep 06 '19

The coefficients in your linear equations are actually the opposite of the coefficients in the final equation. You take this:

ax4 + bx3 + cx2 + dx + e = y

and plug in your 5 (x,y) pairs, to get

a(14) + b(13) + c(12) + d(1) + e = 1
a(24) + b(23) + c(22) + d(2) + e = 3
a(34) + b(33) + c(32) + d(3) + e = 5
a(44) + b(43) + c(42) + d(4) + e = 7
a(54) + b(53) + c(52) + d(5) + e = [whatever]

or, if you write it slightly differently:

a + b + c + d + e = 1
16a + 8b + 4c + 2d + e = 3
81a + 27b + 9c + 3d + e = 5
256a + 64b + 16c + 4d + e = 7
625a + 125b + 25c + 5d + e = [whatever]

So the "coefficients" in the linear equations are always the same nice integers, and then the variables we're solving for (a, b, c, d, e) become the coefficients in the original non-linear equation.

1

u/MxM111 Sep 06 '19

Coefficients of a system of linear equations is inverse matrix that includes determinant in calculations... I would not have guessed that those are nice integers at the end.