Skip to main content

New answers tagged

0 votes

Compilation error while adding two matrices

I have solved the problem while adding two matrices and maybe, it can help the others. The problem is matrix c is defined as random real and while assigning it into function, and adding it with ahmet[[...
Kazim Ahmet Hasim's user avatar
0 votes

Diagonalizing a real symmetric matrix with an orthogonal matrix

You can use Eigensystem In the following ev is the desired matrix. I leave it to the user to choose how to express and use ...
ubpdqn's user avatar
  • 61.6k
0 votes

Extracting matrix coefficients from multivariate matrices

Not sure why you're using C array indices (start at zero) instead of Mma indices (start at one), nor why you ignore one of the matrix entries in the output. If that's not what you're doing, then I've ...
Michael E2's user avatar
  • 236k
2 votes

Creation of one column matrix

Using ReplaceAt (new in 13.1) ReplaceAt[Table[{0}, 4], _ :> {-1}, 1] Using MapAt ...
eldo's user avatar
  • 74.4k
1 vote

A first order differential equation: Inconsistent solutions by two approaches

In both Wolfram Language 13.3.0 Engine for Linux and the cloud version 14.0.0, the original code produces the error message "DSolve::nolist: List encountered within ... There should be no lists ...
LouisB's user avatar
  • 12.6k
2 votes

Removing duplicates between sublists

A variant of 1066's answer ...
eldo's user avatar
  • 74.4k
0 votes

Use Mathematica to Implement Blahut–Arimoto Algorithm (Part: Algorithm for Rate-Distortion)

I don't find that, so I implement one by myself. The results are completely consistent: Try the Mathematica code online! ...
138 Aspen's user avatar
  • 1,373
0 votes

Use Mathematica to Implement Blahut–Arimoto Algorithm (Part: Algorithm for Channel Capacity)

I don't find that, so I implemented one by myself. ...
138 Aspen's user avatar
  • 1,373
2 votes

Select twins from a list of triples

list = {{1, 1, 1}, {1, 2, 3}, {1, 1, 2}, {1, 2, 1}, {2, 1, 1}, {2, 3, 2}, {4, 5, 6}}; Using DeleteElements (new in 13.1) and ...
eldo's user avatar
  • 74.4k
1 vote

Why is Mathematica not simplifying this matrix?

To simplify objects with complex numbers, we can use ComplexExpand first. ...
Jie Zhu's user avatar
  • 798
2 votes

Why is Mathematica not simplifying this matrix?

I don't know if this helps, but ...
Cassini's user avatar
  • 5,586
2 votes

Divide the elements of one column with the corr element of another column

list = {{2, 3}, {3, 4}, {4, 5}, {5, 6}, {6, 7}}; Using ReverseApplied (new in 12.1) With ...
eldo's user avatar
  • 74.4k
0 votes

How can I build a symmetric matrix of up to 100?

A simple method: n = 3; A3 = Table[Superscript[a, Abs[i - j]], {i, 1, n}, {j, 1, n}]; A3 // MatrixForm
AccidentalTaylorExpansion's user avatar
1 vote

How can I build a symmetric matrix of up to 100?

Just a variant: func[a_, n_] := MapAt[Defer[a^#] &, DistanceMatrix[Range[n]], {All, All}] (* examples *) func[a, 3] // MatrixForm func[x, 10] // MatrixForm
ubpdqn's user avatar
  • 61.6k
10 votes

How can I build a symmetric matrix of up to 100?

Look up a Toeplitz matrix: m[n_] := a^(ToeplitzMatrix[n]-1) Alternatively, an explicit construction as a rule-based matrix: ...
Roman's user avatar
  • 47.9k
2 votes

How can I build a symmetric matrix of up to 100?

Maybe something along these lines: ...
lericr's user avatar
  • 29k
3 votes

How can I build a symmetric matrix of up to 100?

$Version (* "14.0.0 for Mac OS X ARM (64-bit) (December 13, 2023)" *) ClearAll["Global`*"] Using strings to hold your specified forms ...
Bob Hanlon's user avatar
  • 159k
3 votes
Accepted

Solving a first order linear matrix differential equation

Write the matrix elementwise then it will work: ...
Daniel Huber's user avatar
  • 52.6k
0 votes

Simplification of arrays of a matrix

This is too long for a comment and might be off the mark but the way I would handle this type of expression is I would use the symbols straight into the array definitions as dummy functions, do my ...
gpap's user avatar
  • 9,717
2 votes

Canonical way to map a function to diagonal elements of a square matrix?

Just a variant: func[f_, mat_] := Fold[MapAt[f, #1, {#2, #2}] &, mat, Range[Length[mat[[1]]]]] For example: ...
ubpdqn's user avatar
  • 61.6k
2 votes

Canonical way to map a function to diagonal elements of a square matrix?

A = {{"a", 0, 0}, {0, E, 0}, {0, 0, E}}; With ReplaceAt (new in 13.1) we can easily add conditions: ...
eldo's user avatar
  • 74.4k
3 votes

How can I "multiply" nested lists?

al = {{a, b, c}, {d, e, f}}; bl = {{r, s, t}, {x, y, z}}; Using J.M's comment and Catenate ...
eldo's user avatar
  • 74.4k
2 votes

Prepend 0 to sublists

list = {{7, 4, 9, 9, 7}, {4, 2, 5, 5, 2}, {6, 5, 9, 2, 4}, {1, 9, 4, 7, 2}}; Using Cases and ...
eldo's user avatar
  • 74.4k
1 vote

Periodical sum of rows by a certain step

m = Table[i, {i, 12}, {4}]; i = {#, # + 1, # + 2} & @ {1, 5, 9}; Using Query and ...
eldo's user avatar
  • 74.4k
1 vote

Identify the positions of a marker in sublists

Using SubsetPosition (new in 12.1) Catenate @ SubsetPosition[#, {1}] & /@ ZeroCrossings {{3, 9}, {4, 5, 8, 12, 13}, {4, 12,...
eldo's user avatar
  • 74.4k
3 votes
Accepted

Retrieving only first function in matrix ODE using NDSolve

try this. Use Flatten[ρ[t]] Instead of ρ[t] In your NDSolve call. Now the solution list of 4 solutions. And then ...
Nasser's user avatar
  • 145k
4 votes
Accepted

How can I extract a matrix and vectors of coefficients from this quadratic expression?

The function you are looking for is "CoefficientArrays". E.g. for your polynomial: var = {x, y, z}; poly = (x - y + a)^2 + (x - z + b)^2; we get the ...
Daniel Huber's user avatar
  • 52.6k
1 vote

Flatten a pair of matrices within a list of matrices

With the 1st list as m and the 2nd as wanted we get the "more general solution" requested in the comment as follows: <...
eldo's user avatar
  • 74.4k
2 votes

How to fill lower trianglar matrix with elements of a vector

n = 5; v = Range[n (n + 1)/2]; Using FoldPairList and TakeDrop ...
eldo's user avatar
  • 74.4k
3 votes

How to solve a matrix differential equation $\frac{d X}{dt} = i(X Y- Y^\dagger X)$?

A brute force solution can be obtained by, first, defining ...
bbgodfrey's user avatar
  • 61.6k
0 votes

How to solve a matrix differential equation $\frac{d X}{dt} = i(X Y- Y^\dagger X)$?

The Lie bracket is an order respecting, non commutave 'derivative' $$\left[X, Y\right] =\nabla_X Y$$ by linearity and product formula $$\left[ X ,Y Z\right] = X Y Z - Y Z X = Y \left[ X , Z\right] + ...
Roland F's user avatar
  • 3,772

Top 50 recent answers are included