# Wikipedia:Reference desk/Mathematics

Welcome to the mathematics reference desk.

Main page: Help searching Wikipedia

How can I get my question answered?

• Provide a short header that gives the general topic of the question.
• Type '~~~~' (that is, four tilde characters) at the end – this signs and dates your contribution so we know who wrote what and when.
• Post your question to only one desk.
• Don't post personal contact information – it will be removed. All answers will be provided here.
• Specific questions, that are likely to produce reliable sources, will tend to get clearer answers,
• Note:
• We don't answer (and may remove) questions that require medical diagnosis or legal advice.
• We don't answer requests for opinions, predictions or debate.
• We are not a substitute for actually doing any original research required, or as a free source of ideas.

How do I answer a question?

Main page: Wikipedia:Reference desk/Guidelines

Choose a topic:
 Computing desk Entertainment desk Humanities desk Language desk Mathematics desk Science desk Miscellaneous desk Archives

# November 16

## Any logical sequence for this...

One wants to find out certain numbers between 123456 and 654321. The numbers should be all :

1. Not containg any digit above 6
2. No digit should occur more than once. (for example 154236 is OK, but not 154266)

What number should be added (which will be a different number each time. For example, since first "next" number will be 123465, which we'll get by adding 9, but next one will be gotten by adding 81, which will be 123546).

But how to get the next one satisfying above two conditions ?  Jon Ascton  (talk) 05:51, 16 November 2017 (UTC)

• XY problem alert: I suspect what you are actually looking for is a way to enumerate permutations, so that you do not really care about storing them as integers.
[1] has some algorithms. [2] gives a few implementations in Python. Some of them enumerate in lexicographic order (= increasing order when the permutations are stored as the digits of a number). TigraanClick here to contact me 09:40, 16 November 2017 (UTC)
Is the digit 0 allowed? If not, there should be 6!=720 numbers which meet the condition. If yes, there should be 7!-1=5039 (in both cases including the boundary numbers). --Stephan Schulz (talk) 09:45, 16 November 2017 (UTC)
No, I'm afraid 0 isn't allowed. Of course, the number of numbers we'll get will be 6!. Yeah, boundary numbers, both 123456 and 654321 will be part of the numbers selected, smallest and biggest respectively. Both meet the conditions: no digit of no digit being <1 or >6, or digit-repeted. Kindly elaborate if you see a problem there:  Jon Ascton  (talk) 11:20, 16 November 2017 (UTC)

For Tigraan: OK, pal, let's revise it (in hope that it won't be an XY problem anymore). Say the problem is all:-

One wants to find out certain numbers between 123456 and 654321. Each of numbers should :

1. Not contain any digit above 6
2. No digit should occur more than once. (for example 154236 is OK, but not 154266)
3. None should have 0 in it.

