I am attempting to solve a system of linear equations using LinearSolve[]
. In my case, the number of unknowns are more than constraints. I learnt that LinearSolve does not give me all solutions. However, I am also unable to use Solve[]
to get all possible solutions.
Here is my example:
InpMatrix={
{1,0,0,0,0,0,0,0,0,0,0,0},
{15,4,0,0,0,0,0,0,0,0,0,0},
{90,48,16,0,0,0,0,0,0,0,0,0},
{270,216,144,16,0,0,0,0,0,0,0,0},
{405,432,432,0,16,0,0,0,0,0,0,0},
{243,324,432,0,0,16,0,0,0,0,0,0},
{16,0,0,0,0,0,256,0,0,0,0,0},
{0,0,0,-16,-16,-16,47104,1024,0,0,0,0}
};
synd={{0},{0},{0},{0},{0},{0},{256},{1024}};
In[217]:= sol = LinearSolve[InpMatrix, synd]
Out[217]= {{0}, {0}, {0}, {0}, {0}, {0}, {1}, {-45}, {0}, {0}, {0}, {0}}
However, the solution I am looking for should be:
{{0}, {0}, {0}, {0}, {0}, {0}, {1}, {-45}, {0}, {30}, {15}, {0}}
Hence I tried to use Solve[]
in the following way:
Solve[InpMatrix.var == synd, var]
But it gives me an error saying:
Solve::nsmet: This system cannot be solved with the methods available to Solve. >>
Solve[{
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{15, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{90, 48, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{270, 216, 144, 16, 0, 0, 0, 0, 0, 0, 0, 0},
{405, 432, 432, 0, 16, 0, 0, 0, 0, 0, 0, 0},
{243, 324, 432, 0, 0, 16, 0, 0, 0, 0, 0, 0},
{16, 0, 0, 0, 0, 0, 256, 0, 0, 0, 0, 0},
{0, 0, 0, -16, -16, -16, 47104, 1024, 0, 0, 0, 0}
}.var == {{0}, {0}, {0}, {0}, {0}, {0}, {256}, {1024}}, var]
Could anyone kindly help me with correctly using Solve[]
or any other functionality that yields all posible solutions ? Preferably I would general solution, a symbolic form with free variables.
InpMatrix
, you do not obtainsynd
. Have you perhaps mixed up the roles of the solution andsynd
? $\endgroup${{0}, {0}, {0}, {0}, {0}, {0}, {1}, {-45}, {0}, {30}, {15}, {0}}
isn't a solution. Try this if you wish:InpMatrix.{{0}, {0}, {0}, {0}, {0}, {0}, {1}, {-45}, {0}, {30}, {15}, {0}} == synd
. It givesTrue
. $\endgroup$NullSpace
? It can be used to produce all solutions toLinearSolve
once you have a single one. E.g., test it withInpMatrix.({0, 0, 0, 0, 0, 0, 1, -45, 0, 0, 0, 0} + {x1, x2, x3, x4}.NullSpace[InpMatrix])
Notice that the output ofNullSpace
shows in this case that you can freely vary the last four coefficients. $\endgroup$