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.

Filter by
Sorted by
Tagged with
5
votes
1answer
319 views

DeleteCases vs. DeleteDuplicates for removing points within a critical Euclidean distance

I'm attempting to remove all points in an array which are within a Euclidean distance "ThresDist" of one-another. Using the command: ...
5
votes
1answer
94 views

String option names for Cells

They seem to be correctly interpreted. I'm asking because of some minor reasons and a major one: NotebookWrite a Cell with WholeCellGroupOpener option I don't know any official confirmation so let ...
5
votes
0answers
199 views

Is there an internal logic behind short form symbols, such as @ (Prefix), @@ (Apply), /@ (Map), /. (ReplaceAll) [closed]

To me, function names (such as Apply and Map) seem more intuitive than their symbols (e.g. @@...
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
2answers
321 views

Finding the position of a specific value in a list

Is it possible to easily find the position of a specific value in a list? For example, if the list is {{x1,y1},{x2,y2},...,{xn,yn}} I would like to know the ...
4
votes
3answers
2k views

Orthonormalization of non-hermitian matrix eigenvectors

When using Orthogonalize[] one can specify which definition of "inner product" is to be used. For example, ...
4
votes
2answers
1k 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 ...
4
votes
3answers
318 views

Is it possible to use infix notation ~ for functions with one argument or more than 2 arguments?

According to a Mathematica textbook, we can write N[x,n] by using infix notation as x ~ N ~ n. How about other functions with ...
4
votes
3answers
471 views

How to set multiple parameters to zero?

Say I have the matrix A = {{a,b,c,d,e}, {f,g,h,j,k}} and I want to set some of these to zero. I have been doing this via ...
4
votes
4answers
455 views

How can I make a summary of all the commands of Mathematica?

I would like to have a simple way to get summary information about all the many commands built into Mathematica. How could I do this? Is there a site I may refer to?
4
votes
4answers
1k views

Using the result of Solve in subsequent calculations

I'd like to know how to use the results of Solve in later calculations. Here's what I'm doing now: This is my expression ...
4
votes
3answers
271 views

Through: how to use it with subtraction of functions?

As the documentation says the command Through works as it follows: f[x_]=x; g[x_]=x^2; Through[(f+g)[x]] --> x + x^2 Like ...
4
votes
3answers
491 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 ...
4
votes
2answers
151 views

RSolve not reducing for a certain recurrence relation

I'm trying to use RSolve as follows to solve a recurrence relation: ...
4
votes
1answer
588 views

How exactly does Postfix notation work?

I guess I've been using the Postfix notation // wrongly for some time now. I assumed it was a quick way to apply a function to ...
4
votes
3answers
215 views

Limit of an Expression Created with Nest

I have implemented Newton's Method, and I am trying to find the exact value of the zero of a polynomial using Limit. The dream is that the following code works: <...
4
votes
2answers
480 views

How to define the irrational domain or any other arbitrary domain?

I have found no way to define the domain of Irrational numbers. I can easily define a test to see if a number is irrational by defining: ...
4
votes
1answer
721 views

Why assign variables to empty curly brackets?

I am trying to read code and I see empty curly brackets. For example: abc = {} or fort[x_] := Module[{}, more stuff here ] ...
4
votes
3answers
2k views

Integrating with multiple indicator functions

I am trying to calculate an integral involving multiple indicator functions, such as: $$ h(u,v,w) = -\int_0^1 J^{\prime\prime}(s) (I_{(0,s]}(u) - s)(I_{(0,s]}(v) - s)(I_{(0,s]}(w) - s)\, dF^{-1}(s)$$...
4
votes
2answers
180 views

Letter g rendered with different descender styles

I've just noticed that Mathematica renders g in two distinct ways: either with a closed descender or a open descender. Seems it happens only for local variables. g ...
4
votes
2answers
553 views

Mathematica can't differentiate when variable name has subscript component

I am not pasting my input code here since the website modifies my code. Instead I am attaching a screenshot of my notebook. Issue: I enter two separate commands (asking Mathematica to differentiate ...
4
votes
1answer
424 views

How to see abstract syntax tree of Wolfram Language expression

I mean, suppose I have this expression: 2 + 2 I want to get something like this: Plus[2, 2] as an output. I've tried FullForm, but this just evaluates 2+2 and returns 4. Is this even possible?
4
votes
2answers
4k views

How does one specify Neumann conditions for NDSolve?

I have a series of functions defined in my notebook, and then want to use this to solve a diffusion-reaction type equation. At the moment, something like this works: ...
4
votes
1answer
173 views

Setting a binary operator Flat

I defined a binary operator in as the first statement in a new Mathematica notebook. {x1_, y1_} ⊕ {x2_, y2_} := Module[{}, Print["do anything"];] where the code ...
4
votes
3answers
92 views

EntityValue timeline

I try to use EntityValue to get the returns of a stock from January 1st 2019 to today. When I use ...
4
votes
2answers
213 views

Mathematica syntax with combined Prefix and Times operator: @* [duplicate]

In a post on the Mathematica Community, Anton Antonov uses a syntax that I have never seen. It is the prefix function @ combined with the Times operator *. The combination appears to bind the ...
4
votes
1answer
77 views

Merging unevaluated key/values

RuleDelayed is a supported key/value wrapper in Associations. What are general guidelines/idiomatic methods for working with ...
4
votes
2answers
165 views

How to calculate this probability?

Here I want to find the probability $p$ which is given by $$p=\int_0^{r_d}\mathcal{L}_I(\beta r^{\alpha}|r)f_R(r)dr$$ with $r_d=1$ and $0 \le r\le r_d$. I want to calulate the probability for ...
4
votes
1answer
426 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 ...
4
votes
2answers
364 views

Why this syntax for renaming columns in datasets?

Form the documentation of Dataset: ...
4
votes
1answer
60 views

A natural syntax for a Query that holds

Often I have an unevaluated expression in a RuleDelayed Key-Value pair and subsequently want ...
4
votes
2answers
86 views

Why can't I pass in a product of matrices in my modified matrixform? [duplicate]

In attempt to build a function that would work like MatrixForm but would wrap a matrix with brackets, I tried the following function: ...
4
votes
1answer
197 views

Highlight the same symbol throughout notebook

Once I saw people using Matlab use a keystroke shortcut that made all the same symbols as a selected symbol become blue. I am wondering is there is a function in Mathematica that is similar. If so, ...
4
votes
1answer
334 views

Upon opening my notebook, I must evaluate cell for code to work properly

I am new to Mathematica. Once I evaluate the cell containing the code, my Manipulate works as desired; however, if I open the file and do not evaluate the cell, the Manipulate goes haywire. Can ...
4
votes
1answer
373 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
686 views

Meaning of (a : _ : 1)

This is an example from Leonid Shifrin's tutorial: ...
4
votes
1answer
175 views

How to download Entity data for an interval of dates

I am interested in downloading "TropicalStorm" data for hurricanes with the highest "WindSpeed" occurring in the years 1990 ...
4
votes
1answer
84 views

How to define an expression which is differently evaluated in calculations and printed

Let's say, we have a list: values = {1.2, 0.04, 0.9}; Is it possible to replace 0.04 by some expression, which displays as <...
4
votes
1answer
246 views

Products of Differential Operators

I have a differential equation defined as the product of operators which I want to expand out into a polynomial in powers of $z\frac{d}{dz}$ $\qquad \prod_{n=1}^p(z\frac{d}{dz}+a_n)$ However when I ...
4
votes
2answers
520 views

Limit won't compute

Does anyone know why the limit: ...
4
votes
1answer
85 views

Constructing an Array from typed expression

I want to produce an array from expressions given by test[one][1] = 3; . . test[one][5] = 7; etc. Normally would use ...
4
votes
1answer
3k views

What do the hashtags represent in the result of Solve, and how should I use them? [duplicate]

There is a function that I'm trying to get the inverse of. My function is a simple polynomial: Tn[T_] := 4/9 T^3/Tc^2 + 5/9 T Now I tried to find ...
4
votes
1answer
80 views

Why am I getting different answers for expressions containing x^(1/2) and x^(0.5)?

I'm doing a constrained optimization function, where I maximize a function with two arguments subject to a simple constraint: ...
4
votes
1answer
127 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. ...
4
votes
1answer
76 views

URLSubmit handling of query parameters

Bug introduced in 11.2 or earlier and persisting through 11.3 [CASE:4007421] confirmed myApi = CloudDeploy@APIFunction[{"i" -> "Real"}, #i &]; Why does ...
4
votes
2answers
387 views

Replacing a function in defined expressions

I'm having a little trouble with substituting functions into an expression. A minimal example is as follows: ...
4
votes
1answer
153 views

Why is ^^ff not the same as ^^ToExpression[“ff”]?

I want to convert a hexadecimal string to a decimal (base 10) number: 16^^ff 16^^ToExpression["ff"] The 1st line returns the correct answer of 255, while the 2nd ...
4
votes
1answer
141 views

How to make InverseFunction work on function defined with restriction on arguments

This example works to define InverseFunction on the first argument of a function ...
4
votes
1answer
60 views

Aliases for keys?

The syntactic sugar for alternatives in replacement rules is clean: {a|b|c-> 1, d->2} Are there any analogous shorthands for keys in associations. I want ...
4
votes
1answer
154 views

Local evaluation works, CloudDeploy did not work

I a playing around with my programming cloud account. What I have found, interactive functions often are not working because there are several details that are not implemented into the cloud. So I ...