Skip to main content

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.

Filter by
Sorted by
Tagged with
4 votes
1 answer
103 views

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

Consider the following data and corresponding ListDensityPlot: ...
John Taylor's user avatar
  • 5,887
2 votes
3 answers
299 views

Styling histograms

Consider this code: ...
John Taylor's user avatar
  • 5,887
0 votes
2 answers
57 views

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

Consider the following region: ...
John Taylor's user avatar
  • 5,887
6 votes
3 answers
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)$. ...
user2978125's user avatar
1 vote
1 answer
58 views

How to solve the following system?

Consider the system ...
John Taylor's user avatar
  • 5,887
1 vote
2 answers
102 views

How to transform a list in the following way?

Consider the following list: ...
John Taylor's user avatar
  • 5,887
3 votes
1 answer
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 ...
seva011's user avatar
  • 336
0 votes
0 answers
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 ...
mathemania's user avatar
2 votes
1 answer
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}: <...
seva011's user avatar
  • 336
1 vote
1 answer
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 ...
seva011's user avatar
  • 336
2 votes
1 answer
64 views

Expression cannot begin with [duplicate]

What is the problem with the following syntax: (5^^ # &) /@ {2, 3} The following error message is produced: ...
Aharon Naiman's user avatar
5 votes
2 answers
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: ...
seva011's user avatar
  • 336
1 vote
1 answer
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: ...
John Taylor's user avatar
  • 5,887
0 votes
1 answer
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}; ...
seva011's user avatar
  • 336
0 votes
1 answer
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. ...
IronicOwl's user avatar
  • 115
2 votes
1 answer
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}$): ...
John Taylor's user avatar
  • 5,887
1 vote
0 answers
41 views

How to quickly check if compiled code calls MainEvaluate?

Consider the following test compiled code: ...
John Taylor's user avatar
  • 5,887
0 votes
0 answers
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 ...
mrejr923's user avatar
0 votes
0 answers
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 ...
Zlelik's user avatar
  • 531
4 votes
2 answers
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) ...
John Taylor's user avatar
  • 5,887
6 votes
2 answers
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 ...
Nasser's user avatar
  • 147k
0 votes
1 answer
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 ...
John Taylor's user avatar
  • 5,887
4 votes
2 answers
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. ...
DansAltamira's user avatar
0 votes
0 answers
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. ...
VertexVexed's user avatar
2 votes
1 answer
108 views

Fastest splitter?

Consider some dataset ...
John Taylor's user avatar
  • 5,887
2 votes
2 answers
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: ...
John Taylor's user avatar
  • 5,887
3 votes
2 answers
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 ...
John Taylor's user avatar
  • 5,887
1 vote
1 answer
65 views

Problem with RegionNearest?

Consider the following region: ...
John Taylor's user avatar
  • 5,887
0 votes
0 answers
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 ...
John Taylor's user avatar
  • 5,887
3 votes
0 answers
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 ...
Chris O's user avatar
  • 91
7 votes
1 answer
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 ...
Claude Leibovici's user avatar
2 votes
0 answers
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 ...
seva011's user avatar
  • 336
0 votes
1 answer
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 ...
TTT's user avatar
  • 57
1 vote
1 answer
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? ...
Deepika Gaur's user avatar
3 votes
1 answer
94 views

Multiple dropdown dialogs in the same window?

Consider a few dropdown dialogs: ...
John Taylor's user avatar
  • 5,887
3 votes
0 answers
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 <...
John Taylor's user avatar
  • 5,887
5 votes
3 answers
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. ...
John Taylor's user avatar
  • 5,887
3 votes
4 answers
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 ...
Diffycue's user avatar
  • 1,844
0 votes
2 answers
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 ...
John Taylor's user avatar
  • 5,887
2 votes
1 answer
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 ...
Yaroslav Bulatov's user avatar
3 votes
0 answers
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 ...
John Taylor's user avatar
  • 5,887
2 votes
2 answers
120 views

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

Consider the following table: ...
John Taylor's user avatar
  • 5,887
0 votes
1 answer
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 ...
Mjoseph's user avatar
  • 255
0 votes
1 answer
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 ...
John Taylor's user avatar
  • 5,887
0 votes
2 answers
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 ...
John Taylor's user avatar
  • 5,887
2 votes
1 answer
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 ...
JDRobin's user avatar
  • 55
2 votes
4 answers
139 views

How to transform the data in the following way?

Consider the following data: ...
John Taylor's user avatar
  • 5,887
1 vote
0 answers
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 ...
Pamela's user avatar
  • 309
4 votes
4 answers
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 ...
John Taylor's user avatar
  • 5,887
3 votes
5 answers
240 views

How to check if the given row matches one of the rows of a table?

Consider some table tabb = RandomInteger[{0, 4}, {5, 4}] and a row row = RandomInteger[{0, 4}, 4] How to check if ...
John Taylor's user avatar
  • 5,887

1
2 3 4 5
21