is.decreasing: Diagnosis a decreasing function

Description Usage Arguments Value See Also Examples

View source: R/is.decreasing.R

Description

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

Usage

1
is.decreasing(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 decreasing one-variable functions on the considered x.bound; otherwise FALSE

See Also

is.increasing

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
is.decreasing(fun=function(x) -2*x+10, x.bound=c(4,6), step=.1)

g = function(x) x^3
is.decreasing(g, x.bound=c(-24,6))

## 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.