# Questions tagged [syntax]

Questions on the correct (or improved) formulation of Mathematica code to achieve particular results. Use this tag (not "symbol") for questions about all those odd @@ /@ # & and _ characters, which are keyboard shortcuts for the Wolfram Language named functions Apply, Map, Slot, Function, and Blank.

1,029 questions
Filter by
Sorted by
Tagged with
103 views

### How to convert the legend bar to scientific form? [duplicate]

Consider the following data and corresponding ListDensityPlot: ...
• 5,887
299 views

### Styling histograms

Consider this code: ...
• 5,887
57 views

### How to find the nearest point using RegionNearest for this case?

Consider the following region: ...
• 5,887
239 views

### Composition of vectorvalued functions

Suppose I have two functions $f,g:\mathbb{R}^2 \to \mathbb{R}^2$ and that I want to compute $g(f(x,y))$. As an example, let's take $f(x,y)=(x+y, x-y)$ and $g(x,y)=(y^2,x^2)$. Then, $g(f(1,2))=(1,9)$. ...
• 175
1 vote
58 views

### How to solve the following system?

Consider the system ...
• 5,887
1 vote
102 views

### How to transform a list in the following way?

Consider the following list: ...
• 5,887
130 views

### Nested integration of the list of functions returns error

I have a list of expressions which I would like to integrate by nested integration. For any element from the list it works without issues (see end of the post), however, when I apply nested ...
• 336
39 views

### NIntegrate: variable is not a valid limit of integration

I have a function $F(z_h)$ given by, $$F(z_h) = \int^{\infty}_{z_h} s(y) T'(y) dy$$ where $T \equiv T(z_h), T' \equiv T'(z_h), s \equiv s(z_h)$, which means they're all functions of $z_h$. Their ...
• 715
109 views

### Outer function for nested list

I have the following routine where I build a pair of function name lists {Flist, Klist} and 1D argument list {a1,a2,a3,a4,a5}: <...
• 336
1 vote
61 views

### Define certain argument in functions which depend on several arguments and built in a list

I got confused working with list of functions of two variables. I construct few lists of functions, one is vector of functions List1 and another is 2D list of ...
• 336
64 views

### Expression cannot begin with [duplicate]

