Questions tagged [expression-manipulation]

How to manipulate expressions structurally, not necessarily complying with the rules of algebra.

Filter by
Sorted by
Tagged with
3
votes
1answer
85 views

Output of `Subsuperscript` in TeXForm?

TeXForm can be used to convert Mathematica expressions directly to LaTeX. However, this function fails on an expression that has a sub- and a super-script: ...
0
votes
1answer
43 views

How to generate a list (or even a sequence or a string) containing {x[1]==0&&x[2]==0&&…&&x[10]==0?

I need to solve a bunch of systems of n equations in n unknowns where n varies. I can do ...
0
votes
1answer
113 views

Transform rational equations to polynomial equations

I have a list of rational equations and I would like to convert it to a list of polynomial equations. I know that none of the variables and none of the denominators could ever be 0. So far I have ...
12
votes
1answer
172 views

Conflict with hidden names

The following code hangs Mathematica 12.0.0: ...
3
votes
1answer
109 views

Strange behavior of `Apart`

Here is a piece of sad comedy based on some Apart behavior. Is there a way to make Apart do the expected step? Consider a very ...
1
vote
0answers
73 views

Is there a good reason why `Slot[]` is not an atomic expression?

Here's a good reason why I think it should be, Map[ If[AtomQ@#, #->"is an atom", #->"not an atom"]& , {"hello",Range@3, # &} , {-1} ] ...
7
votes
3answers
228 views

How to replace $x$ and $x^2$ with different value?

I have an expression now expr = x + x^2 what I want to do is to replace $x$ with $k\times p$ , and $x^2$ with $[k\times p + k\times(k - 1)\times p^2]$. The ...
2
votes
1answer
43 views

Narrowing the range of an interpolating function while keeping integral the same?

Consider an interpolating function derived from some data, e.g. ...
6
votes
1answer
99 views

Expandable summary view for a large expression

I need a convenient interface to interactively explore very large expressions. I am aware of Short and Shallow, and appreciate ...
2
votes
1answer
43 views

Replace sub-expressions matching a pattern unless located under specific heads

Suppose I have some rule, e.g. Re[x_] :> (x + Conjugate[x])/2. I want to apply it to all matching sub-expressions in some expression, excluding any sub-...
2
votes
1answer
60 views

How the terms are arranged in `CoefficientList` command?

I have an expression containing various orders (powers) of F[r]. Using CoefficientList, the output is a blue box which is ...
0
votes
2answers
77 views

Exclude the terms from determinant

i have a long determinant expression such as delta=8+2a+3b+4c+50a^2+2a^3+70b^2+80a*b+20(a^2)b+5(e^x)+a*b(e^x)+....+3e^(-x)+.. I want to exclude the expression ...
0
votes
0answers
61 views

Wrong derivative for a function that I try to define without explicitly giving number of variables

What I actually want is to define functions depending on the number of variables which will be specified during some computation. My (probably wrong) attempt is ...
14
votes
3answers
348 views

Evaluated vs. unevaluated Association

This question might have a remote connection to my older question, it is also about sameness of expressions and subtle differences observable only in certain forms. I encountered this strange ...
3
votes
2answers
123 views

Group symbols by a given partition of the occuring symbols

I have following expression $$-3 b_{\sigma _d}-3 b_{\sigma _v}-b-b_2+2 j-2 j_2-2 j_3+2 j_6+12$$ Mathematica input ...
0
votes
0answers
70 views

How to use replace for only one term in a long expression in Mathematica?

I am doing some Cauchy integration and in some intermediate steps I have something that looks like that: (..many_terms...+I*\epsilon(k1-p1))/k1 where ...
1
vote
1answer
49 views

Generating examples by applying conditions to symbolic expressions

For example, Given a list of symbolic expressions: ...
0
votes
0answers
38 views

Obtaining part of an expression from a position [duplicate]

I would like to recover a subexpression from its position in the expression. For instance: Position[{3, {3, 5, {6}}}, 6] returns the position of 6 in the ...
0
votes
0answers
61 views

How to show the sign of an algebraic expression?

I defined a long expression ...
14
votes
1answer
588 views

How can I obtain a complete list of the kinds of atomic expressions in the Wolfram Language using only the language itself?

I mean, Wolfram is a language--it's words are infinitely combinable. According to answers to my last question, the only way I can find out if an expression is atomic is actually use the expression. ...
1
vote
2answers
84 views

How can I ask the Wolfram Language to tell me if a hypothetical expression with a particular head would be atomic or not?

Integers in the Wolfram Language are atomic expressions, while uses of the Map function are not atomic. But if you didn't know this, how could you find out using only the Wolfram Language? The best I ...
1
vote
3answers
118 views

Why do atomic objects like 56 have a head if they're supposed to be, well, atomic?

This question follows from this one I made earlier. If you ask for FullForm[4] you will get back 4, and that's fine. ...
2
votes
1answer
74 views

Factorization of multivariable polynomial

I have a multivariable polynomial, for instance: $P=yx+2^4xy+3+5^2xz+3^4zx $ I would like to do the following: extract those terms that only have $z$ extract terms that only have $y$ express my ...
0
votes
1answer
40 views

Selectively changing precision while leaving integers and rationals unchanged

I didn't find an answer to this question on the site, but as I was writing up my question, I figured out how to do it, so I thought I should post it and answer my own question so that others can ...
7
votes
3answers
452 views

How to import $\LaTeX$ matrices into Mathematica?

I have a lot of $\LaTeX$ matrices, and I want to find their eigenvalues and eigenvectors. I tried to import them to Mathematica with: ...
2
votes
1answer
36 views

Expression manipulation with exponential

I have the following expression a + b + c + x + y + z + r*E^m + s/E^m + t*E^n + u/E^n I want to extract the coefficients of exponential terms as well as the ...
5
votes
3answers
263 views

Iterate over deepest values in a nested Association

Is it possible to iterate over the values of the deepest layer of keys in a nested association? For example: ...
0
votes
1answer
92 views

Need help in understanding what Extract does

Can anyone explain two examples from the Mathematica Documentation Center reference page on Extract? One is: ...
4
votes
3answers
109 views

Applying functions to leaves of nested list structure, when these leaves are more complex expression trees [duplicate]

Is there a way to apply a function h to the following nested list {{a, b}, {c, d}, {{d, e }, {f, g}}} where this should should become ...
1
vote
3answers
40 views

Grouping expressions by associative equivalence for a single operation

I would like to group expressions under associative equivalence, but only for a specific operation used in the expression (not for other operations). Say we have two binary operations A and B ...
2
votes
1answer
69 views

How to decompose an expression into basic forms (e.g. a[[1]] to Part[a, 1], a=1 to Set[a, 1], etc.)? [closed]

Is there something I can call in Mathematica to figure out the composition of a given expression? I want everything decomposed to the most basic f[a, b, c] format.....
2
votes
2answers
59 views

Groupings over non-atomic elements

I use groupings as below: Join[ Groupings[IntegerPartitions[3], {A -> {2, Orderless}, B -> {2, Orderless}}], {x}] Which generates: ...
1
vote
1answer
30 views

Groupings: orderless version?

Consider the following groupings code: Groupings[IntegerPartitions[3], {A -> 2, B -> 2}] This generates: ...
0
votes
3answers
126 views

How to simplify an expression by substitution?

Sometime Solve and DSolve give a finial form of the solution, which is fine in may applications. However, in some cases, one may ...
4
votes
4answers
141 views

Neat redistribution of association values

Given an original association: original = <| "a" -> {a1, a2}, "b" -> {b1, b2}, "c" -> {c1, c2} |> and a set of redistribution rules e.g. <...
5
votes
2answers
157 views

How to write down a product with omitted terms?

I have the following term which I would like to express correctly in Mathematica: $$ \prod_{j=1,j\neq i}^m(\rho_i-\rho_j) $$ Can you please help?
3
votes
2answers
115 views

Keeping specific terms in Mathematica output

Update: After solving an equation I came up with a complicated expression, is it possible to only keep some specific terms of an expression ? As an example, if the expression is: How can I keep only ...
1
vote
1answer
51 views

How do I force a fractional coefficient to exclude non-numeric symbols?

Short version of question: Suppose I have an expression: expression = a+3b; When I divide by 2, I get: expression/2 It is ...
27
votes
2answers
716 views

Custom atomic expressions - modern tutorial

Atomic but sophisticated expressions are all around for a long time: Graph SparseArray. More are coming with each new release, ...
1
vote
1answer
141 views

How do I extract the matrix from an density matrix equation?

I have a density matrix equation and I wish to put it in the form of a matrix. For example, if I have: $$\rho =Ax_{1}x_{1}+Bx_{1}x_{2}+Cx_{2}x_{1}+Dx_{2}x_{2}$$ Copy-and-paste version ...
1
vote
2answers
63 views

Finding the coefficients of a sum

Suppose I have the following expression: p[l_] := 1 + ((1 - q) p)/q Sum[(p (2 - p))^k/q^k, {k, 0, l}] or $p(\ell)=1+\dfrac{(1-q)p}{q}\sum_{k=0}^{k=\ell}\dfrac{...
1
vote
0answers
117 views

how to sort an expression with descending coefficients?

I have an expression for example psi = 0.24 FF1[0] FF2[1] FF3[-1] + 0.23 FF1[0] FF2[0] FF3[1] + 0.5 FF1[1] FF2[0] FF3[1] + 0.25 FF1[1] FF2[1] FF3[1] I wonder how ...
2
votes
3answers
93 views

Checking if two expressions are related

Is it possible in mathematica to check if two expressions may be able to be written in terms of the other? The expressions I had in mind were of the form $$\alpha = \frac{1-x}{1-y}\,\,\,\,,\,\,\ \beta ...
6
votes
2answers
179 views

Get the intermediate steps of FullSimplify

I have this expression: Log[i] > (i Log[i])/n + Log[n - i] - (i Log[n - i])/n And I attempt to simplify it and get this: ...
0
votes
2answers
57 views

Require an expression to be formatted as an exponential expression

How can I require Mathematica to format an expression like Exp[x] x^s as Exp[x + s Log[x]]?
1
vote
2answers
24 views

How to separate nested subexpressions to list?

I have an expression like this: 3*Subscript[v, 0]^3*Subscript[v, 1]^8*Subscript[v, 2]^7*Subscript[v, 3]^2 I would like to extract the exponents and put them into ...
0
votes
0answers
78 views

How to solve a Poisson's differential equation with a boundary condition at infinity?

Context: This question is relevant to the physical problem of calculating potential for a set of p-n-p junctions. We have to solve a Poisson's differential equation for a p-n-p junction with ...
2
votes
0answers
138 views

Substitution of expressions using Groebner basis

I know this topic came up numerous times (most of the results are detailed in the comments of this link Is there a way to to substitute for symbols, simplify, and back-substitute?). However, I have ...
0
votes
2answers
74 views

Separating variables in a set of equations

I have a very large set of equations eqs with variables denoted by capital letters like PVA[2], QA[2], etc. and small letters like ica[1,2], tr[2,3] etc. And I have ...
0
votes
1answer
78 views

How to get rid of the brackets appearing in non-commutative multiply?

I am getting output as (-T1**T2**T3)**T4**T5 How to get rid of the brackets that are appearing in the output? I want my output as ...

1 2
3
4 5
13