0

I am trying to solve a mathematical problem that is in the form of this function:

f(x) = c1x1 + c2x2 + q1x12 + q2x1x2 + q3x22

Now I have created an interface where the user can input the values of c1, c2, q1, q2, and q3

Now what we need to solve this function are the values of x1 and x2 to be substituted in the equation. In other parts of the algorithm, the values of x1 and x2 usually ends up with something like x1 = (0 - 0.8ρ1) and x2 = (0 - 0.6ρ1)

Now assuming the user keyed in the values of c1, c2, q1, q2, and q3 as 0, 2, -1, 2 and -2 respectively, this will make the function to appear as:

f(x) = 0x1 + 2x2 + -1x12 + 2x1x2 + -2x22

This can be re-written as:

f(x) = 2x2 - 1x12 + 2x1x2 - 2x22

Now if we substitute x1 = (0 - 0.8ρ1) and x2 = (0 - 0.6ρ1) in the equation above we will have:

f(x) = 2(0 - 0.6ρ1) - 1(0 - 0.8ρ1)2 + 2(0 - 0.8ρ1)(0 - 0.6ρ1) - 2(0 - 0.6ρ1)2

As you can see if we solve further we will eventually find the value of ρ1

So the problem now is how can one write a program to solve this kind of problem and get the value of ρ1 in Java, or is there such a program already written? I've tried so many things already but can't come up with a solution.

Any help will be highly appreciated. Thanks

  • Jevison
Jevison7x
  • 709
  • 2
  • 14
  • 31

1 Answers1

0

Sounds to me like you need to finish developping f(x) so it gets to the form ax^2 + bx + c = 0

and then use this to solve: http://www.web-formulas.com/Math_Formulas/Algebra_Polynomials_Second_Degree.aspx

It's not really a Java problem. Once you have the equations for the solution, it'll be easy to write.

mprivat
  • 21,582
  • 4
  • 54
  • 64
  • ax^2 + bx + c = 0 is a cubic function, I'm working on a quadratic function. – Jevison7x Feb 26 '13 at 15:25
  • I'm reasonably sure this isn't quadratic... f(x) = 2(0 - 0.6ρ1) - 1(0 - 0.8ρ1)2 + 2(0 - 0.8ρ1)(0 - 0.6ρ1) - 2(0 - 0.6ρ1)2. You need to develop this further. – mprivat Feb 26 '13 at 16:52