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.

learn more… | top users | synonyms

11
votes
2answers
249 views

Convert operator to string

How to programmatically convert an operator such as Equilibrium into its displayed form as a string? The conversion should work like this: ...
2
votes
2answers
961 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. ...
4
votes
1answer
279 views

Path queries for tree-structured data

Can anyone suggest documentation or tutorials for developing path queries and indices for (XML-like) tree-structured data? Suppose data is organized hierarchically in key->value pairs, eg: ...
4
votes
1answer
98 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. ...
12
votes
7answers
590 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
457 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 ...
24
votes
2answers
788 views

Meaning of backtick in floating-point literal

If I compute, say, 1/3//N, Mathematica displays 0.333333 as the result. When I copy that output to use elsewhere, the paste ...
3
votes
1answer
305 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 ...
37
votes
2answers
942 views

Head and everything except Head?

I have been working on picking expressions apart using Head and Part and encountered a little mystery. Consider the canonical ...
10
votes
3answers
303 views

Why does ++++x return an increment of 2 when the value of x is only incremented by 1?

This line returns 3: x = 1; ++++x However, the value of x after the increment is only ...
4
votes
3answers
235 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 ...
10
votes
3answers
687 views

Working with PhysicalConstants

I recently found the PhysicalConstants` package. First I thought this was nice, since I didn't have to look up some quantities all the time and copy them into the ...
1
vote
1answer
151 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 ...
19
votes
1answer
382 views

Why doesn't PatternTest work with Composition?

While playing around with the solutions to this question, I've found some very strange behaviour: ...
19
votes
4answers
4k views

Is there a syntax for single-line comments for notebooks?

I'm aware that I can use (* ... *) to comment out stuff in a notebook. Many languages have a syntax for single-line comments, such as ...
2
votes
2answers
497 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
372 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
277 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, ...
12
votes
2answers
641 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: ...
9
votes
2answers
538 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
470 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 ...
11
votes
3answers
401 views

With versus Function

I've seen people compare Block with Module and With as scoping constructs, and try to figure ...
41
votes
6answers
1k 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 ...
14
votes
2answers
347 views

Distributing PlusMinus consistently

I would like to give the built-in function PlusMinus, which is undefined by default, the intuitive meaning: considering all possible combinations of $+$ and $-$. ...
7
votes
2answers
248 views

What's the purpose of the Unique function?

As the title says: What's the purpose of Unique? I understand that it generates some unique symbol, but when and for what is it to be used? Are there applications ...
19
votes
5answers
2k views

Clear complains that a subscripted variable is not a symbol or a string?

Here's a small listing where I've used EscqEsc to typeset θ in the notebook: ...
23
votes
1answer
539 views

Convenient string manipulation

With Mathematica I always feel that strings are "second class citizens." Compared to a language such as PERL one must juggle a lot of code to accomplish the same task. The available functionality is ...
17
votes
5answers
424 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?
50
votes
2answers
1k views

Flatten command: matrix as second argument

One thing I could never wrap my head around is how Flatten works when provided with a matrix as the second argument, and the Mathematica help isn't particularly ...
30
votes
4answers
612 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 ...