Grafik Fungsi Matematika
library(mosaicCalc)
## Loading required package: mosaicCore
## Loading required package: Deriv
## Loading required package: Ryacas
##
## Attaching package: 'Ryacas'
## The following object is masked from 'package:stats':
##
## integrate
## The following objects are masked from 'package:base':
##
## %*%, diag, diag<-, lower.tri, upper.tri
## Registered S3 method overwritten by 'mosaic':
## method from
## fortify.SpatialPolygonsDataFrame ggplot2
##
## Attaching package: 'mosaicCalc'
## The following object is masked from 'package:stats':
##
## D
A. Grafik fungsi matematika
Fungsi adalah transformasi dari input ke output. Fungsi digunakan untuk menyatakan hubungan antar besaran. Dalam mengevaluasi suatu fungsi , kita perlu menentukan apa inputnya dan nanti fungsi menerjemahkannya ke dalam output.
Ada tiga fungsi grafik {mosaicCalc} yang memungkinkan Anda membuat grafik fungsi, dan melapisi plot tersebut dengan grafik fungsi atau data lain. Ini adalah:
slice_plot() untuk fungsi satu variabel. contour_plot() untuk fungsi dua variabel. interactive_plot() yang menghasilkan widget HTML untuk berinteraksi dengan fungsi dua variabel.
contoh memplot fungsi garis lurus:
slice_plot(3 * x - 2 ~ x, domain(x = range(0, 10)))
m = -3
b = 4
slice_plot(m * x + b ~ x, domain(x = range(0, 10)))
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) ))
dapat menggunakan makeFun( )untuk memberi nama pada fungsi. Contohnya:
g <- makeFun(2*x^2 - 5*x + 2 ~ x)
slice_plot(g(x) ~ x , domain(x = range(-2, 2)))
Setelah fungsi diberi nama, kita dapat mengevaluasinya dengan memberikan input. Contohnya:
g(x = 2)
## [1] 0
g(x = 5)
## [1] 27
contoh ekspresi yang lebih rumit:
slice_plot(sqrt(abs(g(x))) ~ x, domain(x = range(-5,5)))
LATIHAN 1
x <- 10
slice_plot(A * x ^ 2 ~ A, domain(A = range(-2, 3)))
=> Grafik diatas tidak terlihat seperti parabola karena input ke fungsi adalah A, bukan x. nilai dari x telah disetel ke 10 — grafik dibuat pada rentang A dari −2 ke 3.
LATIHAN 2
Menerjemahkan setiap ekspresi ini dalam notasi matematika tradisional ke dalam plot.
slice_plot( 4 * x - 7 ~ x, domain(x = range(0, 10) ))
slice_plot( cos(5 * x) ~ x, domain(x = range(-1, 1)))
slice_plot( cos(2 * t) ~ t, domain(t = range(0,5) ))
slice_plot( sqrt(t) * cos(5 * t) ~ t, domain(t = range(0, 5) ))
Daftar Pustaka : https://dtkaplan.github.io/RforCalculus/graphing-functions.html#graphing-mathematical-functions