Skip to content
Sign upLog in
← Back to Community

Polynomial Generator

Profile icon
MichaelWang23

Input a list of points and create a polynomial that passes through those points.

Process:

Prompts user to input a set of points
Places the points into a list
Scrolls through the list making separate equations for each by replacing x and y in ax^n + bx^(n-1) . . . mx + n = y (without the coefficients) with the coordinates
Stores each term in each equation in a list and the y value in another
Stores all term lists into a matrix represented by a list of lists and all y values in another
Multiplies the inverse of the matrix of coefficients by the matrix of y values to get the solution matrix
Pairs each coefficient with the value it corresponds to in the solution matrix and prints it out

Voters
Profile icon
SierraKorte80721
Profile icon
SeanHofemann
Profile icon
MichaelWang23
Comments
hotnewtop
Profile icon
TheDrone7

This looks interesting but, what is the "matrix" exactly for and would be nice if you could display it in polynomial form instead of just listing the co-efficients.

Profile icon
MichaelWang23

@TheDrone7
Do I still get full credit or can I fix those for partial credit.

Profile icon
TheDrone7

@MichaelWang23
wait this is an assignment? You apparently posted your assignment on community forums lol and I thought it was just a project so I was suggesting adding more to it.

Profile icon
MichaelWang23

@TheDrone7
oh shoot I thought you were my math teacher xD welp sorry about that. I'll implement your ideas either way, thanks for the tip. Also, would you happen to know how to get rid of the quotation marks and parenthesis when it prints.

Profile icon
MichaelWang23

@MichaelWang23
and also the 0.000000000000132 thing

Profile icon
TheDrone7

@MichaelWang23
ah I see lol. I'm afraid I can't figure out why the quotation marks and stuff is there either.

Profile icon
MichaelWang23

@TheDrone7
to google we go then. Also I'm still pretty new to Python since for the past 2 years I've been coding with something that isn't considered as a language (scratch) so if you see anything really obvious that I should change let me know.

Profile icon
TheDrone7

@MichaelWang23
for a beginner, this is a really nice project. Usually, we see stuff like "Hello world" or plain HTML pages and similarly minor projects, which we eventually unlist. Your post's description also indicated it to be one of those posts because of the lack of detailed explanation of how it accomplishes what it does but when I ran it, I understood what's happening and it changed my mind lol.

Profile icon
TheDrone7

So, my only recommendation, for now, would be when you post something on the forums, keep the description a little more detailed.

Profile icon
MichaelWang23

@TheDrone7
I actually had already coded this in Scratch so I had a general idea of how it would work in Python, it was just how to get the syntax to work. Python also has several libraries that made life a lot easier, like the numpy thing. Also, what should I be putting in my description?

Profile icon
TheDrone7

@MichaelWang23
well, a good thing to do would be to rename it to something like "Polynomial generator" and as for the description, you could explain the process it uses to generate the polynomial.