[All code from this post available as a GitHub gist here]
For Christmas this year, I got myself a fun mathematical gift: a set of 10 non-transitive dice, namely Grime Dice! You can get your own set here. Behold their dicey splendor:
These dice possess the fascinating property that their winning relationships (in the sense of "winning" = "rolls a higher number > 50% of the time") are non-transitive. i.e. if die A wins against die B, and die B wins against die C, it actually does *not* hold, in general, that die A wins against die C. In fact, die C might win against die A! Continue reading Non-transitive Grime Dice, via Mathematica
By now, most everyone is aware of Pi Day, celebrating the famous mathematical constant on 3/14. On this day each year, students and math enthusiasts eat pie and engage in light-hearted -related activities. Then there is e Day, a day for commemorating the equally-important-if-somewhat-less-famous constant on 2/7. The activities are similar, though it's less clear-cut what food one should eat (a high school teacher of mine insisted that the proper e Day food is waffles, evocative of the Cartesian coordinate system). Even events like Pi Approximation Day (22/7 in day/month format), and Mole Day (6:02 10/23) have gained enough momentum to warrant dedicated results from both Google and Bing.
So when is Phi Day? Continue reading Today is Phi Day -- at least, it ought to be
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. Continue reading Nested looping to programmatic depth in 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: Continue reading Extending a 3rd-party API with F# units of measure
A while back I came upon a seemingly not-too-difficult programming exercise:
Define a recurrence by
This isn't too hard to code up, using perhaps a recursive function to represent . With normal double-precision floats, as increases, the result converges neatly toward 100. Super!
Unfortunately, 100 is not even close to the right answer. This recurrence actually converges to 5. Continue reading Muller's Recurrence - roundoff gone wrong
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.
Continue reading A simple benchmark of various math operations
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. Continue reading Response to "Little Performance Explorations: F#"
@StevenStrogatz posed a fun question this evening:
People quickly realized the answer is "no," but how to show it? Continue reading An elliptical pool
If you scan the source code for the Roslyn project, the platform on which the next-gen C# and VB compilers are based, you might stumble across an interesting special behavior that was added in for the sole purpose of preserving backward-compatibility with F#.
[roslyn]\Src\Compilers\CSharp\Source\Symbols\Metadata\PE\PEAssemblySymbol.cs (as of commit dc3171c8a878):
public override bool MightContainExtensionMethods
var moduleSymbol = this.PrimaryModule;
var module = moduleSymbol.Module;
// The F# compiler may not emit an assembly-level ExtensionAttribute, and previous versions of C# never checked for it.
// In order to avoid a breaking change (while preserving the perceived performance benefits of not looking for extension
// methods in assemblies that don't contain them), we'll also look for FSharpInterfaceDataVersionAttribute.
var mightContainExtensionMethods = module.HasExtensionAttribute(this.assembly.Handle, ignoreCase: false) ||
this.lazyContainsExtensionMethods = mightContainExtensionMethods.ToThreeState();
The comment does a nice job of summing up the issue, but allow me to provide some additional context. Continue reading F# extension methods in Roslyn
Here's another nifty Project Euler visualization, one I put together while solving problem 144 a while ago. Continue reading Project Euler visualizations - problem 144