0
$\begingroup$

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?

  • 0
    exactly, i need solved polynomials to test that the function produced the right value.2012-12-18

1 Answers 1

1

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$.

  • 0
    how about synthetic division? How could i create some test problems that solve nicely with both remainders and whole numbers to use?2012-12-18