57005 or alive

Nested looping to programmatic depth in F#

Dec 26, 2014 F#

This post is the December 26th entry in the 2014 English F# Blog Advent Calendar. Check out the other great posts from earlier in the month, or head over to the Japanese-language edition!

Ho ho ho! It’s the day after Christmas, and hopefully everyone has some snazzy new toys to play with.  But just in case Santa left you a lump of coal (“… little Billy used mutable state this year …”), don’t pout, don’t cry, I’ve got you covered.  My gift for all the naughty F# developers out there: a mini-framework for imperative-style looping in F#, adding the functionality of “break,” “continue,” and “return,” along with the ability to nest loops down to programmatic depth.

Extending a 3rd-party API with F# units of measure

Dec 6, 2014 F#

Continuing the recent theme of awesome .NET development news, a blog post from Thursday by the .NET team provided more details on the platform’s future, “.NET Core.”

The ensuing comment thread on Hacker News had some nice F# discussion.  One commenter, though, was not a huge fan, and in particular lamented perceived limitations in the F# units of measure feature:

Muller's Recurrence - roundoff gone wrong

Nov 22, 2014 math Mathematica

A while back I came upon a seemingly not-too-difficult programming exercise:

Define a recurrence  \(x_n\) by

$$f(y, z) = 108 - \frac{815 - 1500/z}{y}$$

$$x_0 = 4$$ $$x_1 = 4.25$$ $$x_i = f(x_{i-1}, x_{i-2})$$

Compute \(x_{30}\) .

This isn’t too hard to code up, using perhaps a recursive function to represent \(x_i\) . With normal double-precision floats, as \(i\) increases, the result converges neatly toward 100. Super!

Unfortunately, 100 is not even close to the right answer. This recurrence actually converges to 5.

A simple benchmark of various math operations

Nov 9, 2014 math performance

How computationally expensive are various fundamental floating point mathematical operations?  Here’s a quick and dirty benchmark, which, although surely quite naive, seems to capture the rough relative cost of a few operations.

Response to "Little Performance Explorations: F#"

Sep 21, 2014 F# performance

I recently saw a tweet from Ryan Riley linking to an article exploring F# performance and floating point processing:

I poked around the code and tested it a bit myself, and figured I would take up the author’s  call for feedback. Comments on the original blog are locked down, so I’ve written up my results here, instead.