Tag Info

Hot answers tagged linear-algebra

5

Maybe MapThread gives the levelspec control you need: lst = {{{a, b}, {c, d}}, {{w, x}, {y, z}}}; g @@ MapThread[f, lst, 1] (* or just g @@ MapThread[f, lst] -- thanks: Mr.W *) (* g[f[{a,b},{w,x}],f[{c,d},{y,z}]] *) g @@ MapThread[f, lst, 2] (* g[{f[a,w],f[b,x]},{f[c,y],f[d,z]}] *) or, g @@ Thread[f @@ lst] (* g[f[{a,b},{w,x}],f[{c,d},{y,z}]] *) or ...

4

This probably doesn't address the full scope of your question but for the particular example you could use MapThread and Apply: ex1 = {{a, b}, {c, d}}; ex2 = {{w, x}, {y, z}}; g @@ MapThread[f, {ex1, ex2}] g[f[{a, b}, {w, x}], f[{c, d}, {y, z}]] Or Transpose and Apply: g @@ f @@@ ({ex1, ex2}\[Transpose]) g[f[{a, b}, {w, x}], f[{c, d}, {y, z}]]

4

You can use CoefficientArrays: xx = {a[0, 0], a[0, 0] + a[1, 0] + a[2, 0] + a[3, 0], a[0, 0] + a[0, 1] + a[0, 2] + a[0, 3], a[0, 0] + a[0, 1] + a[0, 2] + a[0, 3] + a[1, 0] + a[1, 1] + a[1, 2] + a[1, 3] + a[2, 0] + a[2, 1] + a[2, 2] + a[2, 3] + a[3, 0] + a[3, 1] + a[3, 2] + a[3, 3], a[1, 0], a[1, 0] + 2 a[2, 0] + 3 a[3, 0], a[1, 0] + a[1, ...

3

One way is to start with empty matrix. Add the first column. Then loop, each time adding the next column, and checking if the rank of this matrix has increased from before, if so, keep it, else skip over to the next column. Keep doing this until you reach the last column in the original matrix, or have collected m columns, where m is the rank of the original ...

3

If RowReduce won't help, then perhaps I don't know what you're looking for. Here's my understanding of the question in which I use RowReduce to get the answer. Example A random matrix: SeedRandom[1]; mat = RandomSample[#~Join~Accumulate@RandomSample[#, 2] &@ RandomInteger[{-5, 5}, {35, 37}]]; MatrixRank[mat] (* 35 *) We can use the ...

3

LyapunovSolve and DiscreteLyapunovSolve solve several equations Lyapunov, Sylvester, Stein, generalized versions, etc., and as such there is no one standard form. Since they are linear solvers their design was based on the precedent set by LinearSolve. For $\dot{x}=A.x$ to be stable, $P=\text{LyapunovSolve}\left[A^{\mathsf{T}},-Q\right]$ has to be positive ...

3

Small numerical errors generate tiny imaginary parts-Solve it with: Plot[bs // Chop, {(ka), -0.8, 0.8}] Eventually, answering @MarkMcClure's comment: b[k_?NumericQ] := Eigenvalues[H /. ka -> k]; Plot[Quiet@Table[b[ka][[i]], {i, 6}], {(ka), -0.8, 0.8}, Evaluated -> True] NB: The Plot[Quiet@Table[...] ...,Evaluated -> True] thing is a dirty ...

2

The problem is trivially solved using $$\mathbf{A}=\frac{1}{|\rho|^2}v\otimes\rho,$$ which automatically satisfies $$\|\mathbf{A}\rho-v\|=0$$ and $$\det(\mathbf{A})=0.$$ In Mathematica, this is entered as v\[TensorProduct]r/Norm[r]^2.

2

I would approach this specific straightforward example in a straightforward way. Eliminate your matrix using RowReduce[mm]; red=RowReduce[mm]]; red//MatrixForm \$\begin{pmatrix} 1 & 0.&0.&0.&0.&0.&0.&0.&0.&0.&\\ 0 & 1 &0.&0.&0.&0.&0.&0.&0.&0.&\\ 0 & 0 &1 ...

2

You can also use a more "mathy" approach: Assuming xx and alpha are defined as in kguler's answer, A = D[xx, {alpha}] which produces identical output. I like thinking in this way because it is useful for computing hessians (in a slightly different context).

1

χ /. First[NSolve[SetV == #/(Cpf (1 - χ)), χ]] & /@ demand or equivalently χ /. First@Solve[SetV == dem/(Cpf (1 -χ)), χ] (-dem + Cpf SetV)/(Cpf SetV) and now (-# + Cpf SetV)/(Cpf SetV)& /@ demand {(-1.92*10^6 + Cpf SetV)/(Cpf SetV), (-2.07*10^6 + Cpf SetV)/( Cpf SetV), (-2.37*10^6 + Cpf SetV)/( Cpf SetV), (-2.72*10^6 + Cpf SetV)/( ...

1

Simple replace should do the trick χ /. {{χ -> (-1.92`*^6 + Cpf SetV)/(Cpf SetV)}} Yields {(-1.92*10^6 + Cpf SetV)/(Cpf SetV)}

1

Since nobody has posted a "messy" solution yet, let me: if the matrices are in one list alist = {a1,a2,...,an} and the rhs' are in another, blist = {b1,b2,...,bn} then Clear[x]; vars = x[#] & /@ Range[n]; vars /. Solve[Dot[#1, vars] == #2 & @@@ Transpose[{alist, blist}], vars]

1

Thank you for a well-written question with complete code that made this reasonable to answer. Welcome to Mathematica Stack Exchange. :-) You do not need UpValues definitions here. That would only apply if you were attempting to add a rule to e.g. Plus rather than Sup, yet your use of TagSetDelayed makes it clear that you are attaching the rule to Sup. ...

1

It would be good if you provide relevant background on type calculations you want to do, the maximum dimensions of the matrix, whether it is sparse or not and whether it requires symbolic evaluations. In principle Mathematica is efficient enough for handling most Matrix manipulations. The memory constraint will largely be outside of Mathematica as ...

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