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

746 questions
Filter by
Sorted by
Tagged with
9 views

### How to get the symbol name of a list element?

Let's say we have a list g with variable d as its element: Clear[g, d] g = {1,2,3,d} Now <...
29 views

### Why does NIntegrate on interpolated acceleration data give wrong units for velocity? [closed]

I found that when I use NIntegrate on my interpolated acceleration data the result still has units of m/s^2 instead of ...
40 views

### Create a set of prime factor numbers given a set of tuples

Given a set $\Omega$ of tuples, for example, Tuples[{Range[0, 4], Range[0, 3], Range[0, 2]}] how can I create all numbers on the form $p_1^{t_1}p_2^{t_2}p_3^{t_3}$ ...
24 views

### Is there a better syntax to obtain the derivative of a function as a function/operator? (e.g. for simple plotting of derivtives of functions, etc.)

When trying to plot a derivative of a function, (I take Sin as a simple example), the naive approach ...
55 views

### Root finding: Is there no bisection method root finder?

I am trying to find a root to an equation f[k,...]==0 numerically, where k is the variable I am solving for. Using both NSove as ...
140 views

### Can anyone translate this code into simpler one?

I'm new in Mathematica, so can anyone translate the following code into a simpler form where uses more familiar syntax? my mean is #,...
82 views

### What does it mean when a function has two square brackets?

I have been solving some partial differential equations with mathematica, and the solution of one involves a function $c_1$ as follows, $f[x,y,z]=e^{x}c_1[y][y+xz].$ I am not sure exactly what it ...
821 views

### How to solve the Monty Hall problem?

