The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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.

67 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8
votes
0answers
94 views

What is the philosophy behind \[Rule] (a.k.a. `->`) for assigning options?

Today I was banging my head against my desk when I realized that the problem I was experiencing was due to having typed ImageSize[Large] instead of ...
8
votes
0answers
230 views

What is a good way to code long, complex, compilable algorithms?

The functional paradigm of the Wolfram Language used in Mathematica is all around wonderful. For intense numerics, Mathematica comes with the ability to Compile ...
8
votes
0answers
121 views

Syntax error in debug mode

Bug introduced in 8.0 and persisting through 10.3.0 It appears that in debug mode, the \[Piecewise] symbol and its associated grid give a syntax error. For a ...
7
votes
0answers
129 views

Design considerations behind `O` (a.k.a. BigOh, a.k.a. Landau Order)

This works without any warnings: O[Log[x]]. This raises a warning: O[x^2]. I have a few questions around this: Why is it a ...
6
votes
0answers
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: ...
5
votes
0answers
351 views

Syntax error for optional pattern, but only in debugger

This expression (explained here by Leonid) evaluates fine unless Evaluation->Debugger is enabled: h[x : (_Integer) : 1] := x Syntax::sntxf: "x:" cannot be ...
4
votes
0answers
128 views

Crossing a symbol like p, similar to HBAR

Is it possible in Mathematica to cross a symbol like p, similar to h-bar, used to denote the Planck constant? Picture in case of font problems: In case of h, we have HBAR, inputted as ESC-hb-ESC ...
4
votes
0answers
106 views

Why does FromDigits transpose its argument (sometimes)?

a = {{1, 2}, {3, 4}, {5, 6}} ; FromDigits /@ Transpose@ a == FromDigits @ a (* True *) The only "strange" syntax I've found in the docs is But it doesn't ...
4
votes
0answers
163 views

“\:”; flagged as syntax error

While answering question 94032, I noticed that Mathematica 10.2 flagged "\:" <> IntegerString[62378, 16, 4] with a red bracket, apparently indicating a ...
4
votes
0answers
185 views

Multiple Constrained Sum

I need to perform a multiple summation, that obeys some conditions. This arises in the study of a statistical physics model. q=Exp[-β]. I would like to ask if ...
4
votes
0answers
148 views

Is there a way to check whether two notebooks share the same variables?

When I code in Mathematica, I often re-use code from old notebooks which fulfilled a specific purpose; for example, one testing for soft matches in strings, or one that identifies outliers on a graph ...
4
votes
0answers
133 views

Proper treatment of roots and powers in Series?

I have the following problem in Mathematica 9 on Linux. I let Mathematica compute the Series expansion: ...
4
votes
0answers
233 views

Syntax colouring when using Symbolize

I need to use symbols with suffixes in order to make my code readable in relation to the Eurocodes. To do this I use Symbolize from the ...
3
votes
0answers
73 views

Use of ContainsAny in EntityClass

The documentation page for EntityClass states that Property values in implicitly defined entity classes may make use of Quantity (and intervals of Quantity) for ...
3
votes
0answers
78 views

Pre-define list of variables to set them in bulk

I understand this is likely tremendously simple, but I cannot work out how to do the following: vars = {b,c} *define variables* vars = {1,2} *set them* Then I ...
3
votes
0answers
120 views

Check an Option without Evaluation

Consider the following: ...
3
votes
0answers
70 views

Java anonymous functions from JLink?

JLink is really great to act on Java objects and access Java static methods. I'm asking myself if there would be a way to have access to a more recent Java syntax that allows anonymous functions, ...
3
votes
0answers
69 views

Why is `Cell` > `Convert To` > `InputForm` not invertible?

I sometimes post code to PhysicsSE, and I usually convert it to InputForm first before posting, in order to avoid pages and pages of ...
3
votes
0answers
126 views

Assign variables from list inside With or Module

I have found that it is possible to assign variables from lists, as follows. r = {1, 2, 3}; {a, b, c} = r; b 2 However, if ...
3
votes
0answers
790 views

NonLinearModelFit with Two Dimensional List of Weights

I'm currently trying to fit Planck's law (B[λ, T]) to measurements, thereby determining Planck's constant. I have a list of triplets containing wavelength, ...
2
votes
0answers
61 views

How do decrease uncertainty of Monte-Carlo integration?

I have some function of many arguments and need to integrate it over the region given by the products of Heaviside theta functions. Namely, I write, say, ...
2
votes
0answers
46 views

How to add sugar for NetEncoder?

I'm tired of the extra level of list in NetEncoder and would like to get rid of it. The obvious thing fails: ...
2
votes
0answers
68 views

What do these parentheses inserted after “Pretty Print” with StandardForm?

Background: I have a list containing individual elements and sublists. tab = {1, 2, 3, a, {4, 1}, {5, 2}} The individual elements are also to be converted into ...
2
votes
0answers
77 views

Piecewise function Syntax error only in debug mode

