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
2answers
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 <...
0
votes
0answers
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 ...
1
vote
0answers
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}$ ...
0
votes
1answer
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 ...
0
votes
1answer
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 ...
1
vote
1answer
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 #,...
0
votes
0answers
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 ...
12
votes
2answers
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 ...
3
votes
1answer
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 ...
1
vote
1answer
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); ...
0
votes
0answers
18 views

Equation in ContourPlot3D requires Evaluate

Why does ContourPlot3D require Evaluate when Solve does not in the following example? ...
1
vote
1answer
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: ...
1
vote
0answers
65 views

What is … and :? [duplicate]

Reading Maeder's The Mathematica Programmer and in section 4.6 I am interested in the following line: ...
0
votes
1answer
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 ...
2
votes
0answers
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 ...
1
vote
1answer
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), ...
3
votes
2answers
50 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
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 ...
0
votes
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.
4
votes
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: ...
3
votes
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 ...
0
votes
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$ ...
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
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. ...
2
votes
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 ...
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
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 ...
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
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 ...
0
votes
1answer
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 ...
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
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 ...
5
votes
2answers
165 views

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

For example, I have the following ...
1
vote
0answers
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 ...
0
votes
0answers
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? ...
9
votes
4answers
498 views
19
votes
1answer
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 ...
0
votes
0answers
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". ...
2
votes
0answers
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, ...
2
votes
1answer
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: ...
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
72 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
41 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
107 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? <...

1
2 3 4 5
15