Problem For purely recreational purposes I would like to solve the Monty Hall problem with Mathematica using the function Probability (dedicated to the calculation ...
48 views

### Create a list of coordinates given a list of x values and a function

I have a function and $x$-values as a list. How do I construct a list with coordinates $(x_i,y(x_i))$, $i=1, 2, …$ y[x_]:= 2x x = { -3, 0, 4, 5} which should be ...
67 views

### Center and radius of sphere

What is the Mathematica equivalent(s) of the Wolfram Alpha command to get the center and radius of a sphere given by an expression, e.g. (in Wolfram Alpha); ...
18 views

### Equation in ContourPlot3D requires Evaluate

Why does ContourPlot3D require Evaluate when Solve does not in the following example? ...
81 views

### Having trouble plotting $y=\ln\left(T^{3/2}\right)$ and $y=\dfrac{1}{k_B T}$ on the same graph [closed]

Originally, I simply wanted a way to plot $\ln(T^{3/2})$ versus $\dfrac{1}{k_B T}$ But all that appeared was this: ...
65 views

### What is … and :? [duplicate]

Reading Maeder's The Mathematica Programmer and in section 4.6 I am interested in the following line: ...
85 views

### correct use of the command FindInstance

I have tried to solve this system for numbers that go from 1 to 10 non-repeated integers, this occurs to me ...
74 views

### Problem with writing simplified commands [closed]

I would like to know how I can learn to write a complicated command with syntax like the one below. I might know each one separately, but I can not combine them or know the pattern which works for ...
40 views

### Define trace-like function (e.g. cyclically invariant) involving operators without built-in meaning

I am interested in defining a function, say $\mathrm{Tra}$, that imply operators without build-in meaning, say it involves products with the $\cdot$ (Esc . Esc), ...
50 views

I need an operation $\tilde{}$ that lifts another operation (for example, the sum, but this does not have to be limited to real numbers) in the sense that $\widetilde{ (x \oplus y)} = \tilde x + \... 1answer 23 views ### What is the general behavior of the “enter” character, and why does the specific behavior differ in these four situations? I am trying to understand the exact behavior of the "enter" character in Mathematica. (I am not even sure what to call it: perhaps it is really the carriage return or newline character, which is input ... 1answer 30 views ### How to reverse the axes in the following way? Could you please tell me whether (and how) it is possible to make the redesign of the x axis in the plot? I have not found the relevant information in the documentation. 2answers 80 views ### Limit solution domain in Solve How should you write the Solve command or another to give me solutions to this equation for example integers rationals Here are the equations: ... 4answers 99 views ### Interpreting an ODE solution from DSolve I'm doing a project where I need to solve an ODE. . I tried using DSolve to solve it, and it gave me an answer, but I'm unsure how to interpret it. The code I'm ... 1answer 48 views ### Correct syntax for tensor operators? So I have an operator$A_0$whose matrix representation is given by $$A_0 = \begin{pmatrix} 0 & -i \\ -i & 0\end{pmatrix},$$ and I also have two vector states$|0\rangle$and$|1\rangle$... 1answer 37 views ### Issue with Compile for Complex Input/Output I'm writing a Runge-Kutta algorithm for solving a system of coupled differential equations. My code works fine when defined as a module, but when I try to compile it, I get the following error: ... 2answers 72 views ### Isn't there a better way to display mathematical equations as labels, in Manipulate[ ] etc.? I often want to output a mathematical equation in a text environment, and I find it very cumbersome and often the result is also not satisfactory. This example out of the "Advanced Manipulate ... 1answer 64 views ### Define derivative as a new function I’m coding my first physics simulation in Mathematica, and have a problem. I want to do the following inside a single cell input. ... 2answers 303 views ### Why does 'Transpose[list]' work but 'Map[Transpose[#]&, list]' not when attempting to transpose a 2D-array list? [closed] I define this list: list={{100,100},{200,200}} Taking the transpose like this works as intended: Transpose[list] Taking ... 0answers 46 views ### How do I set a control in an “If” statement? I have the following lines of code: ... 2answers 56 views ### Problem with internal variable of a Module which returns the solution of an NDSolve command. y$25947 → InterpilatingFunction[…]

I will try to give a minimal example of my problem. Say I define the following function, spitting out an NDSolve result, using ...
22 views

### Manipulating a system of equalities into particular form

newbie here just trying to learn the Mathematica syntax. I have a list of equations, some of them definitions, others relationships, as follows: ...
44 views

### Plotting a complete response to an oscillation; already have particular solution, not sure how to solve for constants in homogeneous solution

I am writing a code that plots an oscillator's response to a periodic excitation. The response consists of the following: x(t) = xh + xp where xh is the homogeneous solution and xp is the particular ...
27 views

### How to add multiple paths?

What I am trying to do is generate random data based on a normal distribution and plot different paths of the process. But how can I add multiple paths instead of repeating the process over and over ...
47 views

### How to use RandomVariate on a random process? [closed]

I am trying to generate random numbers based on a white process WhiteNoiseProcess[]. Here is my code: ...
24 views

### syntax error when defining a list of matrices: “…cannot be followed by..”

I am literally just defining a list of matrices, but seem to run into the following error when adding the last matrix. (so to be clear, I get no error when I take out the last matrix entry). What's ...
165 views

### Is it possible to pipe(afterthought apply function) with options?

For example, I have the following ...
43 views

### Loop over variable sized arrays

I would like to build an Encoder/Decoder to export my Data from Mathematica to Julia. From Mathematica I get arrays of variable dimensions, these arrays contain variables that don't have a fixed value ...
23 views

### MakeExpression : Input Form error even with perfectly written expressions

I am frustrated by this MakeExpression error which sometimes shows up and sometimes doesn't for perfectly written expressions. How do I tackle this error? What is wrong with my code? ...
498 views

...
164 views

### Why does OperatorApplied by default reverse the arguments?

Perhaps this is just one of those Mathematica curiosities, but I'd like to know why by default OperatorApplied[f][x][y] === f[y,x] versus the more usual way one ...
78 views

### Is it possible to create the following simulation in mathematica?

Consider a set of discrete "states" $|1\rangle,|2\rangle,|3\rangle,\dots,|N_{\text{max}}\rangle$). Next, assume that there are 1000 "particles" occupying the state 1 at the initial moment of "time". ...
41 views

### Why do comments sometimes become Null instead of being removed completely?

Consider the following definition: Piecewise[{{(*comment*)-1, x > 0}, {0, True}}] This is interpreted as intended, with the comment being simply removed, ...
68 views

### Partial Differentiation in Mathematica, syntax error? [closed]

I am trying to differentiate some random function using Mathematica at particular nodes, I am though not being able to implement this without being retrieved the following error message: D: ...