Questions tagged [replacement]
The replacement tag has no usage guidance.
1,650
questions
0
votes
0
answers
50
views
Mathematica solve with conditions on constants differ from replace
I have been trying to solve some complicated linear equations in Mathematica, with variables $y_{i}$, and constants $a, f_{j}$ where $0\leq j\leq10$. I only care about the case where $\sum_{i=1}^{10}...
4
votes
1
answer
127
views
How to write a rule that matches alternatives but return one of them always?
Consider the following rule:
$rule={"Period ID"|p:"Period":>p};
This rule will match ...
3
votes
1
answer
105
views
How to `Collect` where `var` is one expression?
Edit:
Clear["Global`*"];
expr1 = (a + c - b + 1)^3 + (-b + a + c + 2)^4 // Expand
For test case expr1, this is the ...
0
votes
0
answers
37
views
Replacement not working as desired [duplicate]
The following replacement works fine
ReplaceAll[1/F[x],F[x]->y]
(*1/y*)
but this doesn't
...
6
votes
4
answers
343
views
Transform sequence into ragged list
I want to transform
seq = {x, 1, 2, x, 3, x, 4, 5, y, y, 67, y};
into
{1, 2, {3, {4, 5}}, 67}
The only way I found is rather ...
0
votes
1
answer
60
views
Why does Mathematica fail to substitute some terms in an expression but not others?
I have an expression of the form:
$A-\frac{e^{-t/t_1} \; a \; b}{c \; t_1} \; U_1 - \frac{e^{-t/t_2} \; a \; d}{c \; t_2} \; U_2 -\frac{e^{-t/t_2} \; a \; e}{c \; t_2} \; U_2 - \frac{e^{-t/t_3} \; a \;...
4
votes
4
answers
297
views
Replacing string values with one of the sequence-functions
Given the following list of rules (which might contain duplicate
keys), I want to replace the string values with the first preceding numerical value.
...
1
vote
0
answers
41
views
Why list of replacement does not work in the following example? [closed]
I want to replace a long list but in the following format, but it does not work:
(Aa + Bb + Cc) /. {{Aa, Bb, Cc} -> {x + 2, y + 2, z + 2}}
1
vote
0
answers
56
views
Replacement rule runs for a long time [duplicate]
I have a simple expression that reads (some expression in b) q^(8/3):
...
1
vote
1
answer
39
views
How to do this replacement? Match the variable, but not the function [duplicate]
I have the following expression:
$$\frac{\left(-2 \lambda \lambda [\theta ]+\lambda [\theta ]^2+\lambda ^2+\lambda \right) \lambda '[\theta ]^2}{\lambda [\theta ]^2}$$
I want to replace every ...
1
vote
0
answers
40
views
Difference in pattern matching between Cases and ReplaceAll (Already searching at all levels and heads)
Why is there a difference between the pattern matching between Cases and ReplaceAll in the following:
...
1
vote
0
answers
57
views
Random replacement in array
In the spirit of this interesting article of Stephen Wolfram I also decided to study some issues related to mutations.
I’m working with simple {0,1} arrays and I’ve ...
1
vote
1
answer
77
views
How to replace C[1] in solutions of trigonometric equations into k?
This is my code
Table[{HoldForm[Cos[3 x + 2 Pi/5]] == Sqrt[i]/2,
Reduce[Sin[2 x] == Sqrt[i]/2, x, Reals]}, {i, 0, 4}]
How can I replace C1 to ...
3
votes
2
answers
102
views
Multiple replacements in a long expression
Why does the replace /. not work on the second argument in the following expression:
...
0
votes
0
answers
28
views
Time Complexity of Multiway System
I was wondering what the time complexity for the implementation of a Multiway System would be. For reference, we can implement a MultiwaySystem using the Resource Function
...