Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

A Getting as close as possible to a solution (system of equations)?

  1. Jul 13, 2017 #1

    I have a set of equations that look like this:

    y1 = k1*x1 + k2*x2 - A1 = 0
    y2 = k3*x1 + k4*x3 - A2 = 0
    y3 = k5*x2 + k6*x4 - A3 = 0
    y4 = k7*x3 - A4 = 0
    y5 = k8*x4 - A5 = 0

    k1 to k8 are known positive constants. A1 to A5 are known positive constants (I will use different values for A1 to A5 depending on the cirumstances).

    Assuming this system does not have any solution, how do I calculate the values of x1 to x4 such that y1 to y5 come as close to 0 as possible? All constants must be positive.
  2. jcsd
  3. Jul 13, 2017 #2
    Apparently you are looking to minimize (abs(y1)+abs(y2)+abs(y3)+abs(y4)+abs(y5)). This is in contrast to least squares best fit where you would look to minimize (Y1^2+Y2^2+Y3^2+Y4^2+Y5^2).

    The way you are doing it, the exact formula must take into consideration which k's are greater than which other k's.
    But here is a loose procedure.

    1) Solve for x3 and x4 using y4 and y5
    2) Solve for x1 and x2 using y2 and y3, but keep x1 and x2 non-negative.
    3) Evaluate all Y's
    4) For each X, evaluate the changes to Sum(Y's) when X is increased and, for non-zero X, when X is decreased. So you have as many as 8 cases. In each case, the change to Sum(Y's) will be a sum or difference of some of the k's.
    5) If none of these creates a net advantage, you are done.
    6) Pick the X change that creates the fastest improvement, and apply that change to X until X reaches 0 or one of the Y's reaches 0.
    7) Go back to step 3. This loop only ends in step 5.
  4. Jul 13, 2017 #3
    Thank you I will try it out!

    The constants are in this order:
  5. Jul 14, 2017 #4
    So I ended up going with least squares instead becase it was much easier (just manipulating matrices in excel). But I wonder if there is any formula for minimizing (abs(y1)+abs(y2)+abs(y3)+abs(y4)+abs(y5))? Is there any matrix operations similar to that of the least squares method?
  6. Jul 14, 2017 #5
    I found the formula: A^-1*b. But I need to omit one row (thus make 5 different calculations and pick the best).
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted