The Learn Fun Facts blog posted an interesting fun fact about strings. Law’s fun fact is that 8+9+1+89+91=198. Why is this a fun fact? Because the left side of that equation takes every sequence of digits from 891 (except the whole thing) and adds them together to get the digits in reverse order. Contrary to Law’s statement, though, this is not the only three digit number that does this. At the end of the post, he challenges us to figure out if this happens for any five digit combinations. He suggests using a computer to do it, but I wanted to see if basic algebra and a little cleverness could do it. So first I set out on the 3-digit problem to see how the process works.

## The 3-Digit Problem

So, what do we know to start with? We’re working with three digits. Let’s call them x, y, and z. So for 891, x=8, y=9, and z=1. To make them match up with 891, we note that 100x+10y+z=891. To reverse the digits, just reverse the coefficients: x+10y+100z=198.

Now, to figure out that it’s 8, 9, and 1, we can’t assume that from the start. But we are working on making the “substrings” (the sequences of digits within the number) equal x+10y+100z. How do we express the sum of substrings? x+y+z+10x+y+10y+z. If we clean that up a bit, we have 11x+12y+2z. Thus we are trying to find out when this is true:

x+10y+100z=11x+12y+2z

Well, if you just have three variables and one equation, you’re going to get a lot of possible solution. But wait, x, y, and z all have to be single digits. So we know that 0≤x9, 0≤y≤9, and 0≤z≤9. And since we want a three digit number, 1≤x. Since we want to be able to flip it into another three digit number, 1≤z. And since they’re digits, we know that they’re all whole numbers. Okay, now we have some stuff to work with.

If we take our equation from before and subtract all the stuff on the right from both sides we get:

10x+2y-98z=0

Then divide everything by 2:

5x+y-49z=0

We want to isolate one variable to work with, and that z is being subtracted right now, so let’s try moving it back to the right:

5x+y=49z

Well that’s quite the disparity in coefficients! And here’s where the magic is. Since 1≤z, the smallest thing 49z can be is 49. Since we know 1≤x≤9, we also know 5≤x≤45. And since y≤9, the biggest thing 5x+y can be is 54. But since 5x+y=49z, that means the biggest thing 49z can be is 54. And since z is a whole number, we can see that 49*2=98 which is too big. So z must be 1.

If we plug z=1 into our equation, we have:

5x+y=49

Now we’re down to two variables. If we subtract y from both sides we’ll be able to get some nice bounds on 5x, so let’s do that:

5x=49-y

Since 1≤y≤9, 40≤49-y≤48. And since 5x=49-y, 40≤5x≤48. But we know x has to be a whole number. So the only options for x are 8 and 9. So if we plug in either option:

(5*8 or 5*9)=49-y

Which is to say

(40 or 45)=49-y

So if we subtract the two options from each side:

0=(4 or 9)-y

y=4 or 9

And notice that the y=4 goes with x=9, and y=9 goes with x=8. So now all three variables are solved for. Either x=8, y=9, and z=1, or x=9, y=4, and z=1. These correspond to 891 and 941.

So remember that the fun thing about 891 is that 8+9+1+89+91=198. So now let’s look at 941. We can see 9+4+1+94+41=149. Neat! So there are in fact two three-digit numbers with this property.

## Can it be done without the reversal?

On the Learn Fun Facts post, Jack Shalom asks in a comment whether there are any three-digit numbers whose substrings add up to the number itself. The answer is no, and here is the proof.

We start again with 1≤x≤9, 0≤y9, and 0≤z≤9. (We’re not reversing it, so z being 0 would be fine.) Now the equation we want to figure out what makes true is:

100x+10y+z=x+y+z+10x+y+10y+z

Which simplifies to:

100x+10y+z=11z+12y+2z

If we shuffle the ys and zs to the right and xs to the left we get:

89x=2y+z

Since 1≤x, 89≤89x. But since y≤9 and z≤9, the biggest thing 2y+z can be is 2*9+9=27. So this system has no solution.

## The 5-Digit Problem

