Nama : Muhammad Hafidlul Qolbi
NIM : 220605110063
Kelas : C
Mata Kuliah : Kalkulus
Dosen Pengampuh : Prof. Dr. Suhartono, M.Kom
Jurusan : Teknik Informatika
Lembaga : Universitas Islam Negeri Maulana Malik Ibrahim Malang
Latihan soal turunan!!
findiff <- function(f, x, h, method=NULL){
if(is.null(method)){
warning("please select a method")
}else{
if(method == "forward"){
return((f(x+h)-f(x))/h)
}else if(method=="backward"){
return((f(x)-f(x-h))/h)
}else if(method=="central"){
return((f(x+h)-f(x-h))/(2*h))
}else{
warning("you can use method: forward, bacward, or central")
}
}
}
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
findiff(function(x)
3*(x^8) + 5*(x^6) + x*4-x + 11, x=3, h=0.05,
method="central")
## [1] 59889.84
findiff(function(x)
3*(x^4) + 2*(x^2) + x , x=4, h=0.05,
method="central")
## [1] 785.12
findiff(function(x)
3*x + 3*(x^2) + x , x=3, h=0.05,
method="central")
## [1] 22
findiff(function(x)
3*(x^4) + 2*(x^2) + x , x=1, h=0.05,
method="central")
## [1] 17.03
Sumber Referensi:
https://rstudio-pubs-static.s3.amazonaws.com/817659_0a6a882d74da454c9117279b65d95d77.html
https://bookdown.org/moh_rosidi2610/Metode_Numerik/diffinteg.html#diffother