Nama : Sausan Shalihah Alfirdausi

NIM : 230605110064

Mata Kuliah : Kalkulus

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

Program Studi : Teknik Informatika

Universitas : Universitas Islam Negeri Malang

Pada artikel kali ini saya akan membahas tentang pembuatan grafik optimasi.

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

Membuat fungsi h(x) = 2x^2 menggunakan rfun() dari paket mosaicCalc. Fungsi ini disimpan dalam variabel h. Seed=7293` digunakan untuk memastikan bahwa hasilnya dapat direproduksi jika fungsi acak terlibat.

h <- rfun(2*x^2~ x, seed=7293)
argM(h(x) ~ x, bounds(x=-5:5))
## # A tibble: 2 × 3
##        x .output. concavity
##    <dbl>    <dbl>     <dbl>
## 1 -1.68      1.93         1
## 2  0.173     8.25        -1

Menggunakan fungsi argM() untuk mencari nilai argumen h(x) mencapai nilai maksimum lokal atau minimum lokal. bounds(x=-5:5) menentukan rentang pencarian dari -5 hingga 5. Hasilnya akan menampilkan nilai argumen dan nilai fungsi pada nilai tersebut.

slice_plot(h(x) ~ x, bounds(x=-5:5)) %>%
  gf_vline(xintercept = ~ max(1), color="red") %>%
  gf_vline(xintercept = ~ min((0)), color="purple")

Menambahkan garis vertikal berwarna merah pada nilai maksimum dari ekspresi 1. Nilai maksimum ini mungkin terjadi pada suatu titik di rentang x yang dipilih. max(1) akan memberikan nilai maksimum dari 1 dalam rentang x yang ditentukan. Menambahkan garis vertikal berwarna ungu pada nilai minimum dari ekspresi 0. Pada kasus ini, nilai minimum adalah 0, yang terjadi ketika x=0.

Daftar Pustaka https://www.mosaic-web.org/MOSAIC-Calculus/Modeling/06-operations.html