The R Project SVN R

Rev

Rev 70613 | Rev 81601 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 70613 Rev 72263
Line 1... Line 1...
1
% File src/library/stats/man/deriv.Rd
1
% File src/library/stats/man/deriv.Rd
2
% Part of the R package, https://www.R-project.org
2
% Part of the R package, https://www.R-project.org
3
% Copyright 1995-2013 R Core Team
3
% Copyright 1995-2013, 2017 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{deriv}
6
\name{deriv}
7
\title{Symbolic and Algorithmic Derivatives of Simple Expressions}
7
\title{Symbolic and Algorithmic Derivatives of Simple Expressions}
8
\alias{D}
8
\alias{D}
Line 70... Line 70...
70
  \code{sinh}, \code{cosh}, \code{sqrt}, \code{pnorm}, \code{dnorm},
70
  \code{sinh}, \code{cosh}, \code{sqrt}, \code{pnorm}, \code{dnorm},
71
  \code{asin}, \code{acos}, \code{atan}, \code{gamma}, \code{lgamma},
71
  \code{asin}, \code{acos}, \code{atan}, \code{gamma}, \code{lgamma},
72
  \code{digamma} and \code{trigamma}, as well as \code{psigamma} for one
72
  \code{digamma} and \code{trigamma}, as well as \code{psigamma} for one
73
  or two arguments (but derivative only with respect to the first).
73
  or two arguments (but derivative only with respect to the first).
74
  (Note that only the standard normal distribution is considered.)
74
  (Note that only the standard normal distribution is considered.)
-
 
75
  \cr
-
 
76
  Since \R 3.4.0, the single-variable functions \code{\link{log1p}},
-
 
77
  \code{expm1}, \code{log2}, \code{log10}, \code{\link{cospi}},
-
 
78
  \code{sinpi}, \code{tanpi}, \code{\link{factorial}}, and
-
 
79
  \code{lfactorial} are supported as well.
75
}
80
}
76
\value{
81
\value{
77
  \code{D} returns a call and therefore can easily be iterated
82
  \code{D} returns a call and therefore can easily be iterated
78
  for higher derivatives.
83
  for higher derivatives.
79
 
84
 
Line 153... Line 158...
153
## showing the limits of the internal "simplify()" :
158
## showing the limits of the internal "simplify()" :
154
\dontrun{
159
\dontrun{
155
-sin(x^2) * (2 * x) * 2 + ((cos(x^2) * (2 * x) * (2 * x) + sin(x^2) *
160
-sin(x^2) * (2 * x) * 2 + ((cos(x^2) * (2 * x) * (2 * x) + sin(x^2) *
156
    2) * (2 * x) + sin(x^2) * (2 * x) * 2)
161
    2) * (2 * x) + sin(x^2) * (2 * x) * 2)
157
}
162
}
-
 
163
 
-
 
164
## New (R 3.4.0, 2017):
-
 
165
D(quote(log1p(x^2)), "x") ## log1p(x) = log(1 + x)
-
 
166
stopifnot(identical(
-
 
167
       D(quote(log1p(x^2)), "x"),
-
 
168
       D(quote(log(1+x^2)), "x")))
-
 
169
D(quote(expm1(x^2)), "x") ## expm1(x) = exp(x) - 1
-
 
170
stopifnot(identical(
-
 
171
       D(quote(expm1(x^2)), "x") -> Dex1,
-
 
172
       D(quote(exp(x^2)-1), "x")),
-
 
173
       identical(Dex1, quote(exp(x^2) * (2 * x))))
-
 
174
 
-
 
175
D(quote(sinpi(x^2)), "x") ## sinpi(x) = sin(pi*x)
-
 
176
D(quote(cospi(x^2)), "x") ## cospi(x) = cos(pi*x)
-
 
177
D(quote(tanpi(x^2)), "x") ## tanpi(x) = tan(pi*x)
-
 
178
 
-
 
179
stopifnot(identical(D(quote(log2 (x^2)), "x"),
-
 
180
                    quote(2 * x/(x^2 * log(2)))),
-
 
181
          identical(D(quote(log10(x^2)), "x"),
-
 
182
                    quote(2 * x/(x^2 * log(10)))))
-
 
183
 
158
}
184
}
159
\keyword{math}
185
\keyword{math}
160
\keyword{nonlinear}
186
\keyword{nonlinear}