is.decreasing {FuzzyNumbers.Ext.2} | R Documentation |
Diagnosis a decreasing function
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
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 |
Value
TRUE
for decreasing one-variable functions on the considered x.bound
; otherwise FALSE
See Also
is.increasing
Examples
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)
}