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

Dalam dunia matematika dan ilmu komputer, integral adalah konsep penting yang digunakan untuk menghitung luas di bawah kurva fungsi. Dalam artikel ini, kita akan membahas penggunaan bahasa pemrograman R untuk menghitung integral dari dua fungsi matematika yang berbeda. Kita akan menjelajahi implementasi kode R yang sederhana untuk menghitung integral dari fungsi 4 � 3 4x 3 dari 0 hingga 2, serta integral dari 1 3 sin ⁡ ( 3 � ) 3 1 ​ sin(3x) dari 0 hingga � 4 4 π ​ . Mari kita mulai dengan memahami kode R yang digunakan untuk melakukan perhitungan ini.

F1 <- function(x) {
  return(x^4)
}

a1 <- 0
b1 <- 2
result1 <- F1(b1) - F1(a1)
cat("Integral dari 4x^3 dx dari 0 hingga 2 adalah", result1, "\n")
## Integral dari 4x^3 dx dari 0 hingga 2 adalah 16
F2 <- function(x) {
  return((1/3) * sin(3 * x))
}

a2 <- 0
b2 <- pi/4
result2 <- F2(b2) - F2(a2)
cat("Integral dari cos(3x) dx dari 0 hingga pi/4 adalah", result2, "\n")
## Integral dari cos(3x) dx dari 0 hingga pi/4 adalah 0.2357023

Referensi ; https://dtkaplan.github.io