Message Boards Message Boards

1
|
2177 Views
|
1 Reply
|
4 Total Likes
View groups...
Share
Share this post:

Solve linear system

Posted 4 years ago

Hey everyone I need help. I have a project that I have to use Wolfram Mathematica to solve a linear equation by using Cramers rule, but I do not how to can any one help? Please and thank you.

POSTED BY: Patrick Pierre

From Documentation ("Click->Examples->Applications") we have:

At first we can use Solve:

  eq = {x + 2 y + 3 z == 4, x + 4 y + 9 z == 16, x + 8 y + 27 z == 46};
  Solve[eq, {x, y, z}]
  (*{{x -> -5, y -> 3, z -> 1}}*)

Cramers Rule code:

cramers[m_, b_] := Module[{d = Det[m], a},Table[a = m; a[[All, k]] = b; Det[a]/d, {k, Length[m]}]]

m = {{1, 2, 3}, {1, 4, 9}, {1, 8, 27}};
b = {4, 16, 46};
x = cramers[m, {4, 16, 46}]

(*{-5, 3, 1}*)

At the end check if ok.

m.x == b
(*True*)
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