What are the best tools (most efficient) available in .NET (C#) for calculating:
- integrals
- partial derivatives
- other non-trivial math
Can people please comment on Mathematica and Matlab and their integration into C#?
What are the best tools (most efficient) available in .NET (C#) for calculating:
Can people please comment on Mathematica and Matlab and their integration into C#?
Math.NET is a mathematical open source toolkit written in C# for the Microsoft .NET platform that aims to provide a self-contained clean framework for both numerical scientific and symbolic algebraic computations. In particular, Math.NET Numerics is the result of the merger of dnAnalytics with Math.NET Iridium and includes the following features:
I can't vouch for it being the best or more efficient, but a couple of days ago I learned that Luca Bolognese has developed a library of financial functions for .NET
You can find it here: http://code.msdn.microsoft.com/FinancialFunctions
Maybe it'll be usefull for you.
I don't have experience with the Mathematica/.NET bridge, but I have used the Mathematica/Java bridge, which, judging from the documentation is pretty similar. Of course, one question I can't answer is how good the implementation of the interface is in terms of stability and performance.
Conceptually, I've found the Java interface for calling out to Mathematica be pretty good. You have a set of objects and methods that let you start Mathematica sessions and send Mathematica expressions to them to be evaluated. You can either send text (which is easy in simple cases but tricky if you want something non-trivial) or more structured Expr
objects that mirror the syntax tree structure. These expressions will allow you to do just about anything: evaluate integrals numerically or symbollically, take derivatives, solve ODEs, and so on.
The one area where it falls down some is in error handling. Mathematica doesn't have exceptions per se; instead it produces "messages" when it runs into trouble and continues trying to evaluate the expression it's working on. This makes some sense in light of Mathematica's rather unusual semantics (where it operates on expressions with repeated rule rewrites) but the default set of methods for communicating with Mathematica doesn't allow you to easily monitor those messages from within Java (or, it appears, .NET), though it is possible to write your own methods that do a better job of this.
Fourier
was about 4× slower than FFTW last I looked and Mathematica's multicore support is awful). –
Pecker Microsoft's Visual F# programming language was specifically designed for this kind of work so you probably just want to call an existing F# solution from your C# code. For example, in Visual Studio 2010 with our F# for Numerics library installed you can integrate x3-x-1 from -3 to 3 interactively as follows:
> Functional.integrate (fun [x] -> x**3.0 - x - 1.0) [-3.0, 3.0];;
val it : float = -6.0
and compute that function's partial derivative with respect to x
at x=2
as follows:
> Functional.d (fun x -> x**3.0 - x - 1.0) 2.0;;
val it : float = 11.0
You might check out http://www.dmoz.org/Science/Math/Software/ - they list several C# ones. I'd say try a few (demo editions if commercial) and do some profiling to see if they meet your requirements. You could also use MATLAB - see the Limitations and Alternatives section of that entry. (I have no personal experience with these tools.)
Have a look at f# http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/
It will be part of Visual Studio 2010.
If you have an add-on product MATLAB Builder for .NET, you can package MATLAB code into a .NET assembly that can be called from C#.
© 2022 - 2024 — McMap. All rights reserved.