Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

piecewise

Piecewise Linear Function


Description

Compute zeros and area of a piecewise linear function.

Usage

piecewise(x, y, abs = FALSE)

Arguments

x, y

x- and y-coordinates of points defining the piecewise linear function

abs

logical; shall the integral or the total area between the x-axis and the function be calculated

Details

Compute zeros and integral resp. area of a piecewise linear function given by points with x and y as coordinates.

Value

Returns a list with the integral or area as first element and the vector as all zeroes as second.

See Also

Examples

x <- c(0,  2, 3,  4, 5)
y <- c(2, -2, 0, -2, 0)
piecewise(x, y)
piecewise(x, y, abs=TRUE)

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.