Message Boards Message Boards

Determine solution of an underdetermined linear equation system

Posted 1 year ago

How can I get the same (i.e., a plane equation as) solution set of the linear system of equations in Mathematica as in Maple on the attached PDF (from a friend)?
Thanks in advance

Attachments:
POSTED BY: Nina Teller
5 Replies
Posted 1 year ago

Thanks for your help! If you have time, maybe you could explain me the meaning of each input? From your answer and maybe from the one in the other block post:

m = {{1, 1, 1}, {1, 2, 3}, {1, 4, 9}};
b = {1, 2, 3};
abc = LinearSolve[m, b]
f = Dot[abc, {x, y, z}]
sol = Solve[f == 0, z]
Plot3D[z /. sol, {x, 0, 15}, {y, 0, 15}]

, because I would like to understand the system.

If you do not have time, it does not matter, because you have already helped me a lot!

POSTED BY: Nina Teller

Certainly! Here's what each input in your code does:

m = {{1, 1, 1}, {1, 2, 3}, {1, 4, 9}};: This sets the value of m to be a 3x3 matrix (i.e. a list of 3 lists, each containing 3 numbers).

b = {1, 2, 3};: This sets the value of b to be a 1x3 vector (i.e. a list of 3 numbers).

abc = LinearSolve[m, b]: This solves the linear system of equations m . abc = b, where . represents matrix multiplication, and returns the solution as a 1x3 vector. In other words, abc is the solution to the system of equations represented by m and b.

f = Dot[abc, {x, y, z}]: This calculates the dot product of the vectors abc and {x, y, z} and sets the result to f. The dot product is a scalar value calculated as the sum of the element-wise product of the two vectors.

sol = Solve[f == 0, z]: This solves the equation f == 0 for the variable z and sets the solution to sol. This gives you all the solutions for z that make f equal to zero.

Plot3D[z /. sol, {x, 0, 15}, {y, 0, 15}]: This creates a 3D plot of the solutions for z obtained in the previous step, with x ranging from 0 to 15 and y ranging from 0 to 15. The /. operator substitutes the solutions for z obtained in sol into the plot expression.

POSTED BY: Mariusz Iwaniuk
Posted 1 year ago

Thanks for your answer! Is it possible to get this solution set with the parameters just using e.g. Solve[...] or so, why does it have to be so complicated?

Is there also a command for this, this matrix is represented as a plane equation? So: x=a+rb+tc (with r and t as parameters and x,a,b,c as vectors)

POSTED BY: Nina Teller

For first question:

 eqns = Thread[A . {c1, c2, c3, c4, c5} == B];
 {c1, c2, c3, c4, c5} /. Solve[eqns, {c1, c2, c3, c4}] (* Maybe simpler *)

For second question see here.

POSTED BY: Mariusz Iwaniuk

Solution for an underdetermined system is not unique:

A = {{6, 3, 2, 3, 4}, {4, 2, 1, 2, 3}, {4, 2, 3, 2, 1}, {2, 1, 7, 3, 
    2}};
B = {5, 4, 0, 1};
ns = NullSpace[A];
x0 = Sum[C[i]*ns[[i]], {i, 1, Length[ns]}];
x1 = LinearSolve[A, B];
x1 + x0
A . % == B // Simplify (*Solution are: TRUE *)
(*{-(3/2) + 3 C[1] - C[2], 2 C[2], -2 + 4 C[1], 6 - 14 C[1], 4 C[1]}*)
(* TRUE *)

or:

Table[C[i], {i, 1, Length[A[[1]]]}] /. 
 Solve[A . Table[C[i], {i, 1, Length[A[[1]]]}] == B, 
  Table[C[i], {i, 1, Length[B]}], MaxExtraConditions -> All] // Expand
A . %[[1]] == B // Simplify (*Solution are: TRUE *)
(*{{C[1], -3 - 2 C[1] + (3 C[5])/2, -2 + C[5], 6 - (7 C[5])/2, C[5]}}*)
 (* TRUE *)

Maple 2022.2 solution: enter image description here

Regards M.I.

POSTED BY: Mariusz Iwaniuk
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract