# Questions tagged [rule]

Questions about transformation rules in Mathematica--constructs that let you set, or programmatically modify, local values for expressions.

356 questions
Filter by
Sorted by
Tagged with
126 views

4k views

### Reverse Lookup: getting keys from values

Lists of Rules or Associations are both a useful way of mapping between values. It also ...
541 views

### Replace list element with element from another list based on condition

I Have a list on integers and another list of "duplicates". E.g. start={{3},{1},{2},{4}}; duplicates={{1,4,7},{5,6}} I would like to substitute each element of ...
137 views

### How to transform the data in the following way?

Consider the following data: ...
227 views

### Crafting a replacement rule to convert derivatives to finite differences

I need to construct a replacement rule to replace (first) derivatives with centered finite differences. What I've got so far is ...
1 vote
128 views

### How to define the following "derivative"?

Consider the following test expression: ...
330 views

### How to simplify the following expression?

Consider the following expression: expr[s1_, s2_, m_] = Sqrt[s1 (s1 - 4*m^2)] + c Sqrt[s1^3 (s1 - 4*m^2)] + d Sqrt[s1^4 s2^2 (s1 - 4*m^2) (s2 - 4*m^2)] Here, <...
1 vote
107 views

### Replacing Kronecker delta times expression with the expression with inserted index

Consider the following symbolic expression: expr = f[a,b]*g[c,d]KroneckerDelta[a,m]KroneckerDelta[d,k] + KroneckerDelta[a,p]f[x,a]+const Could you please tell me ...
384 views

### Why the replacement rule works okay for scalars but not okay for matrices?

Consider the following UpSetDelayed: D[Kstar0[x_, a_], x[b_]] ^:= dKstar0[x, a, b] It works fine if applied to a scalar ...
135 views

### How to assign the following rule?

Consider the following object: function[x,a,b]. It is a symbol carrying one "coordinate" x and two indices a,b. I ...
50 views

### How to simplify the following expression of a matrix with complex conjugation?

Consider the following matrix: ...
43 views

### How to make a rule for the complex conjugation of a symbol?

Consider some symbols piplus, piminus, eta. Let us assume that they appear as conjugated, e....
1 vote
51 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 ...
72 views

### Functions from the output of Solve

The output of the equation Solve[f[x] - x^2 == 0, f[x]] is: {{f[x] -> x^2}} I would like the output to be ...
422 views

### Is there a simple way to apply a function to the RHS of a substitution?

Suppose I have solved a system of equations, resulting in a solution of the form: ...
139 views

### How can I use replacement rules with randomized values? [closed]

Suppose I have a list that I want to use replacement rules to replace each occurrence of a a given symbol with a randomly selected value, with this choice being randomized for each occurrence. For a ...
1 vote
69 views

### How to replace variables with functions in an expression?

I have an expression: KK = -(2*b *(c + 6) *(b + a) *d /(b + d) *(c + d)) a, b, ...