Tag Info

Hot answers tagged

8

Your corrected code: myVect = {x, y}; offDiag = {{0, 1}, {1, 0}}; Maximize[1/2*myVect.offDiag.myVect, myVect.{2, 2} - 1 == 0, myVect] {1/16, {x -> 1/4, y -> 1/4}}


7

I needed this decomposition to answer another question, so I broke down and implemented it myself. The code is more or less a straightforward translation of the pseudocode in Golub/Van Loan: LDLT[mat_?SymmetricMatrixQ] := Module[{n = Length[mat], mt = mat, v, w}, Do[ If[j > 1, w = mt[[j, ;; j - 1]]; v = ...


6

Just to explain... (once upon a time I was also very new to this Mathematica syntax - and often confused). The mentioned "/." replaces all elements in an expression. In addition with "/;" you can add a condition when this replacement should be done. So the solution to your problem is something like matrix1 /. x_ /; x < 5 -> 0 (do not use upper case ...


3

This is a somewhat high-brow way of showing the Cayley-Hamilton theorem, through the power of holomorphic functional calculus. As I mentioned in this answer, one of the standard ways to define a matrix function is through a Cauchy-like construction: $$f(\mathbf A) = \frac{1}{2\pi i} \oint_\gamma f(z)\, (z \mathbf I- \mathbf A)^{-1}\,\mathrm dz$$ where the ...


3

Just for the purpose of illustration (the comments of Guesswhoitis. and bbgogfrey). here are some ways (I prefer Outer): Using: lst = {15, 15, 1, 14, 10, 14, 4, 8, 8, 14, 11, 5, 13, 0, 5, 4} then Outer[Subtract, lst, lst] // MatrixForm Table[lst[[i]] - lst[[j]], {i, 16}, {j, 16}] // MatrixForm Partition[Subtract @@@ Tuples[lst, 2], 16] // MatrixForm ...


3

I cannot reproduce the behavior you observe in my version of Mathematica (10.2 on Win7-64), so I assume that you might be working on an older version. It would be interesting if you could add your version and platform to your question for reference. Nevertheless, in my opinion the problem seems to be that the plotting function is attempting to evaluate ...


3

There are three problems with your posted code. Your objective function is a 1x1 matrix rather than a scalar. Your constraint equation is malformed. One side is a 1x1 matrix, the other is a scalar. They should both be scalars. The variables should be in a flat list. @Willinski already gave a more natural way of expressing vectors in Mathematica, so that ...


2

I write this answer with the caveat that I don't have Mathematica version 9 or later (the versions which now have this very belated function built-in), but with said caveat being offset by knowing a thing or two about the function of a matrix. ;) I'd have to agree with george's take that the docs for MatrixFunction[] could probably have explained things a ...


1

Perhaps BarChart3D using the "Grid" option for ChartLayout may be more useful for your aim, e.g. mat = {{1, -1, 0, 0}, {-1, 2, 0, -1}, {0, 0, 1, -1}, {0, -1, -1, 2}}; BarChart3D[mat, ChartLayout -> "Grid", ChartLabels -> {Range[4], Range[4]}, LabelingFunction -> (Placed[Style[#, Red, Bold], Above] &), ChartStyle -> Blue] or just ...


1

This will be much faster than using rule replacement... Clip[matrix1, {5, Infinity}, {0, Infinity}] If entries are integer, Threshold[matrix1,4] s/b faster, but will fail for non-integers...



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