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
log(3.1)
## [1] 1.131402
Dari hasil didapat bahwa jika kita memasukkkan nilai x0 sama dengan 3.1 maka akan didapatkan nilai fungsi adalah 1.131402.
Contoh lain adalah jika kita mendapatkan fungsi f(x)=4.5-2.69x+5.9908x^2
ini adalah suatu fungsi polinomial jika kita memberi nilai x0 tertentu pada fungsi tersebut maka kita bisa contohkan hasil dari f(x) adalah 3 maka kita bisa mencarai nilai dari x0 dengan cara seperti berikut:
f <- makeFun(4.5-2.69*x+5.008*x^2 ~ x)
f
## function (x)
## 4.5 - 2.69 * x + 5.008 * x^2
Zeros(f(x) - 0 ~ x, bounds(x=-25:25))
## # A tibble: 0 × 2
## # ℹ 2 variables: x <lgl>, .output. <dbl>
slice_plot(f(x) ~ x, bounds(x=-7:7)) %>%
gf_hline(yintercept = ~ 0 , color="blue")