Setelah mengetahui materi tentang diferensiasi (turunan) dan juga cara penyelesainnya menggunakan beberapa metode yang dibahas di artikel sebelumnya. Kemudian, solusi penyelesaian diferensiasi (turunan) dengan metode titik pusat menggunakan Fungsidiff() di R Studio. Sekarang, kita juga akan menyelesaikan diferensiasi (turunan) dengan metode lain, yaitu menggunakan Fungsi findiff() Berikut penjelasannya.
Soal - soal disajikan di sini diambil dari buku berjudul Memahami Kalkulus Dasar MenggunakanSoal diambil dari hal 58.
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")
}
}
}
findiff(function(x){ 3*(x^8) - 5*(x^6) + x^4 - x + 11}, x=1,
h=1*.Machine$double.eps^(1/3),
method="central")
## [1] -3
Soal diambil dari hal 59.
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")
}
}
}
findiff(function(x){ 3*(x^4) + 2*(x^2) + x}, x=3,
h=1*.Machine$double.eps^(1/3),
method="central")
## [1] 337
Soal diambil dari hal 59.
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")
}
}
}
findiff(function(x){ x^3 + 3*(x^2)}, x=3,
h=1*.Machine$double.eps^(1/3),
method="central")
## [1] 45
Soal diambil dari hal 59.
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")
}
}
}
findiff(function(x){ 3*(x^2) + 2*x + 4}, x=2,
h=1*.Machine$double.eps^(1/3),
method="central")
## [1] 14
Soal diambil dari hal 61.
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")
}
}
}
findiff(function(x){ 3*(x^4) + 2*(x^2) + x}, x=4,
h=1*.Machine$double.eps^(1/3),
method="central")
## [1] 785
Demikian, contoh penyelesaian persamaan diferensiasi (turunan) dengan menggunakan Fungsi findiff() ** di R Studio