Package com.singularsys.jep.functions

# Class Binomial

java.lang.Object
com.singularsys.jep.functions.PostfixMathCommand
com.singularsys.jep.functions.BinaryFunction
com.singularsys.jep.functions.Binomial

All Implemented Interfaces:
  `PostfixMathCommandI`, `Serializable`

public class Binomial extends BinaryFunction
Binomial coefficients: binom(n,i). Requires n,i integers >=0. Often written as nCi or column vector (n,i).

The following rules apply:
(n,0) = 1, (n,1) = n, (n,n-1) = n, (n,n) = 1
(n,i) = n! / ( i! (n-i)! )
Pascals triangle rule: (n,i) = (n-1,i-1) + (n-1,i)
Binomial theorem: (a+b)^n = sum (n,i) a^i b^(n-i), i=0..n.

For efficiency the binomial coefficients are stored in a static array.

Author:
  Rich Morris Created on 13-Feb-2005
See Also:
  - Serialized Form

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class com.singularsys.jep.functions.BinaryFunction

  `BinaryFunction.BiFunctionWithException<T>`

- ## Field Summary

  ### Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand

  `curNumberOfParameters, description, name, NaN, numberOfParameters`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Binomial()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static int`
  `binom(int n, int i)`
  Returns the binomial coefficients. nCi.
  `Object`
  `eval(Object l, Object r)`
  Evaluate the function

  ### Methods inherited from class com.singularsys.jep.functions.BinaryFunction

  `instanceOf, instanceOf, instanceOf, instanceOf, run`

  ### Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand

  `asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, asType, checkNumberOfParameters, getDescription, getDescription, getDescriptionWithType, getName, getNumberOfParameters, setCurNumberOfParameters, setDescription, setName, toString, toString`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### Binomial

    public Binomial()

- ## Method Details

  - ### eval

    public Object eval(Object l, Object r) throws EvaluationException
    Description copied from class: `BinaryFunction`
    Evaluate the function
    Specified by:
      `eval` in class `BinaryFunction`
    Parameters:
      `l` - lhs argument
      `r` - rhs argument
    Returns:
      the results
    Throws:
      `EvaluationException` - if the function cannot be evaluated.

  - ### binom

    public static int binom(int n, int i) throws ArrayIndexOutOfBoundsException
    Returns the binomial coefficients. nCi.
    Parameters:
      `n` - n
      `i` - i
    Returns:
      the binomial coefficient
    Throws:
      `ArrayIndexOutOfBoundsException` - if n<0, i<0 or i>n