Use R to graph a function with the plot() command.

# Create a simple x range
x <- seq(-5, 5, 0.1)

# Define the function y = x^2
y = x^2

# Plot using base R
plot(x, y, type = "l", col = "blue", lwd = 2,
     main = "Graph of y = x^2",
     xlab = "x", ylab = "y")
# Add another vertical line through x = -3
abline(v = -3, col = "red", lty = 2, lwd = 2)

We say that a \(f:X\to Y\) is a function if for every \(x \in X\) there exists a UNIQUE \(y \in Y\) such that \(f(x)=y)\). The vertical line test says: If any vertical line crosses the graph more than once, it’s not a function.”

# Circle equation: x^2 + y^2 = 25
theta <- seq(0, 2*pi, 0.01)
x_circ <- 5*cos(theta)
y_circ <- 5*sin(theta)

plot(x_circ, y_circ, type = "l", col = "blue", lwd = 2,
     asp = 1, main = "Graph of x^2 + y^2 = 25",
     xlab = "x", ylab = "y")

# Add vertical line at x = 3
abline(v = 3, col = "red", lty = 2, lwd = 2)