#install.packages("mosaic",repos = "http://cran.us.r-project.org")
#library(mosaic)
install.packages("mosaicCalc",repos = "http://cran.us.r-project.org")## package 'mosaicCalc' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\Debabrata\AppData\Local\Temp\RtmpQbn5X6\downloaded_packages
library(mosaicCalc)## Loading required package: mosaicCore
##
## Attaching package: 'mosaicCalc'
## The following object is masked from 'package:stats':
##
## D
Find the derivatives with the respect to x of the following.
f(x)=1−(e(−λx))
F(x)=f’(x)=df(x)/dx=d(1−(e(−λx)))/dx=d1/dx-d(e(−λx))/dx= 0 - ((-λdx/dx)e(−λx) = λe(−λx)
fx <- function(x){1-e^-(lambda*x)}
#Deriv(fx)
Fx <- D((1-e^-(l*x))~x)
Fx## function (x, e, l)
## e^-(l * x) * (log(e) * l)
fx=(x−a)/(b−a)
F(x)=f’(x)=df(x)/dx=d((x−a)/(b−a))/dx=(1/(b-a))d(x-a)/dx=1/(b-a)
Fx <- D(((x−a)/(b−a))~x)
Fx## function (x, a, b)
## 1/(b - a)
fx=(x−a)2/((b−a)(c-a))
F(x)=f’(x)=df(x)/dx = d((x−a)2/((b−a)(c-a)))/dx = (1/((b−a)(c-a)))d((x-a)2)/dx = (1/((b−a)(c-a)))*2(x-a)
Fx <- D(((x−a)^2)/((b−a)*(c−a))~x)
Fx## function (x, a, b, c)
## 2 * (x - a)/((b - a) * (c - a))
fx=1−((b−x)2/((b−a)(c−a)))
F(x)=f’(x)=df(x)/dx=d(1−((b−x)2/((b−a)(c−a))))/dx=d1/dx - (1/((b−a)(c-a)))d((b-x)2) = 0 - (2(b-x)/((b−a)(c−a)))d(b-x)/dx = (2(b-x)/((b−a)(c−a)))
Fx <- D(1−((b−x)^2/((b−a)*(c−a)))~x)
Fx## function (x, b, a, c)
## 2 * (b - x)/((b - a) * (c - a))
0∫103x3dx = 30∫10x3dx = 3x(3+1)/(3+1) = 3x4/4 + C = 3*104/4 = 7500
integration <- antiD(3*x^3~x, x=10)
integration## function (x = 10, C = 0)
## 3/4 * x^4 + C
integration()## [1] 7500
integration <- antiD(lambda*x*e^-(lambda*x)~x)
integration## function (x, lambda, e, C = 0)
## {
## numerical_integration(.newf, .wrt, as.list(match.call())[-1],
## formals(), from, ciName = intC, .tol)
## }
## <environment: 0x000000002a471450>
0∫0.51/(b−a)dx = x/(b-a) = 0.5/(b-a)
integration <- antiD((1/(b-a))~x,x=0.5)
integration## function (x = 0.5, C = 0, b, a)
## (1/(b - a)) * x + C
integration <- antiD(x*(1/(Γ(α)*B^α))*x^(α−1)*e^(−Bx)~x)
integration## function (x, a, B, e, Bx, C = 0)
## {
## numerical_integration(.newf, .wrt, as.list(match.call())[-1],
## formals(), from, ciName = intC, .tol)
## }
## <environment: 0x000000002aa0fd90>
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
I = matrix(c(1,0,0,0,1,0,0,0,1),3,3)
print(I)## [,1] [,2] [,3]
## [1,] 1 0 0
## [2,] 0 1 0
## [3,] 0 0 1
XI <- cbind(X,I)
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,]
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,]
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,]
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,]
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,]
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
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,]
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,]
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
XI[2,] <- XI[2,] * (-1)
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
Xi=XI[1:3,4:6]
print(Xi)## [,1] [,2] [,3]
## [1,] -4.5 -0.5 1.75
## [2,] 5.0 1.0 -2.00
## [3,] -1.5 -0.5 0.75
solve(X)## [,1] [,2] [,3]
## [1,] -4.5 -0.5 1.75
## [2,] 5.0 1.0 -2.00
## [3,] -1.5 -0.5 0.75
Xd=(X[1,1]*(X[2,2]*X[3,3]-X[2,3]*X[3,2]))+(X[1,2]*(X[2,3]*X[3,1]-X[2,1]*X[3,3]))+(X[1,3]*(X[2,1]*X[3,2]-X[2,2]*X[3,1]))
print(Xd)## [1] -4
det(X)## [1] -4
U=X
print(U)## [,1] [,2] [,3]
## [1,] 1 2 3
## [2,] 3 3 1
## [3,] 4 6 8
#U[2,] <- -(U[2,1]/U[1,1])*U[1,] + U[2,]
U[2,] <- -3*U[1,] + U[2,]
print(U)## [,1] [,2] [,3]
## [1,] 1 2 3
## [2,] 0 -3 -8
## [3,] 4 6 8
#U[3,] <- -(U[3,1]/U[1,1])*U[1,] + U[3,]
U[3,] <- -4*U[1,] + U[3,]
print(U)## [,1] [,2] [,3]
## [1,] 1 2 3
## [2,] 0 -3 -8
## [3,] 0 -2 -4
#U[3,] <- -(U[3,2]/U[2,2])*U[2,] + U[3,]
U[3,] <- -(2/3)*U[2,] + U[3,]
print(U)## [,1] [,2] [,3]
## [1,] 1 2 3.000000
## [2,] 0 -3 -8.000000
## [3,] 0 0 1.333333
L=round(X%*%solve(U),2) # LU=X, hence L=X(Ui)
print(L)## [,1] [,2] [,3]
## [1,] 1 0.00 0
## [2,] 3 1.00 0
## [3,] 4 0.67 1
I=X%*%Xi
print(I)## [,1] [,2] [,3]
## [1,] 1 0 0
## [2,] 0 1 0
## [3,] 0 0 1