The 5-digit version is obviously trickier. Because it’s so cumbersome to write and read the process of defining everything again, I’ll skip to the equation. This time I use a through e as digits for the number abcde since they’re easier to tell apart than some of the later letters.:

1111a+1222b+233c+34d+4e=a+10b+100c+1000d+10000e

Which can be rewritten as:

1110a+1212b+133c-966d-9996e=0

Solving this would not be super interesting. First you would isolate e, find out it has to be 1 or 2, and continue from there in much the same way was with the 3-digit problem. So I won’t spend more time on that. However, the general case could be fun. Where did 1111, 1222, 233, 34, and 4 come from? Well, each digit gets a 1 from the single digit strings. Then the first four get a ten from the double digit strings and the last four get a one. Then the first three get a 100 from the triple digit strings, the second through fourth get a ten, and the last three get a one. Finally, the first two get a 1000 for the four digit strings, the second and third get a 100, the third and fourth get a 10, and the last two get a 1. So a got one of each, b got to double up on everything except hundreds, c was excluded from getting a thousand but got two hundreds, three tens, and three ones, and so on.

This pattern could rather easily be adapted to any length of number. I hypothesize that with such generated numbers there’s some way to generate the solutions with single digits, but that will take more work.

## ASMS: Math

There are countless pictures floating around at any given time asking people to do a simple arithmetic problem. Usually the problem requires knowing the order operations are carried out in. Then an argument ensues in the comments, usually with some people sounding really sure that the order of operations only applies in the context of a class on the order of operations. (You could of course have an arithmetic that is strictly left to right, but the standard convention is what it is. Arguing that you’re ignoring the standard convention for the order of operations is as silly as picking a wrong answer and defending it with a nonstandard definition of the plus or times sign.)

I decided to make a somewhat better problem.

Better as in slightly more interesting. I understand the strategy: The comments and shares generated give a page a lot of exposure. People like their pages having exposure. Almost nobody even bothers with mine. But mine seems far less annoying. The few comments it does get are also far less annoying.

