Alias for root of a polynomial












4












$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.










share|improve this question









$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


















4












$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.










share|improve this question









$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
















4












4








4





$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.










share|improve this question









$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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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




















  • $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












3 Answers
3






active

oldest

votes


















4












$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 *)





share|improve this answer









$endgroup$













  • $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



















5












$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)$







share|improve this answer











$endgroup$













  • $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




    $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



















2












$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$.






share|improve this answer











$endgroup$














    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    4












    $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 *)





    share|improve this answer









    $endgroup$













    • $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
















    4












    $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 *)





    share|improve this answer









    $endgroup$













    • $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














    4












    4








    4





    $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 *)





    share|improve this answer









    $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 *)






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered May 13 at 18:15









    Bob HanlonBob Hanlon

    62.8k33599




    62.8k33599












    • $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$
      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$
    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











    5












    $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)$







    share|improve this answer











    $endgroup$













    • $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




      $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
















    5












    $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)$







    share|improve this answer











    $endgroup$













    • $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




      $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














    5












    5








    5





    $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)$







    share|improve this answer











    $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)$








    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited May 13 at 17:49

























    answered May 13 at 15:34









    Carl WollCarl Woll

    81.4k3105209




    81.4k3105209












    • $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




      $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






    • 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











    2












    $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$.






    share|improve this answer











    $endgroup$


















      2












      $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$.






      share|improve this answer











      $endgroup$
















        2












        2








        2





        $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$.






        share|improve this answer











        $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$.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited May 13 at 21:58









        AccidentalFourierTransform

        5,45511142




        5,45511142










        answered May 13 at 18:09









        SomosSomos

        2,4151111




        2,4151111






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            He _____ here since 1970 . Answer needed [closed]What does “since he was so high” mean?Meaning of “catch birds for”?How do I ensure “since” takes the meaning I want?“Who cares here” meaningWhat does “right round toward” mean?the time tense (had now been detected)What does the phrase “ring around the roses” mean here?Correct usage of “visited upon”Meaning of “foiled rail sabotage bid”It was the third time I had gone to Rome or It is the third time I had been to Rome

            Bunad

            Færeyskur hestur Heimild | Tengill | Tilvísanir | LeiðsagnarvalRossið - síða um færeyska hrossið á færeyskuGott ár hjá færeyska hestinum