Find the derivatives with the respect to x of the following

  1. \[F(x\mid x \ge 0)=1-e^{-\lambda x}\]

\[\implies \frac{d}{dx}*1 - \frac {d}{dx}(-e^{-\lambda x})\] \[\implies \frac{d}{dx}*1 - \frac {d}{dx}(-e^{-\lambda x}) \implies 0 - \frac {d}{dx}(-e^{-\lambda x})\] \[\implies - (-\lambda\frac {d}{dx}x)*e^{-\lambda x} = \lambda e^{-\lambda x}\] \[\implies F(x\mid x \ge 0)=1-e^{-\lambda x} = \lambda e^{-\lambda x}\]

f1 <- D(1-e^{-(lambda * x)}~x, x=10)
print(f1)
## function (x = 10, e, lambda) 
## numerical.first.partial(.function, .wrt, .hstep, match.call())
## <environment: 0x0000000020c642c0>
  1. \[F(x\mid b>a)= \frac {x-a}{b-a}\] \[= \frac{d}{dx}(\frac {x-a}{b-a}) = \frac{1}{b-a}\frac{d}{dx}{x-a} = \frac{1}{b-a}(\frac{d}{dx}x - \frac{d}{dx}a)\]

\[\implies F(x\mid b>a)= \frac {x-a}{b-a} = \frac{1}{b-a}\]

f2 <- D((x-a)/(b-a)~x, x=0)
print(f2)
## function (x = 0, a, b) 
## 1/(b - a)
  1. \[F(x|a<x \le c \le b)=\frac {(x-a)^2}{(b-a)(c-a)}\]

\[ =\frac {1}{(b-a)(c-a)} * \frac {d}{dx}((x-a)^2)\]

\[u = (x-a), \implies \frac {1}{(b-a)(c-a)} * \frac {d}{du}u^2 * \frac {d}{dx}(x-a)\]

\[ = \frac {1}{(b-a)(c-a)} * 2u * 1\]

\[ = \frac {2(x-a)}{(b-a)(c-a)}\]

f3 <- D((x-a)^2/(b-a)*(c-a)~x, x=0)
print(f3)
## function (x = 0, a, b, c) 
## 2 * (x - a)/(b - a) * (c - a)
  1. \[ F(x|a \le c<x<b)=1-\frac {(b-x)^2}{(b-a)(c-a)}\]

\[u = (b-x), \implies \frac {d}{dx} * 1- \frac {1}{(b-a)(c-a)} * \frac {d}{du}u^2 - \frac {d}{dx}(b-x)\] \[\implies 0 - \frac {1}{(b-a)(c-a)} * 2*(b-x) - (-1)\]

\[ = \frac {2(b-x)}{(b-a)(c-a)}\]

f4 <- D((b-x)^2/(b-a)*(c-a)~x, x=0)
print(f4)
## function (x = 0, b, a, c) 
## -(2 * (b - x)/(b - a) * (c - a))

Solve the following definite and indefinite integrals

  1. \[\int_0^{10}3x^3dx\]

\[ = 3\int_0^{10}x^3dx = 3\frac{x^{3+1}}{3+1}\]

\[ = 3\frac{x^{4}}{4} + C\] \[ \lim_{x \to 0} 3\frac{0^{4}}{4} = 0\] \[ \lim_{x \to 10} 3\frac{10^{4}}{4} = 7500\]

f5 <- antiD(3*x^3~x, x=10)
print(f5)
## function (x = 10, C = 0) 
## 3/4 * x^4 + C
print(f5())
## [1] 7500
  1. \[\int \lambda xe^{-\lambda x}dx\]

\[\implies u = -\lambda x; \space \space \lambda\int \frac {xe^u}{\lambda^2}udu = \frac {\lambda}{\lambda ^2} \int xe^{u}udu; \space \space let \int e^udu = e^u \implies\] \[ \frac {\lambda}{\lambda ^2} (e^uu - e^u) = \frac {\lambda}{\lambda ^2} (e^{-\lambda x}(-\lambda x) - e^{-\lambda x})\] \[ = \frac {\lambda}{\lambda ^2} (-\lambda e^{-\lambda x}x - e^{-\lambda x}) + C\]

f6 <- antiD(lambda * x * e^{- (lambda * x)}~x)
print(f6)
## function (x, lambda, e, C = 0) 
## {
##     numerical_integration(.newf, .wrt, as.list(match.call())[-1], 
##         formals(), from, ciName = intC, .tol)
## }
## <environment: 0x00000000226493d8>
  1. \[\int_0^{.5}\frac{1}{b-a}dx\]

