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

Numerical Iteration

Gunakan fungsi R/mosaik Iterate(). Argumen pertama adalah ekspresi gelombang yang mendefinisikan fungsi yang akan diiterasi. Yang kedua adalah tebakan awal. Yang ketiga adalah jumlah langkah iterasi. Contohnya:

better <- makeFun((guess + x/guess)/2 ~ guess)
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

Keluaran yang dihasilkan Iterate() berupa bingkai data. Tebakan awal ada pada baris dengan n = 0 . Baris yang berurutan memberikan keluaran, langkah demi langkah, dengan setiap langkah iterasi baru.

Referensi: Kaplan, Daniel. 2022. MOSAIC Calculus. GitHub Pages. https://dtkaplan.github.io/MC2/