The following problems were given to Tennessee State University (TSU) Freshman Engineering Seminar students in the Fall 2015 semester.

Note: If you wish to replicate the R code below, then you will need to copy and paste the following commands in R first (to make sure you have all the packages and their dependencies):

install.packages("install.load")

# install and/or load the packages and their dependencies, this does not require extra system dependencies (this process may take a while depending on the number of dependencies)

# if you have Java, Jython, Python, Sympy, Numpy, Yacas, etc. installed on your system, then you can use the code below:
# install and/or load the packages and their dependencies, including the extra system dependencies (this process may take a while depending on the number of dependencies)

install.packages("import") # install the import package

import::from(pracma, roots, fzero) # import ode45 from the pracma package

This document was created with rmarkdown 1.2 using the following:

• R 3.3.2 (2016-10-31)
• htmlTable 1.7
• signal 0.7-6
• mosaic 0.14.4
• iemisc 0.9.7
• DescTools 0.99.18
• prob 0.9-5
• Deriv 3.8.0
• import 1.1.0
• pracma 1.9.5
• rSymPy 0.2-1.1
• Ryacas 0.3-1

# 1) $$\int~x^2 + 2x - 2 x~dx$$

Solved using the mosaic package:

library(mosaic)

antiD(x^2 + 2 * x - 2 ~ x)
## function (x, C = 0)
## 1/3 * x^3 + 1 * x^2 - 2 * x + C

Solved using the Ryacas package:

library(Ryacas)  # requires yacas

x <- Sym("x")

Integrate(x^2 + 2 * x - 2, x)
## expression(x^3/3 + x^2 - 2 * x)

Solved using the rSymPy package:

library(rSymPy) # requires Java, Jython, Python

x <- Var("x")

sympy("integrate(x**2 + 2*x - 2, x)")

[1] "-2*x + x**2 + x**3/3"

# 2) $$\frac{d}{dx}~x + 2x - 2$$

The following solution is using base R only:

simp.exp <- expression(x^2 + 2 * x - 2)

(D.sc <- D(simp.exp, "x"))
## 2 * x + 2

Solved using the Deriv package:

library(Deriv)

f <- function(x) x^2 + 2 * x - 2

Deriv(f)
## function (x)
## 2 + 2 * x

Solved using the mosaic package:

library(mosaic)

D(x^2 + 2 * x - 2 ~ x)
## function (x)
## 2 * x + 2

Solved using the Ryacas package:

library(Ryacas)  # requires yacas

x <- Sym("x")

deriv(x^2 + 2 * x - 2, x)
## expression(2 * x + 2)

Solved using the rSymPy package:

library(rSymPy) # requires Java, Jython, Python

x <- Var("x")

sympy("diff(x**2+2*x-2, x, 1)")

[1] "2 + 2*x"

# 3) If x = 5, then what is $$x^2 + 2x - 2$$?

x <- 5

x^2 + 2 * x - 2
## [1] 33

# 4) 5, 2, 4, 6, 9.2, 10.0, 100, 7, 2

1. What is the mean of the above data set?
mean(c(5, 2, 4, 6, 9.2, 10, 100, 7, 2))
## [1] 16.13333

1. What is the median of the above data set?
require(stats)

median(c(5, 2, 4, 6, 9.2, 10, 100, 7, 2))
## [1] 6

1. What is the mode of the above data set?
library(DescTools)

Mode(c(5, 2, 4, 6, 9.2, 10, 100, 7, 2))
## [1] 2

# 5) If you have a standard 54 card deck, what is the probability that you will pick any card from the Hearts suite?

# The Jokers are included

library(prob)

cds <- cards(jokers = TRUE, makespace = TRUE)  # include the probability column in the
# cards function and create a data.frame called cds of the cards function

Heart <- subset(cds, suit == "Heart")  # subset cds with only the Heart suit

Heartprob <- Prob(Heart)  # Calculates the probability

Heartprob
## [1] 0.2407407

