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
Fungsi Kalkulus : Integral dan Diferensial Diferensial Untuk mendapatkan turunan dari fungsi dapat dengan menggunakan fungsi yang sudah disediakan oleh R yaitu D atau deriv.
Contoh :
Turunan dari f(x)=x2
xfs <- expression (exp(x^2))
D(xfs ,"x")
## exp(x^2) * (2 * x)
atau
xturunan <- deriv (~x^2,"x")
x <- 2
eval ( xturunan )
## [1] 4
## attr(,"gradient")
## x
## [1,] 4
Integral
Untuk mendapatkan integral dari suatu fungsi, dapat menggunakan fungsi yang sudah disediakan oleh R yaitu fungsi integrate atau dengan menggunakan package Ryacas
Integral Tak Tentu Integral tak tentu dapat dicari dengan menggunakan fungsi yac_str. Contoh :
Integral dari f(x)=x2+4x
("Integrate(t) t^4 * Exp(-t)")
## [1] "Integrate(t) t^4 * Exp(-t)"
Integral Tentu Integral tentu dapat dicari dengan menggunakan fungsi integrate.
Integral dari f(x)=x2+4x dengan batas -10 sampai 10
f1 <-function(x) x^2 + 4*x
integrate(f1,lower = -10,upper = 10)
## 666.6667 with absolute error < 7.6e-12
Integral dari f(x)=t4exp(−t) dengan batas 0 sampai tak hingga
f2 <-function(t) t^(4) * exp(-t)
integrate(f2,lower = 0,upper = Inf)
## 24 with absolute error < 2.2e-05
gamma(5)
## [1] 24