Derivatives

Question 1

f = expression(1-exp(-Lambda*x))
D(f, 'x')
## exp(-Lambda * x) * Lambda

Question 2

f = expression((x-a)/(b-a))
D(f, 'x')
## 1/(b - a)

Question 3

f = expression(((x-a)^2)/((b-a)*(c-a)))
D(f, 'x')
## 2 * (x - a)/((b - a) * (c - a))

Question 4

f = expression(1 - ((b-x)^2/((b-a)*(c-a))))
D(f, 'x')
## 2 * (b - x)/((b - a) * (c - a))

Integrals

Question 5

func <- function(x)
{
  3*(x^3)
}
integrate(func, 0,10)
## 7500 with absolute error < 8.3e-11

Question 6

#???

Question 7

#???

Question 8

#???

Linear Algebra

Question 9

m <- matrix(c(1,3,4,2,3,6,3,1,8),3,3)
i <- diag(c(1,1,1))
a <- cbind(m,i)
a
##      [,1] [,2] [,3] [,4] [,5] [,6]
## [1,]    1    2    3    1    0    0
## [2,]    3    3    1    0    1    0
## [3,]    4    6    8    0    0    1
#Row Reduction

#Pivot Operation: -3R1 + R2 -> R2
a[2,] <- -3*a[1,]+a[2,]
a
##      [,1] [,2] [,3] [,4] [,5] [,6]
## [1,]    1    2    3    1    0    0
## [2,]    0   -3   -8   -3    1    0
## [3,]    4    6    8    0    0    1
#Pivot Operation: -4R1 + R3 -> R3
a[3,] <- -4*a[1,]+a[3,]
a
##      [,1] [,2] [,3] [,4] [,5] [,6]
## [1,]    1    2    3    1    0    0
## [2,]    0   -3   -8   -3    1    0
## [3,]    0   -2   -4   -4    0    1
#Pivot Operation: R3 + R1 -> R1
a[1,] <- a[3,]+a[1,]
a
##      [,1] [,2] [,3] [,4] [,5] [,6]
## [1,]    1    0   -1   -3    0    1
## [2,]    0   -3   -8   -3    1    0
## [3,]    0   -2   -4   -4    0    1
#Pivot Operation: -2R3 + R2 -> R2
a[2,] <- -2*a[3,]+a[2,]
a
##      [,1] [,2] [,3] [,4] [,5] [,6]
## [1,]    1    0   -1   -3    0    1
## [2,]    0    1    0    5    1   -2
## [3,]    0   -2   -4   -4    0    1
#Scale Operation: -(1/4)R3  -> R3
a[3,] <- (-1/4)*a[3,]
a
##      [,1] [,2] [,3] [,4] [,5]  [,6]
## [1,]    1  0.0   -1   -3    0  1.00
## [2,]    0  1.0    0    5    1 -2.00
## [3,]    0  0.5    1    1    0 -0.25
#Pivot Operation: (-1/2)R2 + R3 -> R3
a[3,] <- (-1/2)*a[2,]+a[3,]
a
##      [,1] [,2] [,3] [,4] [,5]  [,6]
## [1,]    1    0   -1 -3.0  0.0  1.00
## [2,]    0    1    0  5.0  1.0 -2.00
## [3,]    0    0    1 -1.5 -0.5  0.75
#Pivot Operation: R3 + R1 -> R1
a[1,] <- a[3,]+a[1,]
a
##      [,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
#Inverse of Matrix m
a[,4:6]
##      [,1] [,2]  [,3]
## [1,] -4.5 -0.5  1.75
## [2,]  5.0  1.0 -2.00
## [3,] -1.5 -0.5  0.75

Question 10

m <- matrix(c(1,3,4,2,3,6,3,1,8),3,3)
det(m)
## [1] -4

Question 11

U <- m
m
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    3    3    1
## [3,]    4    6    8
#Determine Upper Matrix

#Pivot Operation: 3R1-R2 -> R2
U[2,] = 3*U[1,]-U[2,]
L21 = -3

#Pivot Operation: 4R1 - R3 -> R3
U[3,] = 4*U[1,]-U[3,]
L31 = -4

#Pivot Operation: (2/3)*R2 - R3 -> R3
U[3,] = (2/3)*U[2,] - U[3,]
L32 = -2/3


U #Upper Matrix U
##      [,1] [,2]     [,3]
## [1,]    1    2 3.000000
## [2,]    0    3 8.000000
## [3,]    0    0 1.333333
L <- matrix(c(1,L21,L31,0,1,L32,0,0,1),3,3)
L # Lower Matrix L
##      [,1]       [,2] [,3]
## [1,]    1  0.0000000    0
## [2,]   -3  1.0000000    0
## [3,]   -4 -0.6666667    1

Question 12

m %*% a[, 4:6]
##      [,1] [,2] [,3]
## [1,]    1    0    0
## [2,]    0    1    0
## [3,]    0    0    1