Dosen Pengampu : Prof .Dr.Suhartono, M.Kom

Lembaga : Universitas Islam Negeri Maulana Malik Ibrahim Malang

Fakultas : Sains dan Teknologi

Jurusan : Teknik Informatika

Kelas : (C) Kalkulus

NIM : 230605110080

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
## The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
## which was just loaded, will retire in October 2023.
## Please refer to R-spatial evolution reports for details, especially
## https://r-spatial.org/r/2023/05/15/evolution4.html.
## It may be desirable to make the sf package available;
## package maintainers should consider adding sf to Suggests:.
## The sp package is now running under evolution status 2
##      (status 2 uses the sf package in place of rgdal)
## 
## Attaching package: 'mosaicCalc'
## The following object is masked from 'package:stats':
## 
##     D
library(ggplot2)

INTEGRAL TAK TENTU

Integral tak tentu adalah konsep dalam kalkulus yang mewakili antiturunan atau kebalikan dari diferensiasi. Dalam matematika, ketika mengambil turunan dari suatu fungsi,harus menemukan gradien atau laju perubahan fungsi tersebut. Sebaliknya, ketika melakukan integral tak tentu dari suatu fungsi, akan mencari fungsi yang ketika di-diferensiasi menghasilkan fungsi awal.

Notasi umum untuk integral tak tentu dari fungsi f(x) adalah:

∫f(x)dx

dengan F(x) sebagai fungsi antiturunan dari f(x), yang ditulis sebagai:

F(x)= ∫f(x)dx

Dalam notasi ini, F(x) adalah fungsi yang memiliki turunan f(x). Proses mencari antiturunan atau integral tak tentu disebut juga sebagai “mengambil integral.”

library(pracma)
## Warning: package 'pracma' was built under R version 4.3.2
## 
## Attaching package: 'pracma'
## The following object is masked from 'package:mosaicCore':
## 
##     logit
## The following objects are masked from 'package:mosaic':
## 
##     cross, deg2rad, dot, logit, pdist, rad2deg, rand
## The following objects are masked from 'package:Matrix':
## 
##     expm, lu, tril, triu
# Install dan muat paket 'pracma' untuk fungsi integral
install.packages("pracma")
## Warning: package 'pracma' is in use and will not be installed
library(pracma)

# Contoh fungsi yang akan diintegrasikan
f <- function(x) {
  return(x^2 + 2*x + 1)
}

# Menghitung integral tak tentu dari fungsi f
integral_result <- integrate(f, lower = 0, upper = 2)

# Menampilkan hasil integral
cat("Hasil integral tak tentu:", integral_result$value)
## Hasil integral tak tentu: 8.666667
# Install dan muat paket 'pracma' untuk fungsi integral
install.packages("pracma")
## Warning: package 'pracma' is in use and will not be installed
library(pracma)

# Contoh fungsi yang akan diintegrasikan
f <- function(x) {
  return(x^2 + 2*x + 1)
}

# Batas bawah dan atas untuk integral
lower_limit <- 0
upper_limit <- 2

# Menghitung hasil integral
integral_result <- integrate(f, lower = lower_limit, upper = upper_limit)

# Membuat vektor x untuk plot fungsi
x <- seq(lower_limit, upper_limit, length.out = 100)

# Membuat vektor y dengan nilai fungsi pada setiap titik x
y <- f(x)

# Membuat plot fungsi
plot(x, y, type = "l", col = "blue", lwd = 2, main = "Grafik Fungsi dan Area di Bawah Kurva",
     xlab = "x", ylab = "f(x)")

# Menambahkan area di bawah kurva
polygon(c(lower_limit, x, upper_limit), c(0, y, 0), col = "skyblue", border = NA)

# Menambahkan teks dengan hasil integral
text(1, 8, sprintf("Integral = %.2f", integral_result$value), col = "red", cex = 1.2)

# Menampilkan plot
grid()