Tuesday, September 30, 2008

A mathematical problem

As a scientist, although I got a transfer credit for the first year calculus, I dont know much about real world calculus! And i am happy that I dont know anything much about it because thats the best result you can get: Know Nothing! This proves that there still much to learn ahead and excitement to come!

Here's the problem that got me stuck for ages:

My friend owns a roller shade company and he need to make boxes for them. He makes the barrels himself and they come in various diameters. Now he has to roll a shade of length L onto in and after each turn, the total diameter increases exponentially (because it is a spiral and spirals grow exponentially, not linearly). Then we can obtain the total diameter of the barrel and the shade rolled onto. Once we have that, we can order boxes of correct dimensions.

Here is a picture of the situation:




Now, the only way i tried to solve this problem is by rolling and counting the number of turns made first.

So lets denote:

Length of shade: L

Width of shade: W

Thickness of shade: h

diameter of barrel : D

3.1412 : pi

n = number of rolls

Now lets roll the first turn: we can do that by subtracting the circumference of the diameter++ from the sheet of shade.

n = 1 => So 1st turn: [L - pi(D)] cm left to roll onto

n = 2 => 2nd turn: [(L - pi(D)) - pi(D+h)]

<=> [(L - pi(2D + h)] cm left to roll onto. pi(D+h) means that the new circumference has increased by the thickness of the shade, which also varies in size.

n = 3 => 3rd turn: [(L - pi(D)) - pi(D+h) - pi(D+2h)]

<=> [(L - pi(D)) - pi((D+h) + (D+2h))]

<=> [(L - pi(D)) - pi(2D + 3h)]

<=> [(L - pi(3D + 3h)] cm left to roll onto.

n = 4 => 4th turn yields: [L - pi(4D + 6h)] cm left to roll onto

n = 5 => 5th roll yields: [L - pi(5D+10h)] cm left to roll onto

n = 6 => 6th roll yields: [L - pi(6D + 15h)] cm left to roll onto

... nth roll

So for n>1 rolls:

We can observe a pattern. If we look at the last digit in each equation, we see 1, 3, 6, 10, 15, ...

And this pattern is best described as triangular numbers: http://en.wikipedia.org/wiki/Triangular_numbers

So we can actually write a program that can generate a list/range of numbers from

2 -> m # {2,3,4,5,......,(m-1)}, lets call this list m

then we create a regular list starting from 1 -> p # {1,2,3,4,.........,p}, lets call this list p

Assume m and p are natural numbers. Then we add each number in a specific way:

for i in range(0,m):

p[i+1] = p[i] + m[i]

Then list p will have elements: {1,3,6,10,15,...}

and save it in an ordered list named Q. Then, if we can start with our base case, n = 1, we can substitute each number from this ordered list to the last digit in our n+1 equation corresponding to the proper index. So we will have an ordered list Q of triangular numbers. That would solve the problem creating the pattern.

Now for the coefficient of D, we can see a similar pattern but it seems to be related to the number of rolls. So for every new equation for (n+1) turns, we can form a formula:

Assume that n > 0:

Length remaining to roll =

if n = 1, [ ( L - pi( (n)D ) ]

else if n > 1, [ ( L - pi( (n)D + Q[n-2]*h ) ) ]

Q[n-2] indicates the index of the element in Q

So now we have a general formula to calculate the number of turns possible given a length of a shade and the diameter of the barrel. We dont care much about the width of the barrel and shade as it does not affect our calculations.

Now since we can predict the length of any nth roll, we can write some code to check if the length remaining is smaller than the length required for the next (n+1) roll and if it is smaller, we can stop there and return 'N', the number of rolls possible.

We now have the number of turns possible but I still cannot find a way to find the diameter at that Nth point. I am still working on it but if anyone has any hints, please let me know, that would be great!

I hope you enjoyed this problem as much as I did.

Assignment 1 and the symmetric pattern

For assignment 1, problem 2, i noticed something fishy... Something playing around with my mind..

I could sense a pattern going on but couldn't trace it down. The problem is that we are given 2 meals, L and S. A suitable cycle for the meals in which the meal for the next day differs by exactly one would be: {}, {S}, [L,S}, {L},

So when we add a new meal and manually compute the set, we get this:

{}, {S}, [L,S}, {L}, {L,P}, [L,S,P}, {S,P}, {P} which is correct.

But I noticed something interesting. Starting from the first element {}, lets make a copy of this list. If we take the region after the last element and before the "," [i.e: {}, {S}, [L,S}, {L} (THIS REGION HERE) ,] and use it as a vertical symmetry axis, we can rotate the list by 180 degrees and we would obtain an image of our original list.




Then if we add the new meal 'P' in each set in our newly rotated list, we get this:
{}, {S}, [L,S}, {L}, {L,P}, [L,S,P}, {S,P}, {P}

And this corresponds to what we would get by manually verifying it:
{}, {S}, [L,S}, {L}, {L,P}, [L,S,P}, {S,P}, {P}

So, could there be a pattern? Lets check by adding a new meal 'Q'. We repeat the same stesp. Lets create an imaginary vertical symmetry axis at the point labelled 'here': ...{P} (HERE) ,

Lets make a copy of the list and rotate it. We would get this:
{}, {S}, {L,S}, {L}, {L,P}, {L,S,P}, {S,P}, {P} ( Symmetry Axis here) , {P}, {S,P}, {L,S,P}, {L,P}, {L}, {L,S}, {S}, {}

So if we add the new meal 'Q' in each set of our newly rotated list, we would get:
{}, {S}, {L,S}, {L}, {L,P}, {L,S,P}, {S,P}, {P}, {P,Q}, {S,P,Q}, {L,S,P,Q}, {L,P,Q}, {L,Q}, {L,S,Q}, {S,Q}, {Q}

And if we verify manually, we would get the same! So there exists a pattern to solve this question! In a programming language, we can achieve this by copying the list, reversing the elements, add the new element in each array, appending the modified copy to our original list and voila!

Maybe the law of supersymmetry in physics (which states that for any object, there exists its symmetric twin somewhere else in the universe) could explain this but this technique works for any length of the list!

Now we can also observe that the length of the list is equal to 2 ^ (number of meals)
Inductively we can prove that when new meal is added, the length of the new list of meals is double that of the original list.

n>2

We need to rpove P(n) => P(n+1)

<=> 2^(n+1) = 2^n x 2^1
<=> P(n) x 2 # Which means P(n) was actually 2^n

So inductively we can show that the length of the new list is double the size of the original list.

Hope it helped!

First

Welcome everybody to my blog! This is my first post and I will be posting very frequently about my experience with CSc236. Just as a short recap, I had a nightmarish time with CSC165 - Maths reasoning for computer scientists. I cannot understand why but i feel that I like CSC236! Its more like applying the proof techniques in CSC165 to real world problems. Well, we will see how it goes... Stay tuned for more posts.

-Bimal