Tag Info

New answers tagged

2

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. (To answer your question in the comments) the Lyapunov function is still $V=x^{\mathsf{T}}.P.x$, but ...


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


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


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.


0

You probably want something that works in higher dimensions but, for your 2D example can hack Dataset with Transpose: {{{a, b}, {c, d}}, {{w, x}, {y, z}}} // Dataset // Transpose // Query[Apply@g, Apply@f] // Normal (* g[f[{a, b}, {w, x}], f[{c, d}, {y, z}]] *) Maybe Inner for order tensors can be emulated with some combo of arguments to Transpose ...


3

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}]]


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


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


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


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


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


1

I post here another way of doing this. Since the algorithm below builds a block matrix I suspect it is slower for large matrices than the previous answer (this was also indicated on my machine, when I tried it on some examples). My coding skills are however very limited, so the reason it is slower might be my fault. getIntersectionbasis[l1_, l2_] := ...


2

You'd need to row reduce the intersection set to remove linear dependencies it might have. The code below should handle this. getIntersectionBasis[] := {} getIntersectionBasis[{}] := {} getIntersectionBasis[{}, __] := {} getIntersectionBasis[__, {}] := {} getIntersectionBasis[l1_] := getIntersectionBasis[l1, l1] getIntersectionBasis[l1_, l2_, l3__] := ...


3

Another method is to use Array, the fourth parameter of which sets the function that combines expressions: m = RandomReal[9, {3, 3, 3}]; Array[m[[#]] &, 3, 1, Dot] {{606.041, 638.877, 525.972}, {1011.5, 1068.12, 856.671}, {532.56, 556.236, 435.836}} Equivalent to: Dot @@ m {{606.041, 638.877, 525.972}, {1011.5, 1068.12, 856.671}, {532.56, ...


1

productF = Block[{Times = Dot}, Product[#, #2]] &; Examples: m = Table[PauliMatrix[i], {i, 1, 3}]; productF[j, {j, m}] (* {{I, 0},{0, I}} *) productF[PauliMatrix[j], {j, 3}] (* {{I, 0},{0, I}} *) For better emulation of Product one may include the HoldAll attribute and accept additional Product iterators with: productF2 = Function[, ...


4

Matrix multiplication is built in in Mathematica. Just use the dot for multiplication. Here are two 2x2 matrices a = PauliMatrix[1] b = PauliMatrix[3] (* Out[49]= {{0, 1}, {1, 0}} *) (* Out[50]= {{1, 0}, {0, -1}} *) Here's a product a.b (* Out[53]= {{0, -1}, {1, 0}} *) and here is the product of the same factors in reverse order b.a (* Out[52]= ...


1

1- you can't use Set (=) try using Equal (==) 2- I don't see meaning of simplifying (you will go back to original expression) eq = 1 == DD/R eq[[1]] + U == eq[[2]] + U (*1 + U == DD/R + U*) Simplify[%] (*DD/R == 1*)



Top 50 recent answers are included