Derivatives
library(Deriv)
myf1<-function(x){
(1-exp(-lambda*x))
}
hw1<-Deriv(myf1)
hw1
## function (x)
## lambda * exp(-(lambda * x))
myf2 <- function(x){
(x-a)/(b-a)
}
hw2<-Deriv(myf2)
hw2
## function (x)
## 1/(b - a)
myf3 <- function(x){
(x-a)^2/((b-a)*(c-a))
}
hw3<-Deriv(myf3)
hw3
## function (x)
## 2 * ((x - a)/((b - a) * (c - a)))
myf4 <- function(x){
1 - (b-x)^2/((b-a)*(c-a))
}
hw4<-Deriv(myf4)
hw4
## function (x)
## 2 * ((b - x)/((b - a) * (c - a)))
library(mosaicCalc)
## Loading required package: mosaicCore
##
## Attaching package: 'mosaicCalc'
## The following object is masked from 'package:stats':
##
## D
hw5<- antiD(3*x^3~x,x=10)
hw5
## function (x = 10, C = 0)
## 3/4 * x^4 + C
hw5()
## [1] 7500
library(mosaicCalc)
hw6<-antiD(x*lambda*(exp(-lambda*x))~x)
hw6
## function (x, lambda, C = 0)
## {
## numerical_integration(.newf, .wrt, as.list(match.call())[-1],
## formals(), from, ciName = intC, .tol)
## }
## <environment: 0x000000001b2018a0>
library(mosaicCalc)
hw7 <- antiD((1/(b-a))~x, x=.5)
hw7
## function (x = 0.5, C = 0, b, a)
## (1/(b - a)) * x + C
With the following matrix,
A=matrix(c(1,3,4,2,3,6,3,1,8),3,3)
AB <- cbind(A, diag(3))
AB[2,] <- AB[2,] - 3*AB[1,]
AB[3,] <- AB[3,] - 4 * AB[1,]
AB[2,] <- -1 * AB[2,] + AB[3,]
AB[3,] <- 2 * AB[2,] + AB[3,]
AB[3, ] <- AB[3,]/4
AB[1,] <- AB[1, ] - 2 * AB[2,]
AB[2, ] <- AB[2, ] - 4 * AB[3,]
AB[1, ] <- AB[1, ] + 5 * AB[3,]
AB
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 1 0 0 -4.5 -0.5 1.75
## [2,] 0 1 0 5.0 1.0 -2.00
## [3,] 0 0 1 -1.5 -0.5 0.75
det(A)
## [1] -4
library(matrixcalc)
A=matrix(c(1,3,4,2,3,6,3,1,8),3,3)
lu.decomposition(A)
## $L
## [,1] [,2] [,3]
## [1,] 1 0.0000000 0
## [2,] 3 1.0000000 0
## [3,] 4 0.6666667 1
##
## $U
## [,1] [,2] [,3]
## [1,] 1 2 3.000000
## [2,] 0 -3 -8.000000
## [3,] 0 0 1.333333
hw12<-A %*% solve(A)
hw12
## [,1] [,2] [,3]
## [1,] 1.000000e+00 -2.220446e-16 4.440892e-16
## [2,] -4.440892e-16 1.000000e+00 2.220446e-16
## [3,] 0.000000e+00 0.000000e+00 1.000000e+00