Linked Questions

60 votes
4 answers
11k views

Can I simplify an expression into form which uses my own definitions?

This seems like a simple thing to do, but I couldn't find anything relevant from Mathematica documentation. So suppose I have an expression: a*b/(a + a*Cos[a/b]) ...
Echows's user avatar
  • 981
22 votes
7 answers
19k views

How do I replace a variable in a polynomial?

How do I substitue z^2->x in the following polynomial z^4+z^2+4? z^4+z^2+4 /. z^2->x ...
niklasfi's user avatar
  • 2,623
10 votes
3 answers
510 views

Matching (y/x)^u terms wherever the appear in an expression

Mathematica keeps rewriting expressions, so it is hard to figure what pattern to use. I am trying to replace all occurrences of $\frac{y}{x}$ by $t$, but Mathematica re-writes $\frac{1}{\left(\frac{y}...
Nasser's user avatar
  • 143k
9 votes
3 answers
3k views

Replace expressions with symbols

First of all: I'm new to Mathematica, so I would appreciate it if the answers are quite complete. I have the result of calculation that is expressed in $\sin$ and $\cos$. Now, all of these can be ...
JT_NL's user avatar
  • 983
8 votes
2 answers
274 views

Representing a value in an output as a self defined variable

I'm trying to find a way to have Mathematica always represent a numerical value as a self defined variable that I define using lhs=rhs. For example, if I execute <...
David K.'s user avatar
  • 213
5 votes
2 answers
612 views

Why is an integer not considered as a real?

Please consider the following: zeros={0.,0}; data={1, 0., 0}; DeleteCases[data, #]&/@zeros Head/@zeros (*{Real, Integer}*) (*{{1, 0}, {1, 0.}}*) For my ...
John's user avatar
  • 4,361
3 votes
3 answers
640 views

Replacing a sum of expressions

I have an equation which Mathematica solves but gives a huge output. However I notice in this output that the same expression occurs many times. Namely: $E=864 a^6 - 432 a^4 b^2 + 54 a^2 b^4 - b^6 + ...
Phibert's user avatar
  • 147
2 votes
1 answer
165 views

Replace an expression with a slightly tricky LHS transformation

I would like to make the substitution x^(11*y) -> r in the following equation x^(11 *y^z) - 1 to end up with: ...
Blair Azzopardi's user avatar
2 votes
1 answer
1k views

How to transform an expression using algebraical instead of pattern rules [duplicate]

I would like to transform rules algebraically. A very simple example would be: - k^2 - 2 k x + x^2 /. {2*k -> 1} This transforms to: - $$k^2-2 k x+x^2$$ ...
Blair Azzopardi's user avatar
2 votes
1 answer
67 views

Algebraic replacement [duplicate]

How do I replace an algebraic expression with a symbol? I'm trying to replace repeated terms such as $(a+b)$ with c, for example, so that $x(4a + 4b) + x^2(6a + 6b)$ becomes $x4c + x^26c$ .
PoemTechnology's user avatar
1 vote
2 answers
99 views

Applying a simple transformation rule when Plus automatically simplifies

I have the following simple rules: {x2-x1->s1, -(x2-x1)->-s1, x3-x2->s2, -(x3-x2)->-s2} I want to apply that rule to the following: ...
N D's user avatar
  • 25
1 vote
0 answers
39 views

replacement rules don't account for signs [duplicate]

I would like to make a single replacement rule that disregards the sign. I have the following expression: ...
Alejandro Marcos Aragon's user avatar
0 votes
1 answer
278 views

simplification rule with symmetry

What rule can you think of to replace the first line by the second? I have a bunch of expression like these, which I would like to simplify. All dependent cross terms must be written in the same ...
sjdh's user avatar
  • 7,757
0 votes
0 answers
54 views

How do you make basic substitutions in Mathematica? [duplicate]

I have an equation: e == m*c^2 + (1/2)*c^2*m*v^2 $$e==m c^2 + \frac{1}{2}c^2\space m\space v^2$$ I need to remove the $v$ variable and replace it with $p$. I also ...
Quark Soup's user avatar
  • 1,610