What number should be added (which will be a different number each time. What number should be added (which will be a different number each time. For example, since first "next" number will be 123465, which we'll get by adding 9, but next one will be gotten by adding 81, which will be 123546)  Jon Ascton  (talk) 11:20, 16 November 2017 (UTC)

• Yawn. Well, this does not look like a homework problem, and it is simple enough that I can just blurt out the solution, I guess. The following Python script solves the problem:
import itertools
def tuple_into_num(l):
N=len(l)
res=0
for i in range(N):
res += l[i]*10**(N-1-i)
return res

gen=itertools.permutations([1,2,3,4,5,6])
for item in gen:
print(tuple_into_num(item))

Resulting blob:
All permutations of [1,2,3,4,5,6] (in integer form)

123456 123465 123546 123564 123645 123654 124356 124365 124536 124563 124635 124653 125346 125364 125436 125463 125634 125643 126345 126354 126435 126453 126534 126543 132456 132465 132546 132564 132645 132654 134256 134265 134526 134562 134625 134652 135246 135264 135426 135462 135624 135642 136245 136254 136425 136452 136524 136542 142356 142365 142536 142563 142635 142653 143256 143265 143526 143562 143625 143652 145236 145263 145326 145362 145623 145632 146235 146253 146325 146352 146523 146532 152346 152364 152436 152463 152634 152643 153246 153264 153426 153462 153624 153642 154236 154263 154326 154362 154623 154632 156234 156243 156324 156342 156423 156432 162345 162354 162435 162453 162534 162543 163245 163254 163425 163452 163524 163542 164235 164253 164325 164352 164523 164532 165234 165243 165324 165342 165423 165432 213456 213465 213546 213564 213645 213654 214356 214365 214536 214563 214635 214653 215346 215364 215436 215463 215634 215643 216345 216354 216435 216453 216534 216543 231456 231465 231546 231564 231645 231654 234156 234165 234516 234561 234615 234651 235146 235164 235416 235461 235614 235641 236145 236154 236415 236451 236514 236541 241356 241365 241536 241563 241635 241653 243156 243165 243516 243561 243615 243651 245136 245163 245316 245361 245613 245631 246135 246153 246315 246351 246513 246531 251346 251364 251436 251463 251634 251643 253146 253164 253416 253461 253614 253641 254136 254163 254316 254361 254613 254631 256134 256143 256314 256341 256413 256431 261345 261354 261435 261453 261534 261543 263145 263154 263415 263451 263514 263541 264135 264153 264315 264351 264513 264531 265134 265143 265314 265341 265413 265431 312456 312465 312546 312564 312645 312654 314256 314265 314526 314562 314625 314652 315246 315264 315426 315462 315624 315642 316245 316254 316425 316452 316524 316542 321456 321465 321546 321564 321645 321654 324156 324165 324516 324561 324615 324651 325146 325164 325416 325461 325614 325641 326145 326154 326415 326451 326514 326541 341256 341265 341526 341562 341625 341652 342156 342165 342516 342561 342615 342651 345126 345162 345216 345261 345612 345621 346125 346152 346215 346251 346512 346521 351246 351264 351426 351462 351624 351642 352146 352164 352416 352461 352614 352641 354126 354162 354216 354261 354612 354621 356124 356142 356214 356241 356412 356421 361245 361254 361425 361452 361524 361542 362145 362154 362415 362451 362514 362541 364125 364152 364215 364251 364512 364521 365124 365142 365214 365241 365412 365421 412356 412365 412536 412563 412635 412653 413256 413265 413526 413562 413625 413652 415236 415263 415326 415362 415623 415632 416235 416253 416325 416352 416523 416532 421356 421365 421536 421563 421635 421653 423156 423165 423516 423561 423615 423651 425136 425163 425316 425361 425613 425631 426135 426153 426315 426351 426513 426531 431256 431265 431526 431562 431625 431652 432156 432165 432516 432561 432615 432651 435126 435162 435216 435261 435612 435621 436125 436152 436215 436251 436512 436521 451236 451263 451326 451362 451623 451632 452136 452163 452316 452361 452613 452631 453126 453162 453216 453261 453612 453621 456123 456132 456213 456231 456312 456321 461235 461253 461325 461352 461523 461532 462135 462153 462315 462351 462513 462531 463125 463152 463215 463251 463512 463521 465123 465132 465213 465231 465312 465321 512346 512364 512436 512463 512634 512643 513246 513264 513426 513462 513624 513642 514236 514263 514326 514362 514623 514632 516234 516243 516324 516342 516423 516432 521346 521364 521436 521463 521634 521643 523146 523164 523416 523461 523614 523641 524136 524163 524316 524361 524613 524631 526134 526143 526314 526341 526413 526431 531246 531264 531426 531462 531624 531642 532146 532164 532416 532461 532614 532641 534126 534162 534216 534261 534612 534621 536124 536142 536214 536241 536412 536421 541236 541263 541326 541362 541623 541632 542136 542163 542316 542361 542613 542631 543126 543162 543216 543261 543612 543621 546123 546132 546213 546231 546312 546321 561234 561243 561324 561342 561423 561432 562134 562143 562314 562341 562413 562431 563124 563142 563214 563241 563412 563421 564123 564132 564213 564231 564312 564321 612345 612354 612435 612453 612534 612543 613245 613254 613425 613452 613524 613542 614235 614253 614325 614352 614523 614532 615234 615243 615324 615342 615423 615432 621345 621354 621435 621453 621534 621543 623145 623154 623415 623451 623514 623541 624135 624153 624315 624351 624513 624531 625134 625143 625314 625341 625413 625431 631245 631254 631425 631452 631524 631542 632145 632154 632415 632451 632514 632541 634125 634152 634215 634251 634512 634521 635124 635142 635214 635241 635412 635421 641235 641253 641325 641352 641523 641532 642135 642153 642315 642351 642513 642531 643125 643152 643215 643251 643512 643521 645123 645132 645213 645231 645312 645321 651234 651243 651324 651342 651423 651432 652134 652143 652314 652341 652413 652431 653124 653142 653214 653241 653412 653421 654123 654132 654213 654231 654312 654321

Wonderful ! You got all those numbers by writing so small a coding ! And if I tried it using VB6 (my obsession) I had to write at least 20 times if not more than that. Guess, must learn this blackmagic called Python... Jon Ascton  (talk) 14:01, 16 November 2017 (UTC)
Tigraan is being so verbose. This also works:
import itertools
gen=itertools.permutations([1,2,3,4,5,6])
for line in gen:
print("".join([str(item) for item in line]))

Dragons flight (talk) 14:45, 16 November 2017 (UTC)
Maybe I'm too anal, but that last line should be
    print(int("".join([str(item) for item in line])))


.

The OP asked for numbers, not strings that happen to be decimal representations of numbers ;-). --Stephan Schulz (talk) 15:31, 16 November 2017 (UTC)
How can we give him a number instead of some form of representation of that number? I feel that I am in the border between mathematics and philosophy! -- Q Chris (talk) 15:47, 16 November 2017 (UTC)
Well, as long as the number is printed, the difference is philosophical. But assuming the OP wants to do something with the numbers inside the program, the type matters. In Python, a string and an int have different types with different properties, and, more importantly, different operations. --Stephan Schulz (talk) 16:15, 16 November 2017 (UTC)
Well, I would have written a shorter script but I did not have the time. I would probably have taken more time finding how to avoid the t-uple to int routine than it took writing it. And even inside it, I was pretty sure when writing the for loop than there was a more Pythonic option but did not care - for the interested reader: the untested return sum(l[i]*10**(N-1-i) for i in range(N)) is a good candidate.
On the "philosophical" issue of what type to return, I saw a relevant comment something like five years ago on http://thedailywtf.com/ to the effect that "if you are not adding or multiplying them, they are not really numbers"; meaning a program should not use integers to store data that is not meant for arithmetics. Exhibit #1 was a front end display of a "phone number" field as "1.5579E10" or similar; a phone number is functionally a string, even if it is a string of digits.
Here, we cannot read OP's mind and they did not tell what they are going to use the "integers" for, but the problem screams that those are permutations, not numbers, so the natural representation is probably an array/list. In those optics a string (= array of characters) is better than an int output (and worse than a list/t-uple output in Python). TigraanClick here to contact me 17:36, 16 November 2017 (UTC)
You miss one important point. The OP was asking for numbers. So we should give him numbers. We don't know if he wants or needs numbers, but we should always follow rule number one of practical project management: The most important goal is not to succeed, but to make sure that the finger of blame is pointing in the right direction (i.e. away from you ;-). --Stephan Schulz (talk) 07:58, 17 November 2017 (UTC)
The OP asked also "what number should be added each time", i.e. to get each permutation from the one before (though they deleted that bit further down the dialogue). As a matter of interest, if the permutations are put in ascending order, is there any obvious pattern to these successive differences? →217.43.234.32 (talk) 10:25, 17 November 2017 (UTC)
I hand-hacked a script for the differences, and there are some regularities, but nothing obvious. I then entered the first few terms into the On-Line Encyclopedia of Integer Sequences and it came back with sequence A219664, which basically is a generalised form of the differences of the permutations sequence and has no particularly interesting properties listed. The original series, however, is at A178476, and that one has a link to A178475 (the same thing with digits 1-5), which lists a relatively efficient procedure for computing the nth element. BTW, I suspect it's a symptom of terminal nerd if you click around OEIS in the same way you click around Wikipedia... --Stephan Schulz (talk) 11:53, 17 November 2017 (UTC)
Since the difference of any two permutations of a number given in base b is a multiple of b-1, it is reasonable to divide these first differences by 9 when seeking patterns. This yields , with interesting notes in the comments section. -- ToE 18:39, 20 November 2017 (UTC)

# November 21

## Turning things inside out

Take a watch with a metal watchband, like the ones pictured here, and you can easily turn it inside out. Take a bottomless and topless paper tube (e.g. a cereal box with flaps opened) and you can't. What's the difference? Is it related to the fact that the diameter of the watchband circle is a good deal greater than the width (i.e. your arm's circumference is many cm, while the band is 1cm or 2cm wide) while the cereal box's interior diameter is a good deal larger than its circumference? I came here because this question reminds me of chatting with a former roommate about his topology-related Ph.D. dissertation, where he was talking about turning mugs inside out, or something like that. Nyttend backup (talk) 16:29, 21 November 2017 (UTC)

I think it has more to do with the stiffness of the material. For example, if you take an empty bag of potato chips (made of paper or plastic) and open the bottom, it's fairly easy to turn it inside out, even though the dimensions are similar to those of the cereal box. On the other hand if the watchband were not flexible, but something like a rigid steel ring, it would not be possible to turn it inside out. This is not really a topological issue of course, because in topology the objects under consideration are assumed to be infinitely flexible and stretchable. CodeTalker (talk) 02:05, 22 November 2017 (UTC)
[Edit conflict.] This is more a function of material property than geometry. A tube with a similar aspect ratio to you paper tube, but made out of more pliant material such as thin rubber (a quarter of a bicycle's innertube) or fabric (a sleeve cut from a long sleeve shirt or a sock with the toe cut open), could easily be everted. -- ToE 02:06, 22 November 2017 (UTC)
Only tangentially related, but you may be interested in reading our sphere eversion article and watching the first video in § External links. Also, if you ever have an old bicycle tube to be discarded, first cut the valve out and then evert the punctured torus. (Some talcum powder may help the process.) This is described in § Topology, but it is very cool to see first hand, particular given the aspect ratio of an innertube. The end result is still a punctured torus, but of a very different appearance. -- ToE 02:06, 22 November 2017 (UTC)
See [3] about turning a tube inside out. This is the tallest that has been done with rigid plates. Dmcq (talk) 12:17, 22 November 2017 (UTC)

# November 24

## Intersection of Hyperplance and Hypercube

Let ${\displaystyle A=\{x\in \mathbb {R} ^{n}|a^{T}x=b\}}$ (for ${\displaystyle a\in \mathbb {R} ^{n},b\in \mathbb {R} }$) be a hyperplane, and ${\displaystyle B=[0,1]^{n}}$ be a hypercube.

Does the intersection ${\displaystyle A\cap B}$ equal the convex hull of two ${\displaystyle n-2}$-dimensional hypercubes? David Frid (talk) 12:52, 24 November 2017 (UTC)

Even in the case of a 3-D cube you can get a hexagon by such a cut and you can't get six outside points as thehull of two lines with four end points in total. Dmcq (talk) 16:33, 24 November 2017 (UTC)

## Maximum Distance

Let ${\displaystyle A}$ be the intersection of some hyperplane and hypercube. Let ${\displaystyle p\in \mathbb {R} ^{n}}$. Let ${\displaystyle f(x)={\begin{cases}d(x,p)&x\in A\\0&\mathrm {else} \end{cases}}}$ (${\displaystyle d}$ denotes the Euclidean distance).

Does ${\displaystyle f}$ have a local maximum, which is not a global maximum too? David Frid (talk) 13:25, 24 November 2017 (UTC)

You can have a local maximum which is not a global maximum. For instance just consider a plane intersecting a cube to give a square. The distance to the two far corners from a point near the middle of one side will be local maxima. On the other hand with the point close to one corner there will just be a single maximum to the opposite corner. Dmcq (talk) 16:39, 24 November 2017 (UTC)
• (edit conflict) Let n=2. The hypercube is a square (including the interior), and the hyperplane is a line intersecting the square in the line segment AB, with endpoints A and B on the square’s boundary. Let P be a point in the plane such that its nearest point on AB is the point C = (2/3)A +(1/3)B. Then f has maxima at A and B with the global maximum at B. Loraof (talk) 16:45, 24 November 2017 (UTC)