class is the abstract base class from which all other curve classes
are derived. It defines a common set of methods and properties for curves.
method evaluates the curve at a specific point.
evaluates the derivative, and
evaluates the definite integral over a specified interval. The
method returns a
of degree 1 that is the tangent to the curve at a specific point.
If overridden by a descendant class, the
method returns the curve that is the derivative of the instance. The
method attempts to find all the roots or zeros of the curve.
A particular type of curve is defined by a set of parameters.
These parameters can be set and retrieved through the
which is, which is a vector.
A Point structure represents a point in two-dimensional
space. It has two properties, X and Y that specify the x and y-coordinate of the point.
is a curve whose value and, optionally, derivative and integrals, are calculated
using user-supplied methods. The methods are supplied as
FuncT, TResult delegates.
A general curve has no parameters.
To create a general curve, call the constructor with one, two, or three
FuncT, TResult delegates as parameters.
The first argument is the delegate used to evaluate the function.
The second parameter, if present, specifies the derivative function.
The third parameter, if present, specifies an integral function.
The ValueAt method simply evaluates the value
delegate of the general curve.
If a derivative delegate has been supplied, it is used to by the SlopeAt, TangentAt, and GetDerivative methods. If no derivative was supplied,
a numerical derivative is calculated using static methods in the FunctionMath class.
If an integral delegate has been supplied, it is used to by the Integral method. If no integral was supplied, a numerical
integral is calculated using the AdaptiveIntegrator class in the
The following example creates GeneralCurve objects,
one for the function f(x) = 1/(1+x*x), and one for the Airy function
AiryAi. It calculates the tangent line to each curve at
x = 1 and finds the point at which they intersect.
private double f(double x)
return 1 / (1 + x * x);
private double df(double x)
double y = 1 + x * x;
return -2 * x / (y * y);
public void TestGeneralCurve()
GeneralCurve c1 = new GeneralCurve(f, df, System.Math.Atan);
var l1 = c1.TangentAt(1);
GeneralCurve c2 = new GeneralCurve(Special.AiryAi, Special.AiryAiPrime);
var l2 = c2.TangentAt(1);
Private Function f(x As Double) As Double
Return 1 / (1 + x * x)
Private Function df(x As Double) As Double
Dim y As Double = 1 + x * x
Return -2 * x / (y * y)
Public Sub TestGeneralCurve()
Dim c1 As GeneralCurve = New GeneralCurve(
AddressOf f, AddressOf df, AddressOf Math.Atan)
Dim l1 = c1.TangentAt(1)
Dim c2 As GeneralCurve = New GeneralCurve(
AddressOf Special.AiryAi, AddressOf Special.AiryAiPrime)
Dim l2 = c2.TangentAt(1)
No code example is currently available or this language may not be supported.
let f x = 1.0 / (1.0 + x * x)
let df x =
let y = 1.0 + x * x
-2.0 * x / (y * y)
let func f = Func<double,double>(f)
let TestGeneralCurve =
let c1 = GeneralCurve(func(f), func(df), func(Math.Atan))
let l1 = c1.TangentAt(1.0)
let c2 = GeneralCurve(func(Special.AiryAi), func(Special.AiryAiPrime))
let l2 = c2.TangentAt(1.0)
For the first function, there is a closed form solution
for the integral and the derivative. The integral for the
Airy function isn't available. Note that we didn't really
need to provide the integral here.