\[\implies\int_0^{.5}\frac{1}{b-a}dx =\frac{x}{b-a} + C \implies\] \[\lim_{x \to 0}\frac{0}{b-a} = 0,\] \[lim_{x \to 0.5}\frac{0.5}{b-a} = \frac{0.5}{b-a}\]

f7 <- antiD((1/(b-a))~x, x=.5)
print(f7)
## function (x = 0.5, C = 0, b, a) 
## (1/(b - a)) * x + C
  1. \[ \int_0^{x}x \frac {1}{\Gamma(\alpha)\beta^\alpha}x^{\alpha - 1}e^{- \beta x}\]

With the following matrix,

X <- matrix(c(1,3,4,2,3,6,3,1,8), 3, 3)
print(X)
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    3    3    1
## [3,]    4    6    8
  1. Invert it using Gaussian row reduction.
XI <- cbind(X, diag(3))
print(XI)
##      [,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
(XI[2,] <- XI[2,] - 3*XI[1,])
## [1]  0 -3 -8 -3  1  0
print("R2 = R2 - 3R1")
## [1] "R2 = R2 - 3R1"
print(XI)
##      [,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
(XI[3,] <- XI[3,] - 4*XI[1,])
## [1]  0 -2 -4 -4  0  1
print("R3 = R3 - 4R1")
## [1] "R3 = R3 - 4R1"
print(XI)
##      [,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
(XI[2,] <- XI[2,] - XI[3,])
## [1]  0 -1 -4  1  1 -1
print("R2 = R2 - R3")
## [1] "R2 = R2 - R3"
print(XI)
##      [,1] [,2] [,3] [,4] [,5] [,6]
## [1,]    1    2    3    1    0    0
## [2,]    0   -1   -4    1    1   -1
## [3,]    0   -2   -4   -4    0    1
(XI[3,] <- XI[3,] - 2*XI[2,])
## [1]  0  0  4 -6 -2  3
print("R3 = R3 - 2R2")
## [1] "R3 = R3 - 2R2"
print(XI)
##      [,1] [,2] [,3] [,4] [,5] [,6]
## [1,]    1    2    3    1    0    0
## [2,]    0   -1   -4    1    1   -1
## [3,]    0    0    4   -6   -2    3
(XI[2,] <- XI[2,] + XI[3,])
## [1]  0 -1  0 -5 -1  2
print("R2 = R2 + R3")
## [1] "R2 = R2 + R3"
print(XI)
##      [,1] [,2] [,3] [,4] [,5] [,6]
## [1,]    1    2    3    1    0    0
## [2,]    0   -1    0   -5   -1    2
## [3,]    0    0    4   -6   -2    3
(XI[3,] <- XI[3,] / 4)
## [1]  0.00  0.00  1.00 -1.50 -0.50  0.75
print("R3 = R3 / 4")
## [1] "R3 = R3 / 4"
print(XI)
##      [,1] [,2] [,3] [,4] [,5] [,6]
## [1,]    1    2    3  1.0  0.0 0.00
## [2,]    0   -1    0 -5.0 -1.0 2.00
## [3,]    0    0    1 -1.5 -0.5 0.75
(XI[1,] <- XI[1,] - 3*XI[3,])
## [1]  1.00  2.00  0.00  5.50  1.50 -2.25
print("R1 = R1 - 3R3")
## [1] "R1 = R1 - 3R3"
print(XI)
##      [,1] [,2] [,3] [,4] [,5]  [,6]
## [1,]    1    2    0  5.5  1.5 -2.25
## [2,]    0   -1    0 -5.0 -1.0  2.00
## [3,]    0    0    1 -1.5 -0.5  0.75
(XI[2,] <- XI[2,] * (-1))
## [1]  0  1  0  5  1 -2
print("R2 = R2 * -1")
## [1] "R2 = R2 * -1"
print(XI)
##      [,1] [,2] [,3] [,4] [,5]  [,6]
## [1,]    1    2    0  5.5  1.5 -2.25
## [2,]    0    1    0  5.0  1.0 -2.00
## [3,]    0    0    1 -1.5 -0.5  0.75
(XI[1,] <- XI[1,] - 2*XI[2,])
## [1]  1.00  0.00  0.00 -4.50 -0.50  1.75
print("R1 = R1 - 2R2")
## [1] "R1 = R1 - 2R2"
print(XI)
##      [,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
  1. Find the determinant.
