# Tag Info

11

This is almost certainly an out-of-memory crash. The underlying issue is that the OS X front-end is a 32-bit program, so has a process memory limit of around 2 GB. It is normal for an attempted allocation beyond that limit to lead to a crash. A similar size ArrayPlot example I tried on my Windows machine (where the front-end is 64-bit) used more than 3 GB ...

9

Now fixed in version 10.2. In[1]:= m = {{0, 1}, {-1, 0}}; In[2]:= {AntihermitianMatrixQ[m], HermitianMatrixQ[m], AntihermitianMatrixQ[m]} Out[2]= {True, False, True} As per the comments, yes, there is information stored in the internal representation of matrices (for example, a symmetry flag) and no, it is not accessible from top level code.

9

Note: the answer below referred to a previous version of the question You may have more success with SparseArray. For instance: SparseArray[ {{i_, i_} -> 1, {i_, j_} /; Abs[i - j] == 1 -> 2}, {20000, 20000}, 0 ]; // RepeatedTiming (* Out: {0.21, Null} *) You would use patterns to assign values to positions within the matrix determined ...

7

Update: it seems this only works in 10.1 and later, but not in 10.0. This works: Assuming[(a | b | c) ∈ Matrices[{d, d}], TensorExpand@Transpose[a.(b + c)]] (* Transpose[b, {2, 1}].Transpose[a, {2, 1}] + Transpose[c, {2, 1}].Transpose[a, {2, 1}] *) We needed to tell Mathematica that a, b and c are square matrices and use TensorExpand. Check here: ...

7

Here's another perspective for you. cf[x_] := ColorData[{"DeepSeaColors", {2, 0}}][Mod[Sqrt[8 x + 1] + 1, 2]]; Graphics[{PointSize[Small], cf[#], Point[ulamCoords[#]]} & /@ Range[1024], Background -> Black] This color function allows us to (visually) trace "triangularity level curves" of a sort, where the brightest points are triangular ...

7

