Extreme Optimization > Mathematics Library for .NET > QuickStart Samples > ConstantCurve QuickStart Sample (VB.NET)

Extreme Optimization Mathematics Library for .NET

ConstantCurve QuickStart Sample (VB.NET)

Illustrates the use of the Constant class (Extreme.Mathematics.Curves namespace) in Visual Basic .NET.

C# code Back to QuickStart Samples

' The Constant class resides in the Extreme.Mathematics.Curves namespace.
Imports Extreme.Mathematics.Curves

Namespace Extreme.Mathematics.QuickStart.VB

    ' Illustrates the use of the DoubleComplex class in the
    ' Extreme Optimization Mathematics Library for .NET.
    Module ConstantCurve

        Sub Main()
            ' All curves inherit from the Curve abstract base
            ' class. It cannot be instantiated. This class 
            ' defines methods and properties that are available
            ' to all derived types, including Constant, Line,
            ' Quadratic, Polynomial, ChebyshevSeries and
            ' LinearFunction.
            '
            ' This QuickStart sample illustrates the Constant
            ' class.

            ' 
            ' Creating Constant curves.
            '

            ' Let's start by creating a Constant curve and some 
            ' Line curves.
            ' A Constant curve has the same value everywhere.
            Dim constant1 As Constant = New Constant(3)
            ' There is one predefined Constant curve, which is
            ' zero everywhere:
            Dim constant2 As Constant = Constant.Zero

            '
            ' Curve Parameters
            '

            ' The shape of any curve is determined by a set of parameters.
            ' These parameters can be retrieved and set through the
            ' Parameters collection. The number of parameters for a curve
            ' is given by this collection's Count property.
            '
            ' Constants have one parameter: the y value.
            Console.WriteLine("constant1.Parameters.Count = {0}", _
                constant1.Parameters.Count)
            ' Parameters can easily be retrieved:
            Console.WriteLine("constant1.Parameters(0) = {0}", _
                constant1.Parameters(0))
            ' Parameters can also be set:
            constant1.Parameters(0) = 3

            '
            ' Curve Methods
            '

            ' The ValueAt method returns the y value of the
            ' curve at the specified x value:
            Console.WriteLine("constant1.ValueAt(2) = {0}", _
                constant1.ValueAt(2))

            ' The SlopeAt method returns the slope of the curve
            ' a the specified x value:
            Console.WriteLine("constant1.SlopeAt(2) = {0}", _
                constant1.SlopeAt(2))

            ' You can also create a new curve that is the 
            ' derivative of the original:
            Dim derivative As Curve = constant1.GetDerivative()
            Console.WriteLine("Slope at 2 (derivative) = {0}", _
                derivative.ValueAt(2))

            ' You can get a Line that is the tangent to a curve
            ' at a specified x value using the TangentAt method:
            Dim tangent As Line = constant1.TangentAt(2)
            Console.WriteLine("Slope of tangent line at 2 = {0}", _
                tangent.Slope)

            ' For many curves, you can evaluate a definite
            ' integral exactly:
            Console.WriteLine("Integral between 0 and 1 = {0}", _
                constant1.Integral(0, 1))

            ' You can find the zeroes or roots of the curve
            ' by calling the FindRoots method:
            Dim roots As Double() = constant1.FindRoots()
            Console.WriteLine("constant1 curve has {0} roots.", _
                roots.Length)

            Console.Write("Press Enter key to exit...")
            Console.ReadLine()
        End Sub

    End Module

End Namespace
Overview
Introduction
Features
Documentation
QuickStart Samples
Sample Applications
Downloads
Get it now!
Download trial version
How to Buy
Search

"The Extreme Optimization Statistics Library for .NET is a major boon for those doing statistical work in .NET. I strongly recommend this product."
- Marc Brooks

"I have made it my mission to institutionalize the value of good API design.  I strongly believe that this is key to making developers more productive and happy on our platform. It is clear that you value good API design in your work, and take to heart developer productivity and synergy with the .NET framework."
- Brad Abrams,
Lead Program Manager, Microsoft.

This is a partial list of companies who are using our libraries:
ABB Robotics
Allstate
Applied Materials
Arcam
Astra Schedule
Babson College
Canadian Council on Learning
Canyon Associates
Caxton Associates
CECity
Constellation Energy
CreditSights
DeepOcean
Duke University
Dynamotive
Elecsoft
Engelhard Corporation
Epcor
Equipoise Software
Galileo International
GAM UK
Gammex
GlaxoSmithKline
Global Matrix
The Hartford
Infinera Corporation
Intel
JDS Uniphase
LaBranche & Co.
Learning & Skills Council
Jacobs Consultancy
Litman Gregory
Lucas Systems
Malvern Instruments
Medrio
Merck & Co.
Mintera.
Monitor Software
MorningStar
NanoString Technologies
Paletta Invent
Parametric Portfolio Associates
Prosanos
RATA Associates
RiskShield
Ramboll
Standard & Poor's
Strategic Analysis Corporation
Univ. of Alicante
Univ. of South Carolina
vielife
Xerox
US Army