Skip to main content

New answers tagged

1 vote

Finding and Plotting Minima

You can use ComplexExpand to get rid Abs and so forth, if z, ...
Goofy's user avatar
  • 3,570
2 votes

How to apply `Length` in all elements

Using Cases: Cases[{1, {2, 3}, {4, 5, 6}}, x_ :> ReplaceAll[0 -> 1]@Length@x] ...
E. Chan-López's user avatar
2 votes

How to apply `Length` in all elements

list = {1, {2, 3}, {4, 5, 6}}; Using Max Max[1, #] & @* Length /@ list {1, 2, 3} ...
eldo's user avatar
  • 81.2k
4 votes
Accepted

How can I sort all levels except the innermost level?

Use Map[ f, expr, level spec] ...
A. Kato's user avatar
  • 1,460
5 votes

How can I sort all levels except the innermost level?

l1 = {{{d, c}, {b, a}}, {{4, 3}, {2, 1}}}; l2 = {{{{d, c}, {b, a}}, {{4, 3}, {2, 1}}}, {{{d, c}, {b, a}}, {{4, 3}, {2, 1}}}}; Using ...
E. Chan-López's user avatar
7 votes
Accepted

How to optimize performance with DeleteDuplicates?

In checking duplicates, you are considering 2, 4, 6, 8, 10 are the same as 1, 3 ,5, 7, 9, respectively. Then, instead of testing all possible replacement, I recommend you to convert into standard ...
A. Kato's user avatar
  • 1,460
1 vote

How to exclude singularities for `NMinimize`

If we take objective from @user64494 answer, we first check the region where objective \[Element] Reals ...
Ulrich Neumann's user avatar
1 vote

Selecting only the quartic terms from an expression

A classic way is to scale each variable by a dummy variable, say, k. Then the coefficient of k^n consists of all the degree <...
Michael E2's user avatar
  • 239k
1 vote
Accepted

Selecting only the quartic terms from an expression

...
Bob Hanlon's user avatar
  • 160k
0 votes

How to exclude singularities for `NMinimize`

The following works without any errors and warnings in 14.0 on Windows 10. We use exact numbers to avoid problems with the evaluation. ...
user64494's user avatar
  • 27.3k
0 votes

Inverse gradient operator

This is the code from the article you provided in your question: https://arxiv.org/pdf/0804.2239 ...
ayr's user avatar
  • 2,444
1 vote

Slope of a line

data = {{x1, y1}, {x2, y2}}; A variant of Bob Hanlon's slope3 using ReverseApplied (new in ...
eldo's user avatar
  • 81.2k
1 vote

How to replace sequences in a list based on specific patterns?

...
ubpdqn's user avatar
  • 62.8k
2 votes

Why is the matrix "mat" not modified here?

...
E. Chan-López's user avatar
3 votes

Why is the matrix "mat" not modified here?

...
eldo's user avatar
  • 81.2k
2 votes

How can I permute pair of elements in a list?

Just for somethinng different: ...
ubpdqn's user avatar
  • 62.8k
2 votes

How can I permute pair of elements in a list?

An attempt ...
user1066's user avatar
  • 20.8k
5 votes
Accepted

How can I permute pair of elements in a list?

...
A. Kato's user avatar
  • 1,460
5 votes

How can I permute pair of elements in a list?

res = MapAt[Reverse, {All, 2 ;; -1}] @ (Transpose[{Cases[list, _Symbol], #}] & /@ Permutations[Cases[list, {__}]]); Join @@@ res // Column
eldo's user avatar
  • 81.2k
3 votes

How to replace sequences in a list based on specific patterns?

It is not clear from the question, but I understand that only A? and B? are combined, but somehow A? and V? are not. Then, the following code will work for a data containing A3 and B3 as well. (I ...
A. Kato's user avatar
  • 1,460
5 votes
Accepted

How to replace sequences in a list based on specific patterns?

SequenceReplace[list, (x : {A1, B1} | {B1, A1} | {A2, B2} | {B2, A2}) -> x] (* {V1, {A1, B1}, {A2, B2}, {B1 A1}, V2} *) If you also want to handle ...
Najib Idrissi's user avatar

Top 50 recent answers are included