Not very efficient, but you may find it useful for some experiments. I perused the code from the link you provided (kuba's), although there are better alternatives in the answers. ClearAll[spiral, genTri, mp]; spiral[n_?OddQ] := Nest[ With[{d = Length@#, l = #[[-1, -1]]}, Composition[ Insert[#, l + 3 d + 2 + Range[d + 2], -1] &, ...

7

You're going to have to write a separate function that uses Integrate instead of NIntegrate if you want something that looks like a matrix of traditional integrals, which is what I think you want. You also need to use HoldForm to keep the integral from evaluating. You also need someway to set the values that you want in the held version of the expression. ...

6

Clearly, OP did not even try to read the answer I linked to in my previous answer. In any event: I merely exploited the block structure of the underlying linear system for the polyharmonic spline. We start with data looking like this: $$\begin{pmatrix}x_1&y_1&z_1\\x_2&y_2&z_2\\&\vdots&\\x_n&y_n&z_n\end{pmatrix}$$ wa = ...

5

There will be more clever answers from people who better understand Mathematica's order of evaluation and how to use Hold and such, and so I can't answer your question in exactly the way that you've phrased it, but here's how I go about doing these types of things. First, instead of declaring the values of x, omega, and R as you've done, make a list of ...

5

For the love of this fine site, please post copyable code along with accompanying images the next time! Anyway: myb1 = {{{{1, 2}, {1, 2}}, {{2, 3}, {3, 4}}}, {{{5, 2}, {8, 2}}, {{1, 2}, {1, 2}}}}; Map[MatrixPower[#, 2] &, myb1, {2}] {{{{3, 6}, {3, 6}}, {{13, 18}, {18, 25}}}, {{{41, 14}, {56, 20}}, {{3, 6}, {3, 6}}}} Map[#.# &, ...

5

Using method that Guess who it is suggested I managed to get around 75% faster result. Unsample[x_] :=Riffle[temp = Riffle[x, x] // Transpose; temp, temp]//Transpose ans = Table[Map[Unsample[#] &, arr[[i]]], {i, 5000}]; // AbsoluteTiming Your suggested solution evaluates in 1 to 1.2 sec on my machine, while this one evaluates in 0.63 s. I suspect ...

4

I am going to demonstrate this with a smaller matrix to enable us to more readily view the results. A0 = Table[Subscript[a, i, j], {i, 8}, {j, 8}]; A0//MatrixForm Step 1. Partition A0 into 4x4 blocks A0byBlock = Partition[A0, {4, 4}]; A0byBlock // MatrixForm Step 2. Map f onto A0 at level 2 A0out = Map[f, A0byBlock, {2}]; A0out // MatrixForm ...

4

Matrices (and also vectors and other tensors) are multipled using Dot. Using your code, just replace * by . (I also removed all ('s and )'s as they don't do anything in this context. {{x, y, 1}}.{{a, b/2, d/2}, {b/2, c, e/2}, {d/2, e/2, f}}.{{x}, {y}, {1}} Result:

4

Look at what you get when you do e.g. f[1,1,1] and Conjugate[f[1,1,1]]. As the docs for Conjugate state, "Conjugate does not always propagate into arguments", and here it does not propagate into Cos and Sin. A solution seems to be to do f[kx_, ky_, t_] := -t E^(-I kx a) (1 + 2 E^(I (3 kx a)/2)*Cos[Sqrt[3]/2 ky a]); BlockA[kx_, ky_, t_] := ...

4

Instead of While[i<21,...], use Table[...,{i,20}]. The ... part can be reduced to r = k[[a[[i]]]]; Factor[Det[r]] To find the PolynomialLCM, simply replace the head ( List) of the table with PolynomialLCM using Apply, or @@ for short: PolynomialLCM @@ Table[...,{i,20}]

4

To factor out numeric factors in any argument of Dot: (2 yy.(3 zz)).(4 zz) //. Dot[a___, d_?NumericQ b_, c___] :> d Dot[a, b, c] 24 yy.zz.zz Edit: If you want this to happen automatically, you can add the rule as a new definition for Dot: Unprotect[Dot]; Dot[a___, d_?NumericQ b_, c___] := d Dot[a, b, c] Protect[Dot]; Now the factoring happens ...

3

It's a good idea to include the error you got in your question. It gives a clue and might prompt someone to investigate: NDSolve::ndinid: Initial condition {0} is not in the range specified by the discrete variable NDSolve`s$147246. >> Now Sign is discontinuous and will cause NDSolve to invoke special processing of the ODE. I suspect that the strange ... 3 Is the following sufficiently general? t[e_] := e /. Dot[Times[z1_ /;!ArrayQ[z1], Dot[z2__]], z3__] :> z1 Dot[z2, z3] Simplify[a, TransformationFunctions -> {Automatic, t}] (* yy.zz.zz *) 3 Just to separate this from a package-based answer. In Mathematica 10.2, you can now do this with the built-in function SmithDecomposition. So using the same matrix from my previous answer: mat = {{1, 2, 3}, {-2, 3, 1}, {3, 2, 1}}; MatrixForm /@ SmithDecomposition[mat] Where the second element is the Smith normal form. 2 Replace the Print[det] in the print with: Paste[det] 2 m1 = 1/(s + 1); m2 = 1/(s + 1)^2; TransferFunctionModel[m1, s][s] - TransferFunctionModel[m2, s][s] {{-(1/(1 + s)^2) + 1/(1 + s)}} TransferFunctionModel[ TransferFunctionModel[m1, s][s] - TransferFunctionModel[m2, s][s], s] == TransferFunctionModel[m1 - m2, s] True 2 As others have already stated, keeping the whole 70000x70000 matrix will require too much memory. Storing just the relevant information in a SparseArray will help. Let me create some sample data and define a distance function: nd = 70000; data = RandomReal[{0, 1}, {nd, 3}]; eps = 0.01; ed[i_, j_] := EuclideanDistance[data[[i]], data[[j]]] Now we need ... 2 The problem is with the behaviour of Set. Consider the following example: a = {1,2,3,4,5}; a[[2;;]] = {1,2,3,4} a[[3;;]] = {1,2,3,4} a[[4;;]] = {1,2,3,4} a[[5;;]] = {1,2,3,4} Notice that in the [[2;;]] part, Mathematica decides you want to replace elements 2, 3, 4 and 5 of a with the corresponding elements 1, 2, 3, 4 rather than all with the list ... 2 [This is what Wolfram tech support told me when I filed a bug report:] That is because using machine precision (inexact) numbers such 0. (as opposed to exact numbers like 0) forces Eigenvectors[] to seach for eigenvectors numerically and hence the error message. For example, please evaluate and compare the results of the following expression used with ... 2 You can use Inactivate with TraditionalForm. Inactivate[h = (R.omega + x).x] // TraditionalForm Inactivate prevents the operations from executing and TraditionalForm gives the formatted output. Hope this helps. 2 I am not sure what a valid transpose of a StateSpaceModel is but here is an attempt: ssm = StateSpaceModel @ TransferFunctionModel[{{a^2/(s^2 + b s + c)}}, s] Transpose /@ #[[{1, 3, 2, 4}]] & /@ ssm 2 You shouldn't post such a code. Please isolate your problematic chunk first. Anyway. q[t_] := {xb[t], yb[t], θb[t], θ1[t], d2[t], d3[t]}; initu = Thread[q[0] == {0, 0, 0, 0, 1, 1}]; initv = Thread[q'[0] == {0, 0, 0, 0, 0, 0}]; jj = Join @@ ({Thread[M.q''[t] + V + G == {u1[t], u2[t], u3[t], u4[t], u5[t], u6[t]}], initu, initv}) /. {x_} == y_ ... 2 Hasan, So you have a matrix defined something like this (with the right hand side something else, presumably)? hMatrix[x_, y_] := {{x, 0, 0, 0}, {0, y, 0, 0}, {x, y, x + y, 0}, {0, 0, 0, x y}} So then you can make a list for hMatrix[1,1], hMatrix[2,2], ... etc. like this (change 5 to any other number): hMatrices = Table[hMatrix[i, i], {i, 5}] And then ... 2 As @GuessWhoItis mentioned, some or all of this can be done analytically. But I'll answer your question regarding Mathematica syntax, as it seems to be the goal of what you're trying to achieve here. Mathematica does not recognise "i" being a variable in "ci". The best way to deal with this is to define cVector=Table[c[i],{i,n}]; or alternatively, ... 1 Simplify@Eigenvectors[{{Cos[0. + x], Exp[I x]}, {1, 0}}]$\left( \begin{array}{cc} e^{-1. i x} \left(-0.25 \sqrt{1.+2. e^{2 i x}+16. e^{3 i x}+e^{4 i x}}+0.25 e^{2. i x}+0.25\right) & 1. \\ 0.25 e^{-1. i x} \left(\sqrt{1.+2. e^{2 i x}+16. e^{3 i x}+e^{4 i x}}+e^{2. i x}+1.\right) & 1. \end{array} \right)\$

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