Lembaga : Universitas Negeri Maulana Malik Ibrahim Malang

Fakultas : Sains dan Teknologi

Jurusan : Teknik Informatika

Kelas : (B) Kalkulus

NIM : 230605110047

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

Dalam ilmu komputer atau pemograman, iterasi adalah sifat tertentu dari algoritma atau program komputer di mana suatu urutan atau lebih dari langkah algoritmik dilakukan loop di program. Hal ini dibedakan dari teknik berulang yang disebut rekursi.

Di dalam matematika, iterasi dapat diartikan sebagai suatu proses atau metode yang digunakan secara berulang-ulang (pengulangan) dalam menyelesaikan suatu permasalahan matematik.

sebelum menjalankan rumus iterasi di dalam RStudio kita harus menginstall library mosaicCalc dengan cara dibawah ini:

library(mosaicCalc)
## Warning: package 'mosaicCalc' was built under R version 4.3.2
## 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

untuk memulai kita harus menggunakan fungsi untuk komputer terlebih dahulu:

better <- makeFun((guess + x/guess)/2 ~ guess)
better
## function (guess, x) 
## (guess + x/guess)/2
better(1, x=55)
## [1] 28

Melakukan iterasi lagi dengan cara memasukkan hasil output iterasi sebelumnya ke dalam iterasi selanjutnya.

better(28, x=55)
## [1] 14.98214
better(14.98214, x=55)
## [1] 9.326589
better(9.326589, x=55)
## [1] 7.611854
better(7.611854, x=55)
## [1] 7.418713
Iterate(better(guess, x=55) ~ guess, x0=1, n=8)
##   n     guess
## 1 0  1.000000
## 2 1 28.000000
## 3 2 14.982143
## 4 3  9.326590
## 5 4  7.611854
## 6 5  7.418713
## 7 6  7.416199
## 8 7  7.416198
## 9 8  7.416198
Iterate(function(x, y) c(x+y, x-y), x0 = c(3,5), n=10)
##     n   x   y
## 1   0   3   5
## 2   1   8  -2
## 3   2   6  10
## 4   3  16  -4
## 5   4  12  20
## 6   5  32  -8
## 7   6  24  40
## 8   7  64 -16
## 9   8  48  80
## 10  9 128 -32
## 11 10  96 160

Dari Tabel Diatas kita bisa lihat bahwa c(3,5), angka 3 itu variabel x yang dimulai dari angka 3 dan 5 adalah variabel y yang dimulai dari angka 5. baris ke 2 dari variabel x itu hasil dari x + y, sedangkan baris ke 2 dari variabel y itu hasil dari x - y begitu seterusnya. Huruf n adalah jumlah iterasi yang dilakukan n = n - 1 , dilakukan pengurangan karena pada n dimulai dari angka 0.

Referensi:

https://dtkaplan.github.io/MC2/Modeling/06-operations.html