Tag Info

Hot answers tagged

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 ...


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).


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.


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]



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