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

Mathematica Using mathematica to reduce a system of n equations and m variables

  1. Sep 1, 2014 #1
    Hi guys,

    I have a system of six equations and thirteen variables. I would like to reduce it to seven free parameters. I used Reduce to solve it but it is taking really long (one full day and no output yet) and I think there must be a better way. Here is my code

    Code (Text):
    Y = {{y1}, {y2}, {y3}}
    T = {{t11, t12, t13}, {t21, t22, t23}, {t31, t32, t33}}
    K = k*IdentityMatrix[3]

    M = Y.Transpose[Y] + T.Transpose[T] - K %This is a symmetric matrix

    Reduce[M[[1]][[1]]==0&&M[[1]][[2]]==0&&M[[1]][[3]]==0&&M[[2]][[2]]==0&&M[[2]][[3]]==0&&M[[3]][[3]]==0, Reals]
    What should I do to speed this up? I'm sure if I spent a few hours, I could do it by hand but surely, there is a simple way to do it in Mathematica or other software? Thanks!!
  2. jcsd
  3. Sep 2, 2014 #2
    Well, it's been a while; but, how do you figure you can reduce this system?

    I don't know Mathematica, nor what you are doing there.

    From what I remember, you seem to have a system of "too many" unknowns and "too few" equations. If those variables of yours are true state variables (i.e., they are linearly independent from each other), I am afraid there is nothing you can do to reduce your system; instead, you simply have too many solutions and you need to figure out which one you want.
  4. Sep 2, 2014 #3
    If I give you n variables and m constraints, you can get n-m independent variables. My thirteen variables are not independent (they are related to each other by six equations). I want to reduce is to 13-6=7 independent variables.

    A simplistic example of three variables and two equations: x+y+z=2 and x-y=3, you can give me one independent variable, say x. Thus we have x, y=x-3 and z=5-2x.
  5. Sep 3, 2014 #4
    Oh. I see. I kind of understand, now. But I saw 2 equations and 3 unknowns before and I still see 2 equations and 3 unknowns afterwards; except that, now, you have 1 variable that you have chosen to call "free" but needs to be set to something and what remains becomes a square, solvable system.

    So, for an under-determined system like this one, can you just pick any unknowns as your "free" variables?

    And, without manipulating your original equations, can't you simply assign numeric values to the picked "free" variables, plug the values in and let the system become square and solvable? May not be as elegant...
  6. Sep 3, 2014 #5


    User Avatar
    Science Advisor
    Gold Member
    2017 Award

    Maybe this is what is happening. In general,you might still have a subset of equations that is contradictory. Then additional variables will not turn an unsolvable problem into a solvable one unless you change that subset of equations. But you would think that the program would quickly spot that problem and tell you.

    EQ1: x1=1
    EQ2: x1=2
    EQ3: x2+x3+x4+x5 = 0
  7. Sep 3, 2014 #6
    It is a real system (I didn't make the equations up) so it shouldn't be contradictory. You are also right that Mathematica will immediately spot a contradiction because I artificially changed the code to try that.

    gsal, the point is not to solve the system. The point is to reduce the system from having thirteen variables and six constraints to seven variables and no constraints. Then, any values for those seven variables represents a valid state of the system.
  8. Sep 4, 2014 #7


    User Avatar
    Science Advisor
    Gold Member
    2017 Award

    I see. So it is hard to explain why Mathematica is hung up. It seems like a small set of linear equations should be easy for it. Is your computer memory large enough? I have no other ideas.
    Good to know. Thanks.
  9. Sep 5, 2014 #8
    If you look at the first two rows of M you can immediately see the value of k

    Code (Text):
    k == t11^2 + t12^2 + t13^2 + y1^2 == t21^2 + t22^2 + t23^2 + y2^2
    That reduces the number of variables and number of equations by one.
  10. Sep 6, 2014 #9
    You can also experiment with Eliminate. That can sometimes get rid of one variable, and sometimes one equation, but the remaining equations are often considerably more complicated. If the result wasn't too much more complicated then you can sometimes more quickly solve the smaller system and backtrack to get the value of the eliminated variable. And you can try eliminating more than one variable, but the increasing complexity may take much longer than the original problem.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook