Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a file i need to write a unit test for that includes a number of polynomial functions, and i need to provide test data to the function to calculate and compare them with an exact answer(preferably a whole number that i could easily compute myself with some math). I have to test:

  • Multiplication
  • Scaling
  • Addition
  • Subtraction
  • Synthetic Division
  • Quadratic roots
  • Cubic Roots
  • Quartic Roots

most of these will be easy to come up with 'simple' equations to test, but i'm a little stuck once i reach synthetic division and multiplication of polynomials. Could anyone give me a couple "nice" equations that equate to some whole numbers i can use in my tests, even better a method for creating such equations to test?

share|cite|improve this question
You want to generate polynomials with known solutions ? – Amr Dec 18 '12 at 4:17
exactly, i need solved polynomials to test that the function produced the right value. – Need4Sleep Dec 18 '12 at 4:25

Why don't you just multiply some monomials, expand them, then give them to the computer.

For example: $(x+1)(x+2)(x-2)=x^3+x^2-2x-2$. The roots of $x^3+x^2-2x-2$ are $-1,-2,2$.

share|cite|improve this answer
how about synthetic division? How could i create some test problems that solve nicely with both remainders and whole numbers to use? – Need4Sleep Dec 18 '12 at 5:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.