Martin Orr's Blog

CATAM Projects

Posted by Martin Orr on Saturday, 03 May 2008 at 17:17

A substantial part of the past couple of weeks was occupied by CATAM, the computational projects for the Maths Tripos. For each project you write some computer programs for mathematical purposes, then write a report on the results you obtained and the mathematics involved. (This is the only part of the Maths Tripos assessment not done by exams.) This year's projects were more interesting than last year's - at least the ones I did contained a greater mathematical content, and got me interested in elliptic curves. I also did my programming this year in Scala, the language I learned last summer, to try out something different - I have never been entirely satisfied with any programming language for doing mathematics. (And now that I have got into functional programming I have moved the goalposts. I did my CATAM projects in an almost pure functional style, but there were a few places where I couldn't see any efficient way to do that.)

The deadline for that was on Wednesday, and I have finished my supervisions from last term yesterday, so now all that is left until the exams at the start of June is revision. That seems like a long time but there is a lot to revise (and longer than before since in previous years I did some lectures in Easter term).

Tags catam, programming, scala, tripos

Trackbacks

No trackbacks.

Comments

  1. Ken Orr said on Wednesday, 07 May 2008 at 19:56 :

    What's functional programming? can you explain it briefly for the non-expert?

  2. Martin Orr said on Friday, 16 May 2008 at 21:55 :

    Well the thing that makes a program functional is that it doesn't have mutable state i.e. variables which can change their value over time. You use things that are sometimes called variables, but they can only be set once and then can't be changed; so they're basically just to save you typing out the piece of code that determines the value again.

    In particular you can't write loops in a functional program, because that requires a variable to change each time to figure out when to end the loop. If you want something that you would use a loop for in an imperative program, you either write a recursive function or use a higher-order function (a function which takes other functions as arguments).

    Classic factorial example: Imperative: factorial(n): a := 1 for i from 1 to n: a := a*i return a

    Functional: factorial(n) = if n == 0: 1 else: n*factorial(n-1)

    The theory is that it is easier to write correct functional programs, and perhaps even more that it is easier to prove their correctness, because you don't have to figure out how variables change over time. The downside is that it tends to be harder to control how fast your program is and how much memory it will use.

Post a comment

Markdown syntax with embedded LaTeX.
Type LaTeX between dollar signs, and enclose them between backticks to protect it from Markdown.
All comments are subject to moderation before they appear on the blog.

Archives