Nama : Akbar Bimantara T
NIM : 220605110080
Kelas : C
Mata Kuliah : Kalkulus
Dosen Pengampu : Prof. Dr. Suhartono, M.kom
Jurusan : Teknik Informatika
Universitas : UIN Maulana Malik Ibrahim Malang
Cara menggunakan R untuk membuat Grafik Fungsi Matematika
Fungsi digunakan untuk mewakili hubungan antara kuantitas. Dalam mengevaluasi suatu fungsi, harus menentukan apa input yang akan jadi dan fungsi tersebut menerjemahkannya ke dalam output.
fungsi memiliki nama seperti f atau g atau y, dan input dicatat sebagai x. Huruf lain digunakan untuk mewakili parameter. Misalnya, adalah umum untuk menulis persamaan garis dengan cara ini y = mx + b.
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
slice_plot(3 * x - 2 ~ x, domain(x = range(0, 10)))
m = -3
b = -2
slice_plot(m * x + b ~ x, domain(x = range(0, 10)))
Untuk mengubah garis menjadi horizontal atau lurus maka nilai variabel m diganti menjadi 0, contohnya seperti dibawah ini :
m = 0
b = -4
slice_plot(m * x + b ~ x, domain(x = range(0, 10)))
Mencoba Contoh-contoh lain sebagai berikut :
A = 100
slice_plot( A * x ^ 2 ~ x, domain(x = range(-2, 3)))
A = 5
slice_plot( A * x ^ 2 ~ x, domain(x = range(0, 3)), color="red" )
slice_plot( cos(t) ~ t, domain(t = range(0,4*pi) ))
Jika ingin memberi nama pada fungsi bisa dengan makeFun(), seperti dibawah ini
g <- makeFun(2*x^2 - 5*x + 2 ~ x)
slice_plot(g(x) ~ x , domain(x = range(-2, 2)))
Disini bisa juga memberi nama pada fungsi seperti contoh diatas.
slice_plot(sqrt(abs(g(x))) ~ x, domain(x = range(-5,5)))
slice_plot(t^2 ~ t, domain(t = range(-2, 2)))
slice_plot( sqrt(t) * cos(5 * t) ~ t, domain(t = range(0, 5) ))