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.

1
vote
2answers
19 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
47 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
116 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
63 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
49 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
42 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
188 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
67 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
224 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
26 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
77 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
85 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
71 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
121 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
17 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
206 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
71 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
41 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
45 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
30 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
81 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
47 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
34 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
209 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
95 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
26 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
44 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
32 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
331 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
48 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
45 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
58 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
48 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 ...
1
vote
2answers
42 views

Move part of expression

What is the best way to take a part of an expression and put it somewhere else in the same expression? Essentially I need to combine a Extract, ...
1
vote
1answer
62 views

Simplifying a Sum of Fractions by Removing Fractions in Denominators

I have a sum of fractions of the form $x1 - \frac{(x2 + x3)}{(x4 + x5)} - \frac{(x6 + \frac{x7}{x13})}{(x8 - x9 - \frac{x10}{(x11 + x12)})}.$ How might I simplify it to remove fractions from the ...
0
votes
3answers
100 views

Replacements within a mathematica expression?

Say I have many expressions of the form $$\text{expr} = \frac{1}{AB(C+D)^n E^m}$$ where $A,B,C,D$ and $E$ are symbols and $n,m$ arbitrary powers. In order to convert between the mathematica output and ...
3
votes
1answer
39 views

InitializationFunction for TemplateObject

Shortly, I want something like this to work: ...
1
vote
3answers
78 views
2
votes
2answers
62 views

Expanding powers in an expression and Hold

Let an expression like -(1/2) + (3 x^5)/2 be given. How can this be turned into -(1/2) + (3 x x x x x)/2? All powers of ...
0
votes
0answers
42 views

How to use === with condition?

I have two expressions, and they are same when k is positive and x is non-zero real number. Below code gives me ...
4
votes
2answers
88 views

Expanding Log[Product[…]]

I'm trying to get the log-likelihood of a Gaussian in the form $$ p(\textbf{x}|u,\sigma^2)=\prod_{n=1}^{N}\mathcal{N}(x_n|\mu,\sigma^2) \quad (1) $$ $$ \ln\ p(\textbf{x}|\mu,\sigma^2)=-\frac{1}{2\...
6
votes
3answers
227 views

How can I delete a random part of an expression?

I have the expression: Times[0.19157500241430547,Power[Plus[0.7235014213631388,k,Times[-1,Power[m,c]]],Times[g,z]]] Also represented as: ...
5
votes
2answers
169 views

Extracting coefficients from sum

I'm having the hardest time working if I have a sum of products, with coefficients out the front, like expr = 1 + 2 a[0] b[1] + 2 a[0] b[1] c[3] + c[6] + 5 d[3, 4] ...
3
votes
2answers
127 views

Handling long expressions

After using Expand on the result of a calculation I get a long expression which is a sum of 8654461 terms (nearly 8.7 million). ...
1
vote
3answers
65 views

Elimination of terms not containing at least one variable from a set

I have an expression with each term therein either containing at least one $n_i \in \left\{ n_1 , n_2 \dots , n_{5} \right\}$ or no $n_i$ at all. I would like to easily eliminate all the terms that ...
3
votes
2answers
136 views

Sums as rational vector dot products with a basis constants vector

I have series of values which, by visual inspection, appear to be sums of certain constants, not divisible by each other, with rational weights. I want to convert these sums to vectors of weights for ...