CodePlexProject Hosting for Open Source Software

Simple C#/F# library for Symbolic Differentiation and whatever else comes to mind ;)

This project is about building a library of useful code and at the same time have fun with the latest C# 3.0 / F# CTP features :)

And now also to explore the interoperability between C# and F# :))

At the moment we have a simple implementation of the following:

C# and F#:

- Tokenizer

- Combinator Parsers inspired by Brian's brillian Inside F# blog

- AST

- Symbolic Differentiation Visitor

- Simplifier Visitor

- Functions support

- Conditional expression support (new)

F# only:

- Aggregation of sequences based on Expressions ;)

- Parallel computation of expressions based on depth of AST (Example: Expression like: (A+B) * (D+E) uses 2 cores and ( (A +B) * (D+E) ) + ( (A +B) * (D+E) ) uses 4 cores :))))

- ToString Visitor

Requirements:

- Any code contributed to this project be fully TDDed.

- No code generation code is allowed.

What's next:

- Expand the functionality of each component to cover as many cases as possible and improve the quality of the code and testing along the way.

Recommended Readings

Structure and Interpretation of Computer Programs

Expert F#

References:

http://fsharpcode.blogspot.com

http://en.wikipedia.org/wiki/Differentiation_rules

http://lorgonblog.spaces.live.com/blog/cns!701679AD17B6D310!133.entry?_c=BlogPart

http://blogs.msdn.com/lukeh/archive/2007/08/19/monadic-parser-combinators-using-c-3-0.aspx

http://www.cs.nott.ac.uk/~gmh/pearl.pdf

http://leibnizdream.wordpress.com/2007/12/22/first-class-functions2-multiprogramming/

Parallel versus Sequential Computation Performance:

Expression: (((A + B) * (A + B)) * ((A + B) * (A + B))) + (((A + B) * (A + B)) * ((A + B) * (A + B)))

Data Size: A: 1..1000000 B: 1..1000000

Intel Xeon CPU X5450 QUAD-CORE @ 3.00Ghz X2 (8 cores) 3.25 GB of Ram

Sequential elapsed: 00:06:28.4842822

Parallel elapsed: 00:01:48.6659580

Operations were made more intensive using the following code:

(+) : for (int i = 0; i < 10000; i++) { z = x + y; }

(*) : for (int i = 0; i < 10000; i++) { z = x * y; }

Performance comparison between C# and F# Tokenizer:

(Size of the test data: 100.000 Letters separated by spaces)

C#: 00:09:39.7925956 (hh:mm:ss)

F#: 00:09:42.6639161 (hh:mm:ss)

Enjoy ;)

Edmondo Pentangelo

Last edited Sep 9, 2009 at 10:32 PM by holoed, version 27