-3

I have to solve the polynomials in addition but its really hard for me. How can I do this?

poly1 = "2x^3 + 3x^2 + 2";
poly2 = "2x^2 + 6";


//result
2x^3 + 5x^2 + 8
joshxb2
  • 15
  • 5

1 Answers1

0

Often a system will just record the coefficients, and store the power by position:

double[] poly1 = {2,3,2};
double[] poly2 = {0,2,6};

Then to add two polynomials you just add the numbers at each position.

markspace
  • 10,621
  • 3
  • 25
  • 39