Loading [MathJax]/jax/output/HTML-CSS/jax.js
  • Linear Algebra
  • Code
  • Conclusion

Linear Algebra

 

Exercise C10

In Example TMP the first table lists the cost (per kilogram) to manufacture each of the three varieties of trail mix (bulk, standard, fancy). For example, it costs $3.69 to make one kilogram of the bult variety. Re-compute each of these three costs and notice that the computations are linear in character.

 

 

Code

 

# Matrix of (kg/batch) Trail Mix
trails <- matrix(c(7, 6, 2, 6, 4, 5, 2, 5, 8), nrow = 3, ncol = 3)
trails
##      [,1] [,2] [,3]
## [1,]    7    6    2
## [2,]    6    4    5
## [3,]    2    5    8

 

# Find Batches (trails divided by 15)
trails_batch <- trails/15
trails_batch
##           [,1]      [,2]      [,3]
## [1,] 0.4666667 0.4000000 0.1333333
## [2,] 0.4000000 0.2666667 0.3333333
## [3,] 0.1333333 0.3333333 0.5333333

 

# Cost of Trail Mix
trails_cost <- matrix(c(3.69, 3.86, 4.45), nrow = 3, ncol = 1)
trails_cost
##      [,1]
## [1,] 3.69
## [2,] 3.86
## [3,] 4.45

 

# Solve to check for linearity
results <- solve(trails_batch, trails_cost)
results
##      [,1]
## [1,] 2.55
## [2,] 4.65
## [3,] 4.80

Conclusion

 

Since the values do not change within the matrix and there’s no other computations being done, if these results were to be plotted then there would be straight lines.