Skip to main content

F# for Scientists

F# for Scientists

Jon Harrop, Don Syme (Foreword by)

ISBN: 978-1-118-21081-9 September 2011 368 Pages




"This work strikes a balance between the pure functional aspects of F# and the object-oriented and imperative features that make it so useful in practice, enable .NET integration, and make large-scale data processing possible."
—Thore Graepel, PhD, Researcher, Microsoft Research Ltd.

Over the next five years, F# is expected to become one of the world's most popular functional programming languages for scientists of all disciplines working on the Windows platform. F# is free and, unlike MATLAB® and other software with numerical/scientific origins, is a full-fledged programming language.

Developed in consultation with Don Syme of Microsoft Research Ltd.—who wrote the language—F# for Scientists explains and demonstrates the powerful features of this important new programming language. The book assumes no prior experience and guides the reader from the basics of computer programming to the implementation of state-of-the-art algorithms.

F# for Scientists begins with coverage of introductory material in the areas of functional programming, .NET, and scientific computing, and goes on to explore:

  • Program structure

  • Optimization

  • Data structures

  • Libraries

  • Numerical analysis

  • Databases

  • Input and output

  • Interoperability

  • Visualization

Screenshots of development using Visual Studio are used to illustrate compilation, debugging, and interactive use, while complete examples of a few whole programs are included to give readers a complete view of F#'s capabilities.

Written in a clear and concise style, F# for Scientists is well suited for researchers, scientists, and developers who want to program under the Windows platform. It also serves as an ideal supplemental text for advanced undergraduate and graduate students with a background in science or engineering.




List of Figures.

List of Tables.


1. Introduction.

1.1 Programming guidelines.

1.2 A brief history of F#.

1.3 Benefits of F#.

1.4 Introducing F#.

1.5 Imperative programming.

1.6 Functional programming.

2. Program Structure.

2.1 Nesting.

2.2 Factoring.

2.3 Modules.

2.4 Objects.

2.5 Functional design patterns.

2.6 F# development.

3. Data Structures.

3.1 Algorithmic complexity.

3.2 Arrays.

3.3 Lists.

3.4 Sets.

3.5 Hash tables.

3.6 Maps.

3.7 Choosing a data structure.

3.8 Sequences.

3.9 Heterogeneous containers.

3.10 Trees.

4. Numerical Analysis.

4.1 Number representation.

4.2 Algebra.

4.3 Interpolation.

4.4 Quadratic solutions.

4.5 Mean and variance.

4.6 Other forms of arithmetic.

5. Input and Output.

5.1 Printing.

5.2 Generic printing.

5.3 Reading from and writing to files.

5.4 Serialization.

5.5 Lexing and parsing.

6. Simple Examples.

6.1 Functional.

6.2 Numerical.

6.3 String related.

6.4 List related.

6.5 Array related.

6.6 Higher-order functions.

7. Visualization.

7.1 Windows Forms.

7.2 Managed DirectX.

7.3 Tesselating objects into triangles.

8. Optimization.

8.1 Timing.

8.2 Profiling.

8.3 Algorithmic optimizations.

8.4 Lower-level optimizations.

9. Libraries.

9.1 Loading .NET libraries.

9.2 Charting and graphing.

9.3 Threads.

9.4 Random numbers.

9.5 Regular expressions.

9.6 Vectors and matrices.

9.7 Downloading from the Web.

9.8 Compression.

9.9 Handling XML.

9.10 Calling native libraries.

9.11 Fourier transform.

9.12 Mataprogramming.

10. Databases.

10.1 Protein data bank.

10.2 Web services.

10.3 Relational databases.

11. Interoperability.

11.1 Excel.

11.2 MATLAB.

11.3 Mathematica.

12. Complete Examples.

12.1 Fast Fourier transform.

12.2 Semi-circle law.

12.3 Finding n th.-nearest neighbors.

12.4 Logistic map.

12.5 Real-time particle dynamics.

Appendix A: Troubleshooting.

A.1 Value restriction.

A.2 Mutable array contents.

A.3 Negative literals.

A.4 Accidental capture.

A.5 Local and non-local variable definitions.

A.6 Merging lines.

A.7 Applications that do not die.

A.8 Beware of "it".




"The hardbound book is a really solid treatment." (Computing Reviews, February 5, 2009)