Tag Info

Hot answers tagged

8

Grid directly supports such lines, called Dividers: m = augmentedMatrix[6]; g = Grid[m, Dividers -> {7 -> {Red, Dashed}}] All that remains is to incorporate the large ( ) brackets used by MatrixForm: MatrixForm[{{g}}] Another approach is to realize that both MatrixForm and Grid produce a GridBox expression: Shallow[ToBoxes @ MatrixForm[m], ...


7

This is not a matter of "force". A Root object represents the exact root of a polynomial that cannot be represented exactly in closed form, or (in the case of cubics and quartics) cannot be represented succinctly. It is not "unsolved"; it is just a way of writing something that is hard or impossible to write down otherwise. If you want to convert cubic or ...


6

SeedRandom@0; mat = RandomInteger[{0, 10}, {2, 3, 3}]; MatrixForm@List@Grid[List@(TableForm /@ mat), Dividers -> {2 -> Directive[Red, Dashed]}] Of course you can play with spacings: TableForm[#, TableSpacing -> {1, 1}] & /@ mat To go a bit further with Dividers: SeedRandom@0; mat = RandomInteger[{0, 10}, {10, 3, 3}]; ...


6

mat = {{2, 1, 0}, {3, 0, 1}, {4, 2, 1}, {2, 0, 3}, {1, 0, 0}, {0, 0, 1}, {3, 3, 2}, {0, 2, 1}, {0, 1, 1}, {2, 1, 2}}; rules = {0 -> 1000 ,1-> 11, 2-> 22, 3 -> 33, 4-> 44}; mat[[All, -1]] = mat[[All, -1]] /. rules; mat (* {{2, 1, 1000}, {3, 0, 11}, {4, 2, 11}, {2, 0, 33}, {1, 0, 1000}, {0, 0, 11}, {3, 3, 22}, {0, 2, 11}, {0, 1, ...


5

x = {TCC12, TCC12, B96, TM12, TCC12, B96}; x /. {a___, b_, b_, c___} :> {a, b, c} {TCC12, B96, TM12, TCC12, B96} First /@ Split[x] Same output, but probably faster. Update thanks to Belisarius (m = {{1, 1, 1, 1}, {2, 2, 0, 2}, {0, 1, 0, 0}, {2, 2, 0, 0}}) // MatrixForm Map[First, Split /@ m, {2}] // MatrixForm


4

mat[[All, -1]] = Transpose[mat][[-1]] /. rules; mat {{2, 1, 1000}, {3, 0, 11}, {4, 2, 11}, {2, 0, 33}, {1, 0, 1000}, {0, 0, 11}, {3, 3, 22}, {0, 2, 11}, {0, 1, 11}, {2, 1, 22}}


4

Let me reconstruct your Vandermonde matrix: A = Outer[Power, Range[10], Range[0, 3]]; A // MatrixForm Then there are two possibilities to compute SVD: Analytic expressions Numerical values Your input is the integer array so Mathematica choose the first one and try to give your the answer in an analytic form. It returns the result as roots of the ...


3

Here are a couple of ways: Cases[mat, {e__, l_} :> {e, l /. rules}] or ReplacePart[mat, {i_, 3} :> (mat[[i, 3]] /. rules)]


3

If the rule doesn't fit, change it: rules = {a_, b_, #} :> {a, b, #2} & @@@ {0 -> 1000, 1 -> 11, 2 -> 22, 3 -> 33, 4 -> 44}; mat /. rules {{4, 4, 1000}, {4, 1, 1000}, {1, 2, 33}, {3, 1, 1000}, {2, 0, 33}, {4,3, 33}, {2, 1, 11}, {2, 0, 44}, {3, 3, 22}, {1, 2, 22}}


2

With[{m = Transpose[mat]}, Transpose[Append[Most[m], Last[m]/. rules]]]


2

Update Another try arrow = Graphics[{Arrowheads[Small], Arrow[{{0, 0}, {6, 0}}]}, ImageSize -> {50,10}]; product[m_, n_] := Module[{s, t}, {{Subscript[r, n]/m[[n, n]]}, t = MapAt[#/m[[n, n]] &, m, n], Table[ s = Subscript[r, i] - t[[i, n]] Subscript[r, n]; t = MapAt[# - t[[i, n]] t[[n]] &, t, i]; s, {i, n + 1, Length[m]}], t} ...


2

Table and MapAt with Span can reduce the code to almost two lines: n = 3; A = RandomInteger[10, {n, n}]; MatrixForm[A] LU = Join[A, IdentityMatrix[n], 2]; res = Table[{LU = MapAt[#/LU[[k, k]] &, LU, k], LU = MapAt[# - #[[k]] LU[[k]] &, LU, k + 1 ;;]}, {k, n}]; Map[augmentedMatrixForm, res, {2}] // Grid With "tags" it is a bit longer LU ...


2

If you are going to work with non-commutative algebras like the matrix multiplication I recommend you try the NCAlgebra package. << NC` << NCAlgebra` (2 a) ** (3 b) 6 a ** b P.S. In NCAlgebra all lowercase variables are non-commutative by default.


1

You can generate such matrices using the following code: n = 8; MatrixForm[ Table[Piecewise[{{\[Alpha], i == j}, {\[Beta], Abs[i - j] == 1 || Abs[i - j] == n - 1}}], {i, n}, {j, n}]] which generates $$\left( \begin{array}{cccccccc} \alpha & \beta & 0 & 0 & 0 & 0 & 0 & \beta \\ \beta & \alpha & \beta ...


1

Given a matrix mat replace the 0s in mat with an expression that depends on the indices. randommatrix = RandomInteger[1, {6, 6}]; randommatrix // MatrixForm MapIndexed[# /. {(0) -> Quiet@Style[Evaluate[diff2 @@ #2], Red], _ :> 0} &, randommatrix, {2}] // MatrixForm mat = 1 - Unitize[tttt2]; args = Table[{w, Pprobe}, {w, 2.5, 3., 0.1}, ...


1

Just do this. A = {{1, 1, 1, 1}, {1, 2, 4, 8}, {1, 3, 9, 27}, {1, 4, 16, 64}, {1, 5, 25, 125}, {1, 6, 36, 216}, {1, 7, 49, 343}, {1, 8, 64, 512}, {1, 9, 81, 729}, {1, 10, 100, 1000}} // N; {U, S, V} = SingularValueDecomposition[A]; U // MatrixForm S // MatrixForm You can confirm the results. U.S.Conjugate[Transpose[V]] // Rationalize ...


1

data = RandomInteger[4, {10, 3}]; rules = {0 -> 1000, 1 -> 11, 2 -> 22, 3 -> 33, 4 -> 44}; data /. {a__?NumberQ, b_} :> {a, b /. rules} // MatrixForm


1

Another variant: deleteConsecutive = Split[#][[All, 1]]& deleteConsecutive@{TCC12, TCC12, B96, TM12, TCC12, B96} (* {TCC12, B96, TM12, TCC12, B96} *)


1

f = #1 & @@@ Split @ # &; x = {TCC12, TCC12, B96, TM12, TCC12, B96}; f@x (* {TCC12,B96,TM12,TCC12,B96} *) m = {{1, 1, 1, 1}, {2, 2, 0, 2}, {0, 1, 0, 0}, {2, 2, 0, 0}}; f /@ m (* {{1},{2,0,2},{0,1,0},{2,0}} *)



Only top voted, non community-wiki answers of a minimum length are eligible