# Questions tagged [syntax]

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.

696 questions
Filter by
Sorted by
Tagged with
237 views

### How to Write Partition with Infix?

The documentation says that using Infix ~, the following input f[e1,e2,e3,...] can be rewritten as ...
2k views

### What does (0 &) mean in an evaluation? [closed]

My Mathematica code is this: Simplify[D[Sqrt[1 + (u')^2 + (-60 x - 20 u u')^2], u]] It returns this: ...
689 views

### Finding the square root of a squared number?

Taking the square root of the square of a number Variable set to a real value I'm wondering why these examples a = -4.3; Sqrt@a² Sqrt@(a^2) Sqrt[a^2] Sqrt[a²] ...
88 views

### How to use a function as a value in an association? [closed]

I just started learning Mathematica. I was wondering if it is possible to use a function as an value in an association. Ideally, it would be something like this: ...
105 views

### Converting prefix to infix

Is there a way in Mathematica to convert prefix to infix notation (where precedence order is preserved)? For example, how would I convert S[a, S[b, c]] to ...
347 views

### FindFaces in Mathematica 11.3

I just upgraded to Mathematica 11.3. but now my FindFaces instructions do not work anymore. I guess they changed the syntax in 11.3. Here is the original code: <...
571 views

### Can someone explain this code for joining two lists by the first element of each sublist?

Background (which may be skipped, unless context is needed) I've recently begun learning Mathematica (and only up to chapter 3 of Wellin), but wanted to write some code to get a better feel for ...
122 views

### Separation of statements vs “space mul”, formal definition of Mathematica syntax?

In Mathematica, space can often be used to indicate multiply. For example "a b" = "a * b". On the other hand, in a *.m file, we also have multiple statements separated by newlines. How does the ...
346 views

### How can I define a ⊕ operator?

What is wrong with the following code? CirclePlus := SparseArray[Band[{1, 1}] -> {##}] & a_ ⊕ b_ := CirclePlus[a, b] SetDelayed::write: Tag Function in (...
144 views

### Why 2^^1*^k does not work?

Table[2^^1*^k,{k,0,10}] This gives an error, why is that? Also this BaseForm[2 ** 1*^ #, 16] & /@ Range What is ...
425 views

### Ignore some values at return

Is there Mathematica analogue of Python _ (underscore) or Matlab ~, a special variable, that can be used when a function returns ...
124 views

### Why can Format be used on the left side?

I am learning Mathematica in random order by reading its documentation. This approach is what I like most when learning new things. Consider the following 2 cases. Syntax A: ...
78 views

### Variable dimensional integrals

I need to Integrate a function, but let the number of dimensions vary. Integrate[Product[Exp[-( t[[i]] )^2], {i,1,4}], options] ...
131 views

### Is (x|y|…)∈set the same as x∈set&&y∈set&&…?

I've sometimes seen that this operator is used to specify that each of given variables is in some set, e.g. Reals. Like ...
2k views

### Defining a function with parameters as variables [duplicate]

I have an expression V = (a + a)b. How would I define a function of a, a and <...
163 views

### Why are SetProperty and PropertyValue not working here?

I have a very simple graph, a loop: ...
647 views

### How to convert an image to a compressed string representation equivalent to one copied to clipboard by CopyToClipboard[image]?

In my recent question I asked How to embed an image into a string? The suggested solution was ...
78 views

### Non-trivial partitions of numbers using Combinatorica

I have made a code which gives back partitions of numbers in two Young diagrams (one Young diagram is trivial). For example, the partitions of 1 are ...
119 views

### Where does Documentation Center introduce the basics?

While helping a user who mistakenly thought that log rather than Log was the correct built-in function name, I included a gently-...
199 views

315 views

### Best way to write an equation with subscripts and superscripts

This post is not about a specific Mathematica problem but about to develop the best way to enter mathematical equations with subscripts and superscripts. I have a ...
172 views

### What is the role of _ in this expression?

I'm fairly familiar with basic Mathematica, but some of its more advanced syntax (especially certain special characters) eludes me. In the Scope section in the documentation of ...
83 views

### Infix non-ASCII operator needs a space to be parsed correctly in a script

Bug introduced in 9.0 or earlier and persisting through 11.1 First off: ...
412 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, ...
290 views

### How to imitate list comprehensions for constant arrays?

In Python, ['a'] * 10 generates ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'] and ...
256 views

### Nested function with an increasing argument

If, for example, I have a nesting function like Nest[1 + x^n (#) &, 1, 3] it gives the result ...
303 views

### Integral of the integral using NIntegrate

Consider the integral NIntegrate[Exp[-NIntegrate[x, {x, 0, y}]], {y, 0, 2.8}] It displays an error ...
858 views

### Is it possible to make the Button execute two or more actions?

According to the help: Button[label,action] Is it possible to make the button execute two actions?
325 views

### Overlapping pure functions

Let say I need and option for Plot: RegionFunction -> (-6 < #2 < 6 &) But I also want those ...
263 views

### Why SetDelayed won't work

I'm trying to do this: Riffle[list = {a, b, c, d, e, f}, tem = RandomInteger[1, Length@list-1]] {a, 0, b, 0, c, 1, d, 0, e, 0, f} But I think this method is ...
497 views

### List reversion inspired by Python

In python, if you wish to reverse a list, here is the trick: range(10)[::-1] => [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] Note: ...
274 views

### Relational operators on vectors

How do I use relational operators on vectors? {1, 2, 3} > {0, 1, 2} (*outputs {1, 2, 3} > {0, 1, 2}*) More generally, I want ...
479 views

### What is the right way to write a function that includes other functions?

I want to include multiple sub functions: $b(x) = 10x$ $w(x) = s + b(x)$ $c(x) = x^2$ into two main functions: $ua(x) = w(x)-c(x)$ $ub(x) = w(x)-c(x)^2$ As a reaction to this answer, I wrote ...
480 views

### Game schedule where each player meets only once

I am trying to generate a game schedule where $k$ players at the time, out of $n$ participants, meet in each game, but any player meets another player only once. In each game, with $k$ simultaneous ...
761 views

### Integrate using \[Esc] int \[Esc]

I like writing integrals symbolically instead of using Integrate[]. I suddenly seem to not be able to do this and am confused. I type \[Esc] int \[Esc] then ...
307 views

### Syntax highlighting conflict

I'm trying to syntax highlight this expression: x=$\sqrt{\pi }$//N and from various sources I've learned that x (the assigned symbol) belongs to context Global while the Pi and N belongs to System. So ...
234 views