Questions tagged [syntax]

Questions on the correct (or improved) formulation of Mathematica code to achieve particular results. Use this tag (not "symbol") for questions about all those odd @@ /@ # & and _ characters, which are keyboard shortcuts for the Wolfram Language named functions Apply, Map, Slot, Function, and Blank.

Filter by
Sorted by
Tagged with
5
votes
2answers
245 views

What is wrong with my Which command syntax?

Here is an example of my issue: condition=m>0; f[m_] = Which[condition == True, 1, condition == False, 2] f[-10] returns ...
0
votes
1answer
39 views

Using the symbol of the system of equations [duplicate]

Part 1 I'd like to know how to use the symbol of system of equations (left curly braces). I tried the following code: Part 2 How can I add a third equation?
0
votes
1answer
85 views

Symbol of system of equations

I'm wondering if there is a way to use the symbol (the left curly bracket) of a system of equations. So far I found only the following "symbol": I need to remove the two conditions. EDIT2: ...
0
votes
1answer
39 views

Adding Assumptions in double integral written in "math input" mode

I've the following double integral and I'd like to write Assumptions->Re[c]>0, but if I try to do it, I get a syntax error. How can I add the above condition but without changing the ...
1
vote
1answer
59 views

Use symbol to replace function

I'm trying some transformations and they are getting complicated. It's common in physics to replace functions by symbols so you term get shorter. Lets say I have transformation ...
10
votes
2answers
189 views

How to compile matrix product?

Consider the following matrices: ...
1
vote
0answers
66 views

How to compile the following evaluation?

I have the following question. I want to generate three vectors p1Unrotated,p2Unrotated,p3Unrotated at some reference frame, then rotate them by some random angles $...
5
votes
1answer
91 views

On the quotation mark around Method option in NDSolve

I note that in the documents about NDSolve or its variants, the main Method option has no quotation mark while its sub-...
1
vote
0answers
17 views

Assumptions when maximizing a function

I'm trying to solve this (rather basic) maximization problem using Mathematica: $$ \left\{ \begin{aligned} \sqrt2 s &= 2d\\ r^2 &= x^2+d^2\\ h(x) &= r+x\\ A(x) &= s^2\\ V(x) &= \...
1
vote
0answers
54 views

A question about generating table [closed]

Consider a vector that is generated somehow, say vec:={RandomReal[{0,2}],RandomReal[{0,1}],RandomReal[{2,3}]}; Note that it is evaluated on-flight, I cannot ...
8
votes
1answer
268 views

How to compute RandomReal faster?

