Wrestling with substitution rules
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
Summary
I am struggling with substitution rules.
Example
Here are several cases which are problematic:
Clear[a,ñ];
a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2 /. a + b -> ñ
Actual result:
1 + a + 2 b, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2
Desired result:
1 + ñ + b, -ñ, 2 ñ, ñ^2
Question
Currently, the rule is permuted for every case, e.g.
2 a + 2 b -> 2ñ
Can the alpha substitution rule be generalized That, is there a single rule to handle all cases?
replacement rule
add a comment |Â
up vote
1
down vote
favorite
Summary
I am struggling with substitution rules.
Example
Here are several cases which are problematic:
Clear[a,ñ];
a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2 /. a + b -> ñ
Actual result:
1 + a + 2 b, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2
Desired result:
1 + ñ + b, -ñ, 2 ñ, ñ^2
Question
Currently, the rule is permuted for every case, e.g.
2 a + 2 b -> 2ñ
Can the alpha substitution rule be generalized That, is there a single rule to handle all cases?
replacement rule
You mean: "One to rule them all"? ;)
â Henrik Schumacher
1 hour ago
UsePolynomialReduce
to obtain algebraic "substitutions".In[208]:= PolynomialReduce[a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2, a + b - alpha, a, b][[All, 2]] Out[208]= 1 + alpha + b, -alpha, 2 alpha, alpha^2
â Daniel Lichtblau
46 mins ago
1
Generally, to apply a relationship broadly, write the corresponding rule such that the LHS of the rule is as simple as possible, e.g., solution posted by @HenrikSchumacher. Since rules are applied to the structure of the internal (FullForm) representation, this will result in the highest number of matches with the LHS.
â Bob Hanlon
23 mins ago
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Summary
I am struggling with substitution rules.
Example
Here are several cases which are problematic:
Clear[a,ñ];
a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2 /. a + b -> ñ
Actual result:
1 + a + 2 b, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2
Desired result:
1 + ñ + b, -ñ, 2 ñ, ñ^2
Question
Currently, the rule is permuted for every case, e.g.
2 a + 2 b -> 2ñ
Can the alpha substitution rule be generalized That, is there a single rule to handle all cases?
replacement rule
Summary
I am struggling with substitution rules.
Example
Here are several cases which are problematic:
Clear[a,ñ];
a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2 /. a + b -> ñ
Actual result:
1 + a + 2 b, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2
Desired result:
1 + ñ + b, -ñ, 2 ñ, ñ^2
Question
Currently, the rule is permuted for every case, e.g.
2 a + 2 b -> 2ñ
Can the alpha substitution rule be generalized That, is there a single rule to handle all cases?
replacement rule
replacement rule
edited 1 hour ago
Henrik Schumacher
43.9k263129
43.9k263129
asked 1 hour ago
dantopa
46928
46928
You mean: "One to rule them all"? ;)
â Henrik Schumacher
1 hour ago
UsePolynomialReduce
to obtain algebraic "substitutions".In[208]:= PolynomialReduce[a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2, a + b - alpha, a, b][[All, 2]] Out[208]= 1 + alpha + b, -alpha, 2 alpha, alpha^2
â Daniel Lichtblau
46 mins ago
1
Generally, to apply a relationship broadly, write the corresponding rule such that the LHS of the rule is as simple as possible, e.g., solution posted by @HenrikSchumacher. Since rules are applied to the structure of the internal (FullForm) representation, this will result in the highest number of matches with the LHS.
â Bob Hanlon
23 mins ago
add a comment |Â
You mean: "One to rule them all"? ;)
â Henrik Schumacher
1 hour ago
UsePolynomialReduce
to obtain algebraic "substitutions".In[208]:= PolynomialReduce[a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2, a + b - alpha, a, b][[All, 2]] Out[208]= 1 + alpha + b, -alpha, 2 alpha, alpha^2
â Daniel Lichtblau
46 mins ago
1
Generally, to apply a relationship broadly, write the corresponding rule such that the LHS of the rule is as simple as possible, e.g., solution posted by @HenrikSchumacher. Since rules are applied to the structure of the internal (FullForm) representation, this will result in the highest number of matches with the LHS.
â Bob Hanlon
23 mins ago
You mean: "One to rule them all"? ;)
â Henrik Schumacher
1 hour ago
You mean: "One to rule them all"? ;)
â Henrik Schumacher
1 hour ago
Use
PolynomialReduce
to obtain algebraic "substitutions". In[208]:= PolynomialReduce[a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2, a + b - alpha, a, b][[All, 2]] Out[208]= 1 + alpha + b, -alpha, 2 alpha, alpha^2
â Daniel Lichtblau
46 mins ago
Use
PolynomialReduce
to obtain algebraic "substitutions". In[208]:= PolynomialReduce[a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2, a + b - alpha, a, b][[All, 2]] Out[208]= 1 + alpha + b, -alpha, 2 alpha, alpha^2
â Daniel Lichtblau
46 mins ago
1
1
Generally, to apply a relationship broadly, write the corresponding rule such that the LHS of the rule is as simple as possible, e.g., solution posted by @HenrikSchumacher. Since rules are applied to the structure of the internal (FullForm) representation, this will result in the highest number of matches with the LHS.
â Bob Hanlon
23 mins ago
Generally, to apply a relationship broadly, write the corresponding rule such that the LHS of the rule is as simple as possible, e.g., solution posted by @HenrikSchumacher. Since rules are applied to the structure of the internal (FullForm) representation, this will result in the highest number of matches with the LHS.
â Bob Hanlon
23 mins ago
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
3
down vote
a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2 /. a -> ñ - b // Simplify
1 + b + ñ, -ñ, 2 ñ, ñ^2
add a comment |Â
up vote
2
down vote
Also
Simplify[a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2, a + b == ñ]
1 + b + ñ, -ñ, 2 ñ, ñ^2
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2 /. a -> ñ - b // Simplify
1 + b + ñ, -ñ, 2 ñ, ñ^2
add a comment |Â
up vote
3
down vote
a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2 /. a -> ñ - b // Simplify
1 + b + ñ, -ñ, 2 ñ, ñ^2
add a comment |Â
up vote
3
down vote
up vote
3
down vote
a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2 /. a -> ñ - b // Simplify
1 + b + ñ, -ñ, 2 ñ, ñ^2
a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2 /. a -> ñ - b // Simplify
1 + b + ñ, -ñ, 2 ñ, ñ^2
answered 1 hour ago
Henrik Schumacher
43.9k263129
43.9k263129
add a comment |Â
add a comment |Â
up vote
2
down vote
Also
Simplify[a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2, a + b == ñ]
1 + b + ñ, -ñ, 2 ñ, ñ^2
add a comment |Â
up vote
2
down vote
Also
Simplify[a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2, a + b == ñ]
1 + b + ñ, -ñ, 2 ñ, ñ^2
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Also
Simplify[a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2, a + b == ñ]
1 + b + ñ, -ñ, 2 ñ, ñ^2
Also
Simplify[a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2, a + b == ñ]
1 + b + ñ, -ñ, 2 ñ, ñ^2
answered 43 mins ago
kglr
169k8192396
169k8192396
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f185287%2fwrestling-with-substitution-rules%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
You mean: "One to rule them all"? ;)
â Henrik Schumacher
1 hour ago
Use
PolynomialReduce
to obtain algebraic "substitutions".In[208]:= PolynomialReduce[a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2, a + b - alpha, a, b][[All, 2]] Out[208]= 1 + alpha + b, -alpha, 2 alpha, alpha^2
â Daniel Lichtblau
46 mins ago
1
Generally, to apply a relationship broadly, write the corresponding rule such that the LHS of the rule is as simple as possible, e.g., solution posted by @HenrikSchumacher. Since rules are applied to the structure of the internal (FullForm) representation, this will result in the highest number of matches with the LHS.
â Bob Hanlon
23 mins ago