Questions tagged [replacement]
The replacement tag has no summary.
1,713 questions
3
votes
1
answer
156
views
What, if any, is the list analogue of KeyValuePattern?
I am trying to understand the function of KeyValuePattern. According to the documentation,
KeyValuePattern[{patt1, ...}] is a ...
1
vote
0
answers
81
views
Replacement of I to -I not working [duplicate]
Let
$f(x) = A \exp(i k x) + B \exp (-i k x)$.
If we replace every $i$ by $-i$, we are supposed to get
$g(x) = A \exp(-i k x) + B \exp (i k x)$.
However, the Mathematica code does not work as expected.
...
1
vote
1
answer
102
views
Why is rule matching FiniteField not working? [closed]
I am introducing a rule:
$Post = # /. x_?NumericQ FiniteField[q_?PrimeQ] [s_] :> FiniteField[q] [x] FiniteField[q] [s] &;
But for some reason, upon ...
3
votes
1
answer
113
views
Replacing fraction (rational number) inside Hold
How can be a fraction inside Hold replaced?
Nothing of the following works:
...
2
votes
0
answers
92
views
How to define the derivative of variables inside an expression so chain rule can be correctly applied to the full expression
I don't use Mathematica as much and only use it for some specific tasks from time to time (mostly simplifying expressions and calculating integrals and derivatives).
Lets say I have an large ...
1
vote
0
answers
46
views
Strange behavior of Rule in a function [duplicate]
I found a confusing thing about Rule.
(*code 1*)
(a^2 /. i_^2 :> i) -> b
gives ...
6
votes
2
answers
230
views
How can I force reevaluation of Association values? [duplicate]
After switching from 13.2 to 14.3, I noticed that some behavior of Association has changed:
...
4
votes
3
answers
395
views
Why does this Association show its Head, and how do I make it evaluate?
Evaluating
<|"key" -> {<|"key" -> "val"|>}|> /. {<|stuff__|>} :> <|stuff|>
Produces
...
3
votes
2
answers
214
views
Usage of replacement
With a naive thought, it seems that rule as below can match in expr. However, it does not match. Could I know what mistake I ...
0
votes
0
answers
130
views
Repeated substitute shortened with "Map"
I have an expression e[x,y,z] and like to see all results when picking all independent variables from a fixed set of constants ...
2
votes
2
answers
147
views
How can I reduce the degree of a polynomial in two variables by substitution?
This is similar to the how-to-replace-variable-with-power question, but here it involves two variables with different power combinations.
This quesion arises from paper forward kinematics of the 6-6 ...
2
votes
3
answers
194
views
Removing unmatched elements from nested list after ReplaceAll
I'm doing some heavy symbolic calculations and for preliminary simple tests I need to replace all coefficients except some choosings, e.g.:
...
0
votes
2
answers
130
views
Why does a replacement rule fail for a custom defined function but works for a generic symbol?
I'm pretty new to Mathematica and I have a question about how to deal with replacement rules in presence of function definitions.
Basically I want to implement a mean/covariance calculator, in the ...
5
votes
1
answer
294
views
Understanding difference between {{{a}}} /. {x_} :> q[x] and {{{a}}} /. List -> q [closed]
Following Shifrin's "Mathematica Programming: an advanced introduction", pp. 93-94,
I entered
{{{a}}} /. {x_} :> q[x]
and I got, as expected by the ...
1
vote
2
answers
138
views
multivariate chain rule with Replace[] [closed]
f'[x] /. f -> (f[g[#]] &)
adopts the chain rule. Now I need df(r,$\theta$)/dr in x and y coordinates, hence transforming from polar to Cartesian coordinates,...