# Questions tagged [expression-manipulation]

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

600 questions
Filter by
Sorted by
Tagged with
756 views

### How to convert a notebook cell to a string retaining all formatting, colorization of identifiers etc?

I have an opened Mathematica notebook containing several cells. Suppose, I am interested in one of them -- it may contain a complete or incomplete expression (e.g. with syntax errors, highlighted ...
877 views

### How to embed an image into a string?

Note: The bug described in the post is in Mathematica 9, and has been fixed in 10.0. The documentation for String contains the following statements: Strings can ...
712 views

### Is it possible to define custom compound assignment operators like ⊕= similar to built-ins +=, *= etc?

I would like to do something like this: ...
1k views

### How to add equations' left and right sides together?

If we have two equations E1 and E2, and instead of using Solve to solve it, we simply need to manually add them up which would allow some simplification that could ...
602 views

### How to decompose a complex expression containing repeated subexpressions? [duplicate]

Suppose I have an expression like ...
2k views

ArcTan really bothers me, so is there a way to make Mathematica write Logarithm instead of ...
997 views

### Counting multiplications (complexity function)

I'm trying to count the number of times multiplication appears in an expression (for the purpose of constructing a ComplexityFunction that would help me simplify a terrible algebraic expression for ...
260 views

### Indexing of Large Autonomous System of Equations for Use in NDSolve

I currently have a list of ~150 autonomous ODE's that I need to be able to work with using NDSolve. Fortunately I already have them formatted in plaintext, which ...
362 views

### Symbolic manipulation of functional form

I have a functional polynomial expression of the form: ...
243 views

### Examine function parameters programmatically

I write a lot of scripts in Mathematica and I'd like to eliminate the boilerplate that parses command-line arguments and assigns them to variables of the correct type before doing the real work. I was ...
1k views

### Comparing Mathematica expressions like diff

I am looking for a way to compare (or "diff") two Mathematica expressions, similarly to how to diff utility can compare two text files and report the differences. Has anyone already written such a ...
594 views

### How to extract the coefficient from an expression

Here is the expression. I want to extract the coefficient just as the table showing below. I can do it by hand, but I expect a code that can automatically identify how many differenct terms there ...
204 views

### Trying to show an expression is always zero

I have a symbolic matrix $$m = \begin{pmatrix}A1 & B1 & C1\\A2 & B2 & C2 \\ A3 & B3 & C3\end{pmatrix}$$ and I believe that Det[m] is ...
494 views

### Why is ReplaceAll behaving like this?

I'm learning to use the ReplaceAll function and I found the behavior of which is quite confusing. For Sqrt[f[x, y]] /. f[___] -> u Mathematica returns <...
2k views

### Dropping Higher Order Terms in symbolic evaluation

I have a series of symbolic manipulations (along with some coefficients). As a sample, here is one of the intermediate forms ...
533 views

### Match and replace subexpression

I would like to replace the expresion $(n1-1)$ to $z1$ in following: 2*n1*p[n1-1,n2] 2*(z1+1)*p[z1,n2] I have tried Replace...
2k views

### How can I prevent Mathematica from evaluating or “simplifying” an expression?

Simple example: ...
305 views

### How to change the Integer to a special form in an expression?

I have an expression. I want to change all the Integers to a new form. The rule is, x_Integer->x._f. But we should consider some special cases. For example, ...
5k views

### Extracting variables from an expression

I'm looking for a way to extract a list of variables from an expression, for example with an input like: ...
2k views

### Variable name string to expression

I'm not sure how to name this problem appropriately. But anyway. I have, say, three variables (arrays in my case), which I call: A1, A2, A3 I would like to ...
861 views

### How to get the matrix coefficient from a QuadraticForm expression in a very fast way?

As we know, QuadraticFormDistribution is the distribution of z.a.z + b.z + c for a real-valued p x p symmetric positive definite ...
865 views

### List manipulation to build a functional expression

Since Mathematica deals with Head[a, b] as an expression in this way The first Part of Head[a, b] is ...
2k views

### How do I get my equation to have the form $(x-a)^2 + (y-b)^2 + (z-c)^2-d = 0$?

I want Mathematica to express the equation $$-11 - 2 x + x^2 - 4 y + y^2 - 6 z + z^2=0$$ in the form $$(x - 1)^2 + (y - 2)^2 + (z - 3)^2 - 25=0$$ How do I tell Mathematica to do that?
2k views

### Behavior of expression evaluation in Plot

I'm confused with Mathematica's way of parsing expressions. I've been struggling with this for a while and never found an exhaustive answer, sometimes things don't parse the way I think they would ...
499 views

### How can I retrieve the point coordinates from a LOG Plot after the data points were manually moved?

I'm having problems with getting coordinates out ofa ListLogLogPlot I basically plotted a list, then selected data points on the graph, moved these points around, ...
756 views

### Graph and manipulate DSolve result

Given a DSolve example: ...
1k views

### Pattern matching a pattern with patterns

Confusing title, I know. But the question is, if we have two patterns which have the same general structure but different names used in the patterns and different names: ...
23k views

### How to change plot style or other options after it was created

For example: p = Plot[Sin[x], {x, 0, 1}] Is it possible to write options in Show to change the curve's color for example into ...
4k views

### How do I expand a sum?

I have a problem with Mathematica's symbolic manipulations. As an example, consider the following expression: $$\sum _{i=1}^n -2 x_i \left(-a x_i-b+y_i\right)=0$$ How do I get Mathematica to expand ...
1k views

1k views

### How can I completely ban usage of some functions in output and mandate use of others?

For example, I hate that Mathematica uses Pochhammer symbol in outputs and prefer all the expressions in Gamma function. How can ...
757 views

### Extracting equations from Piecewise expressions

Say I have a PDF: PDF[LogNormalDistribution[1.75, 0.65], x] Calculating it, Mathematica gives me an expression that looks like this: I want to extract the ...
2k views