(For the curious, it’s a surprisingly easy problem thanks to the multiple choice. You know the cos(x) is sticking around when you integrate with respect to z. Then when you integrate with respect to x it’ll turn into a sin(x) and the whole thing will be a constant. So the third integration just multiplies it by 200. So you have some constant times the sine of something. B is the only option.

## Enough LaTeX for basic logic typesetting

I’m currently taking a (meta)logic class. There are assigned problem sets. A lot of people either don’t know how to type logical symbols or else cannot be bothered to fight with Word. I’m a fan of LaTeX. I like it for several reasons, one of them being easy use of logical symbols.

There are a lot of guides to using LaTeX. To my knowledge, none start from nothing and end with just what’s needed for a logic class. So here I fill in that void. My goal is to be comprehensive enough to cover what’s needed to type up assignments for a logic class while not including anything else so someone can be up and running with just this guide in a few minutes.

### Setting Up

First, you need something to edit your text and something to compile it to a PDF or whatever other format you like. I personally use Overleaf. It’s a free, online application that lets you type in one column with live updates to what it looks like on the page in the other column. It also has templates, allows collaboration, and has some other nice features that are not important to our purposes here. (Full disclosure: The link is a referral link. If you refer people, you get extra storage space and pro features for free. The default free features and space are fine, though.)

There are other popular options. If you need to compile offline, I suggest TeXmaker. If you go this route, you need to download MiKTeX. If you want to write something very long, you may want to type into a text editor and then copy and paste into Overleaf or TeXmaker. (By “long” I mean over fifty pages, give or take based on things like included pictures.)

Onto the actual typing process. If you’re using Overleaf, go to the “My Projects” page and then create a new project. Choose “blank paper”. Then you’ll have this code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
\end{document}

If you’re not using Overleaf, go ahead and put that code into your document.

There is a bit of tweaking to the basic template to make this better. Before the \begin{document} line, add a line containing just \usepackage{amsmath}. Then add lines with add \title{TITLE} and \author{NAME}. Then after the \begin{document} line, add a line saying \maketitle. If you want it to not be huge, type \small\maketitle\normalsize. (The \small makes it small. The \normalsize makes the stuff after it normal size.) At this point my document looks like this.

\documentclass{article}
\usepackage[utf8]{inputenc}
\title{Phil 125 Homework Set 2}
\author{Nichole Smith}
\begin{document}
\small\maketitle\normalsize
\end{document}

### Typing the Document

Everything after this replaces “(Type your content here.)”.

• Typing letters and numbers works as you would expect. Certain symbols are used by the code so typing them is not straightforward. (The & and squiggle brackets are the most notable here.)
• Single line breaks are ignored. So if you type some stuff, hit return/enter, and then type some more, it will show up as one paragraph. (This can be useful. I like to type every step of a proof in a new line. Then it compiles into a paragraph.)
• Double line breaks give you a new paragraph.
• If you want extra space, use \vspace{1cm} as its own paragraph. You can choose lengths other than 1cm if you want.

Onto the logic specific stuff. Of critical importance is math mode. Whenever you surround text with dollar signs ($) LaTeX treats it as mathematical symbols. So, if you type$x$it will be italicized like a variable should be. Math mode does not have spaces. So$two words$will not have a space between them. (If you need a space while in math mode for some reason, “\ ” gives you a space. That is a backslash with a space after it.) Note all logical symbols have to be typed in math mode. The logical symbols: • \land gives you the and symbol • \lor gives you the or symbol • \lnot gives you the not symbol • \rightarrow gives you the material conditional arrow • \Rightarrow gives you the logical implication arrow • \leftrightarrow gives you the biconditional arrow • \Leftrightarrow gives you the logical equivalence arrow (So, capitalizing the arrow tags makes them the bigger arrows) • = is the equal sign • Parentheses are parentheses • \subset gives you the strict subset symbol • \subseteq gives you the subset symbol • In general, typing \not immediately before another symbol puts a slash through it. E.g. \not\subseteq gives you the not a subset symbol • \in gives you the element symbol • \times gives you the times sign • \neq gives you the not equal sign • > and < can be typed directly. To get the or equal to versions, type \geq or \leq • \emptyset gives you the empty set symbol • \{ and \} give you squiggle brackets • \& gives you the & symbol • \top and \bot give you the tautology and contradiction symbols. • \Alpha and \alpha give you upper and lower case alpha. The other Greek letters are similar. • | gives you the Sheffer stroke and \downarrow gives you the Peirce dagger. • An underscore gives you subscript. A caret gives you superscript. E.g. p sub 1 is typed$p_1$. • \hdots gives you a nice ellipsis. Use \cdots if you want them elevated to the middle of the line. • Anything on a line after % will not be compiled. So if you want to make a note to self, you can. I think this covers it. Most of them are pretty straightforward. If you do need more, this webpage has a nifty list. Or, detexify lets you just draw what you want, and it gives you the code. At this point you’re ready to type stuff. I will provide an example now. Say problem 2 asks you to symbolize “neither both p and q, nor q only if p” with the and, material conditional, and nor operators. Then you type: 2. The sentence “neither both$p$and$q$, nor$q$only if$p$” symbolized with the and, material conditional, and nor operators is$(p\land q)\downarrow(q\rightarrow p)$. ### Truth Tables LaTeX can also handle tables very nicely. If you’re lazy, there are online tools to make tables. They have quite a few options. You’re probably fine using that. I prefer more control for my truth tables. Again, you’re fine without. But in case anyone is interested, I’ll explain. Maybe you’ll want to be able to edit the code the generator spits out. (I often use a generator to start and then tweak as needed.) First, here’s the code for the truth table for p_1 or not p_1: \begin{tabular}{c|cccc}$p_1$&$p_1$&$\lor$&$\lnot$&$p_1\\ \hline T & & \textcolor{red}{T} & F & \\ F & & \textcolor{red}{T} & T & \\ \end{tabular} How do you construct this thing? First set up the tabular environment: \begin{tabular}{} \end{tabular} The second set of squiggle brackets after \begin let you set up the columns. Each c gives a center aligned column. If you want left or right aligned columned, use l or r instead of c. Yes, you can mix the three. The | gives a vertical line going down the entire table. Note for truth tables you want a column for every single symbol. That way nothing is under the variables and you can have a straight line of Ts and Fs under the connectives. So, for p_1 or not p_1 we want a column for p_1, a bar, then columns for each of p_1, or, not, and p_1. That’s four more. So, we have: \begin{tabular}{c|cccc} \end{tabular} We have the table set up. Now to fill it in. The first line of the table has the atomic sentences on the left and then the sentence in question on the right. Type the content of each column, separated by &. Then end the line with \\. So, to have the first line of the truth table: \begin{tabular}{c|cccc}p_1$&$p_1$&$\lor$&$\lnot$&$p_1$\\ \end{tabular} To have the horizontal line, type \hline on its own line. Then more on to the next row, doing the same thing you did for the first row. Note that if you want nothing in a certain spot, just leave the space between the two &s empty. So, for the second row, you want a T under the first p_1 (The one on the left side of the table), then nothing under the first one on the right, then a T under the and sign, an F under the not sign, and then nothing under the last p_1. The third line is similar. Now we have: \begin{tabular}{c|cccc}$p_1$&$p_1$&$\lor$&$\lnot$&$p_1\$ \\
\hline
T & & T & F & \\
F & & T & T & \\
\end{tabular}

This is a fine truth table. But, maybe you want to bold the truth values for the main connective. To make T bold, type \textbf{T}. You can replace “T” with other text, of course. If you’re using Overleaf, highlighting the text and pressing Ctrl+B will put the tag in automatically.

This brings us to the complete table as quoted in the beginning of this section.

The comment section is open. Questions and suggestions are welcome.

(Edit notes: As Soren pointed out, I originally put the wrong symbol for commenting. I also realized the amsmath package is not needed, so I removed that. Since these are usually printed in black and white anyway, I got rid of color in favor of boldface type. This has the added benefit of avoiding the need for packages entirely. In the third edit I added the \leq and \geq tags as well as \hdots because I realized they’re needed for indexing variables. \hdots requires the amsmath package, so I added that line back in. Using bold instead of color still seems to be better.)

## The Collatz Trolley Problem

I enjoy a good trolley problem (meme). I came across this one and it presents an odd problem:

All initial values of n thus far tested end up looping with 4, 2, 1, so if it’s any of those, I’m not sure how many people are sucked into the black hole. (Though it’s fewer than 5, so if the goal is minimization of deaths, pulling the lever is ideal regardless.)

This one is a bit odd to think about. On the one hand, at least 5×2^60 initial values have been shown to result in that loop. But many, many more have not (infinitely many, if you believe in infinities).

And if you look at the odd numbers in any sequence the geometric mean of the ratios of outcomes is 3/4, though this only means no divergence. Maybe there’s some cycle involving numbers bigger than 5×2^60.

Also it’s apparently been shown that for any m, the number of option for n between 1 and m is at least proportional to m^.84.

So on the one hand my gut says pull because that evidence sounds kinda compelling. But then some part of me recognizes that m^.84 isn’t even half of m for most m, and 2^61 is relatively small. But then there seems to be some sort of abductive principle allowing the practical inference that pulling is probably right, but I can’t tell what it is.

## Disorder in multiple dimensions

This is a fun post.

Clearly a similar argument can be ran to show the unorderedness of any other field with a rotational operator that just adds dimensions to the reals/complexes (quaternions, octonions, etc.) but I do wonder if either some other property (say, completeness) can be given up to get orderedness or else if some nonstandard field with non-flat geometry can be ordered. (And not be isomorphic to the reals! I suppose this requires and answer to my first question, though, since the reals are the only complete ordered field.)

My friend Jon pointed out that the meaning of orderedness basically requires having a single dimension to order on. (As for all x and y, either x>y, y>x, or x=y. That’s a one dimensional relation.)  Most of the ideas I had in mind with giving up, say, completeness ultimately reduced the dimensionality. (For example, if you take a subset of the complexes that has Re(x)=Re(y)->x=y then you can have an order, but that’s by basically knocking out a dimension.)