Today, I found out…

That there are quite a few ways to generate Pythagorean Triples. How did I acquire this piece of information?

I was trying to solve Problem Nine of Project Euler.

The first method I considered was the one I learnt in school. I realised it was hopelessly inefficient. The method involved running three loops, each nested within the other. It would iterate trying to find three numbers that would fulfill the condition for Pythagorean Triples ( a2 + b2 = c2). It would take too long to find a triple that fulfilled the condition.

I then went to Wikipedia to find other ways to generate triples. I realised there were a fair bunch. In the end, I settled for Euclid’s Formula ( a = 2mn : b = m2 – n2 : c = m2 + n2 ) It gave me the answer in under a minute.

<rant>
I was never taught any of those methods in school. Not even in Mathematics class. Why not? The only thing they ever taught us was what was a Pythagorean Triple. And in Computer Science, why teach us such an inefficient method? I wonder if my teacher knew any other method. Probably not. Bloody System.

</rant>

I like project Euler. A Lot.

Also Wikipedia.

I’m now looking for an efficient way to determine the Primality of a number n. Dividing by all numbers less than √n might be inefficient for a range of two million. The AKS Primality Test looks promising. Now I just have to understand it.

Advertisements
Posted in Myself. Tags: . 7 Comments »

7 Responses to “Today, I found out…”

  1. parvathy Says:

    HOW on earth are u suddenly in love wid maths ???????

  2. Abhijan Says:

    Mate. i echo your sis’ concern. what went wrong? πŸ˜›

    let us rescue you dude. it *hurts* to see you in such a low state.

    *Loving Maths!* Oh Dear Dear

  3. Priyanka Says:

    one of the automatically generated possibly related posts says “How to kill a Human Being.”
    😐

    this is what blogging about math does, methinks.

  4. Prayag Says:

    It’s funny. Couple of nights ago, I had a dream that I had a maths test the next day, and I didn’t have a fucking clue about how to do any of the sums in the syllabus. I woke up sweating in an air conditioned room. And you’re doing maths for fun πŸ˜›

    But it’s good mate. Sharpening your mind and all that. English honours is sometimes such a load of bullshit it must be refreshing to challenge your mind in tangible ways, from time to time.

  5. Pramita Says:

    You like doing maths. Heh.

    Gives me the creeps.

  6. ahona Says:

    Listen.You are altogether admirable, not of course as Prayag says, we are up to a lot of bullshit, but because, you are keeping your brain very very alive.

    I sharpen pencils. It’s goodstuff.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: