Cramer's rule: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
|||
Line 1,625: | Line 1,625: | ||
=={{header|Maple}}== |
=={{header|Maple}}== |
||
<lang Maple> |
<lang Maple>with(LinearAlgebra): |
||
cramer:=proc(A,B) |
|||
⚫ | |||
local n,d,X,V,i; |
|||
x := LinearAlgebra:-Determinant(Matrix([[2,-3,5,1],[3,-32,2,-6],[1,-47,3,-1],[5,49,-3,3]]))/LinearAlgebra:-Determinant(A); |
|||
n:=upperbound(A,2); |
|||
y := LinearAlgebra:-Determinant(Matrix([[2,-1,-3,1],[3,2,-32,-6],[1,3,-47,-1],[5,-2,49,3]]))/LinearAlgebra:-Determinant(A); |
|||
d:=Determinant(A); |
|||
z := LinearAlgebra:-Determinant(Matrix([[2,-1,5,-3],[3,2,2,-32],[1,3,3,-47],[5,-2,-3,49]]))/LinearAlgebra:-Determinant(A);</lang> |
|||
X:=Vector(n,0); |
|||
{{Out|Output}} |
|||
for i from 1 to n do |
|||
<pre>w := 2 |
|||
V:=A(1..-1,i); |
|||
A(1..-1,i):=B; |
|||
y := -4 |
|||
X[i]:=Determinant(A)/d; |
|||
z := 1</pre> |
|||
A(1..-1,i):=V; |
|||
od; |
|||
X; |
|||
end: |
|||
⚫ | |||
B:=Vector([-3,-32,-47,49]): |
|||
printf("%a",cramer(A,B));</lang> |
|||
{{out}} |
|||
<pre>Vector(4, [2,-12,-4,1])</pre> |
|||
=={{header|Mathematica}}== |
=={{header|Mathematica}}== |