or

# The Jokers are not included

library(prob)

cds <- cards(makespace = TRUE)  # include the probability column in the cards function and
# create a data.frame called cds of the cards function

Heart <- subset(cds, suit == "Heart")  # subset cds with only the Heart suit

Heartprob <- Prob(Heart)  # Calculates the probability

Heartprob
## [1] 0.25

# 6) What is the angle between force F and the x-axis, where F = 30i + 50j - 20k newtons? (Olia 25)

library(iemisc)

Fx <- 30  # 30i

Fy <- 50  # 50j

Fz <- -20  # -20k

cos_thetax <- Fx/sqrt(Fx^2 + Fy^2 + Fz^2)

theta <- acosd(cos_thetax)  # degrees

theta
## [1] 60.87843

# 7) Solve the equation x(2x - 3) = 5 for x. (Olia 73)

Solved using the signal package:

library(signal)

roots(c(2, -3, -5))
## [1]  2.5 -1.0

Solved using the pracma package:

import::from(pracma, roots)

roots(c(2, -3, -5))
## [1]  2.5 -1.0

Solved using the pracma package:

import::from(pracma, fzero)

fzero(function(x) 2 * x^2 - 3 * x - 5, 2)
## $x ## [1] 2.5 ## ##$fval
## [1] 0

# 8) Solve this system of equations: (Olia 75)

$x - y + z = -3$ $2x + y = 1$ $y - 3z = 7$

a <- matrix(c(1, -1, 1, 2, 1, 0, 0, 1, -3), nrow = 3, ncol = 3, byrow = TRUE)

b <- c(-3, 1, 7)

solve(a, b)
## [1]  0  1 -2

# A segment of a spreadsheet is shown below. Use the numbers in the cells to answer the following questions. (Olia 159-160)

install.load::load_package("data.table", "htmlTable", "iemisc")

spread <- data.table(v1 = c(NA, 1:5), v2 = c("A", "20", "5", "6", "7", "8"),
v3 = c("B", "21", "A2^2", "A3^2", "A4^2", "A5^2"), v4 = c("C", "22", "B2*A$1", "B3*B$1", "B4*C$1", "B5*D$1"), v5 = c("D", "23", "", "", "", ""))

css.cell = "padding-left: 1em; padding-right: 1em;")
 Spreadsheet segment (Olia 159-160) A B C D 1 20 21 22 23 2 5 A2^2 B2*A$1 3 6 A3^2 B3*B$1 4 7 A4^2 B4*C$1 5 8 A5^2 B5*D$1

# 9) What will be the top to bottom values in column B (Olia 159-160)?

A <- c(20, 5, 6, 7, 8)

B <- data.table(B = c(21, A[2]^2, A[3]^2, A[4]^2, A[5]^2))

htmlTable(B, rnames = FALSE, align = "c", align.header = "c", caption = "B column spreadsheet segment (Olia 159-160)")
 B B column spreadsheet segment (Olia 159-160) 21 25 36 49 64
D <- 23

C <- 22

C <- c(22, B[2] * A[1], B[3] * B[1], B[4] * C, B[5] * D)

# 10) What will be the top to bottom values in column C (Olia 159-160)?

A <- c(20, 5, 6, 7, 8)

B <- c(21, A[2]^2, A[3]^2, A[4]^2, A[5]^2)

D <- 23

C <- 22

C <- data.table(C = c(22, B[2] * A[1], B[3] * B[1], B[4] * C, B[5] * D))

htmlTable(C, rnames = FALSE, align = "c", align.header = "c", caption = "C column spreadsheet segment (Olia 159-160)")
 C C column spreadsheet segment (Olia 159-160) 22 500 756 1078 1472

## Works Cited

Masoud Olia, Ph.D., P.E. and Contributing Authors, Barron’s Fundamentals of Engineering Exam, Hauppauge, New York: Barron’s Educational Series, Inc., 2015, pages 25, 73, 75, 159-160.