is.increasing: Diagnosis an increasing function

Description Usage Arguments Value See Also Examples

View source: R/is.increasing.R

Description

is.increasing tests if the introduced one-variable function is increasing (or in fact, non-decreasing) on the considered x.bound or not. In other words, is.increasing returns TRUE if the introduced function is increasing on the considered x.bound; and it returns FALSE otherwise. The goal of introducing function is.increasing in package FuzzyNumbers.Ext.2 is using in function f2apply.

Usage

1
is.increasing(fun, x.bound = c(-1, 1), step = 0.01)

Arguments

fun

a one-variable R function

x.bound

a vector with two real ordered elements which determine a bound on x-axis for checking the monotonic of the considered function

step

a positive real-valued number which determine the increment of the considered sequence for checking the monotonic of the considered function. The default of step is 0.01. Increasing step value can cause the decreasing the time of computation and also couse the decreasing the precision of the calculations.

Value

TRUE for increasing one-variable functions on the considered x.bound; otherwise FALSE

See Also

is.decreasing

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
is.increasing(fun=function(x) 2*x, x.bound=c(4,6), step=.1)

g = function(x) x^2
is.increasing(g, x.bound=c(-24,6), step=.01)

h = function(x) x^5
is.increasing(h, c(-24,6), .01)
curve(h(x), xlim=c(-2,2))


## The function is currently defined as
function (fun, x.bound = c(-1, 1), step = 0.01) 
{
    x = seq(x.bound[1], x.bound[2], by = step)
    i = 1
    while (fun(x[i]) <= fun(x[i + 1])) {
        if (i < length(x) - 1) {
            i <- i + 1
        }
        else (return(TRUE))
    }
    return(FALSE)
  }

FuzzyNumbers.Ext.2 documentation built on May 1, 2019, 9:15 p.m.