Questions tagged [replacement]

The tag has no usage guidance.

1,380 questions
Filter by
Sorted by
Tagged with
29 views

Remove empty TextCell[] from numerical expression

I am evaluating an expression like this: ...
68 views

Define/store individual elements of Table output for back-substitution

At its core, mine is a very simple communication error between me and Mathematica that I haven't been able to crack, so I do apologise if it seems embarassingly inane. Please consider the following ...
77 views

Replacing function by another one each time it appears

I have expression involving Cos of some parameters. I would like to replace those Cos by their infinite series each time they do appear. I tried the following which doesn't work: ...
232 views

Given x ⊕ x =5,x ⊕ (y ⊕ z) = (x ⊕ y)+z-5 what is 2009 ⊕ 1949

There is an operation "⊕" that satisfies $x ⊕ x =5$ $x ⊕ (y ⊕ z) = (x ⊕ y)+z-5$ what is 2009 ⊕ 1949? I think it is feasible to solve with Mathematica, but my code doesn't give a useful ...
66 views

Change Replace Rule with Function Input

I am trying to create a function that takes in an input $\mu$ and place that input into the replace rule for a numerical integration, as seen in the code below: ...
116 views

Lévy C curve fractal from a substitution systems in NKS book p.190?

How can I make the geometrical transformation described in the page 190 in the New Kind of Science book by Stephen Wolfram to produce the fractal pattern? https://www.wolframscience.com/nks/p190--...
92 views

Substitution of expressions in a symbolic expression

I define tables of symbolic variables in the following form (for convenience) ...
60 views

Renaming expressions dynamically in Mathematica

