Questions tagged [expression-manipulation]

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

Filter by
Sorted by
Tagged with
1 vote
1 answer
61 views

Clarification of the $MemberQ$

There are a number of expressions: ...
  • 1,893
1 vote
1 answer
56 views

Save expression for future use [closed]

I have an expression given by a summation, which takes a few hours to compile and which gives me over a million terms. How can i save up this expression to use him another day, wihtout doing the sum ...
2 votes
1 answer
77 views

Pattern not matching BoundaryMeshRegion

Mathematica 13.1 on Windows 10. Can someone explain why the following does not match: MatchQ[BoundaryMeshRegion[Cube[]], BoundaryMeshRegion[__]] (* False *)
  • 29.5k
0 votes
0 answers
23 views

How to attach Upvalues to CompoundExpression?

I'm trying to make something like this work: Evaluating someData // Query[whatever...] /* summarizeInPrettyWay /* promptToRemoveCompoundExpression ; should produce ...
  • 122
7 votes
2 answers
238 views

How to remove branches in Piecewise with measure 0

I am doing Convolve over UnitTriangle in 2 dimensions and the resulting piecewise function has conditions with measure zero (...
  • 2,070
1 vote
3 answers
89 views

Extracting elements from a List in a specific way

I have a set of polynomial expressions in multiple variables: ...
  • 193
0 votes
0 answers
30 views

ToExpression in nested Set/SetDelayed

Suppose we have the following definitions. ...
3 votes
2 answers
142 views

Find the smallest subexpression containing all subexpressions matching a given pattern

I need to write a function that, given an expression like 1/x + 1/(Abs[x] + 1/(1 + Abs[y - Abs[x]])) finds all its subexpressions matching a certain pattern (say, <...
0 votes
1 answer
40 views

Given the expression of `x`, how can I eliminate the terms that tend to zero as `x` goes to infinity but keep those which are non-zero or infinite?

Suppose I have an expression of x. Now I want to somehow evaluate its "limit" at x->Infinity, but in such a way ...
  • 2,940
0 votes
1 answer
56 views

How to avoid the endless loop and remove the definition?

The function ...
  • 19
0 votes
0 answers
59 views

Back-substitution

Suppose that we have an expression (expr in the code below) and replace a long term with a new parameter (K). For a simple example; ...
  • 507
1 vote
0 answers
27 views

Replace subexpression with variable in result from Laplace transform

I'd like to clean up the result I obtained from an inverse Laplace transform: First of all, I'd like to replace the square root expressions in the hyperbolic function arguments (part encircled in ...
  • 11
2 votes
1 answer
75 views

A complicated derivative problem

I have some equation,like this $$ \begin{aligned} &\hat{t}_{g o}=\frac{R}{V_{m}}\left(1+\frac{(n+2) \sigma^{2}+(n+1)^{2}(n+2) \sigma_{f}^{2}}{2(2 n+3)(2 n+5)}-\frac{(n+1) \sigma \sigma_{f}}{2(2 n+...
2 votes
1 answer
59 views

CellObject[Number] to its content

As in the following sreenshots, roughly speaking, Out[43] is CellObject[97601]. I want to set ...
  • 3,221
3 votes
3 answers
108 views

Parsing an expression for coefficients and more

I have many expressions of this form: ...
1 vote
0 answers
24 views

TreePosition with multiple (not just node data) conditions

Given a Tree object, TreePosition takes patterns only on the "data" of the node plus a level spec. ...
  • 3,621
2 votes
1 answer
63 views

Symbolic PDE manipulation

I'd like to transform a PDE in a way such that I can express a temporal derivative as a spatial derivative using some known relation. Very simple example: ...
  • 21
0 votes
1 answer
30 views

Confusing abnormalities observed when counting a specific operator in an expression [duplicate]

Recently I have met with some confusing abnormalities when trying to determine if there is a specific operator (usually Plus[] ) in an expression by programming. ...
  • 443
4 votes
2 answers
137 views

Extracting the constant term

Finite difference problem There are a large number of variables, interacting at most five at a time. A sample term is: How to extract the constant term? In this example, the constant term is -1/4.
  • 1,000
-1 votes
1 answer
52 views

Factorize expression by specific term [closed]

I am new to Mathematica but I would like to know how to force Mathematica to factorize an expression by a specific term. Exemple, imagine I have a term like this: And I have an expression like this: ...
1 vote
0 answers
57 views

Can one collect with respect to two groups of variables?

Here is a toy example of what I want: given ...
0 votes
2 answers
75 views

How to extract logarithmic terms in an expression?

I have some expressions of the type $f(x) \,+\, g(x) \,\log(x) \,+\, h(x) \,\log(1-x^2)$ where $f$, $g$, and $h$ can be any rational functions of $x$. I am trying to use Mathematica to extract each ...
6 votes
1 answer
186 views

Why does my list of positions contain a leading and following element not in the original list?

I have a list which contains non-integers (three in this case) each of which I need to replace with a different Random Variate. ...
  • 649
2 votes
2 answers
90 views

Get rid of some solutions proposed by Reduce/Solve

I would like to take the result of a Reduce function call and eliminate any solutions that depend on the value of a particular variable (call it $y$). For instance, I am trying to get the parameters ...
2 votes
1 answer
186 views

How do I extract the component from an expression

I'm embarrassed that I don't even know the language for what I'm asking. The result of an operation I'm performing is: $$expression=-dt^2 \left(c + a t\right)^2$$ $dt$ is basically an infinitesimal in ...
  • 1,521
1 vote
1 answer
78 views

Speclevel in Reverse

I have an expression involving several dot products, I give a simplified example: expr={A.B,C.D} I want to reverse all dot products, and try ...
1 vote
1 answer
79 views

Separating terms in an expression with many variables by their "nature"

I have an expression like this: $f=t_1(\sin(\alpha),\cos(\beta),\cos(\gamma)^2) \cdot r_1(x,y,z)+t_n(\sin(\alpha),\cos(\beta),\cos(\gamma)^2) \cdot r_n(x,y,z)$ Where $t_i$ and $r_i$ - functions of ...
  • 1,893
0 votes
0 answers
80 views

Can Mathematica simplify expressions with prescribed relations?

I have a linear map $T$ on a vector space which satisfies $T^4 = 1$ and want to simplify expressions of the form: $$[X,TY] + [Y,TX] + [Y,T[TX,TY]] + [X,T[TX,TY]],$$ where $[\cdot, \cdot]$ denotes the ...
  • 1
3 votes
1 answer
97 views

How to use RightComposition efficiently in the context of one-liners?

I find myself recently writting, more often than not, code that makes heavy use of RightComposition eg. expr//f/*g/*h It is relatively straightforward to first ...
  • 122
3 votes
0 answers
77 views

How to convert Graph atomic object back into unevaluated expression? [duplicate]

For the purposes of further development of my shortInputForm function, I wish to convert Atomic objects such as Graph into non-...
3 votes
2 answers
103 views

Extract first term of each element in a list

Suppose I have a list of the form list={a+b,c+d,Xi+Psi*Zeta,0} How can I make a list of only the first term of each element in that list? In this case the list ...
  • 207
1 vote
1 answer
107 views

How to convert this Mathematica expression to another, as described here?

I am working on a function of which the core will consist of something like: ...
0 votes
0 answers
60 views

Get depth of vertices in TreeGraph

I want to get the depth of each vertex in a TreeGraph, g. I might convert g into an ...
  • 3,099
0 votes
1 answer
37 views

How to change the location of strings inside the manipulate function?

...
  • 141
3 votes
3 answers
178 views

Encode expression into a list

I have an expression of the form: $$c {\partial^{k+l} \Phi(\theta,\phi,n) \over \partial \theta^k \partial \phi^l}$$ $n,k,l$ are (positive) integers. $c$ is some constant. It is also possible that $c$ ...
  • 1,249
1 vote
2 answers
70 views

Converting an indefinite integral to definite integral

For example, I have the following integral expression: g[x, y] = Integrate[f[x, y],x] How can I modify the above expression to achieve the following definite ...
  • 350
1 vote
2 answers
72 views

Factoring an arbitrary power from the rest of the expression in an exponential expression

I have the following expression: Exp[r*t*x + e*r*y + t*x*r^2 + y^2*e*Sqrt[r]] I want to choose some arbitrary terms in the power and for example write the ...
  • 350
0 votes
1 answer
94 views

Simplifying multiplies of sums into a single double sum

I have the following expression: Sum[x^n, {n, 1, Infinity}]*Sum[Log[m, x], {m, 2, Infinity}] How can I Force Mathematica to write this expression in the following ...
  • 350
0 votes
1 answer
74 views

Transforming one exponential expression to multiplication of exponential expressions [duplicate]

I have the following expression: Exp[a * x + b * y + c * z] I want to write this expression as: ...
  • 350
2 votes
2 answers
235 views

How to express Bessel Functions in terms of Hankel Functions

I have the following expression BesselJ[\[ImaginaryI]*m, k*r] FunctionExpand knows how to transform from ...
  • 350
1 vote
1 answer
37 views

How can I extract a list of terms with functions in terms of a specific variable

I have an expression in the following form: a f[x] + b Exp[g[x, y]] + r[z] f[y] + f[y] Sin[h[x, y, z]^2] + r[z] Log[t[z, y]] I want to extract an expression ...
  • 350
1 vote
3 answers
61 views

Extract a row from dataset based on two strings

Say I have a list as below: ...
  • 171
1 vote
0 answers
54 views

Same displayed expressions produce different outputs

I know EngineeringForm is a wrapper which prevents evaluation of content, but pasting chunks of other cells with an EngineeringForm number, got these two simple expressions w/ the same input ...
1 vote
0 answers
65 views

How to make a function in terms of constants to inherit the attribute of being constant

I have defined two variables a and b: SetAttributes[a, Constant]; SetAtributes[b, Constant]; I have defined a function c as ...
  • 350
1 vote
0 answers
90 views

Extracting expressions from LHS of an assignment

I need to list all variables in a notebook containing several Set assignments, lhs=rhs, and equations, ...
  • 433
2 votes
2 answers
96 views

Equality of expressions with different variable names

I have some multivariate systems of expressions that I want to check for equality up to allowing relabelling of the variables. For example the two expressions below would be the same: ...
  • 55
5 votes
3 answers
252 views

How to locate a value from a list

I made a list with two values in each cell. ...
1 vote
1 answer
65 views

Denoting the whole in Position/Extract/ReplacePart

Position returns lists of numbers consumed by Extract, ReplacePart and others as "...
1 vote
0 answers
78 views

Coefficient works on $\pi$, $x$ and $x^2$, but not on $\pi ^2$

Consider (\[Pi] + 2 \[Pi]^2 + 3 x + 4 x^2) Executing ...
  • 1,185
0 votes
0 answers
62 views

Manipulation of expression

Let ss2 = (γ + ν)/β; is2 = ((γ + ν)/β) (β/((γ + ν)) - 1); I wish to do the following computation but want to keep the output in terms of ss2 and is2: ...
  • 487

1
2 3 4 5
15