The goal of the program is to do math operations on 2 polynomials. I'm having some problems with each function I've written, where they are 'mostly' working, but fail under certain conditions, and I'm hoping someone can help me spot them. I'm attaching my code and the output I'm getting.
Example Output:
Testing addition
[0] + [0] = 0
[0] + [1] = 1
[0] + [x] = x
[3 x] + [-3 x] = 0 x
[-3 x] + [0] = -3 x
[-3 x] + [1] = -3 x + 1
[-3 x] + [x] = -2 x
[-3 x] + [3] = -3 x + 3
[-3 x] + [3 x] = 0 x
[2/3 x^2 - 2] + [-3/4 x^10 + 1/5 x^5] = -3/4 x^10 + 1/5 x^5 + 2/3 x^2 - 2
[2/3 x^2 - 2] + [2 x^5 + 2] = 2 x^5 + 2/3 x^2 -
[2/3 x^2 - 2] + [3 x^10 + 2] = 3 x^10 + 2/3 x^2 -
[-3/4 x^10 + 1/5 x^5] + [0] = -3/4 x^10 + 1/5 x^5
[-3/4 x^10 + 1/5 x^5] + [1] = -3/4 x^10 + 1/5 x^5 + 1
[3 x^10 + 2] + [2/3 x^2 - 2] = 3 x^10 + 2/3 x^2 -
[3 x^10 + 2] + [-3/4 x^10 + 1/5 x^5] = 9/4 x^10 + 1/5 x^5 + 2
[3 x^10 + 2] + [2 x^5 + 2] = 3 x^10 + 2 x^5 + 4
[3 x^10 + 2] + [3 x^10 + 2] = 6 x^10 + 4
Testing subtraction
[0] - [0] = 0
[0] - [1] = 1
[0] - [x] = x
[0] - [3] = 3
[0] - [3 x] = 3 x
[0] - [-3] = -3
[0] - [-3 x] = -3 x
[0] - [2 x^2 - 2 x] = 2 x^2 - 2 x
[0] - [3 x^10 + 2] = 3 x^10 + 2
[1] - [0] = 1
[1] - [1] = 0
[1] - [x] = x + 1
[2 x^5 + 2] - [-3/4 x^10 + 1/5 x^5] = 3/4 x^10 + 9/5 x^5 + 2
[2 x^5 + 2] - [2 x^5 + 2] = 0
[2 x^5 + 2] - [3 x^10 + 2] = -3 x^10 + 2 x^5
[3 x^10 + 2] - [0] = 3 x^10 + 2
[3 x^10 + 2] - [1] = 3 x^10 + 1
[3 x^10 + 2] - [x] = 3 x^10 - x + 2
[3 x^10 + 2] - [3] = 3 x^10 - 1
[3 x^10 + 2] - [3 x] = 3 x^10 - 3 x + 2
[3 x^10 + 2] - [-3] = 3 x^10 + 5
[3 x^10 + 2] - [3 x^10 + 2] = 0
Testing multiplication
[0] * [0] = 0
[0] * [1] = 0
[0] * [x] = 0
[0] * [3] = 0
[0] * [3 x] = 0
[0] * [-3] = 0
[0] * [-3 x] = 0
[1] * [0] = 1
[1] * [3] = 1
[1] * [3 x] = 1
[1] * [-3] = 1
[1] * [-3 x] = 1
[1] * [2 x^2 - 2 x] = 1
[x] * [2 x^5 + 2] = x
[x] * [3 x^10 + 2] = x
[3] * [0] = 3
[3] * [3] = 3
[3] * [-3 x] = 3
[3 x] * [3 x^10 + 2] = 3 x
[-3] * [0] = -3
[-3 x] * [-3 x] = -3 x
[-3 x] * [3 x^10 + 2] = -3 x
[2 x^2 - 2 x] * [0] = 4 x^2 - 4 x
[2 x^2 - 2 x] * [2 x^5 + 2] = 4 x^2 - 4 x
[-3/4 x^10 + 1/5 x^5] * [3 x] = -3/2 x^10 + 2/5 x^5
[2 x^5 + 2] * [0] = 4 x^5 + 4
[3 x^10 + 2] * [x] = 6 x^10 + 4