# Questions tagged [expression-manipulation]

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

640 questions
Filter by
Sorted by
Tagged with
1answer
313 views

### Extracting function calls from an expression

I have an expression like this: expr = F[0, 1] + 2 F[0, 0] - 17*F[2, 0] and I want to transform it to a list consisting of all function calls with its arguments: ...
2answers
197 views

### Merging two held expressions into a held compound expression

Consider e1 = Hold[a = x + x; b = y + y + y]; e2 = Hold[c = a + a + b + b + b; c^2]; How can I obtain the following? ...
1answer
158 views

### Why is ^^ff not the same as ^^ToExpression[“ff”]?

I want to convert a hexadecimal string to a decimal (base 10) number: 16^^ff 16^^ToExpression["ff"] The 1st line returns the correct answer of 255, while the 2nd ...
1answer
653 views

### Set gives an unexpected error message (Set::partw)

Here is a minimal example: s = 1 /(a + b) + 1 /(2 a + b); s[] = Sum[s[] /. b -> k, {k, 3}] s[] s[] = Sum[s[] /. b -> k, {k, 3}] ...
1answer
163 views

### How to convert the expression '{a->a0, b->b0}' to the expression 'a=a0; b=b0'? [duplicate]

How to convert the expression '{a->a0, b->b0}' to the expression 'a=a0; b=b0'? I think this is a common question and do not know if someone has asked it before. Any help or suggestion will be ...
4answers
4k views

### How to extract expression from ConditionalExpression

p1 := y /. {First[Solve[x^2 + y^2 + x == 1, y, Reals]]} ...
1answer
156 views

### Selecting expressions from a sequence that are not subexpressions of earlier elements

I have a While loop that generates and prints an expression on each iteration (there can be thousands of iterations). UPDATE: Some expressions are generated in ...
2answers
306 views

### Partial result of aborted evaluation of FullSimplify

When FullSimplify invoked on a large expression, it can run for hours. If I do not have time to wait, and abort the evaluation, I get no result, although, ...
3answers
261 views

### How to collect expressions from cells created by Print?

I have a notebook where evaluation of a certain cell produced hundreds of adjacent output cells using Print. I need to create a list containing all expressions from ...
1answer
179 views

### check if the expression is a equation

I need to check if the expression is a correct equation with only 1 variable x and without functions, that are not build into Mathematica. For example Sin[x]==0 ...
0answers
107 views

### How to combine DifferenceRoot objects for odd and even-indexed terms

I'm trying to analyze a certain infinite sequence $S$, indexed by positive integers starting from $1$. It can be split into two subsequences: $S^{odd}$ by removing all even-indexed elements and ...
2answers
752 views

### How to Clear variables represented as a list of strings?

Say I have a string list called fullpara fullpara={"width", "long", "line", "distance"} And there are corresponding variables ...
1answer
101 views

### How to bail out from a non-applicable transformation function?

I provide a custom function in TransformationFunctions options of FullSimplify that can do a transformation only for some values ...
1answer
691 views

### Using FunctionExpand to evaluate symbolic derivatives

Some symbolic derivatives of certain special functions are not expanded automatically, but FunctionExpand often helps to get a derivative-free closed form ...
2answers
877 views

### Replace doesn't replace the denominator [duplicate]

I have the following expression in Mathematica -((E^(2 - 2 Sqrt[(x - x)^2]) (x - x))/Sqrt[(x - x)^2]) I want to replace anything of the ...
1answer
2k views

### How to extract a possible closed form from WolframAlpha[] output

To find a possible closed form of a number, I can use the function WolframAlpha["6.38905609893065", IncludePods -> "PossibleClosedForm"] It returns a result ...
4answers
197 views

### Operations on expressions within Hold

I want to convert {Hold[1 + 2], Hold[3 + 4], Hold[5*6]} into Hold[{1 + 2, 3 + 4, 5*6}]. I have tried ...
0answers
62 views

### Matching Root[…] objects with patterns, unexpected hidden argument

I needed to write patterns that could distinguish between arbitrary-function and polynomial forms of Root objects, for example, ...
0answers
99 views

...
2answers
446 views

### Why is ToRadicals[] not able to handle all cases? Is there a workaround?

The documentation for the function ToRadicals says: ♦ There are some cases in which expressions involving radicals can in principle be given, but ...
2answers
1k views

### Adapting CoefficientList (and the related functions) to work with Laurent polynomials

