# 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.

679 questions
Filter by
Sorted by
Tagged with
2k views

### How do I begin to plot an electric field for two point charges?

I'm using Mathematica for the first time and I believe I am having trouble with the syntax. I'm trying to plot a two point electric field and the first step in getting an electric field plot would be ...
168 views

I am interested in downloading "TropicalStorm" data for hurricanes with the highest "WindSpeed" occurring in the years 1990 ...
70 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 ...
2k views

### How to efficiently input matrices in Mathematica (compared to what MATLAB offers)

Every time I want to manually input a matrix in Mathematica, it takes me a while since every new row has to be in a separate pair of curly braces. For instance: ...
182 views

### Writing a conditional expression [closed]

I want to test a specific condition on z1 and z2 such that if z1 is greater than zero and <...
658 views

### How to extract the first and last element

It is a elemental question maybe,but I am confusing still.If I have a 1-dimension list list a = Range[5] (* {1, 2, 3, 4, 5} *) ...
96 views

### How to make a address to string

I get a Window address,Of course it should be a string in generally,but I got a non-string by some method,such as paste your clipboard into your notebook directly or other ways.I want to do some ...
179 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 ...
136 views

### What is a proper way to express derivatives with respect to a symbol? [duplicate]

Mathematica's default way of representing derivatives is to express them with respect to a function's input slot. But what if I want to use the chain rule? To replace df(x)/dx with df(0.5 y)/dy 0.5, ...
57 views

### Why is my array not displayed in TableForm? [duplicate]

Why is the array produced by the following not displayed in TableForm? ...
74 views

### Why is Carbon and other elements (not available) in StoppingPowerData?

I am trying to look up StoppingPowerData for a number of elements and while this snippet works for several I have tried (Aluminum, Lead, Iron for example), I get a result of (not available), but no ...
29 views

### How to search effectively for information on MMA Syntax such as “_?” [duplicate]

In another question here, I saw this poincareMetric[u_?VectorQ, v_?VectorQ] := ... Whilst I am familiar with the syntax label_Type, e.g. x_Real, I had not seen ...
475 views

### How could I define function with function such as Coefficient? [duplicate]

For example, I have eq1=ax+by+cz; and then I want to define new function, $eq2$, as eq2[x_]:=Coefficient[eq1,a]; eq2 ...
214 views

### How to return the unevaluated variable names from a list of variables which have been declared

I feel like this should have a simple answer but I haven't found anything that works. The toy example of what I want is as follows: ...
142 views

### Using Case to pull Keys and Values out of a nested Association

The set up: First a helper function: Clear[values] values[m_, l_, v_] := <|"Math" -> m, "Log" -> l, "Value" -> v|> I have a nested Association of ...
117 views

### How to put the result(and its specified variable) to clipboard

I have a such custom function to do some complicated thing: customFun[str_] := Defer[StringJoin["abc",ToString[#]]&@*StringLength][StringDrop[str,{1,-1,2}]] ...
109 views

### Roots of an equation output [duplicate]

I'm trying get the critical points of the function $f(x)=(( 1 - 3*(x + 1)^3)/(x^4 + 1))*(x - 2)$ so I took the derivative which is $(16 + 18 x - 9 x^2 - 28 x^3 - 48 x^4 - 18 x^5 + 3 x^6)/(1 + x^4)^2$ ...
146 views

### Unexpected behavior of MapAt

For the description, I have a simplified problem like the following: MapAt[f[1, #1], {a, b, c, d}, #2] & @@@ {{1, 2}, {3, 4}} will give ...
121 views

### Can't get the correct answer with this Adaptive Simpson's Rule algorithm

I think the mathematical portion of my algorithm is correct, but I don't really know the mathematica syntax. How do I get the actual function to be evaluated? Code: ...
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: ...
60 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? ...
233 views

### FillingStyle->{None,Automatic} gives unexpected results?

Plot[1 - x^2, {x, -1.5, 1.5}, Filling -> Axis, FillingStyle -> {None, Automatic}] produces an outcomes I find unexpected: In contrast, ...
45 views

### Learning Shortcut Syntax - Newbie Question [duplicate]

I'm learning Mathematica in order to work with Linear Algebra. I found a good post here about matrix manipulation, but realized that the author used conventions that I couldn't find documented in the ...
107 views

### Use Accumulate while creating Table

Can I somehow create a list and its cumulative sum at the same time, e.g. with Table: Now I do it in two steps ...
462 views

### List positions without brackets [duplicate]

Suppose I have a list l which contains the indices of some array a. For instance, l = {{1,1},{1,2}} a = {{a11,a12},{a21,a22}} I want to access the elements of a ...
513 views

### Using Newton's Method to solve system of equations

I am getting an error that just gets stuck formatting notepad, i don't think there's anything in my code that is wrong, but I'm never sure. ...
181 views

### Creating 3D image from importing 2D images [closed]

I'm trying to recreate a 3D image from it's 2D slices. I have saved the 2D images as "image1, image2, etc". I've imported them this way: ...
76 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 ...
91 views

### Solve / Reduce runs overnight - should I keep waiting?

I'm pretty new to Mathematica and I'm trying to solve a system of two equations, but both Solve[] and Reduce[] have been running ...
194 views

### System of nonlinear complex-valued equations using Solve

I'm trying to figure out the proper syntax to use in Mathematica to solve the following system of $6$ nonlinear complex-valued equations in $6$ unknowns $a,b,c,d,e,f$, where $a,d,f \in \mathbb{R}$ and ...
536 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 ...