# Questions tagged [rule]

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

332 questions
Filter by
Sorted by
Tagged with
1 vote
119 views

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

Consider the following test expression: ...
106 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
97 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 ...
130 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 ...
380 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 ...
47 views

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

Consider the following matrix: ...
40 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
40 views

### ParallelTable and NC polynomial simplification

I use NC algebra to apply simplification rules on non commutative polynomials. I would like to treat a huge number of polynomials, ~200, so I would like to run these computations in parallel. However, ...
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 ...
62 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 ...
118 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
68 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, ...
22 views

### Confusing result when pattern matching a BlankSequence (__) to a list, then calling unary function on the list [duplicate]

The following makes sense to me: In = f[a, b] /. f[x__] -> x Out = Sequence[a, b] In = f[a, b] /. f[x__] -> {x} Out = {a, b} However, the ...
42 views

### How to enforce a rule on terms that are a combination of the original term?

I have an equation of the type Exp[a[r]] + Exp[a[r]/2] + Exp[-a[r]] And I want to rule Exp[a[r]] -> 1-2*m[r]/r so that it ...
1 vote
62 views

### How to use a rule and its derivative on an equation?

I generated a very simple rule that is of the type {a -> 0, a -> 0, a -> 8/3*pi} And I want to impose this set of rules on an equation. The ...
264 views

### Add the values in the rule

{ a -> 1, a -> 2, b -> 3, b -> 4 } You can see that both a and b have two values, so how do I add these two vaule?Like this ...
72 views

### how to understand the locality of variables in Mathematica

(in the first i should say may be the title is not very accurate) how to understand case like the following: ...
101 views

### Modify the start and end index of a function involving RuleDelayed

I have a list $\{a,b,c,d,e,f\}$ and an array of variables $\{y,y,y,y,y,y\}$. I want to use the RuleDelayed function represented by the symbol <...
75 views

### How to use rhs of a given list in a code? [closed]

I have the following Mathematica code: ...
1 vote
73 views