Interface MathFunction

All Superinterfaces:
Comparable<MathFunction>, Function<Double,Double>
All Known Implementing Classes:
ArcSine, ArcTangent, Concatenation, Constant, Exponential, Logarithm, Nan, Power, Product, Quotient, Sine, Sum

public interface MathFunction extends Comparable<MathFunction>, Function<Double,Double>
MathFunction interface.

Copyright (c) 2024-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.

Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
  • Method Details

    • getDerivative

      MathFunction getDerivative()
      Returns the derivative of the data with respect to fractional length.
      Returns:
      derivative of this MathFunction
    • simplify

      default MathFunction simplify()
      Attempts to find a simplified version of this MathFunction (e.g. replace 1 - 5 by -4).
      Returns:
      this, or a simplified version thereof
    • getScale

      default double getScale()
      Get the scale factor of this MathFunction.
      Returns:
      the scale factor of this MathFunction
    • scaleBy

      MathFunction scaleBy(double factor)
      Incorporate a multiplication factor to this MathFunction.
      Parameters:
      factor - the factor to incorporate
      Returns:
      a new MathFunction that yields the same result as the original function multiplied by the factor
    • printValue

      default String printValue(double value)
      Format a numerical value. If the value is integer, format it without decimal point. If the value is not integer, use a reasonable format.
      Parameters:
      value - the value to format
      Returns:
      the formatted value
    • compareChains

      default int compareChains(MathFunction chain1, MathFunction chain2)
      Compare chains for sorting.
      Parameters:
      chain1 - chain MathFunction of first MathFunction (may be null)
      chain2 - chain MathFunction of second MathFunction (may be null)
      Returns:
      int < 0 when chain1 sorts before chain2; > 0 when chain1 sorts after chain2; 0 when chain1 is equal to chain2
    • sortPriority

      int sortPriority()
      Sorting priority of this type of MathFunction (low values shall sort before higher).
      Returns:
      sorting priority of this type of MathFunction
    • compareWithinSubType

      int compareWithinSubType(MathFunction other)
      Determine sorting order among instances of a particular sub type of MathFunction. The sorting order should sort MathFunctions that may be combined next to one another. Because MathFunctions are also used in SortedSets, this comparator may return 0 if and only if this and other are entirely equal!
      Parameters:
      other - the other MathFunction that must be of the same type
      Returns:
      int; < 0 when this sorts before other; > 0 when this sorts after other; 0 when this and other are identical
    • mergeAdd

      default MathFunction mergeAdd(MathFunction other)
      This MathFunction is added to another; try to replace both by a combined MathFunction.
      Parameters:
      other - the other MathFunction
      Returns:
      combined MathFunction, or null when the two could not be combined
    • mergeMultiply

      default MathFunction mergeMultiply(MathFunction other)
      This MathFunction is multiplied by another; try to replace both by a combined MathFunction.
      Parameters:
      other - the other MathFunction
      Returns:
      combined MathFunction, or null when the two could not be combined
    • mergeDivide

      default MathFunction mergeDivide(MathFunction other)
      This MathFunction is divided by another; try to replace both by a combined MathFunction.
      Parameters:
      other - the other MathFunction
      Returns:
      combined MathFunction, or null when the two could not be combined
    • compareTo

      default int compareTo(MathFunction other)
      Specified by:
      compareTo in interface Comparable<MathFunction>
    • getKnotReport

      KnotReport getKnotReport(Interval<?> interval)
      Report what is known about knots of this MathFunction in some Interval. The report does not take chained functions into account.
      Parameters:
      interval - the Interval on which knowledge of knots is requested
      Returns:
      summary of what is known about knots in the Interval
    • getKnots

      SortedSet<Double> getKnots(Interval<?> interval)
      Report all knots of this MathFunction in some Interval. Throws IllegalStateException when the number of knots in the Interval is not known, or infinite.
      Parameters:
      interval - the Interval over which the knots must be reported
      Returns:
      all the knots of this MathFunction in the requested Interval
      Throws:
      UnsupportedOperationException - when the number of knots cannot be returned in a set because it is not known, or infinite