Showing posts with label Math. Show all posts
Showing posts with label Math. Show all posts

Tuesday, July 24, 2007

TI-89 Long Division Program

Today I had to find the first 50 digits of 1/95. With all our modern technology, it should be easy to find, right? Unfortunately, the Windows calculator cuts off at 36 digits, and my sophisticated TI-89 cuts off all operations after a measly 16 digits.

The solution? I wrote me own long division program:

div(n,x,t)
Prgm
""->res
10->n
0->d
0->s
While t>d
iPart(n/x)->q
n-x*q->r
res&string(q)->res
r->n
if s=0 and x>n then
res&"."->res
1->s
EndIf
d+1->d
10*n->n
EndWhile
EndPrgm


This program accepts three parameters: n, x, and t. It divides n by x and outputs the first t digits into the variable res (for result :P).

Wednesday, April 25, 2007

USAMO!

Whew - this week has been crazy. And I think we all know why ... it's USAMO time! Or was ...

Fortunately, I was able to talk to Messrs Block and Micek, and negotiated my ability to take the USAMO, but at great cost. The first day I had to take the USAMO in Micek's classroom ... while freshmen were taking the STAR testing. They were loud, to say the least, and I could focus only with great difficulty, at least until 12:20 (3:20 ET - that is, 1:40 before time was up) when the freshies left. (But don't worry, I didn't break any rules - I was proctored and I didn't chat.) This may explain my relatively poor performance on Day One.

The second day was easier, as I was able to negotiate taking the test in the library (don't worry, oh eagerly pissed-off USAMO graders, I was indeed proctored), and I performed much better. Big surprise.

I was quite out of shape mathematically. I had only started practicing seriously for the USAMO about a month before, and I couldn't seriously hope to do very well with so little practice. Of course, taking old tests is a little pointless if you can't solve a single problem... ;) In this regard, I think I did much better than I expected - in the immortal words of Ubemaya, "my goal is a non-negative score, although I'd be happy to get a negative score also."

My equipment wasn't the best either. The first day I took my dad's expensive Byelorussian sketching kit, but unfortunately the compasses there were rather dull, as they had not been used for quite awhile. Keeping this in mind, I took my own, much smaller compass set the next day, only to understand why I hadn't taken it the first day - the quality was so bad that I could hardly use them, and the set did not include a protractor, just when I needed one (for problem six, I finally had to resort to constructing right triangles on graph paper and then tracing 60 degree angles to draw a neat equilateral triangle). Once again Staedler's quality shows me why those guys should just stick to making erasers ...

But enough about working conditions. Time to talk about the problems!

As I mentioned earlier, I didn't do too well on the first day, partly because of the friggin freshmen, and partly because of my own stupidity of course. I immediately jumped ahead and solved the second problem, taking something like two hours to write up an incredibly neat, incredibly detailed solution - only to realize after faxing the solutions that I was supposed to find a circle with radius sqrt(2)/2, not a square with side length 1! Well, I hope I'll get two or three points, because other than this my solution is a pretty good one. Next, I attacked problem one, finding out some facts and then hitting a brick wall - I submitted some hastily done formulae in hope of maybe one point. And problem three - that I could hardly understand, let alone find a way to solve. Total for Day One: 3-4 points of a possible 21.

The second day I performed much better. I solved Problem Four satisfactorily, for six, maybe even seven points. The great thing about Problem Four was that it asks for an answer - 8025 - so I KNOW I got the problem right! =) And I proved the equilateral equality for #6, though I did not make any headway into proving the general inequality: I'm hoping for one or two points for the equality. Problem Five I stared at and stared at, but couldn't solve, as, I imagine after seeing the solution, neither could 99% of test takers. Total for Day Two: 7-9 points of a possible 21.

So, in total I got 10-13 points, which isn't bad at all for someone who expected to get zero (see my previous post for details about all that). After a little practice, and hopefully without interference from pesky freshmen, I may even qualify for MOP next year! (18-20 points needed to qualify for sophomores and juniors)

Sunday, April 22, 2007

USAMO?

By an unfortunate coincidence, the two 4.5-hour days of the USAMO fall right in the middle of standardized testing week. To add to the problem, Mr. Micek won't be able to proctor me this time, and I'll need web access to download the problems. And suspiciously, the vice principal, Mr. Block, always seems to be in a meeting when I come by the office, and doesn't respond to my emails either. Well, tomorrow's the day before the first day of the USAMO, so I'll have to get some answers from him, even if I have to camp out outside the office.

Of course, my practice test scores are rather depressing. By a very lenient scoring system, I give myself:

