Class Power

java.lang.Object
org.djutils.math.functions.Power
All Implemented Interfaces:
Comparable<MathFunction>, Function<Double,Double>, MathFunction

public class Power extends Object implements MathFunction
MathFunctions that are a constant times some power of x; generally f(x) → a * x^b where a ∈ ℝ and b ∈ ℝ

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
  • Constructor Details

    • Power

      public Power(MathFunction chain, double weight, double power)
      Construct a new power function.
      Parameters:
      chain - the MathFunction that yields the x for this power function
      weight - the value at x == 1
      power - the exponent of x
    • Power

      public Power(double weight, double power)
      Construct a new power function.
      Parameters:
      weight - the value at x == 1
      power - the exponent of x
    • Power

      public Power(MathFunction chain, double power)
      Create a new power function with weight 1.0 and the supplied value as exponent.
      Parameters:
      chain - the MathFunction that yields the x for this power function
      power - the exponent of chain
    • Power

      public Power(double power)
      Create a new power function with weight 1.0 and the supplied value as exponent.
      Parameters:
      power - the exponent of x
  • Method Details

    • apply

      public Double apply(Double x)
      Specified by:
      apply in interface Function<Double,Double>
    • getDerivative

      public MathFunction getDerivative()
      Description copied from interface: MathFunction
      Returns the derivative of the data with respect to fractional length.
      Specified by:
      getDerivative in interface MathFunction
      Returns:
      derivative of this MathFunction
    • simplify

      public MathFunction simplify()
      Description copied from interface: MathFunction
      Attempts to find a simplified version of this MathFunction (e.g. replace 1 - 5 by -4).
      Specified by:
      simplify in interface MathFunction
      Returns:
      this, or a simplified version thereof
    • getScale

      public double getScale()
      Description copied from interface: MathFunction
      Get the scale factor of this MathFunction.
      Specified by:
      getScale in interface MathFunction
      Returns:
      the scale factor of this MathFunction
    • scaleBy

      public MathFunction scaleBy(double factor)
      Description copied from interface: MathFunction
      Incorporate a multiplication factor to this MathFunction.
      Specified by:
      scaleBy in interface MathFunction
      Parameters:
      factor - the factor to incorporate
      Returns:
      a new MathFunction that yields the same result as the original function multiplied by the factor
    • sortPriority

      public int sortPriority()
      Description copied from interface: MathFunction
      Sorting priority of this type of MathFunction (low values shall sort before higher).
      Specified by:
      sortPriority in interface MathFunction
      Returns:
      sorting priority of this type of MathFunction
    • compareWithinSubType

      public int compareWithinSubType(MathFunction other)
      Description copied from interface: MathFunction
      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!
      Specified by:
      compareWithinSubType in interface MathFunction
      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

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

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

      public MathFunction mergeDivide(MathFunction other)
      Description copied from interface: MathFunction
      This MathFunction is divided by another; try to replace both by a combined MathFunction.
      Specified by:
      mergeDivide in interface MathFunction
      Parameters:
      other - the other MathFunction
      Returns:
      combined MathFunction, or null when the two could not be combined
    • getKnotReport

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

      public SortedSet<Double> getKnots(Interval<?> interval)
      Description copied from interface: MathFunction
      Report all knots of this MathFunction in some Interval. Throws IllegalStateException when the number of knots in the Interval is not known, or infinite.
      Specified by:
      getKnots in interface MathFunction
      Parameters:
      interval - the Interval over which the knots must be reported
      Returns:
      all the knots of this MathFunction in the requested Interval
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object