Questions on correct (or improved) formulation of Mathematica code to achieve particular results. Use this tag (not "symbol") for questions about all those odd @@ /@ # & and ~ characters.
1
vote
2answers
180 views
Finding the position of a specific value in a list
Is it possible to easily find the position of a specific value in a list? For example, if the list is {{x1,y1},{x2,y2},...,{xn,yn}} I would like to know the ...
5
votes
1answer
170 views
Why does the Front End group backslashes into pairs?
What is \\ for? Help finds nothing on it. An odd number of backslashes greater than one are grouped by two and the last one is displayed with a different color. ...
10
votes
2answers
97 views
Functions in a different context are replaced with infix forms of their namesake in System`
So, in an attempt to help out Fabian with his question, I did what I often do, and created a new symbol in the Pillsy` package that I could play with. Since it was ...
0
votes
1answer
224 views
What does the slash-colon symbol do?
I came across a bit of code that uses the syntax /: and I don't know what it does. I can't find its documentation, or maybe I'm just not looking properly. The code ...
5
votes
2answers
320 views
Constructing a Summation with a Variable Number of Inner Sums
I have a question regarding multiple sums. And my second index depends on the first index. Here it is:
$$
\sum_{d=1}^{P}e^{-d}\sum_{\substack{1\leq k_{1}\leq Q \\ 1\leq k_{2}\leq Q \\... ...
28
votes
3answers
471 views
Usage of \[InvisibleApplication] and other related invisible characters
From the front end, \[InvisibleApplication] can be entered as Esc @ Esc, and is an invisible operator for @!. By an unfortunate ...
2
votes
3answers
577 views
Orthonormalization of non-hermitian matrix eigenvectors
When using Orthogonalize[] one can specify which definition of "inner product" is to be used. For example, ...
4
votes
1answer
75 views
How do you set an Optional parameter with a global variable on a Function defined in a Package
In a Package I am writing, I'm trying to define a function with an Optional parameter in it that is set to a global variable.
...
8
votes
1answer
134 views
Accept Infinity as an Integer argument
I have the following function, albeit contrived:
Foo[x_Integer] :=
Module[{i},
i = 1;
While[i <= x && i <= 10, i++];
i - 1
];
I am ...
8
votes
2answers
176 views
Cases[data,Colon[key,_]] vs. Cases[data,key:_] toward XPath, XQuery
Exploring methods to index and search tree-structured key:value pairs via named-entity index (key paths) as opposed to Position-based indexing.
Using Rule as ...
7
votes
5answers
1k views
Notation of partial derivative
I want to write partial derivatives of functions with many arguments. Why is it that when I type
f[x,y] ctrl+6 (0,1)
it turns out to be bad syntax? The output of
...
3
votes
1answer
240 views
Explanation on why Compile statement works only if input and output sizes work
I found the following code:
Compile[{{m, _Real, 2}}, Fourier[m]][Table[N[i - j], {i, 4}, {j, 4}]]
which doesn't work correctly. But the following was posted as a ...
2
votes
2answers
515 views
NMinimize with defined function call getting error NMinimize::nnum
I want to call the NMinimize function for my own defined calculations but I got an error. Below is a simple example.
...
11
votes
7answers
396 views
Equating matrices (or higher order tensors) element-wise
Say I have two matrices (or, as in my case, higher order tensors) $A,B$, and I want to solve the equation $A=B$. To do so , I need a list of equations that equate entry-wise the elements of $A$ and ...
8
votes
4answers
306 views
Error when using rule as a list index - { i, x[[i]] } /. i -> 5
I can't seem to use a rule to index a vector.
x = Range[10];
{ i, x[[i]] } /. i -> 5
I get the following error when evaluating the above code, even if the ...
8
votes
2answers
464 views
Collapse a section of a huge function
(I have recently taken to Mathematica... still a noobie)
Is there an elegant way of hiding/collapsing only a portion of a function (for example, in Matlab, within a function, one can collapse the for ...
4
votes
3answers
160 views
Brackets in output make unable to use output to identify matrix element
I'm trying to write a code where each matrix element swaps with a randomly selected neighbor (cardinal directions only) to redistribute the matrix. So far I've been able to replace an element with its ...
29
votes
6answers
930 views
Functions vs. patterns
Every time I define a new function, I wonder which construct I should use: true functions obtained by using Function, or rule-based syntax. For example, these are ...
1
vote
1answer
135 views
Differentiation w/o assiging concrete values
v = Subscript[v, 0]*Sin[(Pi*S)/Subscript[S, 0]];
a = dv/ds v;
a = D[v, s]
returns
...
18
votes
1answer
273 views
Why doesn't PatternTest work with Composition?
While playing around with the solutions to this question, I've found some very strange behaviour:
...
2
votes
2answers
255 views
Single dot textual form
How do I render a letter with a single dot above it?
I see \[DoubleDot] and \[TripleDot] are readily available, but what about ...
3
votes
5answers
255 views
Using variables in function names
I want to make a list of plots and my functions are named C1, C2... Cn.
The command I wish ...
5
votes
4answers
255 views
Multiple colors in Graphics[] environment
There are other questions on the site that are similar to this one, but the answers provided didn't help me.
I want to draw disks of different radii. Each radius is the absolute value of a variable, ...
10
votes
2answers
321 views
Representing second derivatives with a double overdot
I would like to express a second derivative with two dots above the variable. You can do this with a first derivative by saying:
...
10
votes
2answers
305 views
Flatten at a certain level
In an earlier question the brainteasing fourth syntax variant of Flatten was discussed. I see that with
...
10
votes
2answers
330 views
How do you programatically load data into symbols?
I am trying to convert a list of string names into symbols, which will then be used to store data. I have 24 files (where the name of each file is a member of the list mentioned above) that I need to ...
6
votes
3answers
285 views
With versus Function
I've seen people compare Block with Module and With as scoping constructs, and try to figure ...
17
votes
5answers
318 views
Change syntax from other programs to mathematica syntax
Is there a good way to transform syntax from other computer algebra systems or from latex to mathematica syntax?