Is there a slick way to make CoefficientList (and the other similar functions, CoefficientRules etc.) work for Laurent ...
1answer
195 views

### Need a generalization of RootApproximant to recognize linear combinations over algebraic numbers

RootApproximant does a very good job when I need to recognize an algebraic number and when enough of its digits are known (or even when an unlimited number of ...
2answers
1k views

### How to automatically get rid of trig functions in an expression?

I have a large expression containing many terms like this: Sin[1/2 ArcTan[(2 Log)/(Log^2 - 2)]] where a trig function is invoked on a rational multiple of ...
1answer
581 views

### Embedding StreamPlot in Graphics3D

I am trying to visualise the action of the infinitesimal generator of a Lie group on the solution of a 2-ODE system drawn in the 3D space (t,y1,y2): t is time and y1,y2 are the two dependent variables....
2answers
879 views

### How to reduce the number of operations needed to evaluate an expression? [duplicate]

For some numerical calculations in C++ I have, for example, this complicated expression to evaluate. Given as Mathematica input, in its original form it is ...
4answers
7k views

### How can I transfer mathematical expressions between Mathematica and Maple?

Is there a simple way to copy mathematical expressions between Mathematica and Maple (or at least in one direction)? I mean only expressions built from numbers and predefined mathematical functions, ...
2answers
702 views

### Summa package problem

I need to use the features of the Summa package but it doesn't work in Mathematica 9. It gives the error Cannot open UtilitiesFilterOptions My question is: ...
2answers
3k views

### Simplifying expressions involving Sum

I am trying to use Mathematica to simplify a symbolic expression involving Sum. The expression is defined as follows: ...
5answers
419 views

### Is there an analogue of the Variables command for general expressions? [duplicate]

The command Variables[poly] gives me a list of all variables that appear in the expression poly, which involved sums, ...
0answers
53 views

### Detecting a more general pattern [duplicate]

I need a function that, given 2 patterns, determines if the first pattern is more general than the second (i.e. that any expression successfully matched by the second, will be successfully matched by ...
2answers
530 views

### Getting a usable expression tree

I need to get the expression tree for some expression. expr //TreeForm The above grabs the expression tree but it isn't in some sort of usable format. Just an ...
1answer
211 views

### A question about derivatives (cubics)

Given an equation: f(z) = a (x + I y)^3 + b (x + I y)^2 + c (x + i y) + d Which can be re-written as: ...
2answers
466 views

### Passing list of options to Plot

I'm looking for a way to create a variable that I can use to hold all of the graphics directives for, say, a plot command. For example, I have 8 plots with variations on the following: ...
2answers
304 views

### How to unthread?

For example {a + b} == {c + d} // Thread (*{a + b == c + d}*) how to get {a + b} == {c + d} from ...
3answers
2k views

### Conjugating symbolic expression [duplicate]

I am trying to conjugate a symbolic expression, and I have explicitly stated the real terms. However, I simply can't get it to work: ...
1answer
169 views

### What are the scoping rules for function parameters shadowing System symbols?

Here are some very contrived code snippets, highly unlikely to appear in real code, but still I am curious why they behave like this: ...
1answer
196 views

### Assigning Sequence to Part of a SparseArray (bug?)

Part ▪ You can make an assignment like t[[spec]]=value to modify any part or sequence of parts in an expression. ▪ If ...
1answer
102 views

### Why is NHoldFirst not propagated to symbolic derivatives?

I encountered a nasty problem that N cannot evaluate expressions containing a symbolic Derivative of a multi-parameter function ...
0answers
319 views

### Strange behavior of undocumented RawArray and ArrayObject expressions [duplicate]

I discovered several strange results and inconsistencies while trying to understand what undocumented RawArray and ArrayObject ...
1answer
705 views

### How to convert an image to a compressed string representation equivalent to one copied to clipboard by CopyToClipboard[image]`?

In my recent question I asked How to embed an image into a string? The suggested solution was ...
1answer
795 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 ...
2answers
974 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 ...
3answers
735 views

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

I would like to do something like this: ...
2answers
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 ...
1answer
633 views

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

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

### How can I get Mathematica to write Log instead of ArcTan?

ArcTan really bothers me, so is there a way to make Mathematica write Logarithm instead of ...
4answers
1k 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 ...
1answer
269 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 ...
3answers
363 views

### Symbolic manipulation of functional form

I have a functional polynomial expression of the form: ...
1answer
247 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 ...