NIM : 220605110107
Universitas : Universitas Islam Negeri Maulana Malik Ibrahim Malang
Jurusan : Teknik Informatika
Anti turunan atau lebih familiar dikenal sebagai integral merupakan bentuk pengembalian turunan ke bentuk awalnya. Setelah belajar menggunakan turunan dengan bahasa pemrograman R maka, sepatutnya kita belajar juga menggunakan integral.
Langkah awal yang harus kita lakukan adalah dengan membuat sebuah fungsi dan menginput nilai x
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
f <- makeFun( A * x ^ 2 ~ x, A = 0.5)
f(2)
## [1] 2
Cara cek fungsi =
f
## function (x, A = 0.5)
## A * x^2
Sedikit riview tentang turunanyang telah dibahas di artikel sebelumnya
df <- D(f(x) ~ x)
df(2)
## [1] 2
Kita dapat membuat sebuah grafik dnengan sliceplot untuk fungsi awal dan hasil turunannya
slice_plot(f(x) ~ x, domain(x = -1:1)) %>%
gf_labs(title = "Original function f(x)")
slice_plot(df(x) ~ x, domain(x =-1:1), color = "red") %>%
gf_labs(title = "New function df(x), the derivative of f(x)")
Disini kita akan mulai belajar tentang integral, integral disini menggunnakan fungsi antiD seperti contoh dibawah ini :
library(mosaic)
DF <- antiD(df(x) ~ x , A = 0.5)
DF
## function (x, A = 0.5, C = 0)
## A * x^2 + C
DF(1)
## [1] 0.5
Pembuatan integral yang kemudian langsung diturunkan agar menjadi fungsi awal
library(mosaicCalc)
f <- makeFun( A * x ^ 2 ~ x, A = 0.5)
h <- antiD( f(x) ~ x ,A=0.5)
dh <- D(h(x) ~ x )
dh(1)
## [1] 0.5
Pembenntukan fungsi dan input x
f1 <- makeFun(sin(x ^ 2) ~ x)
f2 <- makeFun(sin(x ^ 2) + 3 ~ x)
f3 <- makeFun(sin(x ^ 2) - 100 ~ x)
f1(1)
## [1] 0.841471
f2(2)
## [1] 2.243198
f3(10)
## [1] -100.5064
Melakukan turunan pada fungsi dan input x
df1 = D(f1(x) ~ x)
df2 = D(f2(x) ~ x)
df3 = D(f3(x) ~ x)
df1(1)
## [1] 1.080605
df2(2)
## [1] -2.614574
df3(3)
## [1] -5.466782
Integral biasa yang diintegralkan lagi
fun = antiD( x^2 ~ x )
fun
## function (x, C = 0)
## x^3/3 + C
Integral dengan batas
fun(x = 3) - fun(x = 2)
## [1] 6.333333