I have variables $E_{1},E_{3}$ that are bounded in the following way: $$ \tag 1 E_{1}>m_{1}, \quad E_{3}>m_{3}, E_{2}\equiv m-E_{1}-E_{3}>m_{2}, \\ -1 < \frac{E_{2}^{2}-m_{2}^{2}-(E_{1}^{2}...
1
vote
1answer
76 views

A very basic question about weighted data

I have a dataset in the form {{A1,B1,C1,...},{A2,B2,C2,...},...} and the weights in the form {w1,w2,w3,...} Having this ...
1
vote
0answers
64 views

How to generate random points with weight distribution and specific criteria? [duplicate]

Consider some function $f(E_{1},E_{2})$, say $$ \tag 1 f(E_{1},E_{2}) = \exp[-E_{1}^{3}+E_{2}^{2}] $$ I want to generate random $n$ points $E_{1}$, $E_{2}$ using this function as weights, with an ...
5
votes
1answer
129 views

What Does this Syntax Mean in Ouput from DSolve?

When I run the code DSolve[y*D[f[x, y, z], z] - z*D[f[x, y, z], y] == 0, f[x, y, z], {x, y, z}] I get the following output. I don't understand this syntax. I ...
1
vote
1answer
99 views

Expression cannot begin with "$\sum_{j=0}^{\floor*\frac{a}{b}} j$"

This is my first time using Wolfram Mathematica and writing in TeX. I'm on the free trial version of Mathematica, and I'm writing in a notebook, using the "Inline TeX Input" option on the &...
1
vote
1answer
73 views

Single-press TemplateBox deletion

One of the handy things about TemplateBox is that it can be used to define an alias for a more "natural symbol" (by having an empty list first argument ...
1
vote
0answers
46 views

What does the Q stand for in some built-in symbols? [closed]

What is the "Q" in built-in symbols such as FreeQ[expr, form], MemberQ[list, form]? (Query?) Thanks.
9
votes
1answer
251 views

How to visualize overtones in Mathematica?

I would like to visualize the difference in sounds extracted by different musical instruments, which is due to different overtones. In order to do this, I define the following samples: ...
0
votes
1answer
39 views

Trigonometric simplification .Correct syntax? [closed]

I cannot simplify this expression any further, which should result in 7. Could you please provide me with the correct syntax, I have tried several without success. $$Assumptions[A + B + C == 0 , ...
2
votes
1answer
92 views

Coloring all the variables with the same name with the same color

I would like to know if there is a possibility to automatically color the variables with the same name with the same color. For example, like in the picture below: Right now I need to do it manually ...
1
vote
1answer
71 views

How to express number in exponential decimal such as 1e2=100?

I am using MATLAB for a long time, and usually I express the number as exponential decimal such as x = 1e2; % x=100 However, if I write this form in mathematica, ...
0
votes
1answer
56 views

How to make the following plot

Consider the following dataset: tab1 = Table[{i, i^2, 0.8*i^(3/2), i^4}, {i, 1, 10, 1}] Is it possible to make a plot similar to the one shown below (where there ...
1
vote
1answer
55 views

generate quadratic functions to evaluate membership of points

How can I make a printable list with different quadratic functions and with points that belong or not to them so that a young person can check whether or not the point belongs to the parabola? my code ...
5
votes
1answer
119 views

Incorrect syntax highlighting? "Variables made special by use in arguments" not working

This example is obviously not useful on its own, but it will cover everything I actually need to know for a more complicated function I'm making. The example is to recreate the ...
0
votes
0answers
57 views

Importing n different pdf files and sending them to n different emails

How with MMA could I do to load from a folder called "jobs" "n" different pdf files and send them to "n" different "gmail" emails stored in a mails.txt file in ...
3
votes
0answers
59 views

Cheatsheet for the use of special characters syntax

My favorite mass-use of special characters is if I have an expression that is linear in all variables (call the variable list $L$) and it must be identical zero. Then I generate my equation system ...
5
votes
3answers
241 views

Simplify/Expand equation so that right side equals 0

Given an equation like $$x^2 + (x + 82)^2 = (x + 100)^2,$$ how do I type to make this into $$x^2-36x-3276=0\; ?\tag{1}$$ This almost does it ...
0
votes
2answers
54 views

How to create an operator which is a composition of a sequence of operators?

Suppose I have a sequence of operators $\partial_x$, $\partial_x^2$,..., $\partial_x^n$. I want to define an operator which is a composition of these $D_x^{(n)}=\partial_x\circ\partial_x^2\circ\cdot\...
5
votes
3answers
292 views

Evaluate equation for multiple values

This works fine; ((x - Sqrt[x])/(x + Sqrt[x]) - (x^2 - x)/36) /. x -> {1, 4, 8} but this does not ...
0
votes
1answer
45 views

Resizing the graph of a function with radicals , Why?

I am trying to graph this function $c(t)=\frac{2-\sqrt{t+3}}{1-t}$ using this code, to see its behavior at infinity. I need that in the vertical axis appears the value when $t->1$ (The graphs ...
3
votes
3answers
190 views

Filtering and Averaging

I have a large 3D matrix (Length = 300k) with duplicated values list={{1,1,a},{1,1,b},{1,2,c},{1,2,d},{1,3,e}...} If the first and second elements exactly match ...
9
votes
2answers
3k views

Is there a short way of writing (x==a || x==b || x==c)?

Something like x == (a|b|c) but that doesn't work.
1
vote
0answers
82 views

Input subscripts in Wolfram Cloud

I would like to input "rendered" subscripts in Wolfram Cloud, without having to verbosely type Subscript[a, b]. The local notebook shortcut is ...
0
votes
2answers
68 views

How to generate multiplication tables up to nxn?

I'm doing a simple multiplication table and I have this that I'm having a hard time with. I imagine that there must be a shorter way to do it, what I can't get is that it paints black the first column ...
0
votes
0answers
61 views

Is there a command to clean the entire front end? How?

I usually work with small pieces of code that result in numbers or text, and I clean up a little at a time to start again. I have searched here in the forum and in the mathematica help for something ...
0
votes
1answer
35 views

Simplifying cross product expressions II

This is related to Simplifying cross product expressions Consider the following: ...
0
votes
1answer
31 views

exclude terms from expansion

Suppose I define F1[R + a] = F1[R] + a D[F1[R],R] F2[R + 2 a] = F2[R] + 2 a D[F2[R],R] and I want to expand the square of their sum keeping only first order terms ...
-2
votes
1answer
83 views

Create table with squares and cubes and colors, how to produce the desired effect?

This should be very simple but I do not get as I want, I have tried, with print, grid, matrix but it doesn't work. Is for my niece, is to create a table of squares and cubes with big bold letters size ...
0
votes
0answers
34 views

can not replace when use ctrl+f

I have a very long output, therefore, I want to find and replace some repeated expressions with abbreviations using crtl +f in Mathematica. when I enter expressions, the mathematical can find it and ...
1
vote
1answer
56 views

Assiging Plot Range to Variables Works For X but Not Theta

Observe the following Mathematica code: ...
1
vote
1answer
64 views

How to define distributivity of CenterDot on bras and kets

I am working on a code for a coupled quantum harmonic oscillator and found myself in a hiccup when trying to evaluate the inner product of linear combinations of bras and kets. I have initially ...
0
votes
2answers
79 views

Use the good Syntax for my code [closed]

I have an error message with my below code but i don't know how to solve it. The problem come from this line k[d_, p_] = g1-[Ht] - p, and mathematica cannot execute ...
2
votes
1answer
50 views

Name of vertical pipe as in a|b

What is | called? Or is something different. In particular, I want to imitate ...
3
votes
2answers
97 views

Syntax error in NMaximize despite following official documentation

This is the code I'm trying to run: ...
0
votes
1answer
40 views

Syntax problem with `LocatorPane`

I am trying to create an image function: ...
2
votes
1answer
71 views

Getting a blank plot but don't see any problem [closed]

I have a problem. I'm trying to plot a function, but I keep getting a blank plot. This is function in InputForm: ...
0
votes
0answers
31 views

Assume some expression is false

I need to Reduce a complicated function and I want to exclude some conditions A and B. How do I assume that the expression A is ...
1
vote
1answer
57 views

Syntax for series with parameter [closed]

I am totally new to this - I cannot find how I can find a series limit that has also parameters, ie like $ a_n = \sqrt{(kn+2)} + \sqrt{(n)} , ~~k \in (0,+\infty )$ edit : cross-posted here https:/...
1
vote
0answers
38 views

What does the option 'Complexexpand' do in the Collect command? [closed]

I'm trying to re-write a long chain of commands I've received in pdf from Mathematica language to Maxima. I have this command: Collect[%, ε, ComplexExpand] I know ...
0
votes
2answers
51 views

Redefining the output of a function

ftn1 = Sin[s]^2 + 3 t^2 + u^5 3 t^2 + u^5 + sin[s]^2 ftn2[s_, t_, u_] := ftn1 ftn2[2, 1, 2] 3 t^2 + u^5 + Sin[s]^2 Hi ...

1
2 3 4 5
18