Why is this weird space appearing after my minus sign

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I'm using MathJax-Node to turn TeX maths equations into both MathML and SVG on my server. Mostly this works fine. But when I render Tupper's self-referential formula, a weird space appears after the second minus sign in the exponent: Rendered formula.



The space also appears on mathURL (which is where the above image comes from). When I examine the MathML generated, I can see that MathJax has explicitly inserted a mspace element.



The TeX I'm using is as follows:



frac12<leftlfloormodleft(leftlfloorfrac y17rightrfloor2^-17leftlfloor xrightrfloor-modleft(leftlfloor yrightrfloor,17right),2right)rightrfloor


Any idea what's going on here?










share|improve this question









New contributor




Sora2455 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 3




    Although this is not exactly a TeX question, but have you looked at the first mod? It is not about the minus sign, but rather the mod. The mod has, by design, a preceding quad space and an appending half quad space.
    – Ruixi Zhang
    1 hour ago















up vote
1
down vote

favorite












I'm using MathJax-Node to turn TeX maths equations into both MathML and SVG on my server. Mostly this works fine. But when I render Tupper's self-referential formula, a weird space appears after the second minus sign in the exponent: Rendered formula.



The space also appears on mathURL (which is where the above image comes from). When I examine the MathML generated, I can see that MathJax has explicitly inserted a mspace element.



The TeX I'm using is as follows:



frac12<leftlfloormodleft(leftlfloorfrac y17rightrfloor2^-17leftlfloor xrightrfloor-modleft(leftlfloor yrightrfloor,17right),2right)rightrfloor


Any idea what's going on here?










share|improve this question









New contributor




Sora2455 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 3




    Although this is not exactly a TeX question, but have you looked at the first mod? It is not about the minus sign, but rather the mod. The mod has, by design, a preceding quad space and an appending half quad space.
    – Ruixi Zhang
    1 hour ago













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I'm using MathJax-Node to turn TeX maths equations into both MathML and SVG on my server. Mostly this works fine. But when I render Tupper's self-referential formula, a weird space appears after the second minus sign in the exponent: Rendered formula.



The space also appears on mathURL (which is where the above image comes from). When I examine the MathML generated, I can see that MathJax has explicitly inserted a mspace element.



The TeX I'm using is as follows:



frac12<leftlfloormodleft(leftlfloorfrac y17rightrfloor2^-17leftlfloor xrightrfloor-modleft(leftlfloor yrightrfloor,17right),2right)rightrfloor


Any idea what's going on here?










share|improve this question









New contributor




Sora2455 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I'm using MathJax-Node to turn TeX maths equations into both MathML and SVG on my server. Mostly this works fine. But when I render Tupper's self-referential formula, a weird space appears after the second minus sign in the exponent: Rendered formula.



The space also appears on mathURL (which is where the above image comes from). When I examine the MathML generated, I can see that MathJax has explicitly inserted a mspace element.



The TeX I'm using is as follows:



frac12<leftlfloormodleft(leftlfloorfrac y17rightrfloor2^-17leftlfloor xrightrfloor-modleft(leftlfloor yrightrfloor,17right),2right)rightrfloor


Any idea what's going on here?







spacing math-operators






share|improve this question









New contributor




Sora2455 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Sora2455 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 1 hour ago









egreg

683k8418193065




683k8418193065






New contributor




Sora2455 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 1 hour ago









Sora2455

62




62




New contributor




Sora2455 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Sora2455 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Sora2455 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 3




    Although this is not exactly a TeX question, but have you looked at the first mod? It is not about the minus sign, but rather the mod. The mod has, by design, a preceding quad space and an appending half quad space.
    – Ruixi Zhang
    1 hour ago













  • 3




    Although this is not exactly a TeX question, but have you looked at the first mod? It is not about the minus sign, but rather the mod. The mod has, by design, a preceding quad space and an appending half quad space.
    – Ruixi Zhang
    1 hour ago








3




3




Although this is not exactly a TeX question, but have you looked at the first mod? It is not about the minus sign, but rather the mod. The mod has, by design, a preceding quad space and an appending half quad space.
– Ruixi Zhang
1 hour ago





Although this is not exactly a TeX question, but have you looked at the first mod? It is not about the minus sign, but rather the mod. The mod has, by design, a preceding quad space and an appending half quad space.
– Ruixi Zhang
1 hour ago











2 Answers
2






active

oldest

votes

















