Tag Info

Hot answers tagged

6

At least internally, the following is a nice recursive way of thinking about the chess board: MatrixPlot[CellularAutomaton[250, {0, 1}, {7, 7}]] Not sure if this is what was meant by functional style. It's hard to make a one-liner functional. To address extensibility: the dimensions of the board are directly dictated by the argument {7,7}, and the ...


5

I'm not quite sure if I understand your problem correctly. Anyway, use Eigensystem to find Eigenvalues and Eigenvectors at the same time. Here we go A = {{5, 4, 2}, {4, 5, 2}, {2, 2, 2}}; Eigensystem[A] (* {{10, 1, 1}, {{2, 2, 1}, {-1, 0, 2}, {-1, 1, 0}}} *) Hence the Eigenvalues are {10,1,1} and the respective Eigenvectors appear ordered ...


4

This seems much simpler than other answers presented: Array[Plus, {8, 8}] ~Mod~ 2 // MatrixPlot Attempting to comply with the requirements of the addendum here is a recursive solution: board[n_] := board[n - 1, {{0}}] board[n_, a_] := board[n - 1, ArrayFlatten[{{a, #\[Transpose]}, {#, 0}}] &[{1 - Last[a]}]] board[0, a_] := a Example: ...


3

Pattern-based functional approach: pat1 := n_Integer /; n > 1 :> Sequence[n, n - 1 /. pat1]; pat2 := v : List[__Integer] /; Max[v] > 1 :> Sequence[v, v - 1 /. pat2]; cb[n_] := MatrixPlot[ {{n}} /. pat1 /. pat2, ColorFunction -> (GrayLevel@Mod[1 + #, 2] &), ColorFunctionScaling -> False, PlotRangePadding -> None, ...


3

This is a functional version of board: ones = {{1, 1}, {1, 1}}; zeros = {{0, 0}, {0, 0}}; board[n_] := Partition[Riffle[ConstantArray[ones, (n)^2/2], {zeros}], n, n - 1] // ArrayFlatten // Image[#, ImageSize -> 400] & board[8] (Defining ones and zeros is optional, so this side effect can be avoided. You will notice also that it only works for even ...


2

Expanding eldos approach for even n to all integers > 0: cb[n_?EvenQ] := MatrixPlot[ArrayPad[DiagonalMatrix[{1, 1}], n/2 - 1, "Reflected"], PlotTheme -> "Monochrome"] cb[n_?OddQ] := MatrixPlot[Most /@ Most @ ArrayPad[DiagonalMatrix[{1, 1}], (n + 1)/2 - 1, "Reflected"], PlotTheme -> "Monochrome"] Manipulate[ cb[n], {n, 1, 11, 1}]


2

Is what you mean by a functional solution a solution that uses functions? Or do you mean in the style of functional programming? If the former, then this works: checked[n_] := Table[Mod[1 + (i + j), 2], {i, 1, n}, {j, 1, n}] numbers[n_] := Transpose[{Range[1, n], ToString /@ (Reverse@Range[1, n])}] letters[n_] := Transpose[{Range[1, n], ...


1

Rewriting your system for easier reading: Y = Array[y, 3]; T = Array[t, {3, 3}]; K = k*IdentityMatrix[3]; M = Transpose[{Y}].{Y} + T.Transpose[T] - K; r = Eliminate[M == Array[0 &, {3, 3}], Join[Y, First@T]] Variables[List @@ r] (* {k, t[2, 1], t[2, 2], t[2, 3], t[3, 1], t[3, 2], t[3, 3]} *)


1

Mathematica does not support Hypergeometric functions of matrix arguments. Currently only the cited paper by Plamen and Koev at http://math.mit.edu/~plamen/files/hyper.pdf contains a link to code that implements it in MATLAB.



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