I am trying to write a statement that will create a new positionVector as I parse through a matrix. What I am trying to accomplish would look something like this, For[i = 1, i <= vectorlength, i++ ...
517 views

Replace sum x+y+z in expressions like 2x+3y+z

Related threads replacing-a-sum-of-expressions and Replace a sum of squared variables by a new squared variable Given the identity $x+y+z=p$ I'd like to simplify the generic expression $$kx+ly+mz$$ ...
116 views

Creating an Array with Subscripts and Superscripts

I would like to figure out how to construct an array using subscripts and superscripts based on the following info: ...
37 views

Are not rules applied in succession?

I am trying this: ...
65 views

Only Reals Rules

I have a huge array of rules with many variables, such as ...
87 views

commutator between tensor products

I am interested in some quantum mechanical calculations in Mathematica. I am working with a tensor product of Hilbert spaces $\mathcal H = \mathcal H_1\otimes \mathcal H_2$. I would like to implement ...
212 views

Replace in Mathematica [closed]

I have: $$X=Z+22*Y$$ $$Y=P$$ Edited: Is there a way to replace $Y$ in the first expression using Mathematica? I tried Replace and it's not giving the desired result. Can I replace both Z and Y at the ...
76 views

My rule does not do anything (understandably)

I want a rule that would transform, for example, And[i,F[j,k],l,G[m,F[j,k],n],p] into And[i,F[j,k],l,G[m,T,n],p], where ...
211 views

How to replace only the isolated variable x

I want to replace the variable x in the result, not x in unrelated x[i]. ...
41 views

Why does DifferenceRoot evaluate only in this table?

I would like to use a complicated function containing DifferenceRoot as a replacement rule, but somehow it evaluates only in ...
75 views

How to plot a function using a table particular values

I would like to plot the following function in terms of kR, but using specific different values, I think the best easy way is using a Table. This is a common useful problem to explore numerical the ...
79 views

I am trying to carry out some operations on the elements of dataset2, which is an 11 x 14 x 6 dimensional array: I have a function, ...
111 views

Pattern matching involving a sum of wildcards

I am trying to implement the following substitution to an expression in Mathematica: ti den[a-ti] -> -1 + a den[a-ti] where ...
92 views

Replace Condition in Replacement Rules

In finding an answer to my other question, I'm finding myself needing to manipulate the conditions imposed on replacement rules, but this is proving to be a little difficult. In particular, how ...
45 views

When numbers plugged in - this expression evaluates to zero, but otherwise will not evaluate to zero

I have the following code: ...
62 views

ReplaceAll with a list of parameters [closed]

Trying to ReplaceAll with a list of parameters, but I can't see how to do it properly: ...
54 views

How to protect the expansion of exponent while applyting rules

I am trying to separate/split an expression (consisting of polynomials) to a list. However I want to keep the exponents intact. Here is an example: ...
222 views

Mathematica can't replace integer multiple of 2 in power

I have some terms contain ww=a+a^2+a^6+a^-4 where (a^2)^p_. -> -dx[p] Exp[-x[p]] x^2 but Mathematica only replace power 2 ...
427 views

Applying a function to every item in a column of a matrix

A problem that arises more often than I care for is that I want to modify specific elements nested lists. Examples may be wanting to add 1 to the second value, get ...
58 views

Why does Replace /. not get evaluated in this formula?

Learning the wolfram Language, in section 32 "The Wolfram Language" // Characters[#]& /. Alternatives @@Characters["aeiou"] -> Nothing ...
55 views

Simplification and patterns

I have a very simple simplification to make, where I need to do a replacement but the pattern matching seems slightly awkward. I would like to simplify: ...
164 views

Conditional replacement element-wise

I have a $4\times 4$ matrix (symbolic). It has a variable, say jj, which should be $1$ for diagonal and $0$ for non-diagonal entries. I need to write a replacement ...
53 views

ReplaceAll with named pattern [closed]

If k is unassigned, this yields {a, b, c}: ...
35 views

Difference in pattern matching between Cases and ReplaceAll

I don't understand why there is a difference in the pattern matching between x a /. coef_*x^pow_. :> {pow, coef} and ...
61 views

How to get the result in terms of a previously defined expression?

Say I have a vector X[n_] := Table[Subscript[x, i], {i, 1, n}] and a matrix of connections: ...
124 views

How can I get the progressive application of list of rules?

I have a very long list of rules, and using this list of rules I want to see how some elements evolve as I successively apply the next rules on the previous rule. Here is the simpler version of my ...
100 views

Turn definitions into rules

I know that this seems to be unnecessary, but here I have a bunch of assignments, like around 50, and I want to create rules for all these to have the freedom to apply these rules only on certain ...
165 views

How to solve for y for a set of implicit (in x and y) linear equations for use in Plot?

From a matrix m={{1, 1}, {-1, 1}}, a vector b={1, 2}, and a list of variables vars={x,y} we ...
33 views

Is there a better syntax to obtain the derivative of a function as a function/operator? (e.g. for simple plotting of derivtives of functions, etc.)

When trying to plot a derivative of a function, (I take Sin as a simple example), the naive approach ...
97 views

Replace multiple variables using a list?

I want to calculate sum of derivatives of expression F = Exp[(x*z - 1) f*b + (x - 1) (1 - f) b] from n-th to (n-k)-th, say k=4. The dummy way which works is: ...
50 views

31 views

Error: Root::npoly: not a polynomial in #1 [closed]

I have a $45\times 45$ matrix $H$ and its elements depend on $Ca$. I want to find its eigenvalues (which will also depend on $Ca$). I do this using: ...
49 views

How to define a series of substituting rules?

suppose I have a long list of many variables: alist = { u, v, w, ... }. At some point, I have another combination of variables depending on { u, v, w, etc.},e.g., alpha = 2 * u + v beta = v + w^2. And ...
294 views

How to use each replacement only once in a list of replacements

I have a list of replacements and some list they are acting on. However, some RHS of the replacements rules are identical (the LHS is not). I want to use those rules one after another (perhaps cycling ...
44 views

How to match a formula in different level

Solve[4 n^4 + 4 n + 3 == 0] The result has many $$\sqrt{\frac{1}{2} \left(1+i \sqrt{3}\right)}$$ so I want to replace them with a letter, for example , ...
55 views

Swap two numbers - but only in a particular context

I have a list of terms such as {2*s[1,2]^2, 3*s[3,5]^4, ...} and I would like to have a replacement that swaps $2 \leftrightarrow 4, 3 \leftrightarrow 1$, but only ...
28 views

How to define the correct replacement

I would like to replace a specific expression denrule={Den1[vk]^e1_*Den2[l]^e2_*Den3[k+l-v*\[Omega]]^e3_*Den4[k]^e4_*Den5[kl]^e5_->j[MI,e1,e2,e3,-e4,-e5]}; The ...
78 views

How do I make a substitution to an expression inside a derivative? [duplicate]

Pardon if I didn't ask the question correctly. Still trying to figure out the language. I have the following expression: $$energy=\frac{1}{2}R_s^{'}[t]^2==\frac{4}{3}G\pi\rho R_s[t]^2$$ ...
77 views

Generate a list of rules from two rules

I have two lists: a = {a1,a2,a3} b = {b1,b2,b3} and I want to generate a list of replacement rules ...
I have a question that may sound stupid and have an easy answer - but I currently do not see it. I have defined a function of four variables, $f[a,b,c,d]=...$, in what I think is correct Mathematica ...