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

learn more… | top users | synonyms

43
votes
3answers
1k views

Replace inside Held expression

I wish to make functional replacement inside Held expression like this: ...
42
votes
2answers
1k views

Head and everything except Head?

I have been working on picking expressions apart using Head and Part and encountered a little mystery. Consider the canonical ...
20
votes
3answers
5k views

Is it possible to change the color of plot in Show?

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 ...
16
votes
2answers
1k views

Scan vs. Map vs. Apply

I cannot understand the difference between Apply, Scan, and Map. I have tried to play with ...
5
votes
5answers
198 views

Is there an analogue of the Variables command for general expressions?

The command Variables[poly] gives me a list of all variables that appear in the expression poly, which involved sums, ...
4
votes
1answer
672 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 ...
10
votes
3answers
793 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: ...
8
votes
4answers
1k 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: ...
18
votes
1answer
615 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 ...
8
votes
3answers
926 views

How to manipulate gauge theory in Mathematica?

I want to know if there is a way of typing into Mathematica an expression like the following, $$\epsilon^{\mu \nu \lambda} f^{abc} A^a_\mu A^b_\nu A^c_\lambda + g\epsilon^{\mu \nu \lambda} A^a_\mu ...
18
votes
3answers
624 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 ...
5
votes
4answers
733 views

How to completely delete the head of a function expression

Is there any way to completely remove the head of an expression function? For example, how would I remove the head Cos from ...
2
votes
4answers
176 views

Print all numbers from a sequence which don't contain the digit 7

so i have this: Cases[RecurrenceTable[{a[n + 1] == 7 a[n] + n, a[1] == 1}, a, {n, 7}], Except[7]] But i noticed that it will only exclude numbers that are 7, and ...
15
votes
3answers
523 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 ...
13
votes
1answer
433 views

Transform an expression into a graph that can be plotted with TreeGraph (not TreeForm)

I would like to plot an expression (like TreeForm does), but using the new TreeGraph functionality. ...
11
votes
2answers
683 views

Displaying a series obtained by evaluating a Taylor series

Description of problem I would like to use Mathematica to display the series obtained by substituting a value for $x$ in a Taylor series expansion. The terms of the series will be rational numbers, ...
7
votes
4answers
439 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 ...
16
votes
1answer
295 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 ...
6
votes
1answer
271 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 Utilities`FilterOptions` My question is: ...
27
votes
8answers
1k 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?
13
votes
6answers
299 views

Construct an infix operation from a list

Inspired by this question, if I have a list {a, p, b, q, c} where p and q are binary ...
8
votes
1answer
1k 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 ...
6
votes
6answers
196 views

Trying to write out the prime factorization of a number with CenterDot and Superscript

I am trying to use CenterDot and Superscript, in conjunction with Apply to write out the prime factorization of any given integer. Everything works well UNLESS the prime factorization of the number ...
9
votes
2answers
4k views

How to expand tan(x+y) as normal form?

TrigExpand@Tan[x + y] gives $\frac{\sin (x) \cos (y)}{\cos (x) \cos (y)-\sin (x) \sin (y)}+\frac{\cos (x) \sin(y)}{\cos (x) \cos (y)-\sin (x) \sin (y)}$ but I ...
13
votes
2answers
506 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 ...
3
votes
2answers
318 views

Simplifying expressions involving Sum

I am trying to use Mathematica to simplify a symbolic expression involving Sum. Particularly, I define a sum via ...
3
votes
3answers
248 views

Conjugating symbolic expression

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: ...
8
votes
3answers
871 views

How to extract expression from ConditionalExpression

p1 := y /. {First[Solve[x^2 + y^2 + x == 1, y, Reals]]} ...
2
votes
2answers
179 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, ...
1
vote
3answers
190 views

How to manage list of list of rules?

Considering we have a list: str = "{1 -> {a -> aa, b -> bb}, 2 -> {2a -> \"{b -> bb}\"}}" Bringing this to expression gives: ...
20
votes
1answer
353 views

How can I see which transformations Simplify attempts?

The documentation for Simplify[expr] says that it performs a sequence of algebraic and other transformations on expr, and returns the simplest form it finds. How can I see which transformations it ...
18
votes
1answer
462 views

List of atomic expressions

I was surprised to see Graph objects are atomic. Is there a way (through documentation or programmatically) to find all atomic heads? The ones I know of are: ...
12
votes
3answers
1k 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, ...
10
votes
2answers
252 views

How to do algebra on summations of variable expressions?

Is there any easy, general way to handle algebra on variable Sums? For examples, Gaussian Mixtures or Fourier Series: ...
12
votes
2answers
653 views

Google Code Jam: Mountain View code review

After participating in Google Code Jam 2012 Round 2, it occurred to me that the Mountain View problem boiled down to solving a set of linear inequalities, which could be done in Mathematica. I've only ...
11
votes
3answers
203 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 ...
11
votes
1answer
392 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 ...
10
votes
1answer
135 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: ...
6
votes
0answers
206 views

Using FunctionExpand to evaluate symbolic derivatives

Some symbolic derivatives of certain special function are not expanded automatically, but FunctionExpand often helps to get a derivative-free closed form ...
3
votes
1answer
191 views

Change values in equation with slider

I want to make an equation where the values adjust to my slider which I inserted with manipulate. Well, I tried, but when I use the slider the equation starts to fall apart. Actually this should ...
5
votes
2answers
201 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: ...
4
votes
2answers
192 views

Time-efficient creation of matrix

I have expressions like xx1=FF[1, 1] GG[1, 1] + FF[1, 1] GG[2, 2] + FF[2, 2] GG[2, 2] xx2=2*FF[1, 2] GG[1, 1] + FF[1, 1] GG[1, 2] + FF[2, 2] GG[2, 2] and I want ...
3
votes
2answers
234 views

Replace every Minus to Plus in Expression

Thought this is a rather simple thing, but I was not able to find a solution: I have a polynomial expression like: expr1=a^2-b+c*d expr2=a-b expr3=-a+b-c and ...
1
vote
2answers
555 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 ...
10
votes
4answers
451 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 ...
4
votes
2answers
222 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 ...
3
votes
2answers
116 views

Time-efficient manipulation (zeroing) of expression

I have huge matrices in the form of ...
3
votes
1answer
216 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 ...
2
votes
0answers
78 views

TrigExpand Idiosyncracies

TrigExpand[Sin[x]^2 Log[y]] returns sin^2(x) log(y), as one would expect. However, ...