views:

134

answers:

3

Hello,

I am looking for a C# dll to solve simple equation. Example ..

10 = 2 + 3 + x

Result should be x = 5;

Is this is free DLL?

+3  A: 

It's not incredibly difficult to write your own. Take a look at these examples from an online contest.

drharris
The contest has an important restriction on x: "X will always be of first power!". I'll bet pskk's "simple equations" do meet this restriction (his example does).
Tom Sirgedas
Well, he said simple equations, so I assumed. Quadratic solving is a whole different ballgame than simple evaluation, in which case he should use the library that Lawrence mentioned.
drharris
You can use the same technique for quadratics, except you'll need to fit your equation to 3 points instead of two. (In the example "10=2+3+x", F(x) = "10-(2+3+x)" and we're looking for the zeros of this graph (x,F(x)). We have two points, (0,F(0)) and (1,F(1)), which is enough information. For quadratics, we should use an additional point, (2,F(2)).
Tom Sirgedas
@ Tom Sirgedas - sry for late reply ... yes its always x to the power 1 and x can come up at different places ....
pskk
A: 

Use System.Math if you have to make something more diffucult then an addition. Otherwise .. do it your self IT'S FREE !

Jean-Christophe Fortin
It's only free if your time is worthless (unless you want to learn how to evaluate expressions, in which case it's a good investment)
Jason Williams
@ Jason - this is not the direction that we will be taking ... i need this for Demo purposes only
pskk
+5  A: 

I've used this Math Expression Parsing library with positive results. The documentation he's provided was very useful to boot.

http://www.codeproject.com/KB/recipes/MathieuMathParser.aspx?display=Print

Your app can then accommodate ad hoc equations which the library will parse into component parts. You can then provide the values for required variables and it will evaluate the result.

The library includes many function (trig, log, factorials, datetime, random, etc.) and can handle user-defined functions.

Lawrence P. Kelley