0
3
6 (must've been an easy year ;) )
3
3
0
2

Keep in mind that I'm practicing off old tests (4.5 hours / 5 problems), as opposed to new ones (9 hours / 6 problems). And I should remind my readers that the olympiad starts the day after tomorrow. Hopefully that gives an indication of how screwed I am >.<

Wednesday, March 28, 2007

School is pain. AP exams = very yes.

The title says it all.

Euro is going nuts, with some 2 hours of mandatory studying every night now, in addition to many lunch periods and 7th periods sacrificed for "optional" videos and DBQ practice. To be fair, it is partly my fault - in February, at the start of second semeste, Mr. K asked if there was anything we would like to change in the class. Seizing the opportunity, I proclaimed that there shalt be no mandatory outlines, and it was so. Somebody else - whose name shall not be uttered - did cry out against the projects, saying "it shalt be not so," and it was declared that there shall be no mandatory outlines or projects. And then it all collapsed. We became lazy, we failed our quizzes and tests even more than what's regular for Euro (although oddly enough, I didn't change, but that's just me), and with the AP coming up, we were grossly underprepared. Finally, Mr. K made us an ultimatum last week: if we wanted to pass the AP exam, we must play by his rules, which meant even longer hours than first semester, and a return of the dreaded projects. Furtunately, I was able to set up a forum for our Euro class on Mr. K's behalf, which proved to be a good idea, as we are now able to coordinate our study and work together on class projects. Nevertheless, Euro is really becoming painful now.

But speaking of painful in the literal sense, while studying for the AP Bio test (ridiculous really, the chapters were longer than ever, and we needed to memorize the functions of 30 different hormones), I stayed up so late that when I woke up my leg was sprained so much I had to spend the morning of the test practicing walking again. (I don't know how staying up late has a connection to leg pain, but my parents assure me that it does.) It was getting better, but then we had to run two miles in the rain, a run that in retrospect I should probably have just asked to make up. My leg did not like that run at all.

Even Statistics, the easiest AP in the school, is picking up the pace now. For the first time, I actually have to work hard on the homework, and the tests are becoming challenging as we are getting ready to "battle the APE".

And to add to all that, the USAMO math olympiad is coming up in late April, and I have no idea how to study for it, or indeed, if I even qualified (though I'm fairly sure I did). The unanimous advice on how to prepare is practice, practice, practice, but there's really nothing like the sensation of sitting down, reading a test, working on it, and eventually coming to the conclusion that you can't solve a single problem. >.<

There's plenty of other topics I wanted to write about, but I really want me leg to get better, so perhaps I should stop while it's still 10:28 (by some miracle, there was little homework today; it's the first time in a week that I'm going to bed before 11 o'clock).

Tuesday, March 13, 2007

AIME

Took the AIME today. It was harder than I anticipated, but I still managed to answer 7 problems correctly (6-7 will probably by the cutoff, so I probably qualified for the USAMO ^_^).

I'm not allowed to discuss problems yet, so that'll have to wait for a later post.

Thursday, February 22, 2007

AMC - the longer post

Yesterday, I came to the AMC12 very prepared indeed: I forgot to bring a calculator (had to use a friend's, which kinda screwed me up), a ruler (the only one Mr. M had was 4 feet long), a compass and protracter, and graph paper (got lucky - found a sheet of graph paper in Mr. M's scratch paper pile, proclaimed, "I hit the jackpot!").

When I came to the testing room (Mr. M's room - he also happens to be my Stats teacher) after school, I expected three, maybe four people other than myself there. To my surprise, there were a total of six AMC10 takers and four AMC12 takers (including myself), some of whom I didn't even know. These numbers are about the same as last year, but this year we had the disadvantage of only having one test day (we have only the geniuses behind the High School Exit Exam to thank for taking away the AMC A). Yesterday also happened to be a practice day for the tennis team; we lost about five kids due to that.

It is interesting to note that other than myself, every single test taker paid that very day (we - well, not me of course - had about two week's notice of the AMC). Several paid right before taking the AMC, and Mr. M even let two take the AMC12 without paying (they promised to pay the next day, but I have doubts about that).

Anyways, my lack of proper tools did hurt me, but not as bad as I originally thought. I won't discuss individual problems yet - not sure if I'm allowed to - but this year's test was different from last year's. Call me crazy, but I think that the easy problems were easier, and the harder problems were harder this year, which of course is not a good sign.

I solved 18 problems - not very good - but, after comparing answers with Bob, to my surprise I found that I solved all 18 right, giving me a solid 118.5 score, more than enough to make it to the AIME.

I'm going to be busier than ever now. The AIME is coming up, and after that I have about a month break before the APs. And maybe an SAT or two. Yup, my free time is gonna be severely limited...

Wednesday, February 21, 2007

AMC Day

Took the AMC12 today. Can't write anything more right now, partly because I'm not supposed to discuss details the day of the test, partly because I have to write an Euro essay about a video that I didn't see due to the AMC... >.<

Sunday, January 07, 2007

Reflections

[00:24] Alex: don't tell me you're up at this hour?
[00:24] Bob: go to sleep

Well, my parents are at a wedding (my second cousin, who, for some reason, forgot to invite me), and I assume that it's common courtesy to stay up until they get back (am I right? :P). So, seeing how it's the new year, let me take this time to reflect on the year 2006.

Uh-oh. I just realized I can't remember back that far. Curse my complete lack of any long-term memory!

Well, let me try something a bit easier: can I look back on winter break? After all, school starts again this Monday.

Let's see, this winter break I managed to:

Well, that's about it, the long and short of it. Worth using up most of my winter break on the above items? Dunno.

Thursday, December 28, 2006

Preparing (somewhat unsucessfully?) for the AMC

One of the things I really have to catch up with this winter break is preparation for this year's AMCs. Unlike last year, where I took both the A and the B exams (10A and 12B), this year our school is only hosting the B (stupid high school exit exam getting in the way of everything... completely pointless if you ask me >.<), which means I only have one shot to make it to the AIME. Nevertheless, I am fairly confident about the AMC - today I scored 114 (out of 150, 100 and higher qualifies) on a practice test, so I think I'm all set for that. However, for the AIME... let's just say this is looking to be a repeat of last year (5/15, due to 4 rather careless errors) - I scored a miserable 2 on a practice test, again because of carelessness on my part. Granted, I haven't had any practice since this summer, but still... Looks like I've got a lot of work ahead of me... ;)

Tuesday, September 12, 2006

Math Blues

I was gonna do a blog entry yesterday - honestly! I had a really nice one planned for 9/11, urging America to stay focused and everything. The whole deal. But then, this happened:

In the adjoining figure, two circles of radii 8 and 6 are drawn with their
centers 12 units apart. At P, one of the points of
intersection, a line is drawn in such a way that the chords QP
and PR have equal length. Find the square of the length of QP.

Once again, I stayed up till eleven, this time working on this problem (for my online math class). I have five pages of diagrams and equations on my desk, but I still haven't figured anything out. Here's yesterday's schedule:

9 PM: Finish homework. Decide to work on this problem (class meets tomorrow - err - today).

9:30 PM: Got nothing done. Ask dad for help. We proceed to work on it together.

10:00 PM: Dad has other things to do. I tell him that I'm giving up, go and eat dessert, and then for some strange reason am drawn back into the room. Keep working on it.

10:30 PM: For lack of a better approach, start drawing huge copies of the diagram and measuring. Estimate the answer to be 138 (plus/minus 2).

And I still haven't figured it out. If you have any ideas, feel free to post! Bob - this one's for you ;)

Monday, August 14, 2006

Click Click! - version 0.2


My focus for this version was smoother movement, which I achieved using a bit of math, as shown in the diagram below:




I also decided to play around with it, and made a few cheats (Ctrl, Shift, Z, Num Pad + and -). ^_^

Next on my agenda: a title screen!

Monday, July 24, 2006

Hey, it Works!

The Problem: Creating a geometric mean function for PHP.

First Attempt: Just doing something along the lines of (p1 * p2 * ... * pn) ^ (1/n) . However, even PHP has its limits, and for high n's (we're talking along the lines of hundreds or even thousands), it would just die on us. We needed a better way!

The Solution: Logarithms, yes, logarithms. With basic identities, we find that (p1 * p2 * ... * pn) ^ (1/n) = 10 ^ (1/n * log p1 + log p2 + ... + log pn) ! Now instead of multiplying huge numbers, we're just adding them!

By the way, here's the full function - feel free to it in your own PHP experiments (courtesy myself and Mgccl):

function func_math_mean()
{
$elo = func_get_args();
$num = 0;
foreach ($elo as $value) {
if ($value == 0){
$value = 1;
}
$num = $num + log10($value);
}
$count = func_num_args();
$num = pow(10,$num / $count);
return $num;
}

Saturday, July 22, 2006

LF2, Ladders, and Logarithms

(Don't worry about LF2.5 - I'm still working on it ... and I'll release it in three days!!)

I've decided to help Mgccl, a fellow LF2 modder, build an online ladder system for LF2.

The ladder should have the following features:

  • Track and store the results of all ranked games. (No idea how we'll do this - for now we'll do it on an honor system, where players submit their game results.)
  • Keep track of each players' wins, ties, and draws.
  • Calculate each player's rating, using a variant of the ELO system.
  • Support clans and countries, and rank them as well as ranking individual users.
  • Support all possible team combinations, from 1-vs-1 to 2-vs-5 to 4-vs-4.
  • Track which character each player uses, and rank them on each player (i.e. best Davis players, best Julian players, etc.)
Today, the first thing we did was come up with a database. Here's what we have right now (courtesy of myself and Mgccl):

country:
country_id , country_name , country_flag , country_wins , country_total_elo, country_total_exp

clan:
clan_id , clan_name , clan_leader , clan_wins , clan_losses , clan_draws , clan_ranking, clan_total_elo, clan_total_exp, clan_members

user_stat:
stat_id, stat_elo, stat_exp, stat_rank, stat_win, stat_lose, stat_draw

user_prof:
user_id, clan_id, country_id

team_user_link:
team_id, user_id

vs_games:
game_id , team1_id , team1_winrounds, team2_winrounds

Mgccl also singlehandedly coded the ELO script (this guy's amazing at PHP!) Now we are missing one crucial feature - ranking for team games. Since I'm good at math, it falls to me to solve the following problems:
  1. I must find a way to average the team members' ratings to create a team rating. A simple arithmetic mean won't work - a team with one member rated 1500 and one member rated 1000 does not have a 1250 rating!

  2. Figuring out 1) will let us play 2-vs-2, 3-vs-3, and 4-vs-4 games, but what if we want to play a game with unequal teams? I must calculate how to adjust the temporary team ratings, to account for the fact that teams with more players have a much better chance of winning.

  3. Once I find 1) and 2), I am able to use Mgccl's ELO algorithm to find how to adjust each team's rating, but wait! Teams aren't rated - only players are! I must figure out how to apply the rating adjustment to the team members. As far as I see, the answer to this is to simply take the team adjustment and adjust each team member's rating by it, but I'll have to do some more research on this.

Some data to help me: The ELO system is designed so that if two players (or teams) have a rating difference of 200, then the stronger team should have a 75% chance of winning. I think that if I take a few logarithms, I should be able to figure out the answer to 1) and maybe 2) from that statement.

Whew. Long, very long, incredibly long, post.

Sunday, July 02, 2006

Three 2's

Here's a fun little problem:

Show how you can get any positive integer, using only three 2's and any mathematical operations.

For example, 2+2/2=3 generates 3, but we need to find a solution that can generate any integer.

Answer
Pretty ingenious, no? ;)
BTW, I couldn't get this problem either - my math teacher showed me the answer.

