Extreme Optimization™: Complexity made simple.

Math and Statistics
Libraries for .NET

  • Home
  • Features
    • Math Library
    • Vector and Matrix Library
    • Statistics Library
    • Performance
    • Usability
  • Documentation
    • Introduction
    • Math Library User's Guide
    • Vector and Matrix Library User's Guide
    • Data Analysis Library User's Guide
    • Statistics Library User's Guide
    • Reference
  • Resources
    • Downloads
    • QuickStart Samples
    • Sample Applications
    • Frequently Asked Questions
    • Technical Support
  • Order
  • Company
    • About us
    • Testimonials
    • Customers
    • Press Releases
    • Careers
    • Partners
    • Contact us
Introduction
Deployment Guide
Nuget packages
Configuration
Using Parallelism
Expand Mathematics Library User's GuideMathematics Library User's Guide
Expand Vector and Matrix Library User's GuideVector and Matrix Library User's Guide
Expand Data Analysis Library User's GuideData Analysis Library User's Guide
Expand Statistics Library User's GuideStatistics Library User's Guide
Expand Data Access Library User's GuideData Access Library User's Guide
Expand ReferenceReference

Skip Navigation LinksHome»Documentation»Mathematics Library User's Guide»Curves and Interpolation»Curve Basics

Curve Basics

Extreme Optimization Numerical Libraries for .NET Professional
The Curve Class

The Curve 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.

The ValueAt method evaluates the curve at a specific point. SlopeAt evaluates the derivative, and Integral evaluates the definite integral over a specified interval. The TangentAt method returns a Polynomial of degree 1 that is the tangent to the curve at a specific point. If overridden by a descendant class, the GetDerivative method returns the curve that is the derivative of the instance. The FindRoots 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 Parameters property, which is, which is a vector.

The Point Structure

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.

General Curves

A GeneralCurve 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 Extreme.Mathematics.Calculus namespace.

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.

C#
VB
C++
F#
Copy
// Our function is 1/(1+x^2)
private double f(double x)
{
    return 1 / (1 + x * x);
}
// Its derivative is -2x/(1+x^2)^2
// The derivative of 1/(1+x^2) is ArcTan(x)
private double df(double x)
{
    double y = 1 + x * x;
    return -2 * x / (y * y);
}
// Now let's use these:
public void TestGeneralCurve()
{
    // The integral of f is Arctan(x), which is available from the Math class.
    GeneralCurve c1 = new GeneralCurve(f, df, System.Math.Atan);
    // Find the tangent to this curve at x=1
    var l1 = c1.TangentAt(1);
    // Let's define a GeneralCurve for the Airy function Ai(x):
    // The Airy function and its derivative can be found 
    // in the class Extreme.Mathematics.Special, which defines
    // special functions.
    GeneralCurve c2 = new GeneralCurve(Special.AiryAi, Special.AiryAiPrime);
    // Find the tangent to this curve at x=1
    var l2 = c2.TangentAt(1);
}
' Our function is 1/(1+x^2)
Private Function f(x As Double) As Double
    Return 1 / (1 + x * x)
End Function

' Its derivative is -2x/(1+x^2)^2
' The derivative of 1/(1+x^2) is ArcTan(x)
Private Function df(x As Double) As Double
    Dim y As Double = 1 + x * x
    Return -2 * x / (y * y)
End Function

' Now let's use these:
Public Sub TestGeneralCurve()
    ' The integral of f is Arctan(x), which is available from the Math class.
    Dim c1 As GeneralCurve = New GeneralCurve(
        AddressOf f, AddressOf df, AddressOf Math.Atan)
    ' Find the tangent to this curve at x=1
    Dim l1 = c1.TangentAt(1)
    ' Let's define a GeneralCurve for the Airy function Ai(x):
    ' The Airy function and its derivative can be found 
    ' in the class Extreme.Mathematics.Special, which defines
    ' special functions.
    Dim c2 As GeneralCurve = New GeneralCurve(
        AddressOf Special.AiryAi, AddressOf Special.AiryAiPrime)
    ' Find the tangent to this curve at x=1
    Dim l2 = c2.TangentAt(1)
End Sub

No code example is currently available or this language may not be supported.

// Our function is 1/(1+x^2)
let f x = 1.0 / (1.0 + x * x)
// Its derivative is -2x/(1+x^2)^2
let df x = 
    let y = 1.0 + x * x
    -2.0 * x / (y * y)

// Helper
let func f = Func<double,double>(f)

// Now let's use these:
let TestGeneralCurve =
    // The integral of f is Arctan(x), which is available from the Math class.
    let c1 = GeneralCurve(func(f), func(df), func(Math.Atan))
    // Find the tangent to this curve at x=1
    let l1 = c1.TangentAt(1.0)
    // Let's define a GeneralCurve for the Airy function Ai(x):
    // The Airy function and its derivative can be found 
    // in the class Extreme.Mathematics.Special, which defines
    // special functions.
    let c2 = GeneralCurve(func(Special.AiryAi), func(Special.AiryAiPrime))
    // Find the tangent to this curve at x=1
    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.

Copyright (c) 2004-2023 ExoAnalytics Inc.

Send comments on this topic to support@extremeoptimization.com

Copyright © 2004-2023, Extreme Optimization. All rights reserved.
Extreme Optimization, Complexity made simple, M#, and M Sharp are trademarks of ExoAnalytics Inc.
Microsoft, Visual C#, Visual Basic, Visual Studio, Visual Studio.NET, and the Optimized for Visual Studio logo
are registered trademarks of Microsoft Corporation.