What is the problem with the following syntax: (5^^ # &) /@ {2, 3} The following error message is produced: ...
• 1,225
134 views

### Syntax error when running file created with Save which contains backslashes

I am doing a nested integration. So far the result was successfully saved with Save["filename.wl", IntOutput] and looked as following: ...
• 336
1 vote
84 views

### Why using compiled code inside compiled code may slow things down?

I made some code that I compiled. The snippet looks as follows: ...
• 5,887
52 views

### Build 2D lists of functions and variables in different combinations

Can someone give examples on how to build 2D Lists of function and expressions by the given vectors? I have the following: V1={a,b,c}; V2={1,2,3}; V3={x1,x2,x3}; ...
• 336
46 views

### Syntax regarding Manipulate plot with multiple functions

I am facing the following issue; I have the solution of a ParametricNDSolveValue and would like to plot several solutions with varying parameter in the same Manipulate to see qualitative differences. ...
• 115
103 views

### Fast sampling from Fermi-Dirac distribution under specific conditions

This question is a continuation of the following one. Let us assume a Fermi-Dirac (FD) distribution (times $p^{2}$): ...
• 5,887
1 vote
41 views

### How to quickly check if compiled code calls MainEvaluate?

Consider the following test compiled code: ...
• 5,887
32 views

### Evaluating determinant with entries from ./ output

I generate 16 values (this is a differential equation shooting method problem) from this kind of evaluation, y41 = Evaluate[y4[tf1] /. torsolve4]; When I use them in Det[], it does not work because ...
31 views

### Question about rule syntax/format for CellularAutomaton function [duplicate]

I am trying to understand how to use CellularAutomaton function. For example, I am interested in the Game life and I found a working example here. However I cannot understand or find a detailed ...
• 531
137 views

### How to speed up the following algorithm?

I have some random combinations of numbers pairs (where numbers range from 1 to some ntest) ...
• 5,887
157 views

### Is there a system option to make Mathematica generate syntax error when reading code from file which has red syntax warning in frontend?

I type some equations from text books into database, which later read from Mathematica to solve. Since I do this manually, sometimes I make mistakes where I type ...
• 147k
77 views

### How to select non-repeating pair of numbers?

Consider the following combinations of integers comb, where the integers range from 1 to n ...
• 5,887
215 views

### Trying to Solve system of equations gives empty result

First-time user of Mathematica. I have three equations, and I'm trying to solve for one of the variables. I'm hoping this is just a syntax problem. ...
45 views

### Invalid variables error in SolveValues when using an array of variables

I was attempting to run some code similar to the simple example below. ...
108 views

### Fastest splitter?

Consider some dataset ...
• 5,887
102 views

### Analog of monitor which does not lead to freezes of the interface

I have some heavy computation wrapped by Monitor and ProgressIndicator. It is the template: ...
• 5,887
137 views

### Different behavior of Clear in different versions of Mathematica

Consider the following code: list1 = {1, 2, 3}; m = 17; {list1, m} // Clear In Mathematica 13.2, this syntax with Clear works ...
• 5,887
1 vote
65 views

### Problem with RegionNearest?

Consider the following region: ...
• 5,887
67 views

### Any way to eliminate evaluating cells except for "Abort evaluation"?

I have a notebook with many cells, one of which contains an evaluation of some condition. If it is False, I want to have an automatized way of the "Abort ...
• 5,887
73 views

### Keeping track of braces and brackets { } [ ]

It doesn't take much to end up with lots of braces, i.e, { or }, and brackets, i.e., [ or ], in even a single line of MM code, and it's very easy to lose track of how many there are and where they ...
• 91
377 views

### What is the diffrence between these three commands?

Consider F=1/((x-a)(x-b)) ; G= 1/((x-α)*(x-β)); H=1/((x-r[1])(x-r[2])) ; Using Apart[], the partial fraction decomposition ...
• 1,001
84 views

### Optimizing prallel computing for nested integration

I need an advice for optimization of computing with ParallelMap, as well as general hints to speed up computing discussed below. I have several questions about this ...
• 336
162 views

### Partial differential equation with conditions

I am trying to solve this PDE with Mathematica, and I have checked the syntax a lot, but still don't get a solution ...
• 57
1 vote
68 views

### Syntax::sntxf when using ItoProcess

The following code gives an error message Syntax::sntxf. What is wrong with my code, and how can I fix it? ...
94 views

### Multiple dropdown dialogs in the same window?

Consider a few dropdown dialogs: ...
• 5,887
66 views

### Making speed of MemberQ comparable with explicit If?

Consider the following two lists: listtest = {11, 13, 22, 221, 1, 3} // Sort // N; pdglisttest = RandomInteger[{-222, 222}, 10^6] // N; For the given element of <...
• 5,887
425 views

### How to find the nearest element that is bigger than x?

Consider some list list=RandomReal[{0,1},10^6]; I would like to find the closest element to some value of x that is larger than it, and also extract its position. ...
• 5,887
223 views

### Destructuring the left-hand-side of Optional[s:v]

It is useful to be able to provide default values in pattern-matching, for example, if an element has a key but no corresponding ...
• 1,844
104 views

### How to build the following region?

Consider a 3D figure defined by the dependence $\Delta x(z),\Delta y(z)$. One example is a pyramidal frustum, for which $\Delta x, \Delta y$ are linear functions of $z$, and $z$ lies inside the ...
• 5,887
54 views

### ReplaceAll that works inside Rational?

I'm trying to replace all instances of a 31632259 in a formula with x, but there's something special about how Mathematica ...
• 7,875
223 views

### How to solve the following integrodifferential equation by generic approach?

Consider the following equation: $$\frac{\partial f}{\partial t} - p H(t)\frac{\partial f}{\partial p} = \mathcal{I}[p,t], \tag 1$$ Here, f = f[p,t], with p being ...
• 5,887
120 views

### How to "complete" the table by making all of its rows to have the same number of elements?

Consider the following table: ...
• 5,887
59 views

### Syntax error trying to rewrite expression using rules

I want to use Mathematica to calculate derivatives of some long, complicated expressions. I have an integral with integrand $I_*$ which is a functional that depends on $h(x,t)$ and $\phi(x,t)$. The ...
• 255
77 views

### How to re-organize the table in the following way?

Consider the following table: tab=RandomReal[{0,1},{5,10}] How is it possible to convert it into the form of a 2-column table ...
• 5,887
107 views

### How to combine the tables in the following way?

Consider two tables tab1 = RandomReal[{0, 1}, {5, 4}] tab2 = RandomReal[{0, 1}, {10, 4}] How to quickly make a table where the ith row of ...
• 5,887
119 views

### How to code retarded time in Lienard-Wiechert potential equations?

I have been making strides on my project with the help of others here but have run into another snag: I am having difficulty in expressing the Lienard-Wiechert potentials with retarded time. For ...
• 55
139 views

### How to transform the data in the following way?

Consider the following data: ...
• 5,887
1 vote
82 views

### How to emulate the curves and color of the video? [closed]

I found this animation on the internet, it is part of a joke, but I was intrigued by how the video can be emulated with the colors and the curve proposed in the video.The video talks about neural ...
• 309
161 views

### How to check if at least one ordering of the given row matches one of the rows of a table?

Consider some list of elements ...
• 5,887