How to: find the slope of the tangent line of a curve at a given point

To accomplish this task, you can use the algebra system. In our example we would like to find the slope of 5x³ + 4x² + 3x + 1 at x = 8.

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:

  1. Find the derivative of the curve
  2. Substitute 8 for x
  3. 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


No comments yet.