up vote
3
down vote













You're using “mod” as a math operator like “exp” or “sin”. The command mod is for notation such as



5 equiv 2 mod3


and the inserted space is obviously wanted here.



Use operatornamemod instead.



documentclassarticle
usepackageamsmath

begindocument

[
frac12<
leftlfloor
operatornamemodleft(
leftlfloorfracy17rightrfloor
2^-17lfloor xrfloor-operatornamemod(lfloor yrfloor,17),2
right)
rightrfloor
]

enddocument


I've removed useless (and wrong) left and right pairs.



enter image description here



It works equally well in MathJax (tested on Math.SE):



enter image description here






share|improve this answer





























    up vote
    3
    down vote













    Do you mean this:



    enter image description here



    documentclassarticle

    usepackagexintexpr

    % Tupper

    % q = floor(y/17)
    % r = mod(y, 17) (modulo for floor)

    % Tupper formula boils down to say:

    % bit (x, y) is ON <===> floor(q, 2**(17x+r)) is ODD

    % https://fr.wikipedia.org/wiki/Formule_autor%C3%A9f%C3%A9rente_de_Tupper

    % xintiiexpr notations

    % floored division is //
    % associated modulo is /: (or 'mod')
    % divmod(,) is both // and /: (as in Python)

    begindocument

    % 0 <= x < 106
    % k <= y < k + 17

    xintdefiivar TupperK :=
    960939379918958884971672962127852754715004339660129306651505519271702802395266
    424689642842174350718121267153782770623355993237280874144307891325963941337723
    487857735749823926629715517173716995165232890538221612403238855866184013235585
    136048828693337902491454229288667081096184496091705183454067827731551705405381
    627380967602565625016981482083418783163849115590225610003652351370343874461848
    378737238198224849863465033159410054974700593138339226497249461751545728366702
    369745461014655997933798537483143786841806593422227898388722980000748404719;

    setlengthunitlength1pt

    defparseTupperXY#1#2% #1 = x, #2=y,
    xintdefiivar Yq, Yr = divmod(#2, 17);%
    edefresultTupperXYxinttheiiexpr odd(Yq // 2**(17 * #1 + Yr))relax%
    %

    % This is a bit slow, be patient (big powers of 2 are computed...)
    % Much faster would be to convert TupperK to binary...
    beginpicture(106,17)
    xintFor* #1 in xintSeq0105do % x
    xintFor* #2 in xintSeq016do % y - k
    parseTupperXY#1#2+TupperK
    if1resultTupperXY
    put(numexpr105-#1, numexpr16-#2)rule1pt1pt
    fi


    endpicture

    enddocument



    I hoped this



    documentclassarticle

    usepackagexintexpr

    % Tupper

    % q = floor(y/17)
    % r = mod(y, 17) (modulo for floor)

    % Tupper formula boils down to say:

    % bit (x, y) is ON <===> floor(q, 2**(17x+r)) is ODD

    % https://fr.wikipedia.org/wiki/Formule_autor%C3%A9f%C3%A9rente_de_Tupper

    % xintiiexpr notations

    % floored division is //
    % associated modulo is /: (or 'mod')
    % divmod(,) is both // and /: (as in Python)

    begindocument

    % 0 <= x < 106
    % k <= y < k + 17

    xintdefiivar TupperK :=
    960939379918958884971672962127852754715004339660129306651505519271702802395266
    424689642842174350718121267153782770623355993237280874144307891325963941337723
    487857735749823926629715517173716995165232890538221612403238855866184013235585
    136048828693337902491454229288667081096184496091705183454067827731551705405381
    627380967602565625016981482083418783163849115590225610003652351370343874461848
    378737238198224849863465033159410054974700593138339226497249461751545728366702
    369745461014655997933798537483143786841806593422227898388722980000748404719;

    setlengthunitlength1pt

    xintdefiivar twoToThe17 := 2**17;
    xintdefiivar twoToThe17timesX := 1;

    beginpicture(106,17)
    xintFor* #1 in xintSeq0105do % x
    xintFor* #2 in 012345678910111213141516do % y - k
    xintdefiivar Yq, Yr = divmod(#2 + TupperK, 17);%
    xintifbooliiexpr odd(Yq // (twoToThe17timesX * 2**Yr ))
    put(numexpr105-#1, numexpr16-#2)rule1pt1pt


    xintdefiivar twoToThe17timesX := twoToThe17 * twoToThe17timesX;%

    endpicture

    enddocument


    would be faster, but it is only a bit faster. Hence the bottleneck is in the big divisions, less so in the powers of two.



    It would be faster to cheat a bit and compute binary representation of k via xintDecToBin from xintbinhex for example.






    share|improve this answer






















    • loop is very inefficient because for each #1=x, on computes again and again same power of 2 seventeen times, I will upload improved code.
      – jfbu
      31 mins ago










    • provides a good test of xint big integers capabilities... but too slow for incorporating into test suite...
      – jfbu
      14 mins ago











    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "85"
    ;
    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',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    Sora2455 is a new contributor. Be nice, and check out our Code of Conduct.









     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f451606%2fwhy-is-this-weird-space-appearing-after-my-minus-sign%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    3
    down vote













    You're using “mod” as a math operator like “exp” or “sin”. The command mod is for notation such as



    5 equiv 2 mod3


    and the inserted space is obviously wanted here.



    Use operatornamemod instead.



    documentclassarticle
    usepackageamsmath

    begindocument

    [
    frac12<
    leftlfloor
    operatornamemodleft(
    leftlfloorfracy17rightrfloor
    2^-17lfloor xrfloor-operatornamemod(lfloor yrfloor,17),2
    right)
    rightrfloor
    ]

    enddocument


    I've removed useless (and wrong) left and right pairs.



    enter image description here



    It works equally well in MathJax (tested on Math.SE):



    enter image description here






    share|improve this answer


























      up vote
      3
      down vote













      You're using “mod” as a math operator like “exp” or “sin”. The command mod is for notation such as



      5 equiv 2 mod3


      and the inserted space is obviously wanted here.



      Use operatornamemod instead.



      documentclassarticle
      usepackageamsmath

      begindocument

      [
      frac12<
      leftlfloor
      operatornamemodleft(
      leftlfloorfracy17rightrfloor
      2^-17lfloor xrfloor-operatornamemod(lfloor yrfloor,17),2
      right)
      rightrfloor
      ]

      enddocument


      I've removed useless (and wrong) left and right pairs.



      enter image description here



      It works equally well in MathJax (tested on Math.SE):



      enter image description here






      share|improve this answer
























        up vote
        3
        down vote










        up vote
        3
        down vote









        You're using “mod” as a math operator like “exp” or “sin”. The command mod is for notation such as



        5 equiv 2 mod3


        and the inserted space is obviously wanted here.



        Use operatornamemod instead.



        documentclassarticle
        usepackageamsmath

        begindocument

        [
        frac12<
        leftlfloor
        operatornamemodleft(
        leftlfloorfracy17rightrfloor
        2^-17lfloor xrfloor-operatornamemod(lfloor yrfloor,17),2
        right)
        rightrfloor
        ]

        enddocument


        I've removed useless (and wrong) left and right pairs.



        enter image description here



        It works equally well in MathJax (tested on Math.SE):



        enter image description here






        share|improve this answer














        You're using “mod” as a math operator like “exp” or “sin”. The command mod is for notation such as



        5 equiv 2 mod3


        and the inserted space is obviously wanted here.



        Use operatornamemod instead.



        documentclassarticle
        usepackageamsmath

        begindocument

        [
        frac12<
        leftlfloor
        operatornamemodleft(
        leftlfloorfracy17rightrfloor
        2^-17lfloor xrfloor-operatornamemod(lfloor yrfloor,17),2
        right)
        rightrfloor
        ]

        enddocument


        I've removed useless (and wrong) left and right pairs.



        enter image description here



        It works equally well in MathJax (tested on Math.SE):



        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 1 hour ago

























        answered 1 hour ago









        egreg

        683k8418193065




        683k8418193065




















            up vote
            3
            down vote













            Do you mean this:



            enter image description here



            documentclassarticle

            usepackagexintexpr

            % Tupper

            % q = floor(y/17)
            % r = mod(y, 17) (modulo for floor)

            % Tupper formula boils down to say:

            % bit (x, y) is ON <===> floor(q, 2**(17x+r)) is ODD

            % https://fr.wikipedia.org/wiki/Formule_autor%C3%A9f%C3%A9rente_de_Tupper

            % xintiiexpr notations

            % floored division is //
            % associated modulo is /: (or 'mod')
            % divmod(,) is both // and /: (as in Python)

            begindocument

            % 0 <= x < 106
            % k <= y < k + 17

            xintdefiivar TupperK :=
            960939379918958884971672962127852754715004339660129306651505519271702802395266
            424689642842174350718121267153782770623355993237280874144307891325963941337723
            487857735749823926629715517173716995165232890538221612403238855866184013235585
            136048828693337902491454229288667081096184496091705183454067827731551705405381
            627380967602565625016981482083418783163849115590225610003652351370343874461848
            378737238198224849863465033159410054974700593138339226497249461751545728366702
            369745461014655997933798537483143786841806593422227898388722980000748404719;

            setlengthunitlength1pt

            defparseTupperXY#1#2% #1 = x, #2=y,
            xintdefiivar Yq, Yr = divmod(#2, 17);%
            edefresultTupperXYxinttheiiexpr odd(Yq // 2**(17 * #1 + Yr))relax%
            %

            % This is a bit slow, be patient (big powers of 2 are computed...)
            % Much faster would be to convert TupperK to binary...
            beginpicture(106,17)
            xintFor* #1 in xintSeq0105do % x
            xintFor* #2 in xintSeq016do % y - k
            parseTupperXY#1#2+TupperK
            if1resultTupperXY
            put(numexpr105-#1, numexpr16-#2)rule1pt1pt
            fi


            endpicture

            enddocument



            I hoped this



            documentclassarticle

            usepackagexintexpr

            % Tupper

            % q = floor(y/17)
            % r = mod(y, 17) (modulo for floor)

            % Tupper formula boils down to say:

            % bit (x, y) is ON <===> floor(q, 2**(17x+r)) is ODD

            % https://fr.wikipedia.org/wiki/Formule_autor%C3%A9f%C3%A9rente_de_Tupper

            % xintiiexpr notations

            % floored division is //
            % associated modulo is /: (or 'mod')
            % divmod(,) is both // and /: (as in Python)

            begindocument

            % 0 <= x < 106
            % k <= y < k + 17

            xintdefiivar TupperK :=
            960939379918958884971672962127852754715004339660129306651505519271702802395266
            424689642842174350718121267153782770623355993237280874144307891325963941337723
            487857735749823926629715517173716995165232890538221612403238855866184013235585
            136048828693337902491454229288667081096184496091705183454067827731551705405381
            627380967602565625016981482083418783163849115590225610003652351370343874461848
            378737238198224849863465033159410054974700593138339226497249461751545728366702
            369745461014655997933798537483143786841806593422227898388722980000748404719;

            setlengthunitlength1pt

            xintdefiivar twoToThe17 := 2**17;
            xintdefiivar twoToThe17timesX := 1;

            beginpicture(106,17)
            xintFor* #1 in xintSeq0105do % x
            xintFor* #2 in 012345678910111213141516do % y - k
            xintdefiivar Yq, Yr = divmod(#2 + TupperK, 17);%
            xintifbooliiexpr odd(Yq // (twoToThe17timesX * 2**Yr ))
            put(numexpr105-#1, numexpr16-#2)rule1pt1pt


            xintdefiivar twoToThe17timesX := twoToThe17 * twoToThe17timesX;%

            endpicture

            enddocument


            would be faster, but it is only a bit faster. Hence the bottleneck is in the big divisions, less so in the powers of two.



            It would be faster to cheat a bit and compute binary representation of k via xintDecToBin from xintbinhex for example.






            share|improve this answer






















            • loop is very inefficient because for each #1=x, on computes again and again same power of 2 seventeen times, I will upload improved code.
              – jfbu
              31 mins ago










            • provides a good test of xint big integers capabilities... but too slow for incorporating into test suite...
              – jfbu
              14 mins ago















            up vote
            3
            down vote













            Do you mean this:



            enter image description here



            documentclassarticle

            usepackagexintexpr

            % Tupper

            % q = floor(y/17)
            % r = mod(y, 17) (modulo for floor)

            % Tupper formula boils down to say:

            % bit (x, y) is ON <===> floor(q, 2**(17x+r)) is ODD

            % https://fr.wikipedia.org/wiki/Formule_autor%C3%A9f%C3%A9rente_de_Tupper

            % xintiiexpr notations

            % floored division is //
            % associated modulo is /: (or 'mod')
            % divmod(,) is both // and /: (as in Python)

            begindocument

            % 0 <= x < 106
            % k <= y < k + 17

            xintdefiivar TupperK :=
            960939379918958884971672962127852754715004339660129306651505519271702802395266
            424689642842174350718121267153782770623355993237280874144307891325963941337723
            487857735749823926629715517173716995165232890538221612403238855866184013235585
            136048828693337902491454229288667081096184496091705183454067827731551705405381
            627380967602565625016981482083418783163849115590225610003652351370343874461848
            378737238198224849863465033159410054974700593138339226497249461751545728366702
            369745461014655997933798537483143786841806593422227898388722980000748404719;

            setlengthunitlength1pt

            defparseTupperXY#1#2% #1 = x, #2=y,
            xintdefiivar Yq, Yr = divmod(#2, 17);%
            edefresultTupperXYxinttheiiexpr odd(Yq // 2**(17 * #1 + Yr))relax%
            %

            % This is a bit slow, be patient (big powers of 2 are computed...)
            % Much faster would be to convert TupperK to binary...
            beginpicture(106,17)
            xintFor* #1 in xintSeq0105do % x
            xintFor* #2 in xintSeq016do % y - k
            parseTupperXY#1#2+TupperK
            if1resultTupperXY
            put(numexpr105-#1, numexpr16-#2)rule1pt1pt
            fi


            endpicture

            enddocument



            I hoped this



            documentclassarticle

            usepackagexintexpr

            % Tupper

            % q = floor(y/17)
            % r = mod(y, 17) (modulo for floor)

            % Tupper formula boils down to say:

            % bit (x, y) is ON <===> floor(q, 2**(17x+r)) is ODD

            % https://fr.wikipedia.org/wiki/Formule_autor%C3%A9f%C3%A9rente_de_Tupper

            % xintiiexpr notations

            % floored division is //
            % associated modulo is /: (or 'mod')
            % divmod(,) is both // and /: (as in Python)

            begindocument

            % 0 <= x < 106
            % k <= y < k + 17

            xintdefiivar TupperK :=
            960939379918958884971672962127852754715004339660129306651505519271702802395266
            424689642842174350718121267153782770623355993237280874144307891325963941337723
            487857735749823926629715517173716995165232890538221612403238855866184013235585
            136048828693337902491454229288667081096184496091705183454067827731551705405381
            627380967602565625016981482083418783163849115590225610003652351370343874461848
            378737238198224849863465033159410054974700593138339226497249461751545728366702
            369745461014655997933798537483143786841806593422227898388722980000748404719;

            setlengthunitlength1pt

            xintdefiivar twoToThe17 := 2**17;
            xintdefiivar twoToThe17timesX := 1;

            beginpicture(106,17)
            xintFor* #1 in xintSeq0105do % x
            xintFor* #2 in 012345678910111213141516do % y - k
            xintdefiivar Yq, Yr = divmod(#2 + TupperK, 17);%
            xintifbooliiexpr odd(Yq // (twoToThe17timesX * 2**Yr ))
            put(numexpr105-#1, numexpr16-#2)rule1pt1pt


            xintdefiivar twoToThe17timesX := twoToThe17 * twoToThe17timesX;%

            endpicture

            enddocument


            would be faster, but it is only a bit faster. Hence the bottleneck is in the big divisions, less so in the powers of two.



            It would be faster to cheat a bit and compute binary representation of k via xintDecToBin from xintbinhex for example.






            share|improve this answer






















            • loop is very inefficient because for each #1=x, on computes again and again same power of 2 seventeen times, I will upload improved code.
              – jfbu
              31 mins ago










            • provides a good test of xint big integers capabilities... but too slow for incorporating into test suite...
              – jfbu
              14 mins ago













            up vote
            3
            down vote










            up vote
            3
            down vote









            Do you mean this:



            enter image description here



            documentclassarticle

            usepackagexintexpr

            % Tupper

            % q = floor(y/17)
            % r = mod(y, 17) (modulo for floor)

            % Tupper formula boils down to say:

            % bit (x, y) is ON <===> floor(q, 2**(17x+r)) is ODD

            % https://fr.wikipedia.org/wiki/Formule_autor%C3%A9f%C3%A9rente_de_Tupper

            % xintiiexpr notations

            % floored division is //
            % associated modulo is /: (or 'mod')
            % divmod(,) is both // and /: (as in Python)

            begindocument

            % 0 <= x < 106
            % k <= y < k + 17

            xintdefiivar TupperK :=
            960939379918958884971672962127852754715004339660129306651505519271702802395266
            424689642842174350718121267153782770623355993237280874144307891325963941337723
            487857735749823926629715517173716995165232890538221612403238855866184013235585
            136048828693337902491454229288667081096184496091705183454067827731551705405381
            627380967602565625016981482083418783163849115590225610003652351370343874461848
            378737238198224849863465033159410054974700593138339226497249461751545728366702
            369745461014655997933798537483143786841806593422227898388722980000748404719;

            setlengthunitlength1pt

            defparseTupperXY#1#2% #1 = x, #2=y,
            xintdefiivar Yq, Yr = divmod(#2, 17);%
            edefresultTupperXYxinttheiiexpr odd(Yq // 2**(17 * #1 + Yr))relax%
            %

            % This is a bit slow, be patient (big powers of 2 are computed...)
            % Much faster would be to convert TupperK to binary...
            beginpicture(106,17)
            xintFor* #1 in xintSeq0105do % x
            xintFor* #2 in xintSeq016do % y - k
            parseTupperXY#1#2+TupperK
            if1resultTupperXY
            put(numexpr105-#1, numexpr16-#2)rule1pt1pt
            fi


            endpicture

            enddocument



            I hoped this



            documentclassarticle

            usepackagexintexpr

            % Tupper

            % q = floor(y/17)
            % r = mod(y, 17) (modulo for floor)

            % Tupper formula boils down to say:

            % bit (x, y) is ON <===> floor(q, 2**(17x+r)) is ODD

            % https://fr.wikipedia.org/wiki/Formule_autor%C3%A9f%C3%A9rente_de_Tupper

            % xintiiexpr notations

            % floored division is //
            % associated modulo is /: (or 'mod')
            % divmod(,) is both // and /: (as in Python)

            begindocument

            % 0 <= x < 106
            % k <= y < k + 17

            xintdefiivar TupperK :=
            960939379918958884971672962127852754715004339660129306651505519271702802395266
            424689642842174350718121267153782770623355993237280874144307891325963941337723
            487857735749823926629715517173716995165232890538221612403238855866184013235585
            136048828693337902491454229288667081096184496091705183454067827731551705405381
            627380967602565625016981482083418783163849115590225610003652351370343874461848
            378737238198224849863465033159410054974700593138339226497249461751545728366702
            369745461014655997933798537483143786841806593422227898388722980000748404719;

            setlengthunitlength1pt

            xintdefiivar twoToThe17 := 2**17;
            xintdefiivar twoToThe17timesX := 1;

            beginpicture(106,17)
            xintFor* #1 in xintSeq0105do % x
            xintFor* #2 in 012345678910111213141516do % y - k
            xintdefiivar Yq, Yr = divmod(#2 + TupperK, 17);%
            xintifbooliiexpr odd(Yq // (twoToThe17timesX * 2**Yr ))
            put(numexpr105-#1, numexpr16-#2)rule1pt1pt


            xintdefiivar twoToThe17timesX := twoToThe17 * twoToThe17timesX;%

            endpicture

            enddocument


            would be faster, but it is only a bit faster. Hence the bottleneck is in the big divisions, less so in the powers of two.



            It would be faster to cheat a bit and compute binary representation of k via xintDecToBin from xintbinhex for example.






            share|improve this answer














            Do you mean this:



            enter image description here



            documentclassarticle

            usepackagexintexpr

            % Tupper

            % q = floor(y/17)
            % r = mod(y, 17) (modulo for floor)

            % Tupper formula boils down to say:

            % bit (x, y) is ON <===> floor(q, 2**(17x+r)) is ODD

            % https://fr.wikipedia.org/wiki/Formule_autor%C3%A9f%C3%A9rente_de_Tupper

            % xintiiexpr notations

            % floored division is //
            % associated modulo is /: (or 'mod')
            % divmod(,) is both // and /: (as in Python)

            begindocument

            % 0 <= x < 106
            % k <= y < k + 17

            xintdefiivar TupperK :=
            960939379918958884971672962127852754715004339660129306651505519271702802395266
            424689642842174350718121267153782770623355993237280874144307891325963941337723
            487857735749823926629715517173716995165232890538221612403238855866184013235585
            136048828693337902491454229288667081096184496091705183454067827731551705405381
            627380967602565625016981482083418783163849115590225610003652351370343874461848
            378737238198224849863465033159410054974700593138339226497249461751545728366702
            369745461014655997933798537483143786841806593422227898388722980000748404719;

            setlengthunitlength1pt

            defparseTupperXY#1#2% #1 = x, #2=y,
            xintdefiivar Yq, Yr = divmod(#2, 17);%
            edefresultTupperXYxinttheiiexpr odd(Yq // 2**(17 * #1 + Yr))relax%
            %

            % This is a bit slow, be patient (big powers of 2 are computed...)
            % Much faster would be to convert TupperK to binary...
            beginpicture(106,17)
            xintFor* #1 in xintSeq0105do % x
            xintFor* #2 in xintSeq016do % y - k
            parseTupperXY#1#2+TupperK
            if1resultTupperXY
            put(numexpr105-#1, numexpr16-#2)rule1pt1pt
            fi


            endpicture

            enddocument



            I hoped this



            documentclassarticle

            usepackagexintexpr

            % Tupper

            % q = floor(y/17)
            % r = mod(y, 17) (modulo for floor)

            % Tupper formula boils down to say:

            % bit (x, y) is ON <===> floor(q, 2**(17x+r)) is ODD

            % https://fr.wikipedia.org/wiki/Formule_autor%C3%A9f%C3%A9rente_de_Tupper

            % xintiiexpr notations

            % floored division is //
            % associated modulo is /: (or 'mod')
            % divmod(,) is both // and /: (as in Python)

            begindocument

            % 0 <= x < 106
            % k <= y < k + 17

            xintdefiivar TupperK :=
            960939379918958884971672962127852754715004339660129306651505519271702802395266
            424689642842174350718121267153782770623355993237280874144307891325963941337723
            487857735749823926629715517173716995165232890538221612403238855866184013235585
            136048828693337902491454229288667081096184496091705183454067827731551705405381
            627380967602565625016981482083418783163849115590225610003652351370343874461848
            378737238198224849863465033159410054974700593138339226497249461751545728366702
            369745461014655997933798537483143786841806593422227898388722980000748404719;

            setlengthunitlength1pt

            xintdefiivar twoToThe17 := 2**17;
            xintdefiivar twoToThe17timesX := 1;

            beginpicture(106,17)
            xintFor* #1 in xintSeq0105do % x
            xintFor* #2 in 012345678910111213141516do % y - k
            xintdefiivar Yq, Yr = divmod(#2 + TupperK, 17);%
            xintifbooliiexpr odd(Yq // (twoToThe17timesX * 2**Yr ))
            put(numexpr105-#1, numexpr16-#2)rule1pt1pt


            xintdefiivar twoToThe17timesX := twoToThe17 * twoToThe17timesX;%

            endpicture

            enddocument


            would be faster, but it is only a bit faster. Hence the bottleneck is in the big divisions, less so in the powers of two.



            It would be faster to cheat a bit and compute binary representation of k via xintDecToBin from xintbinhex for example.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 6 mins ago

























            answered 35 mins ago









            jfbu

            42k63135




            42k63135











            • loop is very inefficient because for each #1=x, on computes again and again same power of 2 seventeen times, I will upload improved code.
              – jfbu
              31 mins ago










            • provides a good test of xint big integers capabilities... but too slow for incorporating into test suite...
              – jfbu
              14 mins ago

















            • loop is very inefficient because for each #1=x, on computes again and again same power of 2 seventeen times, I will upload improved code.
              – jfbu
              31 mins ago










            • provides a good test of xint big integers capabilities... but too slow for incorporating into test suite...
              – jfbu
              14 mins ago
















            loop is very inefficient because for each #1=x, on computes again and again same power of 2 seventeen times, I will upload improved code.
            – jfbu
            31 mins ago




            loop is very inefficient because for each #1=x, on computes again and again same power of 2 seventeen times, I will upload improved code.
            – jfbu
            31 mins ago












            provides a good test of xint big integers capabilities... but too slow for incorporating into test suite...
            – jfbu
            14 mins ago





            provides a good test of xint big integers capabilities... but too slow for incorporating into test suite...
            – jfbu
            14 mins ago











            Sora2455 is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            Sora2455 is a new contributor. Be nice, and check out our Code of Conduct.












            Sora2455 is a new contributor. Be nice, and check out our Code of Conduct.











            Sora2455 is a new contributor. Be nice, and check out our Code of Conduct.













             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f451606%2fwhy-is-this-weird-space-appearing-after-my-minus-sign%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            Long meetings (6-7 hours a day): Being “babysat” by supervisor

            Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

            Confectionery