CodePlexProject Hosting for Open Source Software

First of all, you need to build an object model representation of the mathematical expression:

IExpression curve = new SumExpression() { new ProductExpression() { new NumberExpression(5), new PowerExpression(new VariableExpression('x'), new NumberExpression(3)) }, new ProductExpression() { new NumberExpression(4), new PowerExpression(new VariableExpression('x'), new NumberExpression(2)) }, new ProductExpression() { new NumberExpression(3), new VariableExpression('x') }, new NumberExpression(1) };

Then, you can perform algebraic transformations on that. Here are the mathematical steps to accomplish this task:

- Find the derivative of the curve
- Substitute 8 for x
- Evaluate the result using simplification

IExpression slope = curve.Differentiate('x').Substitute(new VariableExpression('x'), new NumberExpression(8)).Simplify();

It is done, the result is 1027 as a NumberExpression.

Last edited May 9, 2010 at 8:03 AM by BlueCode, version 4