F1D
jhplot

Class F1D

  • All Implemented Interfaces:
    Serializable


    public class F1Dextends DrawOptionsimplements Serializable
    Create a function in one dimension using "x" as a variable. The function name could have parameters named in unique way as P0, P1, P2 ... They have to be replaced with values using setPar() method for evaluation. The function may have one independent variable: x

    Operators and functions

    the following operators are supported:

    • Addition: '2 + 2'
    • Subtraction: '2 - 2'
    • Multiplication: '2 * 2'
    • Division: '2 / 2'
    • Exponential: '2 ^ 2' or ** (raise to a power)
    • Unary Minus,Plus (Sign Operators): '+2 - (-2)'
    • Modulo: '2 % 2'
    the following functions are supported:
    • abs: absolute value
    • acos: arc cosine
    • asin: arc sine
    • atan: arc tangent
    • cbrt: cubic root
    • ceil: nearest upper integer
    • cos: cosine
    • cosh: hyperbolic cosine
    • exp: euler's number raised to the power (e^x)
    • floor: nearest lower integer
    • log: logarithmus naturalis (base e)
    • sin: sine
    • sinh: hyperbolic sine
    • sqrt: square root
    • tan: tangent
    • tanh: hyperbolic tangent

    It also recognizes the pi (or Pi) values;
    See Also:
    Serialized Form
    • Constructor Detail

      • F1D

        public F1D(String name,   double min,   double max)
        Create a function in 1D. 500 points are used between Min and Max for evaluation. The title is set to the function's definition The function may have one independent variable: x. Example: x*x Operators and functions

        the following operators are supported:
        • Addition: '2 + 2'
        • Subtraction: '2 - 2'
        • Multiplication: '2 * 2'
        • Division: '2 / 2'
        • Exponential: '2 ^ 2' or ** (raise to a power)
        • Unary Minus,Plus (Sign Operators): '+2 - (-2)'
        • Modulo: '2 % 2'
        the following functions are supported:
        • abs: absolute value
        • acos: arc cosine
        • asin: arc sine
        • atan: arc tangent
        • cbrt: cubic root
        • ceil: nearest upper integer
        • cos: cosine
        • cosh: hyperbolic cosine
        • exp: euler's number raised to the power (e^x)
        • floor: nearest lower integer
        • log: logarithmus naturalis (base e)
        • sin: sine
        • sinh: hyperbolic sine
        • sqrt: square root
        • tan: tangent
        • tanh: hyperbolic tangent

        It also recognizes the pi (or Pi) values;
        Parameters:
        name - String representing the function's definition
        min - Min value
        max - Max value
      • F1D

        public F1D(String name,   double min,   double max,   boolean parsed)
        Same function, but one can specify is it parsed or not.
        Parameters:
        name - Name
        min - Min value
        max - Max value
        parsed - parsed or not.
      • F1D

        public F1D(String name)
        Create a function in 1D for evaluation. The function may have one independent variable: x

        Operators and functions

        the following operators are supported:

        • Addition: '2 + 2'
        • Subtraction: '2 - 2'
        • Multiplication: '2 * 2'
        • Division: '2 / 2'
        • Exponential: '2 ^ 2' or ** (raise to a power)
        • Unary Minus,Plus (Sign Operators): '+2 - (-2)'
        • Modulo: '2 % 2'
        the following functions are supported:
        • abs: absolute value
        • acos: arc cosine
        • asin: arc sine
        • atan: arc tangent
        • cbrt: cubic root
        • ceil: nearest upper integer
        • cos: cosine
        • cosh: hyperbolic cosine
        • exp: euler's number raised to the power (e^x)
        • floor: nearest lower integer
        • log: logarithmus naturalis (base e)
        • sin: sine
        • sinh: hyperbolic sine
        • sqrt: square root
        • tan: tangent
        • tanh: hyperbolic tangent

        It also recognizes the pi (or Pi) values;
        Parameters:
        name - String representing the function
      • F1D

        public F1D(String title,   String name)
        Create new function.
        Parameters:
        title - title
        name - definition
      • F1D

        public F1D(String title,   String name,   double min,   double max,   boolean parse)
        Create a new function. The function may have one independent variable: x

        Operators and functions

        the following operators are supported:

        • Addition: '2 + 2'
        • Subtraction: '2 - 2'
        • Multiplication: '2 * 2'
        • Division: '2 / 2'
        • Exponential: '2 ^ 2' or ** (raise to a power)
        • Unary Minus,Plus (Sign Operators): '+2 - (-2)'
        • Modulo: '2 % 2'
        the following functions are supported:
        • abs: absolute value
        • acos: arc cosine
        • asin: arc sine
        • atan: arc tangent
        • cbrt: cubic root
        • ceil: nearest upper integer
        • cos: cosine
        • cosh: hyperbolic cosine
        • exp: euler's number raised to the power (e^x)
        • floor: nearest lower integer
        • log: logarithmus naturalis (base e)
        • sin: sine
        • sinh: hyperbolic sine
        • sqrt: square root
        • tan: tangent
        • tanh: hyperbolic tangent

        It also recognizes the pi (or Pi) values;
        Parameters:
        title - title
        name - definition
        min - min value
        max - max value
        parse - parset or not
      • F1D

        public F1D(String title,   double[] pars,   double min,   double max,   boolean parse)
        Create a polynomial analytical function using a list of values. Example: pars[0]+pars[1]*x+pars[2]*x*x +pars[3]*x*x*x
        Parameters:
        title - Title of this function
        pars - array of coefficients for polynomial function
        min - Min value for evaluation
        max - Max value for evaluation
        parse - set true if it should be parsed
      • F1D

        public F1D(String name,   boolean parse)
        Build a function. The function may have one independent variable: x

        Operators and functions

        the following operators are supported:

        • Addition: '2 + 2'
        • Subtraction: '2 - 2'
        • Multiplication: '2 * 2'
        • Division: '2 / 2'
        • Exponential: '2 ^ 2' or ** (raise to a power)
        • Unary Minus,Plus (Sign Operators): '+2 - (-2)'
        • Modulo: '2 % 2'
        the following functions are supported:
        • abs: absolute value
        • acos: arc cosine
        • asin: arc sine
        • atan: arc tangent
        • cbrt: cubic root
        • ceil: nearest upper integer
        • cos: cosine
        • cosh: hyperbolic cosine
        • exp: euler's number raised to the power (e^x)
        • floor: nearest lower integer
        • log: logarithmus naturalis (base e)
        • sin: sine
        • sinh: hyperbolic sine
        • sqrt: square root
        • tan: tangent
        • tanh: hyperbolic tangent


        Parameters:
        name - name
        parse - is parsed or not?
      • F1D

        public F1D(String title,   ExpressionBuilder function,   double min,   double max)
        Create a function in 1D. 500 points are used between Min and Max for evaluation. The function may have x as independent variable.
        Parameters:
        title - Title
        function - ExpressionBuilder
        min - Min value
        max - Max value
      • F1D

        public F1D(ExpressionBuilder function,   double min,   double max)
        Build a function.
        Parameters:
        function - input
        min - Min value
        max - Max value
      • F1D

        public F1D(String title,   String name,   double min,   double max)
        Create a function in 1D. 500 points are used between Min and Max for evaluation. Function will be parsed.
        Parameters:
        title - String representing the title
        name - String representing the function's definition
        min - Min value
        max - Max value
      • F1D

        public F1D(IFunction iname,   double min,   double max)
        Create a F1D function from JAIDA IFunction. By default, 500 points for evaluation are used
        Parameters:
        iname - input IFunction
        min - Min value
        max - Max value
      • F1D

        public F1D(IFunction iname)
        Create a F1D function from JAIDA IFunction. By default, 500 points for evaluation are used
        Parameters:
        iname - input IFunction
      • F1D

        public F1D(String title,   IFunction iname,   double min,   double max)
        Create F1D function from JAIDA IFunction. By default 500 points are used
        Parameters:
        title - Title
        iname - input IFunction
        min - Min X values
        max - Max X values
    • Method Detail

      • parse

        public boolean parse()
        Parse the function.
        Returns:
        true if parsed without problems.
      • eval

        public double eval(double x)
        Evaluate a function at a specific point in x
        Parameters:
        x - value in x for evaluation
        Returns:
        function value at x
      • eval

        public double[] eval(double[] x)
        Evaluate a function for an array of x-values
        Parameters:
        x - array of values in x for evaluation
        Returns:
        array of function values
      • eval

        public void eval(double min,        double max)
        Evaluate a function for graphic representation. Number of points for evaluations is 500.
        Parameters:
        Min - value in x
        Max - value in x
      • eval

        public void eval(double min,        double max,        int Npoints)
        Evaluate a function for graphic representation. Number of points for evaluations is 500.
        Parameters:
        Min - value in x
        Max - value in x
        Number - of evaluation points
      • eval

        public void eval()
        Evaluate a function for graphic representation. Min and Max should be given in constructor.
      • doc

        public void doc()
        Show online documentation.
      • toTable

        public void toTable()
        Print the F1D function to a Table in a separate Frame. The numbers are formatted to scientific format. One can sort and search the data in this table (data cannot be modified)
      • setPar

        public void setPar(String parameter,          double value)
        Replace abstract parameter with the value (double). Case sensitive!
        Parameters:
        parameter - parameter name
        value - value to be inserted
      • getH1D

        public H1D getH1D()
        Return H1D histogram from F1D function. The number of points are given by setPoints() method, but the default 500 is used if not given. Min and Max values are given by the values used to parse the function.
        Returns:
      • getH1D

        public H1D getH1D(String hname,         int bins,         double hmin,         double hmax)
        Return a Histogram given by the F1D function. All statistical characteristics of such histogram are meaningless. Bins and Min and Max values are user defined. The function is evaluated at the bin center which is important for small number of bins.
        Parameters:
        hname - Name of the histogram
        bins - number of bins for histogram
        hmin - min value of histogram
        hmax - max value of histogram
        Returns:
        H1D histogram
      • setPar

        public void setPar(String parameter,          int value)
        Replace abstract parameter with the value (integer). Case sensitive.
        Parameters:
        parameter - parameter name
        value - integer value to be inserted.
      • getX

        public double getX(int i)
        Get value in X-axis
        Parameters:
        i - index
        Returns:
        value in X
      • getY

        public double getY(int i)
        Get value in Y-axis
        Parameters:
        i - index
        Returns:
        value in Y
      • setName

        public void setName(String name)
        Sets a name of the function, i.e. what will be used for evaluation
        Parameters:
        name - Name
      • getName

        public String getName()
        Get the name of the function used for evaluation
        Returns:
        Name
      • getParse

        public Calculable getParse()
        Return parsed function. One can evaluate Y as: y =function.getResult(x), where function is what returned by this method.
        Returns:
        function
      • setMin

        public void setMin(double min)
        Set Min value in X
        Parameters:
        min - Minimum value
      • getMin

        public double getMin()
        Get the minimum value in X
        Returns:
        min Minimum value
      • setMax

        public void setMax(double max)
        Set the maximum value in X
        Parameters:
        max - Maximal value
      • getMax

        public double getMax()
        Get the maximum value in X
        Returns:
        Maximal value
      • setPoints

        public void setPoints(int bins)
        Sets the number points between Min and Max for evaluation
        Parameters:
        bins - Number of points
      • integral

        public double integral(String type,              int N,              double min,              double max)
        Numerical integration. Define types as:
        type="gauss4" - Gaussian integration formula (4 points)
        type="gauss8" - Gaussian integration formula (8 points)
        type="richardson" - Richardson extrapolation
        type="simpson" - using Simpson's rule.
        type="trapezium" - trapezium rule.
        Parameters:
        type - type of algorithm. Can be: "gauss4","gauss8","richardson","simpson","trapezium".
        N - the number of strips to use for integration
        min - the first ordinate.
        max - the last ordinate.
        Returns:
        integral
      • integral

        public double integral(int N,              double min,              double max)
        Numerical integration using trapezium rule.
        Parameters:
        N - the number of strips to use for integration
        min - the first ordinate.
        max - the last ordinate.
        Returns:
        integral
      • getIFunction

        public IFunction getIFunction()
        Get Jaida function
        Returns:
      • getArrayX

        public double[] getArrayX()
        Get array of X-values after function after evaluation using the default number of points
        Returns:
        X-values
      • getArrayY

        public double[] getArrayY()
        Get array of Y-values after function after evaluation using the default number of points
        Returns:
        Y-values
      • isParsed

        public boolean isParsed()
        If the function is parsed correctly, return true. Use this check before drawing it.
        Returns:
        true if parsed.
      • toMathML

        public String toMathML()
        Convert the function into MathML form.
        Returns:
        String representing this function in MathML.
      • toJava

        public String toJava()
        Convert the function into Java code.
        Returns:
        String representing this function in Java.
      • simplify

        public boolean simplify()
        Try to simplify this function. It is often useful to rewrite an expression in term of elementary functions (log, exp, frac, sqrt, implicit roots), using the "elementary()" before simplifying it. Retrieve the simplified name as a string using getName() method.
        Returns:
        false if error occurs. Retrieve this error as a string using getException().
      • elementary

        public boolean elementary()
        Convert this function rewrite in term of elementary functions (log, exp, frac, sqrt, implicit roots) This is useful before simplifying function. Retrieve the simplified name as a string using getName() method.
        Returns:
        false if error occurs. Retrieve this error as a string using getException().
      • expand

        public boolean expand()
        Convert this function rewrite in expanded form. Retrieve the expanded name as a string using getName() method.
        Returns:
        false if error occurs. Retrieve this error as a string using getException().
      • factorize

        public boolean factorize()
        Convert this function rewrite in factorized form (if can). Retrieve the expanded name as a string using getName() method.
        Returns:
        false if error occurs. Retrieve this error as a string using getException().
      • numeric

        public boolean numeric()
        Perform some numeric substitutions. Examples: exp(1) should be 2.71828182, "pi" should be 3.14159 etc. Retrieve the expanded name as a string using getName() method.
        Returns:
        false if error occurs. Retrieve this error as a string using getException().
      • differentiate

        public double[] differentiate(int N,                     double min,                     double max)
        Numerical differentiation.
        Parameters:
        N - the number of points to use.
        min - the first ordinate.
        max - the last ordinate.
        Returns:
        array with differentials
      • getPoints

        public int getPoints()
        Get the number of points
        Returns:
        Number of points
      • getException

        public String getException()
        If error occurs at some step, this is the way to retrieve it.
        Returns:
        last exception happened in any method of this class.

SCaVis 1.7 © jWork.org