D <- X
(D[3,] <- D[3,]/2)
## [1] 2 3 4
print("row3 = row3/2")
## [1] "row3 = row3/2"
print(XI)
##      [,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
(D[3,] <- D[3,] - D[1,])
## [1] 1 1 1
print("row3 = row3 - row1")
## [1] "row3 = row3 - row1"
print(D)
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    3    3    1
## [3,]    1    1    1
(D[2,] <- D[2,] - D[1,])
## [1]  2  1 -2
print("row2 = row2 - row1")
## [1] "row2 = row2 - row1"
print(D)
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    2    1   -2
## [3,]    1    1    1
(D[2,] <- D[2,] - 2*D[3,])
## [1]  0 -1 -4
print("row2 = row2 - 2 * row3")
## [1] "row2 = row2 - 2 * row3"
print(D)
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    0   -1   -4
## [3,]    1    1    1
(D[3,] <- D[1,] - D[3,])
## [1] 0 1 2
print("row3 = row1 - row3")
## [1] "row3 = row1 - row3"
print(D)
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    0   -1   -4
## [3,]    0    1    2
(D[3,] <- D[3,] + D[2,])
## [1]  0  0 -2
print("row3 = row3 + row2")
## [1] "row3 = row3 + row2"
print(D)
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    0   -1   -4
## [3,]    0    0   -2
detD <- D[1,1] * D[2,2] * D[3, 3]
paste("The determinant is: ", detD)
## [1] "The determinant is:  2"
  1. Conduct LU decomposition

Let’s find the Upper triangular matrix first. Then the Lower triangular matrix will be made up of 1’s at the diagonal, the multiplication coefficients used to find the upper triangular matrix, and 0’s every other places

 XU <- X

 (XU[2,] <- XU[2,] - 3*XU[1,])
## [1]  0 -3 -8
 print("row2 = row2 - 3 * row1")
## [1] "row2 = row2 - 3 * row1"
 print(XU)
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    0   -3   -8
## [3,]    4    6    8
 (XU[3,] <- XU[3,] - 4*XU[1,])
## [1]  0 -2 -4
 print("row3 = row3 - 4 * row1")
## [1] "row3 = row3 - 4 * row1"
 print(XU)
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    0   -3   -8
## [3,]    0   -2   -4
 (XU[3,] <- XU[3,] - 2/3*XU[2,])
## [1] 0.000000 0.000000 1.333333
 print("row3 = row3 - 2/3 * row2")
## [1] "row3 = row3 - 2/3 * row2"
 print(XU)
##      [,1] [,2]      [,3]
## [1,]    1    2  3.000000
## [2,]    0   -3 -8.000000
## [3,]    0    0  1.333333

Therefore, the upper triangular matrix is U =

print(XU)
##      [,1] [,2]      [,3]
## [1,]    1    2  3.000000
## [2,]    0   -3 -8.000000
## [3,]    0    0  1.333333

While L =

L <- matrix(c(1,3,4,0,1,2/3,0,0,1), 3,3)
print(L)
##      [,1]      [,2] [,3]
## [1,]    1 0.0000000    0
## [2,]    3 1.0000000    0
## [3,]    4 0.6666667    1
  1. Multiply the matrix by it’s inverse

The inverse of the matrix is the set of numbers at the right side of the result gotten after inverting matrix X in question 9 as shown below

 [,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

The inverse is (-4.5, 5.0, -1.5, -0.5, 1.0, -0.5, 1.75, -2.00, 0.75)

Inv <- matrix(c(-4.5, 5.0, -1.5, -0.5, 1.0, -0.5, 1.75, -2.00, 0.75), 3,3)
print(Inv)
##      [,1] [,2]  [,3]
## [1,] -4.5 -0.5  1.75
## [2,]  5.0  1.0 -2.00
## [3,] -1.5 -0.5  0.75

Matrix multiplied by its inverse will therefore be X*Inv

XInv <- X * Inv
print ("X multiplied by its inverse: ")
## [1] "X multiplied by its inverse: "
print(XInv)
##      [,1] [,2]  [,3]
## [1,] -4.5   -1  5.25
## [2,] 15.0    3 -2.00
## [3,] -6.0   -3  6.00