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
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
69 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
34 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
35 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
82 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
23 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). ...
4
votes
1answer
100 views

Right syntax to launch multiple kernels on SLURM cluster

I have access to a SLURM based cluster where I allocate 2 nodes, each with 12 processors. I am looking for a way to launch all 24 kernels to utilize the resources to the maximum for parallel ...
3
votes
0answers
87 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
107 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
56 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
101 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
37 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
39 views

Assuming variables are real and positive [closed]

I thought the following code would work, ...
4
votes
3answers
128 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
90 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
32 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
73 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
34 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
125 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
83 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
89 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
190 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 ...
0
votes
0answers
43 views

difference between max() and max^(0,1)

I have a really complicated function that I need to take partial derivative of. After executing the partial derivative, I got a function that contains both $\max(0,a-b)$ and $\max^{(0,1)}(0,a-b)$ for ...
2
votes
1answer
47 views

Code not working when I'm breaking it up into different lines

The following code works perfectly For[i=1,i<4,i++,Print[i]] However, when I break this into different lines, it stops working. Moreover, the braces appear to ...
0
votes
0answers
31 views

what is the difference between /. and /; in mathematica? [duplicate]

What is the difference between /. and /; in Wolfram Mathematica How would you apply them both and what situations are each of them appropriate to use?
1
vote
1answer
44 views

ContourPlot a list of equations generated by the Table command

The first command below produces proper contour lines while the second command produces an empty plot. I would think that the two commands should produce the same output. What's going on? ...
1
vote
4answers
88 views

Adding plot options after @ in ListLinePlot [closed]

How can plot options like PlotLabel and PlotRange be added after @ in ListLinePlot? For example: ...
7
votes
1answer
709 views

Correct way of simplifying the result of an integral

Many times Mathematica gives enormous results to simple problems. One uses the program more for trouble than for not knowing how to solve the problem. As an ejemplo I present this integral that ...
10
votes
7answers
1k views

How to take the beginning and end parts of a list with simpler syntax?

So basically you have a table of some values, let's call it a: a=Table[n,{n,10}]; (*{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}*) And you ...
6
votes
3answers
483 views

Is $2x$ documented?

According to the official documentation of Times[], multiplication of $x$ and $y$ is represented as one of x*y x×y ...
5
votes
2answers
480 views

Game schedule where each player meets only once

I am trying to generate a game schedule where $k$ players at the time, out of $n$ participants, meet in each game, but any player meets another player only once. In each game, with $k$ simultaneous ...
0
votes
0answers
36 views

Definition of a matrix [duplicate]

...
5
votes
5answers
324 views

Integral of the integral using NIntegrate

Consider the integral NIntegrate[Exp[-NIntegrate[x, {x, 0, y}]], {y, 0, 2.8}] It displays an error ...
2
votes
1answer
84 views

Syntax highlighting indicates I'm unable to comment properly in Mathematica using (**)

I wanted to "comment" some code so the input inside (* *) is ignored. I tried this but the last term z[3] looks like it is not ...
4
votes
3answers
321 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 ...
5
votes
1answer
79 views

How to create a 2D table with varying step?

I would like to produce a table with 2 coordinates, where a step for one coordinate depends on the value of another one. I tried to do this in the following way: ...
6
votes
1answer
423 views

Best way to write an equation with subscripts and superscripts

This post is not about a specific Mathematica problem but about to develop the best way to enter mathematical equations with subscripts and superscripts. I have a ...
6
votes
1answer
80 views

Variable dimensional integrals

I need to Integrate a function, but let the number of dimensions vary. Integrate[Product[Exp[-( t[[i]] )^2], {i,1,4}], options] ...
1
vote
1answer
32 views

Behavior of PlotLegends

I want to have a plot of $x^{\alpha}$, where $\alpha$ is an input, and a plot legend which displays something like $\alpha = \# \text{ rad}$ on the following plot, where # is determined by the input. ...
0
votes
1answer
48 views

How to create the progress indicator for the following process?

Consider the code Table1[m_]:=Table[{m,NIntegrate[Exp[-I*m*x],{x,0,1000}]},{i,0,8000,1}] Table2=Join[Table1[1],Table1[5],Table1[0.2],Table1[0.08]] How to create ...
0
votes
1answer
92 views

How to make split tables in Join?

I have a command Table0[mS_]:=Table[{mS*i,i^2},{i,1,20}] Table1=Join[Table0[1],Table0[2],Table0[3]] When calling Table1[[1]] I expect to get the element Table0[1]...
1
vote
0answers
128 views

Light beams reflecting from parabola

How can we show the paths of three light beams in Mathematica which bounce back after hitting the parabola, in a single plot? Suppose we have the following code ...
2
votes
1answer
119 views

Mathematica just takes infinite time to solve this

Can You help? I don't even care about the exact solution. I will be satisfied by the series expansion of the result around a=0. I tried to solve by series expansion and the same result .. infinite ...
0
votes
0answers
28 views

RegionPlot fails

Consider a function f[x_,y_]:=NIntegrate[g[x,y,z],{z,1.1*x,3000}] where g[x,y,z] is some function. The function f[x,y] is smooth and works perfectly when Plot it....
0
votes
0answers
62 views

How to handle the instability of the integral evaluation in the following case?

I want to integrate a function \[Kappa][gh, ms, ts, th, ph] (for all definitions, see a code below) with the distribution ...
0
votes
3answers
71 views

Removing the square-brackets and their contexts from an expression

Suppose I start with an expression like y[t] + x[t]: is there a function that lets me remove the [t] elements, so I obtain the ...
0
votes
0answers
17 views

Dot product returns symbolically when undesired [duplicate]

StateProb[state_, projector_] := Dot[state, projector, state]; StateProb[state1, Projector[{-(I/Sqrt[2]), 0, 0, 1/Sqrt[2]}]] State is {1/Sqrt[2], 1/Sqrt[2], 1/...

1 2 3 4 5 15