#Anda telah melihat operator kalkulus dasar, diferensiasi, yang diimplementasikan oleh fungsi R mosaicCalc/ D(). Operator diferensiasi mengambil sebagai input fungsi dan variabel “sehubungan dengan”. Outputnya adalah fungsi lain yang memiliki variabel “sehubungan dengan” sebagai argumen, dan kemungkinan argumen lain juga.

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(1)
## [1] 0.5
df <- D(f(x) ~ x)
df(1)
## [1] 1
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)")

DF <- antiD((x) ~ x)
DF <- antiD((x) ~ x)
DF(1)
## [1] 0.5
DF(2)
## [1] 2
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)")

#kebalikan dari operator D. berarti membatalkan apa yang dilakukan D

dh <- antiD( (x) ~ x )
dh <- antiD((x) ~ x )
dh(1)
## [1] 0.5

#satu variabel menjadi dua argumen #Anti-derivatif membatalkan turunan, tetapi apa artinya “membatalkan” properti lokal? Jawabannya adalah anti-turunan (atau, dengan kata lain, integral) memberi tahu Anda tentang beberapa properti global atau terdistribusi dari suatu fungsi: bukan hanya nilai pada suatu titik, tetapi nilai yang terakumulasi pada seluruh rentang titik. Sifat antiturunan global atau terdistribusi inilah yang membuat antiturunan sedikit lebih rumit daripada turunan, tetapi tidak lebih dari itu.

Inti masalahnya adalah ada lebih dari satu cara untuk “membatalkan” turunan. Pertimbangkan fungsi-fungsi berikut, yang masing-masing berbeda:

slice_plot(df(x) ~ x, domain(x=-1:1), color = "red") %>%
  gf_labs(title = "Original function df(x)")

slice_plot(DF(x) ~ x, domain(x=-1:1)) %>%
  gf_labs(title = "New function DF(x), the anti-derivative of df(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

#, semuanya memiliki turunan yang sama f1(x) f2(x) f3(x)

df1 = D(f1(x) ~ x)
df2 = D(f2(x) ~ x)
df3 = D(f3(x) ~ x)
df1(1)
## [1] 1.080605