Math is hard...

I never thought I'd say this, but math is hard.

For my AIME class, I have to do 10-15 problems every week. Last week's batch was easy, buit this week ... ugh.


And that's just the first problem... o.0

Maybe the problems are hard, or maybe I'm just bad at these, I don't know. What I do know is that after nearly a week, I've only solved four of this weeks problems, out of 11. Good thing there's no class this Tuesday (4th of July), so at least I get an extra week!

Tuesday, June 27, 2006

AIME Class: Complex Numbers and Polynomials

Today I had a meeting of my AIME class. The topics being discussed were complex numbers and polynomials, and though neither o these topics is my strong point, the class wasn't that bad.

Here's an interesting problem (interesting because although it looks like a simple arithmetic problem, in reality the solution involves polynomials):



(Note that calculators are not allowed on the AIME.)

I'll let this one stand for a few days, then I'll post the answer. Try doing this without a calculator! :p

Monday, June 19, 2006

USAMTS Prizes! =)

This year I participated in the United States Mathematical Talent Search (USAMTS) and placed Silver, with the fifth-highest score among all freshmen (well, to be fair, only 49 freshmen participated).

After a month or two of waiting (well, actually, I forgot about it within a few days), my prizes came today:

1. A USAMTS T-shirt. It's waaaay too big for me, but I will wait in the hope that someday I'll be able to wear it.
2. My choice of two books: There was a list of eight mainly math-related books to choose from. I chose the only two that were not math-related - one on cryptology and one on theoretical physics, both fairly interesting topics, if a bit difficult to understand at times.
3. A USAMTS pin and a signed letter from the contest director, Richard Rusczyk.

Regardless of the prizes, I highly doubt that I will participate in this contest next year, because it is a lot of work - twenty very difficult problems over the course of about four months. With my AP classes and AIME preparation I doubt I will have enough time to do this.