I've been thinking quite a bit about arithmetic progressions since I came across the problem "The Arithmetic Progression Detective" on Codewars. An arithmetic progression is a sequence of numbers such that, for any consecutive numbers and in the sequence, is always the same value, known as the common difference. One example of an arithmetic progression is the sequence whose common difference
Let be an arbitrary sequence of integers, or terms. Let be the common difference of the arithmetic progression from which deviates by no more than one value—the incorrect value—if such a progression exists. I'm going to call fixable if and only if such a progression exists. If cannot be turned into an arithmetic progression through the replacement of just one number in then is not fixable. Bearing this in mind, what limits can we identify to the range of fixable sequences?
Let be the sequence Let be the sequence is not a fixable sequence. But clearly is, since deviates by just one number from the arithmetic progression
and have a great deal in common. Each includes four numbers. Each superficially resembles an arithmetic progression. Each contains exactly one apparent deviation, in one sense or another: exactly one step whose size differs from the others' in the case of and exactly one incorrect value in the case of So what difference between these two sequences makes fixable and not?
One of the first things I noticed is, unlike consists of steps all but one of which are the same size. To see this, note the following. The step from to in is of size The remaining steps in are of size By contrast, in each step's a different size. Steps one through three, respectively, are of sizes and So, the only step of size in is the third and final step, from to
This goes to show you should not take for granted that contains more steps of size than of any other size, even assuming that there are four or more values in and that only one is incorrect.
But this difference between and does not fully explain their differing with respect to fixability. Some sequences are just like in that they consist of steps all but one of which are the same size, but they are still fixable. One such sequence is All you have to do to fix this is replace with Really any sequence is fixable whose first or last term is the sole incorrect value. For our purposes the incorrect value in is defined as the one and only term whose replacement can single-handedly turn into an arithmetic progression.
What sets apart from a sequence whose first or final term is the only wrong one? Why is not fixable like that kind of sequence? An obvious response is that doesn't contain exactly one incorrect value. But I'm not satisfied with that answer. It's not wrong, but it's not illuminating either. It raises questions like: "How many incorrect values does contain? How exactly do we count them?" We need to explicate what makes a value incorrect and how we can tell a value meets that condition. Maybe the following is a better answer.
In we have a step of size followed by one of size followed by one of size If we could turn that second step into a step of size we'd be able to create an arithmetic progression. But if we try to do that by moving the second step's beginning closer to its end, we widen the first step; the first step ends where the second begins. If on the other hand we move the second step's end closer to its beginning, we widen the third step; the third step begins where the second ends.
So there are ways to decrease the size of the second step from to But they all end up shortening or lengthening one of the other steps, such that it is no longer of size (Well, more precisely, all our options have this result if we limit ourselves to replacing just one integer in with just one integer.) So we don't end up with an arithmetic progression.
That's where differs from The latter sequence consists of a step of size followed by two steps of size Crucially, that first step has an endpoint that no other step has. That is, the first number in the sequence is where the first step begins, and no other step begins or ends with that term. So you can replace that term with any number you want, including a number such that The substitution will affect no step but the first, which is the only one you want to change.
Here is a more formal proof that you cannot turn into an arithmetic progression by replacing just one term with just one integer. We can split into two categories the integers in there are to replace: the numbers on the ends and those in between.
Suppose you replace exactly one of the two numbers on the ends Replacing changes only the size or direction of the first step, whereas replacing changes only the size or direction of the final step. So after you replace the sizes of the second and third steps are still, respectively, and And after you replace the sizes of the first and second steps are still, respectively, and But all the steps in the modified sequence must be the same size, if the sequence is to count as an arithmetic progression. So the modified sequence cannot be an arithmetic progression. In other words, you cannot turn into an arithmetic progression by replacing just or just with just one integer.
Suppose that instead you replace exactly one number strictly between those on the ends Let and be arbitrary integers such that and Let be the sequence resulting from replacing with Let be the sequence resulting from replacing with
Recall that is the sequence Consequently, is the sequence and is the sequence The first two steps in differ from the first two in no other step in differs from its counterpart in The final two steps in differ from the final two in no other step in differs from its counterpart in
Let Then is the signed value representing the size and direction (on the number line) of the step from to in and is that representing the size and direction of the step from to in Furthermore, is the signed value representing the size and direction (on the number line) of the step from to in and is that representing the size and direction of the step from to in
or is an arithmetic progression only if all steps within it are of the same size and direction. Thus, is an arithmetic progression only if
And is an arithmetic progression only if
But it is true neither that
nor that
I shall show that neither of these is true by giving a proof by contradiction of the falsity of each.
Here is a proof by contradiction that
is false.
Assume the following, arguendo:
Then:
But our initial assumption entails
So:
But obviously:
Therefore,
Contradiction! We derived this from our initial assumption. A contradiction cannot be true, so neither can anything that entails a contradiction. Thus, our initial assumption must be false. Since this conclusion follows given an arbitrary integer the proof just given demonstrates that is false regardless of what integer you substitute for in
Now let us prove by contradiction that
is false.
Assume the following, arguendo:
Then:
But our initial assumption entails:
So:
But obviously:
Therefore,
Another contradiction! Since this conclusion follows given an arbitrary integer the proof just given demonstrates that is false regardless of what integer you substitute for in
Recall that is an arithmetic progression only if
And is an arithmetic progression only if
But as the foregoing proofs by contradiction show, it is true neither that
nor that
Therefore, neither nor is an arithmetic progression. But is the result of replacing in with an arbitrary integer, and that of replacing in with an arbitrary integer. So, no matter what integer you substitute for or in you don't thereby get an arithmetic progression.
But if you can't get an arithmetic progression by thus replacing just or and you can't do so by thus replacing just or then you can't do so by thus replacing just or But that means you can't do so by replacing just one integer with just one integer, since and are all the integers there are to replace in
Therefore, you cannot turn into an arithmetic progression by replacing just one term with just one integer.
From the above proof, what lesson should we draw concerning sequences other than This is my takeaway.
Let be some sequence of integers of length (To be clear, we know includes the four values and We don't know if includes other values.) Let Let be the number in Let Let step be the step in from to Note that replacing with a different integer changes only step and step
Let be the sequence resulting from replacing with an arbitrary integer Let be the number in Let The subscript of should be read as not as the expression with which is interchangeable.
Replacing exactly one integer in can only turn into an arithmetic progression on the following condition:
Here is an informal, rough English translation of the logical notation above. There are integers and such that
(I) is the difference between and and
(II) lengthening step (if there is one), and shortening step (if there is one), by units ensures all steps have the same size and direction.
Allow me, now, to prove that is not an arithmetic progression if
Assume the following, arguendo:
is an arithmetic progression, and
You know what we have to do. Derive a contradiction!
By the definitions of and is the number in and is the sequence resulting from substituting for in Thus, the number in is rather than By definition, is the number in So, given that and are each the number in it must be that
Since is the only number in that differs from the number at the corresponding position in
So,
So, by the definition of
Solving for
Then, from the definition of we get
So, seeing as and we may conclude that
Then we solve for as follows:
Now let's take our solutions for and and combine them with the following information. The definition of implies that and Taking all these facts into account, we see both that
and that
Of course, that means and Solving both these equations for we get
as well as
From those two equations, we derive
which we simplify to
From our assumption arguendo that is an arithmetic progression, it follows that Given the conjunction of this equation with it is provable that
which can be rewritten as
The fact that is an arithmetic progression tells us the following as well:
And considering that is indiscernible from apart from having been substituted for this must be true:
This means that, for all numbers equal to neither nor we can replace with in the chain of equations presented immediately prior to the universally quantified generalization:
Time for another proof by contradiction! We want to establish the truth of
so we assume the negation of that for the sake of argument:
From this we derive
which contradicts our previous conclusion that
Therefore,
which completes our subproof!
It goes without saying that both the integer and the difference exist. So, we have found a and a such that
If you're curious, is our and is our That is, we can go from
to
And then we've established So we have finally derived a contradiction from our initial assumptions. Recall what those assumptions were: is an arithmetic progression, and From these we ultimately concluded which contradicts the second of our two initial assumptions.
So, either is not an arithmetic progression, or But this disjunction is just another way of saying is not an arithmetic progression if
And that's what we set out to prove!
Top comments (0)