If I enter the following through mathematica (11.0) through UI $$\begin{cases} 1 &x \geq 0 \\ 0 &True \end{cases}$$ No error is reported. $$\begin{cases} 1 &x \geq 0 \\ 0 &True \end{...
2
votes
0answers
591 views

Conditional statements in intial conditions?

This is potentially a daft question, but I thought I'd ask it; I have some material free to diffuse in a boundary between rn and ro; I've been able to get it working nicely for neumann type boundary ...
1
vote
0answers
121 views

Light beams reflecting from parabola

How can we show the paths of three light beams in Mathematica which bounce back after hitting the parabola, in a single plot? Suppose we have the following code ...
1
vote
0answers
63 views

Difficulty with ExternalEvaluate

I am trying to import a Python function or execute a Python script from inside Mathematica, but the ExternalEvaluate command drives me nuts. I proceed cautiously ...
1
vote
0answers
72 views

Run function as loop over two matrices

I'm still wrapping my head around Mathematica syntax. I have a matrix clustersAll that looks like ...
1
vote
0answers
35 views

Trouble Plotting the maximum values of a function

First off, I apologize if this question is either incredibly obvious, or has been clearly asked and answered before. I've been searching the forum for a while, and the questions and answers thusfar ...
1
vote
0answers
53 views

How to write down existence and uniqueness?

Mathematica has strong commands ForAlland Exists. However, I face difficulties, trying to express "existence and uniqueness" in ...
1
vote
0answers
88 views

NIntegrate and definite Integrate give different results

Suppose the function f[x_,q_]=(15876 Exp[-0.527076 q^2] (x^2-2 x+2) SphericalBesselJ[1,5 q]^2 (q^2-8100 x^2))/(3425*Pi*q^5*x); I need to perform the integration ...
1
vote
0answers
51 views

Strange behavior of NIntegrate

I have some function f[x,y,a], where a is some parameter, defined as piecewise f[x,y,a] = Piecewise[{{g[x,y,a], a<m[x]}, {0, True}}] Here $m$ is some function....
1
vote
0answers
67 views

How to check the positivity of a function depending on many variables?

Suppose we have some complicated function $f(x,y,z,v,u,w)$ with $\{x,y,z,v,u,w\} \in G$; precisely, each variable excepting one is defined in the sub-domain depending on other variables: $w \in G_{1}(...
1
vote
0answers
81 views

Mathematica can't evaluate the function at the point where it is smooth

Suppose the function ...
1
vote
0answers
124 views

Proper syntax for DeleteCases with conditions

List is an array of dimensions {61777, 3}. dist1 & dist2 are RegionDistanceFunctions. Using: ...
1
vote
0answers
41 views

Notation doesn't work if toolbar is used

I am trying the examples on Notation Tutorial In:= a + b\[LongLeftRightArrow]c // FullForm Out:= Plus[a,LongLeftRightArrow[b,c]] Then I try to change ...
1
vote
0answers
61 views

Assigning variables from rules from fit

It became quite clear after running this a few times that my syntax is wrong, but I can't parse out why. Anybody know of a better way to write this? ...
1
vote
0answers
98 views

Decimal alignment in a grid

I tried to find an answer and found quite a few posts on similar topics, but none of them really helped me. Here is a typical example: ...
1
vote
0answers
228 views

How to get user input using FormPage

I am designing a user interface for a word-ladder game using CloudDeploy, CloudExpression and FormPage and I am having trouble with receiving the user input from the form. What I basically need is a ...
1
vote
0answers
84 views

Using Nearest on a 2D List (seeing extra parentheses)

I am working a problem involving colliding particles. I define a list of particle diameters (effectively a bin distribution). I need to know if two particles collide, in what bin diameter should I ...
1
vote
0answers
95 views

Decapitating “explicit” and “implicit” heads

This is a follow up to this question. So far, I named "explicit" heads to those that appear explicitly in the expression. For example, f[x] has an explicit head. I ...
1
vote
0answers
57 views

Matching Root[…] objects with patterns, unexpected hidden argument

I needed to write patterns that could distinguish between arbitrary-function and polynomial forms of Root objects, for example, ...
1
vote
0answers
215 views

Defining an operator

Let s be a positive integer and let DifferenceDelta be this function with step = 1. Define <...
0
votes
0answers
5 views

Excluding an imaginary, partial, part of solution from Solve

When I type the command Solve[{x + 1/x == y - 1/y, x^2 + 1/x^2 == y^2 - 1/y^2}] // Simplify // N I get a 'close to zero' imaginary part, ...
0
votes
0answers
42 views

difference between max() and max^(0,1)

I have a really complicated function that I need to take partial derivative of. After executing the partial derivative, I got a function that contains both $\max(0,a-b)$ and $\max^{(0,1)}(0,a-b)$ for ...
0
votes
1answer
68 views

How to make split tables in Join?

I have a command Table0[mS_]:=Table[{mS*i,i^2},{i,1,20}] Table1=Join[Table0[1],Table0[2],Table0[3]] When calling Table1[[1]] I expect to get the element Table0[1]...
0
votes
0answers
25 views

RegionPlot fails

Consider a function f[x_,y_]:=NIntegrate[g[x,y,z],{z,1.1*x,3000}] where g[x,y,z] is some function. The function f[x,y] is smooth and works perfectly when Plot it....
0
votes
0answers
55 views

How to handle the instability of the integral evaluation in the following case?

I want to integrate a function \[Kappa][gh, ms, ts, th, ph] (for all definitions, see a code below) with the distribution ...
0
votes
0answers
29 views

Having difficulties using results returned by Solve

I'm new to Mathematica, and I am still having some issues figuring out the general syntax. I've got to use Mathematica, as my research requires a powerful symbolic math program. I'm having trouble ...
0
votes
0answers
111 views

Remove background image and redraw lines in black

I do not know if the title is correct. The image that I upload has liked me a lot because of the characteristic that no matter the angle it seems that it is looking at you, you could indicate me how ...