TP

F# Math - Numerical computing and F# PowerPack

This article is the first article of a series where I'll explain some of the F# features that are useful for numeric computing as well as some functionality from the F# PowerPack library. Most of the content was originally written for the Numerical Computing in F# chapter on MSDN (that I announced earlier), but then we decided to focus on using F# with third party libraries that provide more efficient implementation and richer set of standard numeric functionality that's needed when implementing machine learning and probabilistic algorithms or performing statistical analysis. If you're interested in these topics, then the last section (below) gives links to the important MSDN articles.

However, F# PowerPack still contains some useful functionality. It includes two additional numeric types and an implementation of matrix that integrates nicely with F#. The series also demonstrates how to use features of the F# language (and core libraries) to write numeric code elegantly. In particular, we'll use the following aspects:

These are just a few of the F# language features that are useful when writing numeric code, but there are many others. The usual F# development style using interactive tools, type safety that prevents common errors, units of measure as well the expressivity of F# make it a great tool for writing numeric code. For more information, take a look at the MSDN overview article Writing Succinct and Correct Numerical Computations with F#.

Numerical computing and F# PowerPack

If you're looking for information about other PowerPack components, then Daniel Mohl (@@dmohl) wrote a series that covers numerical types and modules (Part 1), asynchronous extensions (Part 2), additional collection types (Part 3), as well as lexing, parsing and SI units (Part 4).

In this article series, we look at most of the numerical computing features provided by the F# PowerPack library. The following list shows the upcoming articles of the series:

Numerical Computing in F# (MSDN)

As already mentioned, F# PowerPack provides only basic implementation of matrices, which is not suitable for tasks that require efficient matrix multiplication. The library also does not implement any advanced operations such matrix decomposition or any support for working with probability distributions or statistical analysis.

If you're interested in writing highly-efficient numeric code in F#, then it is recommended to use a third-party library (such as open-source Math.NET Numerics) that provide more efficient implementation and wider range of features. The MSDN section Introduction to Numerical Computing in F# provides more information including a review of existing libraries. It also includes examples that demonstrate the following three options:

References & Links

Published: Wednesday, 2 November 2011, 2:30 AM
Author: Tomas Petricek
Typos: Send me a pull request!
Tags: functional, f#, writing, math and numerics