Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [expression-manipulation]

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

0
votes
3answers
80 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
116 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
115 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?
0
votes
0answers
42 views

Collecting the derivatives of a sum

I have an expression where thereare many terms that involve the sum of the derivatives of two functions like $\qquad G^{(n)}[\lambda]+q^{(n,0)}[0,\lambda]$ I wanted to use ...
3
votes
2answers
80 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
40 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 ...
19
votes
2answers
411 views

Custom atomic expressions - modern tutorial

Atomic but sophisticated expressions are all around for a long time: Graph SparseArray. More are coming witch each new release,...
1
vote
1answer
62 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
51 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
47 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
78 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
80 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
21 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
50 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
118 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
67 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
54 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
vote
1answer
44 views

Rearranging similar terms in an equation

In a piece of code I am writing, I run into an equation of the form ...
6
votes
3answers
196 views

Taking the numerator and the denominator

Is there any way to get the Numerator and the Denominator of an expression split in the same way that Mathematica graphically represents it. Say I have an expression: ...
0
votes
2answers
84 views

Extracting parts of an expression

I have lists with expressions like this one: {-DTMomentum2[{0, 0, 1}], DTMomentum2[{0, 0, 0}]}. DTMomentum2 is just an undefined ...
7
votes
3answers
225 views

Obtaining a matrix of complex values from associations giving the real and imaginary parts of each element?

I have a list of associations keyed by real and imaginary numbers, like so: ...
0
votes
0answers
29 views

Evaluating Fourier coefficients when Exponential terms are present

I am trying an analytical solution for a 3D Laplace equaition, and just wanted to know if I could use the symbolic calculation capabilities of Mathematica to calculate the Fourier coefficients ...
3
votes
2answers
84 views

Convert a list of lists into a list of rules

I have some trouble converting an imported list looking like this: {{a, b}, {c, d}, {e, f}} into a list of rules looking like this: ...
4
votes
1answer
87 views

Replacement expressions

I have the following expressions: R[1, 1] R[2, 1] R[3, 1] R[4, 1] sum[FF[3, ak[1] - ak[2], 1], EE[2, ak[2] - ak[3], 0], EE[2, ak[3] - ak[4], 0]] By what ...
0
votes
1answer
73 views

How to pass an expression as list elements for a Mathematica command

I'm trying to build a generic function that will calculate sums on different iterators. To simplify let consider: ...
1
vote
1answer
124 views

How can I use the Stirling's approximation to approximate a factorial?

I'd like to exploit Stirling's approximation during the symbolic manipulation of an expression. Essentially, I want replace Factorial[n] with ...
0
votes
0answers
18 views

Manipulating expressions containing complex exponentials and double integrals

Given that I have Integrate[Integrate[Exp[I w (x-u+v)]f[u, v] , u], v] $\int\left( \int e^{iw(x-u+v)} f[u, v] du\right) dv$ First, I want to first extract ...
4
votes
3answers
209 views

How is Sequence[Range[5], 3, 2] // Partition@# & parsed?

For learning purposes, I want to rewrite the following Partition@Sequence[Range[5],3,2] {{1,2,3},{3,4,5}} into another one ...
1
vote
1answer
97 views

Convert String in Expression to Integer

I have reviewed many string replacement Q&A but I have been unable to apply them to this case (MWE): ...
1
vote
2answers
43 views

Collect term in a distributive way

Consider P = x (a2 b2 v^a2-1+a3 b3 v^a3-1+d1+d2-2 y)-(y-d1)(y-d2)-x I would like to collect terms in (x,y,z) in a distributive way, that is to get an expression ...
0
votes
0answers
11 views

Transform String to Expression [duplicate]

I have a variable postVector and another called CHKpostVector. Both are global variables. Only the variable ...
1
vote
0answers
48 views

Do replacement only on certain specific forms

If I want to replace, say, a with a1 + a2 in an expression, I can write ...
0
votes
1answer
31 views

Extract terms containing a specific symbol from an expression

I would like to be able to extract terms that contain either a symbol or a small expression from a larger one. Example (with a somewhat complicated function to give the idea of what I am after): <...
3
votes
0answers
82 views

Select certain term containing some patterns and confusing pattern Alternatives in FreeQ

I am considering a function termsContain[func_,list_] which select in an expression func the terms containing the ones in the ...
1
vote
2answers
48 views

Question about replace command

I want to replace the common part in the equation by different value. Here is my equation ...
18
votes
4answers
2k views

Cleanest way to take a[b[c]] to a[b][c]

As indicated in the title I'm looking for the fastest way to transform a[b[c]] into a[b][c], and the natural generalization to ...
0
votes
1answer
36 views

Expression replacement with variable exponents

I have an expression that consists of a large sum of variables of powers like: X[1]^(2p) X[2]^2 + X[1]^2 X[2]^(2p) + X1[1]^(1+p) X[2]^(1+p) ... Now I would like ...
5
votes
2answers
233 views

How to find all variables of an expression?

Is there a function that can extract a list of variables in an expression? For example, assume we have an expression x^2+y^3+z This expression has variables x, y ...
4
votes
1answer
96 views

How to bring out all factors recursively except one particular term?

I want to write a function keepOnly[expr_, keep_] Such that keepOnly[f[f2*g[g2*h[h2*keep, h1], g1], f1], keep] becomes ...
0
votes
1answer
29 views

How to save numbers that stand in front of x, y, z in expression in to variables, A,B,C

I have a different plane functions in form: Ax+By+Cz =0 I need a factors A, B, C which stand in front of variables x, y and z. Is there any function in Mathematica to do something like this?
1
vote
1answer
46 views

Extracting parts of symbolic expressions

I've searched around and found things that could help me only in cases that are simpler than the one I had in mind. I would like to extract polynomials from expressions that schematically look like $$...
0
votes
0answers
34 views

Manipulating Equations: Substracting two equations

I was wondering why I fail to substract two equations using thread, while it works properly, as described here for additions. Example: Let a system of equations be given: ...
4
votes
2answers
332 views

Drop 1st element of {#a, #b, #c} &

I pass the following to a function: {#a, #b, #c} & These are keys that are used in a list of associations. There are instances where I want to pass only the ...
1
vote
1answer
72 views

How to stop evaluation of Zeta with even arguments

It could be a duplicate question. However I could not find much after a huge searching. I have a huge expression in mathematica involving many Zetas. I want not to evaluate the even Zetas which ...
1
vote
0answers
49 views

Selecting the 1st and then subsequent elements in an expression [closed]

I'm using a mixture of Span and Part to try and extract the arguments of a function that I need. I'm using a function such as $...
1
vote
1answer
47 views

Factor common terms out of a sum, without changing it otherwise?

I have some expressions, that consist of rather lengthy sums such as ...
2
votes
0answers
59 views

Generating a list of 4-digit integers by simulating four dice being thrown eight times

I simulate throwing four dice and merge their values together to form a 4-digit number. This is done eight times and I want to get a list like this one: ...
3
votes
1answer
49 views

Apply on Message resolves MessageName before applying

I want to make a Message from a List. Message[LibraryFunction::argx, 1, 3] ...
1
vote
2answers
50 views

Define a bilinear function of strings

I have a linear combinations of strings, e.g. combStrings = 0.1 "a" + 0.2 "b" I want to define a function f[] which deals ...