# Try “really” doing the math

Taking “tests” by random people at Facebook is a bit fun some times. Everyone needs a bit of “fun time”, so answering some of the non-idiotic “which pornstar are you?”-style tests is ok.

But if you are writing a test with math-related questions, it’s almost as silly and definitely more than a bit annoying to skip checking the answers. Mathematical Thinking includes one of these annoying bugs.

One of the questions you have to answer is:

The price of a microchip declines by 66% every 6 months. At this rate, approximately how many years will it take for the price of an \$81 microchip to reach \$1 per chip?

By a mistake in the calculations I made on paper, I answered 2.5 years, instead of 3 (which is the correct answer). But I was surprised to see that the test marked the answer as “false, because 2 years is the answer”.

So I went back and redid the calculations on paper, and I also wrote a short Python script to double-check my results. Nope, both wrong.

When “declining by 66% every 6 months”, a price becomes 44% of its old value every 6 months. The price at N months is then P(N) = INITIAL * 0.44 ^ (floor(N / 6)). The scale value of the initial price can easily be written in Python as:

```from math import floor

def scalefactor(months, rate=0.44, every=6):
e = floor((1.0 * months) / every)    # exponent after some 'months'
return (rate ** e)```

With this in place, we can now check the price of a chip after an arbitrary number of months:

``` def check1(months, iprice=81.0, rate=0.44, every=6):
sf = scalefactor(months, rate, every)
return {'months': months, 'years': months / 12.0, \
'scale': sf, 'iprice': iprice, 'price': sf * iprice}```

A bit of mapping then shows:

```>>> for k in map(check1, range(0, 40, 6)):
...     print k
...
{'price': 81.0, 'iprice': 81.0, 'months': 0, 'scale': 1.0, 'years': 0.0}
{'price': 35.640000000000001, 'iprice': 81.0, 'months': 6, 'scale': 0.44, 'years': 0.5}
{'price': 15.6816, 'iprice': 81.0, 'months': 12, 'scale': 0.19359999999999999, 'years': 1.0}
{'price': 6.8999040000000011, 'iprice': 81.0, 'months': 18, 'scale': 0.08518400000000001, 'years': 1.5}
{'price': 3.0359577600000001, 'iprice': 81.0, 'months': 24, 'scale': 0.037480960000000001, 'years': 2.0}
{'price': 1.3358214144, 'iprice': 81.0, 'months': 30, 'scale': 0.016491622399999999, 'years': 2.5}
{'price': 0.58776142233600004, 'iprice': 81.0, 'months': 36, 'scale': 0.0072563138560000004, 'years': 3.0}
>>> ```

So it takes 36 months (or 3 years) for the price to drop below 1.0 dollars. That’s not 2 years, sorry :-(

## 4 thoughts on “Try “really” doing the math”

1. vvas

Actually, if the price declines by 66% every six months, it means it becomes 33% of the original price every six months, i.e. one third of the original price. Thus if we start from 81 we get to 27 after six months, 9 after a year, 3 after a year and a half, 1 after two years. Sorry, you lose. No fancy python necessary. :-p

2. Γιώργος

66%+44%=110%. No?

3. keramida Post author

Yes, you are both right. I think I’ll blame “too little coffee in my bloodstream”.

/me ducks

4. koki

καλά, άσε τα μαθηματικά, το έχεις παραχέσει με τα τεστς στο facebook :P αυτό είναι το ρεζουμέ!