Discussion Prompt

Discussion Solution

Problem 12.1.7

Give the domain and range of the multivariable function.

\[f(x,~y)= x^2+y^2 + 2\]

Solution:

The domain of f(x, y) is all (real) values of x and y. The range of f(x, y) is all values greater than or equal to 2. The smallest that the function can be is when both x and y are 0, meaning that the total value will be 2. And as both x and y are being squared in the function, there is no possibility that f(x, y) can be negative.

Below is a histogram showing the results from pulling random numbers for both x and y in between -1000 and 1000. As one can see, the value is always above 2.

f<-function(x,y){x^2 +y^2 + 2}

x<-runif(10000,-1000,1000)
y<-runif(10000,-1000,1000)
result<-f(x,y)

#histogram
hist(result, breaks = 100)

#min result
min(result)
## [1] 84.02945

Here is a more interesting way to look at the function results. Using sequences of values between -100 and 100 for both x and y and calculating the result for each combination, we can see that the minimum value is 2, and we can how the color changes. The light color indicates very high or very low values for both x and y, while the dark indicates numbers around 0 for both x and y.

data2<-c()
for(i in seq(-100,100, by=1)){
  y2<-seq(-100,100, by=1)
  result2<-result<-f(i,y2)
  temp<-cbind(rep(i,201),y2,result)
  data2<-rbind(data2,temp)
}

data2<-data.frame(data2, stringsAsFactors = FALSE)
names(data2)<-c("x2","y2","result2")

library(ggplot2)
qplot(x2,y2, color=result2, data=data2)

#min result2
min(data2$result2)
## [1] 2

Most Valuable Elements in the Course

My answer to the question, “What were the most valuable elements you took away from this course?” would be:

  • A refresher of math that I have not done in many years
  • An overview of the foundations of mathematics behind data science (i.e., linear algebra, statistics, and calculus)
  • Exposure to parts of math that I have not really done before but I know are important for data science (e.g., eigenvalues)