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)
Untuk menghitung luas daerah di bawah kurva fungsi menggunakan integral tentu, kita dapat menggunakan konsep dasar dari integral tentu. Misalnya, jika kita memiliki fungsi f(x) pada interval [a,b] dan kita ingin menghitung luas daerah di bawah kurva tersebut, kita dapat menggunakan rumus integral tentu sebagai berikut:
Luas = ∫ batas bawah a dan batas atas b f(x)dx
Sebagai contoh, misalkan kita ingin menghitung luas di bawah kurva fungsi f(x)=x^2 dari x=0 hingga x=2.
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 load package pracma
install.packages("pracma")
## Warning: package 'pracma' is in use and will not be installed
library(pracma)
# Definisikan fungsi
f <- function(x) {
return(x^2)
}
# Tentukan batas integral
a <- 0
b <- 2
# Hitung integral menggunakan fungsi integrate()
result <- integrate(f, lower = a, upper = b)
# Tampilkan hasil
print(paste("Luas daerah di bawah kurva:", result$value))
## [1] "Luas daerah di bawah kurva: 2.66666666666667"
# Install dan load package pracma
install.packages("pracma")
## Warning: package 'pracma' is in use and will not be installed
library(pracma)
# Definisikan fungsi
f <- function(x) {
return(x^2)
}
# Tentukan batas integral
a <- 0
b <- 2
# Hitung integral menggunakan fungsi integrate()
result <- integrate(f, lower = a, upper = b)
# Buat grafik fungsi
x <- seq(0, 2, length.out = 100)
y <- f(x)
plot(x, y, type = "l", col = "blue", lwd = 2, xlab = "x", ylab = "f(x)", main = "Grafik f(x) = x^2")
# Tambahkan area di bawah kurva
polygon(c(a, x, b), c(0, y, 0), col = "skyblue")
# Tampilkan hasil integral sebagai teks pada grafik
text(1, 2, paste("Luas =", round(result$value, 2)), pos = 4, col = "red")
# Tampilkan grafik
grid()