Alias for root of a polynomial
$begingroup$
I need to work with a variable $u$ such that $u^2 + u + 1 = 0$. I don't want to find a root of the polynomial $u^2 + u + 1$. Rather, I have to work with $u$ symbolically so that a (polynomial) expression in $u$ gets simplified using the equation $u^2 + u + 1 =0$.
For example, let
y = Series[u + 1 + u*x + x^2, {x, 0, 4}]
z = Series[u^2 + u^2*x + x^4, {x, 0, 4}]
Then, I'd expect
SeriesCoefficient[y+z, 0] = 0
SeriesCoefficient[y+z, 1] = -1
Thank you.
symbolic polynomials series-expansion
$endgroup$
add a comment |
$begingroup$
I need to work with a variable $u$ such that $u^2 + u + 1 = 0$. I don't want to find a root of the polynomial $u^2 + u + 1$. Rather, I have to work with $u$ symbolically so that a (polynomial) expression in $u$ gets simplified using the equation $u^2 + u + 1 =0$.
For example, let
y = Series[u + 1 + u*x + x^2, {x, 0, 4}]
z = Series[u^2 + u^2*x + x^4, {x, 0, 4}]
Then, I'd expect
SeriesCoefficient[y+z, 0] = 0
SeriesCoefficient[y+z, 1] = -1
Thank you.
symbolic polynomials series-expansion
$endgroup$
$begingroup$
I'm a Python/R user, this is unintelligible to me, can you explain without Mathematica jargon please?
$endgroup$
– smci
May 14 at 5:51
add a comment |
$begingroup$
I need to work with a variable $u$ such that $u^2 + u + 1 = 0$. I don't want to find a root of the polynomial $u^2 + u + 1$. Rather, I have to work with $u$ symbolically so that a (polynomial) expression in $u$ gets simplified using the equation $u^2 + u + 1 =0$.
For example, let
y = Series[u + 1 + u*x + x^2, {x, 0, 4}]
z = Series[u^2 + u^2*x + x^4, {x, 0, 4}]
Then, I'd expect
SeriesCoefficient[y+z, 0] = 0
SeriesCoefficient[y+z, 1] = -1
Thank you.
symbolic polynomials series-expansion
$endgroup$
I need to work with a variable $u$ such that $u^2 + u + 1 = 0$. I don't want to find a root of the polynomial $u^2 + u + 1$. Rather, I have to work with $u$ symbolically so that a (polynomial) expression in $u$ gets simplified using the equation $u^2 + u + 1 =0$.
For example, let
y = Series[u + 1 + u*x + x^2, {x, 0, 4}]
z = Series[u^2 + u^2*x + x^4, {x, 0, 4}]
Then, I'd expect
SeriesCoefficient[y+z, 0] = 0
SeriesCoefficient[y+z, 1] = -1
Thank you.
symbolic polynomials series-expansion
symbolic polynomials series-expansion
asked May 13 at 15:08
MyathMyath
1423
1423
$begingroup$
I'm a Python/R user, this is unintelligible to me, can you explain without Mathematica jargon please?
$endgroup$
– smci
May 14 at 5:51
add a comment |
$begingroup$
I'm a Python/R user, this is unintelligible to me, can you explain without Mathematica jargon please?
$endgroup$
– smci
May 14 at 5:51
$begingroup$
I'm a Python/R user, this is unintelligible to me, can you explain without Mathematica jargon please?
$endgroup$
– smci
May 14 at 5:51
$begingroup$
I'm a Python/R user, this is unintelligible to me, can you explain without Mathematica jargon please?
$endgroup$
– smci
May 14 at 5:51
add a comment |
3 Answers
3
active
oldest
votes
$begingroup$
You can use Assumptions
assume = u^2 + u + 1 == 0;
y = Series[u + 1 + u*x + x^2, {x, 0, 4}];
z = Series[u^2 + u^2*x + x^4, {x, 0, 4}];
Assuming[assume, SeriesCoefficient[y + z, 0] // Simplify]
(* 0 *)
Assuming[assume, SeriesCoefficient[y + z, 1] // Simplify]
(* -1 *)
$endgroup$
$begingroup$
Withy = Series[u + 1 + x^2, {x, 0, 4}]
your method producesu^2
forAssuming[assume, SeriesCoefficient[y + z, 1] // Simplify]
. I think the expected result is-1-u
.
$endgroup$
– Carl Woll
May 13 at 20:26
$begingroup$
@CarlWoll - I do not know what is "expected", butLeafCount /@ {u^2, -1 - u}
indicates thatu^2
is simpler in the usual sense.
$endgroup$
– Bob Hanlon
May 13 at 20:30
add a comment |
$begingroup$
You can give u
an UpValues
for Power
:
u /: u^n_Integer := Block[{u},
If[n<0,
PolynomialMod[(-u-1)^-n, 1+u+u^2],
PolynomialMod[u^n,1+u+u^2]
]
]
Then:
y = Series[u + 1 + u x + x^2, {x, 0, 4}];
z = Series[u^2 + u^2 x + x^4,{x, 0, 4}];
and:
y + z //TeXForm
$-x+x^2+x^4+Oleft(x^5right)$
$endgroup$
$begingroup$
Carl, what does theBlock[{u}, ...]
do here? I think I'm still confused about the usage ofBlock
.
$endgroup$
– Roman
May 13 at 15:46
1
$begingroup$
@Roman The Block is needed so that recursion is avoided (preventing evaluation of u^n on the right hand side)
$endgroup$
– Carl Woll
May 13 at 16:00
$begingroup$
I get Iteration limit exceeded with $1/u$.
$endgroup$
– Myath
May 13 at 17:40
add a comment |
$begingroup$
The simplest methods are usually the best. I suggest
rule = {u^n_ :> {1, u, -1 - u}[[Mod[n, 3] + 1]]};
y + z /. rule
which will do what you want. Also, the following code
Table[u^n, {n, 0, 6}] /. rule
demonstrates that $u^3 = 1$ and the powers of $u$ are periodic with period $3$.
$endgroup$
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "387"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f198272%2falias-for-root-of-a-polynomial%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
You can use Assumptions
assume = u^2 + u + 1 == 0;
y = Series[u + 1 + u*x + x^2, {x, 0, 4}];
z = Series[u^2 + u^2*x + x^4, {x, 0, 4}];
Assuming[assume, SeriesCoefficient[y + z, 0] // Simplify]
(* 0 *)
Assuming[assume, SeriesCoefficient[y + z, 1] // Simplify]
(* -1 *)
$endgroup$
$begingroup$
Withy = Series[u + 1 + x^2, {x, 0, 4}]
your method producesu^2
forAssuming[assume, SeriesCoefficient[y + z, 1] // Simplify]
. I think the expected result is-1-u
.
$endgroup$
– Carl Woll
May 13 at 20:26
$begingroup$
@CarlWoll - I do not know what is "expected", butLeafCount /@ {u^2, -1 - u}
indicates thatu^2
is simpler in the usual sense.
$endgroup$
– Bob Hanlon
May 13 at 20:30
add a comment |
$begingroup$
You can use Assumptions
assume = u^2 + u + 1 == 0;
y = Series[u + 1 + u*x + x^2, {x, 0, 4}];
z = Series[u^2 + u^2*x + x^4, {x, 0, 4}];
Assuming[assume, SeriesCoefficient[y + z, 0] // Simplify]
(* 0 *)
Assuming[assume, SeriesCoefficient[y + z, 1] // Simplify]
(* -1 *)
$endgroup$
$begingroup$
Withy = Series[u + 1 + x^2, {x, 0, 4}]
your method producesu^2
forAssuming[assume, SeriesCoefficient[y + z, 1] // Simplify]
. I think the expected result is-1-u
.
$endgroup$
– Carl Woll
May 13 at 20:26
$begingroup$
@CarlWoll - I do not know what is "expected", butLeafCount /@ {u^2, -1 - u}
indicates thatu^2
is simpler in the usual sense.
$endgroup$
– Bob Hanlon
May 13 at 20:30
add a comment |
$begingroup$
You can use Assumptions
assume = u^2 + u + 1 == 0;
y = Series[u + 1 + u*x + x^2, {x, 0, 4}];
z = Series[u^2 + u^2*x + x^4, {x, 0, 4}];
Assuming[assume, SeriesCoefficient[y + z, 0] // Simplify]
(* 0 *)
Assuming[assume, SeriesCoefficient[y + z, 1] // Simplify]
(* -1 *)
$endgroup$
You can use Assumptions
assume = u^2 + u + 1 == 0;
y = Series[u + 1 + u*x + x^2, {x, 0, 4}];
z = Series[u^2 + u^2*x + x^4, {x, 0, 4}];
Assuming[assume, SeriesCoefficient[y + z, 0] // Simplify]
(* 0 *)
Assuming[assume, SeriesCoefficient[y + z, 1] // Simplify]
(* -1 *)
answered May 13 at 18:15
Bob HanlonBob Hanlon
62.8k33599
62.8k33599
$begingroup$
Withy = Series[u + 1 + x^2, {x, 0, 4}]
your method producesu^2
forAssuming[assume, SeriesCoefficient[y + z, 1] // Simplify]
. I think the expected result is-1-u
.
$endgroup$
– Carl Woll
May 13 at 20:26
$begingroup$
@CarlWoll - I do not know what is "expected", butLeafCount /@ {u^2, -1 - u}
indicates thatu^2
is simpler in the usual sense.
$endgroup$
– Bob Hanlon
May 13 at 20:30
add a comment |
$begingroup$
Withy = Series[u + 1 + x^2, {x, 0, 4}]
your method producesu^2
forAssuming[assume, SeriesCoefficient[y + z, 1] // Simplify]
. I think the expected result is-1-u
.
$endgroup$
– Carl Woll
May 13 at 20:26
$begingroup$
@CarlWoll - I do not know what is "expected", butLeafCount /@ {u^2, -1 - u}
indicates thatu^2
is simpler in the usual sense.
$endgroup$
– Bob Hanlon
May 13 at 20:30
$begingroup$
With
y = Series[u + 1 + x^2, {x, 0, 4}]
your method produces u^2
for Assuming[assume, SeriesCoefficient[y + z, 1] // Simplify]
. I think the expected result is -1-u
.$endgroup$
– Carl Woll
May 13 at 20:26
$begingroup$
With
y = Series[u + 1 + x^2, {x, 0, 4}]
your method produces u^2
for Assuming[assume, SeriesCoefficient[y + z, 1] // Simplify]
. I think the expected result is -1-u
.$endgroup$
– Carl Woll
May 13 at 20:26
$begingroup$
@CarlWoll - I do not know what is "expected", but
LeafCount /@ {u^2, -1 - u}
indicates that u^2
is simpler in the usual sense.$endgroup$
– Bob Hanlon
May 13 at 20:30
$begingroup$
@CarlWoll - I do not know what is "expected", but
LeafCount /@ {u^2, -1 - u}
indicates that u^2
is simpler in the usual sense.$endgroup$
– Bob Hanlon
May 13 at 20:30
add a comment |
$begingroup$
You can give u
an UpValues
for Power
:
u /: u^n_Integer := Block[{u},
If[n<0,
PolynomialMod[(-u-1)^-n, 1+u+u^2],
PolynomialMod[u^n,1+u+u^2]
]
]
Then:
y = Series[u + 1 + u x + x^2, {x, 0, 4}];
z = Series[u^2 + u^2 x + x^4,{x, 0, 4}];
and:
y + z //TeXForm
$-x+x^2+x^4+Oleft(x^5right)$
$endgroup$
$begingroup$
Carl, what does theBlock[{u}, ...]
do here? I think I'm still confused about the usage ofBlock
.
$endgroup$
– Roman
May 13 at 15:46
1
$begingroup$
@Roman The Block is needed so that recursion is avoided (preventing evaluation of u^n on the right hand side)
$endgroup$
– Carl Woll
May 13 at 16:00
$begingroup$
I get Iteration limit exceeded with $1/u$.
$endgroup$
– Myath
May 13 at 17:40
add a comment |
$begingroup$
You can give u
an UpValues
for Power
:
u /: u^n_Integer := Block[{u},
If[n<0,
PolynomialMod[(-u-1)^-n, 1+u+u^2],
PolynomialMod[u^n,1+u+u^2]
]
]
Then:
y = Series[u + 1 + u x + x^2, {x, 0, 4}];
z = Series[u^2 + u^2 x + x^4,{x, 0, 4}];
and:
y + z //TeXForm
$-x+x^2+x^4+Oleft(x^5right)$
$endgroup$
$begingroup$
Carl, what does theBlock[{u}, ...]
do here? I think I'm still confused about the usage ofBlock
.
$endgroup$
– Roman
May 13 at 15:46
1
$begingroup$
@Roman The Block is needed so that recursion is avoided (preventing evaluation of u^n on the right hand side)
$endgroup$
– Carl Woll
May 13 at 16:00
$begingroup$
I get Iteration limit exceeded with $1/u$.
$endgroup$
– Myath
May 13 at 17:40
add a comment |
$begingroup$
You can give u
an UpValues
for Power
:
u /: u^n_Integer := Block[{u},
If[n<0,
PolynomialMod[(-u-1)^-n, 1+u+u^2],
PolynomialMod[u^n,1+u+u^2]
]
]
Then:
y = Series[u + 1 + u x + x^2, {x, 0, 4}];
z = Series[u^2 + u^2 x + x^4,{x, 0, 4}];
and:
y + z //TeXForm
$-x+x^2+x^4+Oleft(x^5right)$
$endgroup$
You can give u
an UpValues
for Power
:
u /: u^n_Integer := Block[{u},
If[n<0,
PolynomialMod[(-u-1)^-n, 1+u+u^2],
PolynomialMod[u^n,1+u+u^2]
]
]
Then:
y = Series[u + 1 + u x + x^2, {x, 0, 4}];
z = Series[u^2 + u^2 x + x^4,{x, 0, 4}];
and:
y + z //TeXForm
$-x+x^2+x^4+Oleft(x^5right)$
edited May 13 at 17:49
answered May 13 at 15:34
Carl WollCarl Woll
81.4k3105209
81.4k3105209
$begingroup$
Carl, what does theBlock[{u}, ...]
do here? I think I'm still confused about the usage ofBlock
.
$endgroup$
– Roman
May 13 at 15:46
1
$begingroup$
@Roman The Block is needed so that recursion is avoided (preventing evaluation of u^n on the right hand side)
$endgroup$
– Carl Woll
May 13 at 16:00
$begingroup$
I get Iteration limit exceeded with $1/u$.
$endgroup$
– Myath
May 13 at 17:40
add a comment |
$begingroup$
Carl, what does theBlock[{u}, ...]
do here? I think I'm still confused about the usage ofBlock
.
$endgroup$
– Roman
May 13 at 15:46
1
$begingroup$
@Roman The Block is needed so that recursion is avoided (preventing evaluation of u^n on the right hand side)
$endgroup$
– Carl Woll
May 13 at 16:00
$begingroup$
I get Iteration limit exceeded with $1/u$.
$endgroup$
– Myath
May 13 at 17:40
$begingroup$
Carl, what does the
Block[{u}, ...]
do here? I think I'm still confused about the usage of Block
.$endgroup$
– Roman
May 13 at 15:46
$begingroup$
Carl, what does the
Block[{u}, ...]
do here? I think I'm still confused about the usage of Block
.$endgroup$
– Roman
May 13 at 15:46
1
1
$begingroup$
@Roman The Block is needed so that recursion is avoided (preventing evaluation of u^n on the right hand side)
$endgroup$
– Carl Woll
May 13 at 16:00
$begingroup$
@Roman The Block is needed so that recursion is avoided (preventing evaluation of u^n on the right hand side)
$endgroup$
– Carl Woll
May 13 at 16:00
$begingroup$
I get Iteration limit exceeded with $1/u$.
$endgroup$
– Myath
May 13 at 17:40
$begingroup$
I get Iteration limit exceeded with $1/u$.
$endgroup$
– Myath
May 13 at 17:40
add a comment |
$begingroup$
The simplest methods are usually the best. I suggest
rule = {u^n_ :> {1, u, -1 - u}[[Mod[n, 3] + 1]]};
y + z /. rule
which will do what you want. Also, the following code
Table[u^n, {n, 0, 6}] /. rule
demonstrates that $u^3 = 1$ and the powers of $u$ are periodic with period $3$.
$endgroup$
add a comment |
$begingroup$
The simplest methods are usually the best. I suggest
rule = {u^n_ :> {1, u, -1 - u}[[Mod[n, 3] + 1]]};
y + z /. rule
which will do what you want. Also, the following code
Table[u^n, {n, 0, 6}] /. rule
demonstrates that $u^3 = 1$ and the powers of $u$ are periodic with period $3$.
$endgroup$
add a comment |
$begingroup$
The simplest methods are usually the best. I suggest
rule = {u^n_ :> {1, u, -1 - u}[[Mod[n, 3] + 1]]};
y + z /. rule
which will do what you want. Also, the following code
Table[u^n, {n, 0, 6}] /. rule
demonstrates that $u^3 = 1$ and the powers of $u$ are periodic with period $3$.
$endgroup$
The simplest methods are usually the best. I suggest
rule = {u^n_ :> {1, u, -1 - u}[[Mod[n, 3] + 1]]};
y + z /. rule
which will do what you want. Also, the following code
Table[u^n, {n, 0, 6}] /. rule
demonstrates that $u^3 = 1$ and the powers of $u$ are periodic with period $3$.
edited May 13 at 21:58
AccidentalFourierTransform
5,45511142
5,45511142
answered May 13 at 18:09
SomosSomos
2,4151111
2,4151111
add a comment |
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f198272%2falias-for-root-of-a-polynomial%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
I'm a Python/R user, this is unintelligible to me, can you explain without Mathematica jargon please?
$endgroup$
– smci
May 14 at 5:51