library(mosaicCalc)
## Loading required package: mosaic
## Registered S3 method overwritten by 'mosaic':
## method from
## fortify.SpatialPolygonsDataFrame ggplot2
##
## The 'mosaic' package masks several functions from core packages in order to add
## additional features. The original behavior of these functions should not be affected by this.
##
## Attaching package: 'mosaic'
## The following objects are masked from 'package:dplyr':
##
## count, do, tally
## The following object is masked from 'package:Matrix':
##
## mean
## The following object is masked from 'package:ggplot2':
##
## stat
## The following objects are masked from 'package:stats':
##
## binom.test, cor, cor.test, cov, fivenum, IQR, median, prop.test,
## quantile, sd, t.test, var
## The following objects are masked from 'package:base':
##
## max, mean, min, prod, range, sample, sum
## Loading required package: mosaicCore
##
## Attaching package: 'mosaicCore'
## The following objects are masked from 'package:dplyr':
##
## count, tally
##
## Attaching package: 'mosaicCalc'
## The following object is masked from 'package:stats':
##
## D
g <- D(x^2 ~ x)
g(1)
## [1] 2
my_function <- function(x){
return (5 * x^2)
}
my_function(4)
## [1] 80
g <- D(my_function(x) ~ x)
g(5)
## [1] 50
df <- D(sin(x) ~ x)
ddf <- D(df(x) ~ x)
another.ddf <- D(sin(x) ~ x & x)
g <- D(3 * x ^ 2 - 2*x + 4 ~ x)
g(-6)
## [1] -38
g(-4)
## [1] -26
g(-3)
## [1] -20
g(-2)
## [1] -14
g(0)
## [1] -2
g(2)
## [1] 10
g(3)
## [1] 16
g(4)
## [1] 22
g(6)
## [1] 34
slice_plot(3 * x ^ 2 - 2*x + 4 ~ x,domain(x=range(40,-40)))

g <- D(5 * exp(0.2 * x) ~ x)
g(-5)
## [1] 0.3678794
g(-2)
## [1] 0.67032
g(-1)
## [1] 0.8187308
g(0)
## [1] 1
g(1)
## [1] 1.221403
g(2)
## [1] 1.491825
g(5)
## [1] 2.718282
slice_plot(5 * exp(0.2 * x) ~ x,domain(x=range(40,-40)))
