# Questions tagged [replacement]

The tag has no usage guidance.

1,593 questions
Filter by
Sorted by
Tagged with
82 views

### Can you explain this substitution rule?

This rule behaves as I expect: b . c + a . b . c /. (b . c) -> x (* x + a . x *) I would expect the same result with this: ...
203 views

### Different answers when attempting replacement of function argument

I have three function computing Fibonacci numbers which return correct answers when directly called with e.g. fib1: ...
304 views

### How to make ReplaceAll recognize what to be replaced in a situation like this?

I'm a bit confused on how ReplaceAll works. For example ReplaceAll[2x+2y, x+y -> 1] just gives ...
51 views

### ReplaceAll that works inside Rational?

I'm trying to replace all instances of a 31632259 in a formula with x, but there's something special about how Mathematica ...
145 views

### With function replace rule does not work in

If I define an expression , and evaluate it in With function, replace rule does not work. sumT = TA + TE; With[ {TA = 0.1, TE = 0.2}, {TA + TE, sumT} ] output <...
37 views

### Simplifying symbolic expression using replacement rules

I am trying to carry out a linear stability analysis of a two PDE system. I start by defining the equations and then define the perturbation along with the replacement rules required. I then use a ...
1 vote
62 views

### ReplaceAll causing infinite recursion

I have two expressions expressionA = (-B*a + b)/M expressionB = (-A*c + d)/M expressionA depends on ...
74 views

### Same code behaves differently as a pure function and a function, and insider another function

I have a rule-transformer that takes a list of rules (and a list generator = {σ[z], σ[-1], σ}) ...
40 views

### Transform a list of delayed rules with conditions to a new list of delayed rules

I have a list of rules that implement some abstract algebras, for instance, that of the Pauli matrices, ...
110 views

### How to force Mathematica to simplify in terms of half angles?

By basic trigonometric identities, the expression $\frac{\sinh(x)}{\sqrt{2}\sqrt{1+\cosh(x)}}$ simplifies to $\sinh(\frac{x}{2})$. But Mathematica seemingly don't perform this simplification. I tried ...
40 views

### RuleDelayed with Simplify?

I have the Rule yRule = y -> Function[{l,m,x},x^(l + 1) Exp[-((2 I m)/x)] Hypergeometric1F1[1 - l, -2 l, (2 I m)/x] ] Is it possible to replace and simplify ...
202 views

### How to Replace 'delta t' with 'a' in Mathematica Without Affecting Separate Instances of 'delta' or 't'?

In Mathematica, how can I replace instances of delta t in an expression with a, while keeping instances of ...
58 views

### Why is replacement so slow for long sums?

I have an integral of a sum of many terms: $\int \int S_y^2 a a^\dagger f_1(t_1)f_2(t_2)^* + ...$ For example ...
484 views

### Apply function to all first arguments of a nested list of rules

Currently, I have a nested list of rules of the form lst1={1->a,2->{3->c,4->d,5->{6->f,7->{8->h,...}}}} (where I don't know the length of ...
115 views

### Convert list of variables to list of parametrized functions

I have a list of differential equations of some variables eqns = {f[x,y,x',y'],g[x,y,x',y']} e.g., f[x,y,x',y'] = x x' + y y'. ...
62 views

### Replacement of a combination of parameters with a single parameter [closed]

Suppose we have the equation 1+u/(L $\omega$) and we want to replace L $\omega$ / u with Da such that this yields the new equation 1+1/Da. Is Mathematica able to do that? ...
1 vote
81 views

### Applying matrix commutation rules

I want to symbolically replace occurences of matrix terms such as $zAB-zBA$ with $zC$, where $z$ is a number. This works as expected: ...
58 views

### Syntax error trying to rewrite expression using rules

I want to use Mathematica to calculate derivatives of some long, complicated expressions. I have an integral with integrand $I_*$ which is a functional that depends on $h(x,t)$ and $\phi(x,t)$. The ...
1 vote
203 views

75 views

### Replacing something in an expression

I have an expression as follows: expr = K*ComplexExpand[Abs[f]^4] + P*D[(ComplexExpand[Conjugate[f]] // TrigToExp), x] where f is a function with two ...
28 views

### Stack Solve solutions in a loop [duplicate]

I want to solve the following equation in a loop: ...
74 views

### Error with using ReplaceAll

I wrote a For Loop. In this For Loop, I want to change the values of a list. The main issue is: I have a nested list like: ...
144 views

### Keep Log10[] in result

I want to work using Log10[...] yet it keeps reformatting to Log[...]/Log. This simple example can be avoided by using ...
49 views

### Replace coefficients with RootApproximant of themselves

I have an expression, not necessarily a polynomial, and want to take all the coefficients on whatever terms there are and replace them with the RootApproximant ...
256 views

### Displaying integrals with non-variable factors in front [duplicate]

In class I sometimes go through the steps in mathematical derivations using Mathematica. Some of the steps involve substitutions and assumptions that come conceptually outside a strict mathematical ...
27 views

### Replace part of output and simplify it

I have a code that give me : E^(k (k n + (B - A k) HarmonicNumber[n])) (1 - r)^n Now I want to replace HarmonicNumber[n] with: ...
1 vote
48 views

### Why do rules not default to local scope? [closed]

Consider the following: 80 //. a_?EvenQ -> a/2 a = 3 80 //. a_?EvenQ -> a/2 which outputs: 5 3 3/2 I think I understand ...
47 views

### Resubstituting variables back into the calculated

I have lengthy second order derivative of a function that is defined with multiple lines of variables. When I compute the derivative how can I put back into the computed result the auxilary variables ...