0

I never used Java to solve a polynomial equations before. I wonder how can I solve an equation like this:

5.5 (1 - x) + 4 x (1 - x) + 4 x^2 (1 - x) + 6 x^3 (1 - x) + 5 x^4 (1 - x) + 5 x^5 (1 - x) + 5 x^6 (1 - x) + 5 x^7 (1 - x) + 5 x^8 (1 - x) + 5 x^9 (1 - x) + 5 x^10 (1 - x) + 5 x^11 (1 - x) + 5 x^12 (1 - x) + 5 x^13 (1 - x) + 5 x^14 (1 - x) + 5 x^15 (1 - x) = 5

I tried to use apache commons math, but PolynomialFunction constructor expects an array of the coefficients only and based on the number of the coefficients the degree is set. I couldn't find a way to set the terms explicitly.

I wonder how can I solve such equation above in java using any library available. I would appreciate an example as well

Hisham Ragheb
  • 144
  • 2
  • 10
  • 1
    You have to expand this to produce a polynomial with coefficients. 5.5(1-x) adds to the constant term and the x^1 term, 4x(1-x) adds to the x^1 and the x^2 term, etc. This is basic algebra. – ajb May 29 '17 at 02:35
  • 1
    Since (1-x) seems to be a factor in every term, you could build two polynomials and multiply them. – Dawood ibn Kareem May 29 '17 at 02:36

0 Answers0