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
1
vote
1answer
30 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), ...
1
vote
0answers
28 views

Define the behavior of operators without built-in meaning

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 + \...
0
votes
1answer
21 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 ...
0
votes
1answer
26 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.
4
votes
2answers
74 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: ...
3
votes
4answers
95 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 ...
0
votes
1answer
47 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$ ...
1
vote
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: ...
2
votes
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 ...
0
votes
1answer
50 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. ...
2
votes
2answers
299 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 ...
0
votes
0answers
46 views

How do I set a control in an “If” statement?

I have the following lines of code: ...
1
vote
2answers
52 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 ...
1
vote
0answers
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: ...
1
vote
2answers
43 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 ...
0
votes
1answer
26 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 ...
0
votes
1answer
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: ...
1
vote
1answer
23 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 ...
5
votes
2answers
159 views

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

For example, I have the following ...
1
vote
0answers
42 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 ...
0
votes
0answers
22 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? ...
9
votes
4answers
495 views
19
votes
1answer
156 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 ...
0
votes
0answers
76 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". ...
2
votes
0answers
40 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, ...
1
vote
1answer
64 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: ...
0
votes
0answers
22 views

Domain of definition for the following variables: is it possible to derive in Mathematica?

Consider 4 4-vectors $$ P_{0} = (E_{0},0,0,\sqrt{E_{0}^{2}-m_{0}^{2}}), \quad P_{i} = (E_{i},p_{i}s(\theta_{i})c(\phi_{i}),p_{i}s(\phi_{i})s(\theta_{i}),p_{i}c(\theta_{i})), $$ with $c \equiv \cos, s \...
1
vote
1answer
71 views

Solving an equation for a power of unknown variable

How do I solve an equation for a power of $t$, e.g. solving $$-t(x–8)/8 = –2(x+4)/t$$ for $t^2$ instead of $t$, i.e. to get the answer $$t^2=16(x+4)/(x–8)$$ from ...
0
votes
1answer
38 views

Extract solutions in an interval for a trigonometric equation

Consider the solution x1 = x /. Solve[{Cos[x] + Sin[x] == 0}, x] The output is a conditional expression or, with //Normal, a ...
0
votes
1answer
36 views

What does <<2>> mean in an output? Double Less than or greater than signs [closed]

An error in my output gives I am trying to understand what the issue is. I was wondering if this <<2>> has anything to do with it, because I don't know what that syntax means. Is <<2>> ...
3
votes
1answer
85 views

Map substitution of variable in expression

If I have an expression involving a variable x, like 2x+1, and I have a list of different possible ...
0
votes
0answers
25 views

Clear assigned y'[x] from memory [duplicate]

If I, by mistake, write Mathematica assigns $y'(x)=y(x)/5$ and I don't know how to clear that from memory (I had to restart Mathematica). ...
3
votes
0answers
106 views

Different execution behaviour between Wolframcloud and Wolfram Mathematica

When I execute in Wolfram Mathematica: s=0.3; m=5; x=6; it works. But when I execute the same on wolframcloud.com it returns ...
4
votes
1answer
108 views

Plot a graph with an uncertain number of tangents

The code below tries to illustrate a graph ($y=(2-x^3)/x$) that can have 1-3 tangents depending on the tangent point $a$. ...
0
votes
2answers
59 views

Unable to find the exact dimension of an expression

I have defined a variable called y, this contains a huge equation, but when I look for the dimension of y it shows 3. How come a single expression has dimensions of 3? It is supposed to be 1 right? <...
0
votes
0answers
30 views

TagSet::sym Error using Subscript [duplicate]

I am a beginner to Mathematica and I am trying to get it to solve some equations of a function (vector) $B$ of three components, but first I want it to know that the derivates with respect to one ...
2
votes
0answers
125 views

Model 1D Vlasov Equation

Vlasov Equation The non-relativistic form of the Vlasov equation is given by: $$ \partial_{t} f\left( \mathbf{x}, \mathbf{v}, t \right) + \mathbf{v} \cdot \nabla f\left( \mathbf{x}, \mathbf{v}, t \...
1
vote
0answers
38 views

Two point Gaussian quadrature [closed]

I am trying to calculate a two point Gaussian Quadrature on the interval [0,4] and the function f_n = (x^n) + 2 x - 3 for ...
0
votes
2answers
40 views

Assuming variables are real and positive [closed]

I thought the following code would work, ...
4
votes
3answers
133 views

How to implement an integration filter on arrays?

I have the discrete integration filters: $$y(n) = Ax(n) + By(n−p) , \text{$A$, $B$ real constants, $p$ positive integer}$$ EDIT: in the initial version of this question I focussed only on the case $...
3
votes
1answer
101 views

RegionCentroid and center of mass

If we have three masses $m_1,m_2,m_3$ (assuming that are all equal to $1$) located at $r_1,r_2,r_3$ respectively, then the center of mass is at $(1.00,0.83)$. In the Wolfram Documentation page says ...
1
vote
1answer
73 views

Basic Question: how should I read this instruction?

I'm very new at using Mathematica and it's not my Job. It's just something I like. ...
0
votes
1answer
33 views

Real value of a complex expression

Why is the following lines not correct? Clear[a, b] a \[Element] Reals; b \[Element] Reals; f[z_] := z^2 + 3 z - 2 g = f[a + b I] // Expand Re[g] The output ...
0
votes
1answer
75 views

How this equation is solved in reals

I have tried to solve this equation $2^{-2 ^{2^{-x}}}=2$ using FindInstance[2^(-2^(2^(-x))) == 2, x, Reals] The result is ...
0
votes
1answer
29 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
1answer
37 views

Expression with Boole

Let us have an expression for example, this: 2 (-1 + p) (3 - 4 p + 2 p^2) Boole[\[FormalX] == 1] - 9 (1 - 2 p + p^2) Boole[\[FormalX] == 2] ... For the whole ...
5
votes
2answers
132 views

Merge numbers to a new number and find digit on position \(n\)

I'm trying to construct a 'Mathematica solution' for the following 'puzzle' The natural numbers are placed in a row; 12345678910111213... What digit is the 10,000th digit? I don't know ...
2
votes
2answers
84 views

Romberg integration with NestList or FoldList?

I am using a NestList like this: NestList[((4 #2 - #1)/3) & @@@ Partition[#, 2, 1] &, T, Length[T] - 1] But the function that is applied on the Partition ...
6
votes
1answer
95 views

How to use a function as a value in an association? [closed]

I just started learning Mathematica. I was wondering if it is possible to use a function as an value in an association. Ideally, it would be something like this: ...
4
votes
2answers
191 views

Can C-like function call syntax be easily achieved for particular function names?

I'm trying to use Mathematica as a tool to prove that some C code is equivalent to another (up to roundoff errors). For this I need to somehow paste C expressions like ...

1
2 3 4 5
15