\HeaderA{Calculus}{DIFFERENTIATION AND INTEGRATION}{Calculus}
\aliasA{dif}{Calculus}{dif}
\aliasA{int}{Calculus}{int}
\begin{Description}\relax
Differentiation (by two-point differencing) and integration (by
rectangular approximation) in the time domain. For differentiation,
the begining time of the time series is increased by half the sampling
interval, and the length of the record is decreased by 1. It is also
usually a good idea to use the \code{\LinkA{rtrend}{rtrend}} or
\code{\LinkA{rmean}{rmean}} function before integration.
\end{Description}
\begin{Usage}
\begin{verbatim}
dif(s)
int(s)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{s}] an object of class \code{"rsac"}.
\end{ldescription}
\end{Arguments}
\begin{Value}
same as input.
\end{Value}
\begin{Author}\relax
Eric M. Thompson \textless{}eric.thompson@tufts.edu\textgreater{}
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{rtrend}{rtrend}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}

data(srosa)
getunits(srosa)
# convert to cm/s/s
srosa.accel <- dif(mul(srosa, 1e-7))

amax <-  function(X)
  X$x <- max(abs(X$amp))

pga <- max(sapply(X = srosa.accel, amax))
# cm/s/s

spect(srosa)

srosa.disp <- int(rtrend(srosa))

plot(srosa, xlim = c(100, 400))
plot(srosa.disp, xlim = c(100, 400))
srosa.disp <- hp(srosa.disp, c = 0.1)
plot(srosa.disp, xlim = c(100, 400))
spect(srosa.disp)
\end{ExampleCode}
\end{Examples}

