Hot answers tagged

11

A brute force approach: For a permutation p, protations[p] constructs the union of permutations obtained by all possible two-step rotations of its 8 elements after dropping its middle element. We use MemberQ[protations[#], #2]& as the test function in DeleteDuplicates. Then using Partition[#, 3]& for all permutations in the resulting list gives the ...


10

The function $x \mapsto P_x([a,b])$ is continuous and piecewise linear, so it can be easily and exactly integrated with the trapezoidal rule. Then the resulting quadrature rule can be compiled for better performance. The only problem is to place the quadrature points onto the discontinuities of the first derivative. The following CompiledFunction getRowofQ ...


5

Let me give a GroupOrbits approach, imitating many aspects of the accepted solution. Start again with all permutations of the elements: list = {a, a, a, a, b, b, b, c, c}; perms = Permutations[list]; Again, assume each permutation defines a matrix whose central element is placed last: makeMatrix[{e1_, e2_, e3_, e4_, e5_, e6_, e7_, e8_, e9_}] := {{e1, e2, ...


4

The row echolon form of a general sparse matrix is not sparse. However, there is a certain chance that the row echolon form of a suitable row/column perturbation of the original matrix is sparse. This is what direct solvers for sparse arrays usually do when they perform a sparse LU-decomposition. A sparse matrix: G = GridGraph[{300, 300}]; A = ...


3

Not sure whether I got your point, but given: out = sol /. {a -> 1, b -> -1, ay -> 2, by -> -2} then taking elements with second part positive is: Select[sol /. {a -> 1, b -> -1, ay -> 2, by -> -2}, Last[#] > 0 &] (* {{1, 2}, {-1, 2}} *) Extracting elements with both parts positive, e.g. Pick[out, And @@@ (Positive /@ ...


3

For display purposes you can use Row: e.g., Row[{{1, 2, 3}, {4, 5, 6}}, ","] Update: to get {1,2,3,4,5,6} from {{1, 2, 3}, {4, 5, 6}} use Join: Join @@ {{1, 2, 3}, {4, 5, 6}} {1, 2, 3, 4, 5, 6}


2

Try ToExpression[Select[Characters[">DAVID123<" ],StringMatchQ[#,LetterCharacter]&]] which will give you a vector of {D,A,V,I,D} as symbols or variables, but C and D and E and I and K have predefined meaning inside of Mathematica and may cause you grief.


2

I'll show an approach that might or might not work in general but at least seems to have potential. A restriction is that (possibly after preprocessing) all the coefficients of the main variables must be integers. This will be a bit indirect with a few steps, and I do not have the "big picture" insight to clean it up at this point. The idea is to "...


2

matrix = {{1, 2, 3, 4, 5}, {1, 3, 4, 5, 6}, {2, 5, 5, 5, 5}}; matrix[[All, 2]] (* {2, 3, 5} *) Max[matrix[[All, 2]]] (* 5 *)


2

You can use Cases Cases[{Alternatives @@ WL, __}] @ MT {{1, 54, 55}, {5, 188, 21}, {7, 36, 32}, {8, 7, 2}}


2

The user provided matrices: mA = {{50, 3, 10, 2}, {3, 60, 7, 1}, {10, 7, 55, 4}, {2, 1, 4, 45}} mB = {{b11, b12, b13, 0}, {b12, b22, 0, 0}, {b13, 0, b33, b34}, {0, 0,b34, b44}} Parameterize mA where mB has a zero. (See the docs for Indexed.) mAnext = MapIndexed[ If[TrueQ[0 == Extract[mB, #2]], Indexed[a, #2], #1] &, mA, {2}] Extract the parameters ...


2

What we need to do is filter the equations in $B^{-1}=A$ to only positions where original elements of $B$ are non-zero. I'll use pattern-matching to create new matrices $A$ and $B^{-1}$ that change all elements to $0$ that are zero in B. Using a symmetric definition of $B$ (sorry about the subscript formatting) B = {{Subscript[b, 11], Subscript[b, 12], ...


1

The premise of the question is wrong. The eigenvectors for generic $\mu$ do become those for $\mu=0$ in the $\mu\to0$ limit, but with a qualification. To illustrate my point, take the $1\times 1$ matrix $$ M=1+\mu $$ The eigenvector of this matrix is just any non-zero complex number. I will take, just because I want to, $v=i/\mu$. It is clear that in the $\...


1

I'm going to try and show that indeed the question title is false! First we'll need to define the original M matrix in a modular form: M[μ_] := { {0, 1, 0, 0}, {-ω0^2 - μ^2 - 4 g x, 0, 0, μ}, {-μ, 0, 0, 1}, {0, 0, -ωk^2 + μ^2, 0} } This will prove useful later on. Next, we are going to define a function that operates on the M matrix and returns its ...


1

As I see it, it is the case. Let me show you how. The "trick" is just like what @SjoerdSmit has mentioned in the comment: normalization. In addition to M, s, and v, I add two new {sp, vp} = Eigensystem[-I M /. μ -> 0]; Let me take the first eigenvalue and its corresponding vector as an example: So the problem now is when $ \mu\rightarrow0 $, are s[[1]]...


1

Let $G$ be the group of matrices; by definition these are invertible, so their determinant is non-zero. For example, we will take Table[RandomInteger[{0, 10}, {3, 3}], 5] Det /@ % $$\left( \begin{array}{ccc} 5 & 1 & 7 \\ 9 & 3 & 9 \\ 10 & 3 & 3 \\ \end{array} \right),\left( \begin{array}{ccc} 3 & 3 & 3 \\ 3 & 6 &...


1

At least in your toy model, using the respective entries of the inverse of A for initializing FindRoot seems to work quite fine: B0 = B /. Subscript[b, _] :> 1; eq = DeleteCases[Flatten[B0 Det[B] UpperTriangularize[Inverse[B] - A]], 0]; Binit = DeleteCases[Flatten[UpperTriangularize[B0 Inverse[A]]], 0]; vars = DeleteCases[Flatten[UpperTriangularize[B]], ...


1

Turning a comment into an answer. Apparently, {lambda, u} = Eigensystem[NullMatrix, -1, Method -> {"Arnoldi"}]; works fine. u[[1]] seems to be the only null vector. Or do you expect more than one? Then you can do, e.g., {lambda, u} = Eigensystem[NullMatrix, -20, Method -> {"Arnoldi"}]; and check the vector lambda of eigenvalues for zero (or ...


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