Function

References
public abstract class Function : IStorable

Base level class for mathematical functions in the form y = f(x), representing a mapping from individual 64-bit double precision values onto individual 64-bit double precision values.

Do not inherit from this class if you wish to create a new function unless you need an absolutely minimal implementation to start with. Consider instead deriving from FunctionWithCaching.

Constructors

Function

#
protected Function()
Protected constructor.

Function

#
protected Function(IReader reader)
reader (IReader)

Fields

Dot

#
protected const string Dot = "·"
The multiplication central dot operator.

Prime

#
protected const string Prime = "ʹ"
The derivative prime symbol.

Square

#
protected const string Square = "²"
The square (power of two) symbol.

X

#
protected const string X = "x"
The standard variable name.

Properties

Derivative

#
public abstract Function Derivative { get; }
Gets a function which is the derivative of this function. The returned function may be either analytic or approximate.

Integral

#
public abstract Function Integral { get; }
Gets a function which is the indefinite integral of this function. The returned function may be analytic or approximate. Note that numeric approximation of indefinite integrals is a slow and not particularly high quality process.

Nomen

#
public abstract Nomen Nomen { get; }
Gets a description of this function.

Notation

#
public abstract string Notation { get; }
Gets the notation for this function. Notation is aimed at humans and does not need to return a parseable string.

Ui

#
public virtual FunctionUi Ui { get; }
Gets a UI object for modifying this function. This property may return null, not all functions must be editable.

Methods

Asymptotes

#
public virtual Line[] Asymptotes()
Returns an array of *all* the non-vertical asymptotes for this function. This property may return both null and empty arrays, implying no asymptotes. Due to the nature of non-vertical asymptotes, there can only be a finite amount of them.

AutoCoDomain

#
protected void AutoCoDomain(double x0, double x1, out double y0, out double y1, int samples = 100)
Compute the automatic codomain for a given domain.
x0 (double)Domain start.
x1 (double)Domain end.
y0 (out double)Lowest value in codomain.
y1 (out double)Highest value in codomain.
samples (int = 100)Samples.

AutoMaxDomain

#
public static double AutoMaxDomain(params double[] upperLimits)
Compute the automatic maximum domain based on a set of limits.
upperLimits (params double[])

AutoMinDomain

#
public static double AutoMinDomain(params double[] lowerLimits)
Compute the automatic minimum domain based on a set of limits.
lowerLimits (params double[])

DomainEstimate

#
public virtual void DomainEstimate(out double x0, out double x1, out double y0, out double y1)
Return an estimate of the interesting part of a function. Each function may choose how to answer this question individually.
x0 (out double)Lowest x coordinate of interest.
x1 (out double)Highest x coordinate of interest.
y0 (out double)Lowest y coordinate of interest.
y1 (out double)Highest y coordinate of interest.

Holes

#
public virtual Interval[] Holes(double x0, double x1)
Returns a collection of domains for which this function is not defined. This method may return null or an empty array, implying no undefined domains. This method may also return domains outside of the specified interval.
x0 (double)Lower limit of query domain.
x1 (double)Upper limit of query domain.

Integrate

#
public virtual double Integrate(double x0, double x1)
Evaluate the definite integral between two parameters. Unless a function specifically implements an analytic integral, this value will be approximate. Note to implementer: if you provide an analytic integral via the Integral property, that function will be used to compute an analytic result. There is typically no reason to override this method.
x0 (double)Integral start.
x1 (double)Integral end.
Definite integral from x0 to x1.

Num

#
protected static string Num(double value, bool omitZero = false, bool prependSign = false)
Format a numeric constant for use in a function notation.
value (double)Number to format.
omitZero (bool = false)If true, and the number is zero, an empty string will be returned.
prependSign (bool = false)If true, the sign of the number will be prepended as a seperate operator.

Poles

#
public virtual Pole[] Poles(double x0, double x1)
Returns an array of all the poles (i.e. vertical asymptotes) within a domain. This method may return both null and empty arrays, implying no poles. Furthermore this method may choose to return poles which fall outside of the given domain.
x0 (double)Lower limit of query domain.
x1 (double)Upper limit of query domain.

Store

#
public virtual void Store(IWriter writer)
writer (IWriter)
Store

Y

#
public abstract double Y(double x)
Evaluate this function at a given x parameter. This method may return NaN values or even throw. The caller is responsible for handling any and all failure cases.
x (double)Parameter.
f(x)

YYYY

#
public double[] YYYY(double[] x)
Evaluate a large amount of values. Functions may choose to use multiple threads to perform this calculation. This method should not throw, instead every failed evaluation will be represented by a NaN value.
x (double[])Value to evaluate.
Evaluation results. Array will contain double.NaN entries for failed evaluations.

Operators

OperationResultDescription
Function+FunctionFunctionAdd two functions together.
Function/FunctionFunctionDivide one function by another.
Function*FunctionFunctionAdd two functions together.
Function-FunctionFunctionSubtract one function from another.

Convertors

OperationResultDescription
implicitBigIntegerFunctionConvert a number into a constant function.
implicitdoubleFunctionConvert a number into a constant function.
implicitintFunctionConvert a number into a constant function.