Stickytext

I am not from Louisville.
I have never been to Louisville.
I don't even like baseball that much.
This blog is a course log for CSC165H1 in the fall 2014 semester.

Friday 3 October 2014

w-IV

Here is a new post.
It is about the fourth week.
In the course, I mean.

-------------------------------------------------------------

I was told that I should talk about ``the paper folding problem'' and so I shall as not to disappoint my avid readers.

The lecture had an explanation about rotational symmetry, but I didn't much care for it.

A question is posed:
If we fold a piece of paper in half, right hand over top to left hand and unfold it, we have a single crease in our paper pointing downwards. If we fold it once and then again from the far right edge again over top to the left side and completely unfold it, we now have multiple creases. Some of these will point downwards and others upwards. How can we predict the direction and order of theses folds for repeating this process an arbitrary number of times?
To begin, we can simply do this to a piece of paper and look at the results:

N Folds
1 D
2 DDU
3 DDUDDUU
4 DDUDDUUDDDUUDUU

In this case, N is the number of times the folding process is repeated `U' denotes an upward pointing fold, and `D' a downward pointing one. Firstly, we notice that the number of folds is easily predictable by considering that each fold doubles the number of segments that the paper is divided up into and the number of folds is one less than the number of segments. This says that we will have 2^N - 1 folds where the process has been repeated N times.

Now, to the order and orientation of folds. When the folding process is repeated, we never change or remove existing folds. So if we can understand how new folds are added, we can understand recursively how to predict the folding pattern for arbitrarily large and/or non-physical values of N. Knowing that any existing folds must persist, we can rewrite the table to make this clearer.

N Folds
1 D
2 D       D       U
3 D   D   U   D   D   U   U
4 D D U D D U U D D D U U D U U

Now what we are particularly interested in are the folds that are added at each stage. Firstly, we see that from 1 to 2, we add a D and a U on either side of the centre crease. From 2 to 3, We a D and U on either side of each crease which is not from the original crease. Already, we see a pattern forming. Looking at all of the folds created from 3 to 4, we note that they always alternate (D, U, D, U,...). If we consider the implications of this, we understand that it makes perfect sense. When the paper is already folded, it is a continuous strand that passes some number of times from our left hand to our right hand and back, because after the first fold, both ends are kept in the left hand. Because the piece of paper is continuous, after it passes from the left to the right hand, it immediately passes back to the left from the right. Any two consecutive segments that we are about to introduce a new fold to, run antiparallel to each other immediately preceding the fold. Thus any two consecutive new folds must have opposite directionality (UvD or DvU). It should be clear than a recursive iterative solution can therefore easily be arrived at.

The problem while very symmetric in the introduction of new folds has a degree of non-symmetry introduced in that the paper does not begin to receive folds symmetrically until we have already folded it in half uniting the two ends of the paper, effectively creating a `loop'.

So I guess my solution for a general N, might look something like this in MATLAB:

% Up  = 1
% Down = 0
% N = ???  % You need to assign N a value and remove the first '%'
folds_old = 0;
n = 1;

% assuming N > 1

while n < N

    n = n + 1;
    folds_new = NaN(2^n - 1,1);
    % Setting even elements to existing folds 
    folds_new(2:2:end) = folds_old;
    % Set first of odd folds to down
    folds_new(1:4:end) = zeros(size(folds_new(1:4:end)));
    % Set second of odd folds to up
    folds_new(3:4:end) = ones(size(folds_new(3:4:end)));
    folds_old = folds_new;

end

I'm sure there's a way to do this in Python, but I am familiar with MATLAB indexing things and it took, like, a single minute to do, so whatever. If you are unfamiliar, K(A:B:C) in MATLAB takes every Bth element of K starting at index A up to indices no greater than C. Note that indexing starts at 1.

I hope that this has been sufficient or good or whatever. 

Thanks for sloggin' in my bog,

J

No comments:

Post a Comment