Why is this weird space appearing after my minus sign
Clash 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: .
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
New contributor
add a comment |Â
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: .
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
New contributor
3
Although this is not exactly a TeX question, but have you looked at the firstmod
? It is not about the minus sign, but rather themod
. Themod
has, by design, a preceding quad space and an appending half quad space.
â Ruixi Zhang
1 hour ago
add a comment |Â
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: .
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
New contributor
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: .
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
spacing math-operators
New contributor
New contributor
edited 1 hour ago
egreg
683k8418193065
683k8418193065
New contributor
asked 1 hour ago
Sora2455
62
62
New contributor
New contributor
3
Although this is not exactly a TeX question, but have you looked at the firstmod
? It is not about the minus sign, but rather themod
. Themod
has, by design, a preceding quad space and an appending half quad space.
â Ruixi Zhang
1 hour ago
add a comment |Â
3
Although this is not exactly a TeX question, but have you looked at the firstmod
? It is not about the minus sign, but rather themod
. Themod
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
add a comment |Â
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.
It works equally well in MathJax (tested on Math.SE):
add a comment |Â
up vote
3
down vote
Do you mean 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
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.
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 ofxint
big integers capabilities... but too slow for incorporating into test suite...
â jfbu
14 mins ago
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
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.
It works equally well in MathJax (tested on Math.SE):
add a comment |Â
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.
It works equally well in MathJax (tested on Math.SE):
add a comment |Â
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.
It works equally well in MathJax (tested on Math.SE):
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.
It works equally well in MathJax (tested on Math.SE):
edited 1 hour ago
answered 1 hour ago
egreg
683k8418193065
683k8418193065
add a comment |Â
add a comment |Â
up vote
3
down vote
Do you mean 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
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.
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 ofxint
big integers capabilities... but too slow for incorporating into test suite...
â jfbu
14 mins ago
add a comment |Â
up vote
3
down vote
Do you mean 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
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.
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 ofxint
big integers capabilities... but too slow for incorporating into test suite...
â jfbu
14 mins ago
add a comment |Â
up vote
3
down vote
up vote
3
down vote
Do you mean 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
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.
Do you mean 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
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.
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 ofxint
big integers capabilities... but too slow for incorporating into test suite...
â jfbu
14 mins ago
add a comment |Â
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 ofxint
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
add a comment |Â
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.
Sora2455 is a new contributor. Be nice, and check out our Code of Conduct.
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%2ftex.stackexchange.com%2fquestions%2f451606%2fwhy-is-this-weird-space-appearing-after-my-minus-sign%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
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 themod
. Themod
has, by design, a preceding quad space and an appending half quad space.â Ruixi Zhang
1 hour ago