Functions
Show code
rolls <- data.frame(roll = 1:6, double = 2 * (1:6))
levels_shown <- data.frame(
height = c(3, 4, 6),
hits = c(
"preimage is empty",
"preimage contains a roll",
"preimage contains a roll"
)
)
preimage_plot <- ggplot2::ggplot() +
ggplot2::geom_hline(
data = levels_shown,
ggplot2::aes(yintercept = height, linetype = hits),
colour = "#D55E00"
) +
ggplot2::geom_point(
data = rolls,
ggplot2::aes(x = roll, y = double),
size = 3,
colour = "#0072B2"
) +
ggplot2::scale_x_continuous(breaks = 1:6) +
ggplot2::scale_y_continuous(breaks = c(2, 3, 4, 6, 8, 10, 12)) +
ggplot2::scale_linetype_manual(
values = c(
"preimage contains a roll" = "solid",
"preimage is empty" = "dashed"
)
) +
ggplot2::labs(
x = "Input, a (the roll)",
y = "Output, f(a) = 2a",
linetype = NULL
) +
ggplot2::theme_minimal() +
ggplot2::theme(legend.position = "bottom")
if (knitr::is_html_output()) {
htmltools::div(
role = "img",
`aria-label` = fig_alt,
plotly::ggplotly(preimage_plot) |>
plotly::layout(legend = list(orientation = "h", y = -0.2))
)
} else {
preimage_plot
}Show code
graph_points <- data.frame(a = c(-1, 0, 2), value = c(-1, 0, 2)^2)
parabola <- data.frame(a = seq(-1.5, 2.5, length.out = 201))
parabola$value <- parabola$a^2
graph_three_points_plot <- ggplot2::ggplot() +
ggplot2::geom_line(
data = parabola,
ggplot2::aes(x = a, y = value),
colour = "grey80"
) +
ggplot2::geom_point(
data = graph_points,
ggplot2::aes(x = a, y = value, colour = "in the graph"),
size = 3
) +
ggplot2::geom_point(
data = data.frame(a = 1, value = 1),
ggplot2::aes(x = a, y = value, colour = "not in the graph"),
shape = 1,
size = 3,
stroke = 1.2
) +
ggplot2::scale_colour_manual(
values = c("in the graph" = "#0072B2", "not in the graph" = "#D55E00")
) +
ggplot2::scale_x_continuous(breaks = -1:2) +
ggplot2::labs(x = "Input, a", y = "Output, f(a) = a^2", colour = NULL) +
ggplot2::theme_minimal() +
ggplot2::theme(legend.position = "bottom")
if (knitr::is_html_output()) {
htmltools::div(
role = "img",
`aria-label` = fig_alt,
plotly::ggplotly(graph_three_points_plot) |>
plotly::layout(legend = list(orientation = "h", y = -0.2))
)
} else {
graph_three_points_plot
}Show code
rolls <- data.frame(roll = 1:6, double = 2 * (1:6))
doubling_die_plot <- ggplot2::ggplot(rolls) +
ggplot2::aes(x = roll, y = double) +
ggplot2::geom_segment(
ggplot2::aes(xend = 0, yend = double),
linetype = "dotted",
colour = "grey50"
) +
ggplot2::geom_point(
ggplot2::aes(colour = "graph of f"),
size = 3
) +
ggplot2::geom_point(
ggplot2::aes(x = 0, colour = "image of f"),
shape = 15,
size = 3
) +
ggplot2::scale_x_continuous(breaks = 0:6, limits = c(0, 6)) +
ggplot2::scale_y_continuous(breaks = seq(0, 12, 2), limits = c(0, 12)) +
ggplot2::scale_colour_manual(
values = c("graph of f" = "#0072B2", "image of f" = "#D55E00")
) +
ggplot2::labs(
x = "Input, a (the roll)",
y = "Output, f(a) = 2a",
colour = NULL
) +
ggplot2::theme_minimal() +
ggplot2::theme(legend.position = "bottom")
if (knitr::is_html_output()) {
htmltools::div(
role = "img",
`aria-label` = fig_alt,
plotly::ggplotly(doubling_die_plot) |>
plotly::layout(legend = list(orientation = "h", y = -0.2))
)
} else {
doubling_die_plot
}Show code
curve_data <- data.frame(a = seq(-2.5, 2.5, length.out = 201))
curve_data$value <- curve_data$a^2
marked <- data.frame(a = c(-1, 0, 2), value = c(-1, 0, 2)^2)
marked$label <- sprintf("(%d, %d)", marked$a, marked$value)
graph_real_function_plot <- ggplot2::ggplot() +
ggplot2::geom_line(
data = curve_data,
ggplot2::aes(x = a, y = value),
colour = "#0072B2"
) +
ggplot2::geom_point(
data = marked,
ggplot2::aes(x = a, y = value),
size = 3
) +
ggplot2::geom_text(
data = marked,
ggplot2::aes(x = a, y = value, label = label),
nudge_x = 0.35,
nudge_y = 0.4
) +
ggplot2::labs(x = "Input, a", y = "Output, f(a) = a^2") +
ggplot2::theme_minimal()
if (knitr::is_html_output()) {
htmltools::div(
role = "img",
`aria-label` = fig_alt,
plotly::ggplotly(graph_real_function_plot)
)
} else {
graph_real_function_plot
}Show code
x_grid <- seq(-3, 3, length.out = 241)
fg_label <- "f(g(x)) = (x + 1)^2"
gf_label <- "g(f(x)) = x^2 + 1"
compositions <- data.frame(
x = rep(x_grid, 2),
composition = rep(c(fg_label, gf_label), each = length(x_grid)),
value = c((x_grid + 1)^2, x_grid^2 + 1)
)
at_two <- data.frame(
x = 2,
composition = c(fg_label, gf_label),
value = c(9, 5)
)
composition_plot <- ggplot2::ggplot() +
ggplot2::geom_line(
data = compositions,
ggplot2::aes(x = x, y = value, colour = composition)
) +
ggplot2::geom_point(
data = at_two,
ggplot2::aes(x = x, y = value, colour = composition),
size = 3
) +
ggplot2::geom_text(
data = at_two,
ggplot2::aes(x = x, y = value, label = value),
nudge_x = -0.3,
nudge_y = 0.5
) +
ggplot2::scale_colour_manual(values = c("#0072B2", "#D55E00")) +
ggplot2::labs(x = "Input, x", y = "Output, value", colour = NULL) +
ggplot2::theme_minimal() +
ggplot2::theme(legend.position = "bottom")
if (knitr::is_html_output()) {
htmltools::div(
role = "img",
`aria-label` = fig_alt,
plotly::ggplotly(composition_plot) |>
plotly::layout(legend = list(orientation = "h", y = -0.2))
)
} else {
composition_plot
}Show code
x_f <- seq(-2, 4, length.out = 101)
x_inverse <- seq(-3, 9, length.out = 101)
lines_data <- data.frame(
x = c(x_f, x_inverse, x_inverse),
y = c(2 * x_f + 1, (x_inverse - 1) / 2, x_inverse),
curve = rep(
c("f", "inverse of f", "y = x"),
times = c(length(x_f), length(x_inverse), length(x_inverse))
)
)
marked <- data.frame(x = c(3, 7), y = c(7, 3))
labels_data <- data.frame(
x = c(1.2, 7, 7.5),
y = c(5.2, 0.6, 8.2),
label = c("f", "inverse of f", "y = x")
)
inverse_function_plot <- ggplot2::ggplot() +
ggplot2::geom_line(
data = lines_data,
ggplot2::aes(x = x, y = y, colour = curve, linetype = curve)
) +
ggplot2::geom_point(data = marked, ggplot2::aes(x = x, y = y), size = 3) +
ggplot2::geom_text(
data = labels_data,
ggplot2::aes(x = x, y = y, label = label)
) +
ggplot2::coord_fixed(xlim = c(-3, 9), ylim = c(-3, 9)) +
ggplot2::scale_colour_manual(
values = c("f" = "#0072B2", "inverse of f" = "#D55E00", "y = x" = "grey40")
) +
ggplot2::scale_linetype_manual(
values = c("f" = "solid", "inverse of f" = "solid", "y = x" = "dashed")
) +
ggplot2::labs(x = "Input, x", y = "Output, y") +
ggplot2::theme_minimal() +
ggplot2::theme(legend.position = "none")
if (knitr::is_html_output()) {
htmltools::div(
role = "img",
`aria-label` = fig_alt,
plotly::ggplotly(inverse_function_plot)
)
} else {
inverse_function_plot
}Show code
x_square <- seq(-3, 3, length.out = 101)
square_data <- data.frame(x = x_square, y = x_square^2)
marked <- data.frame(x = c(-2, 2), y = c(4, 4))
not_invertible_plot <- ggplot2::ggplot() +
ggplot2::geom_hline(yintercept = 4, colour = "grey40", linetype = "dotted") +
ggplot2::geom_line(
data = square_data,
ggplot2::aes(x = x, y = y),
colour = "#0072B2"
) +
ggplot2::geom_point(data = marked, ggplot2::aes(x = x, y = y), size = 3) +
ggplot2::annotate("text", x = -2.8, y = 4.6, label = "y = 4") +
ggplot2::scale_x_continuous(breaks = -3:3) +
ggplot2::labs(x = "Input, x", y = "Output, h(x) = x^2") +
ggplot2::theme_minimal()
if (knitr::is_html_output()) {
htmltools::div(
role = "img",
`aria-label` = fig_alt,
plotly::ggplotly(not_invertible_plot)
)
} else {
not_invertible_plot
}Show code
n <- 1:10
sequence_labels <- c("a_n = 1/n", "b_n = (-1)^n")
sequences <- data.frame(
n = rep(n, 2),
sequence = factor(
rep(sequence_labels, each = length(n)),
levels = sequence_labels
),
term = c(1 / n, (-1)^n)
)
sequences_plot <- ggplot2::ggplot(sequences) +
ggplot2::aes(x = n, y = term) +
ggplot2::geom_point(size = 2.5, colour = "#0072B2") +
ggplot2::facet_wrap(~sequence, scales = "free_y") +
ggplot2::scale_x_continuous(breaks = n) +
ggplot2::labs(x = "Index, n", y = "Term value") +
ggplot2::theme_minimal()
if (knitr::is_html_output()) {
htmltools::div(
role = "img",
`aria-label` = fig_alt,
plotly::ggplotly(sequences_plot)
)
} else {
sequences_plot
}Show code
# the Greek letter eta, written as a code point to keep this file ASCII
eta_symbol <- intToUtf8(0x3b7)
eta_grid <- seq(-6, 6, length.out = 241)
logistic_curve <- data.frame(eta = eta_grid, sigmoid = plogis(eta_grid))
logistic_points <- data.frame(eta = c(-2, 0, 2), sigmoid = plogis(c(-2, 0, 2)))
logistic_points$label <- sprintf("%.3f", logistic_points$sigmoid)
logistic_function_plot <- ggplot2::ggplot() +
ggplot2::geom_hline(
yintercept = c(0, 1),
linetype = "dotted",
colour = "grey50"
) +
ggplot2::geom_line(
data = logistic_curve,
ggplot2::aes(x = eta, y = sigmoid),
colour = "#0072B2"
) +
ggplot2::geom_point(
data = logistic_points,
ggplot2::aes(x = eta, y = sigmoid),
size = 3,
colour = "#D55E00"
) +
ggplot2::geom_text(
data = logistic_points,
ggplot2::aes(x = eta, y = sigmoid, label = label),
nudge_x = 0.2,
nudge_y = -0.06,
hjust = 0
) +
ggplot2::scale_x_continuous(breaks = seq(-6, 6, 2)) +
ggplot2::labs(
x = paste0("Log-odds, ", eta_symbol),
y = paste0("Probability, logistic(", eta_symbol, ")")
) +
ggplot2::theme_minimal()
if (knitr::is_html_output()) {
htmltools::div(
role = "img",
`aria-label` = fig_alt,
plotly::ggplotly(logistic_function_plot)
)
} else {
logistic_function_plot
}1 Countable sets
Definitions on this page
- Definition 1 (Function, map, mapping, transformation)
- Definition 2 (Argument, input)
- Definition 3 (Value, output)
- Definition 4 (Relation)
- Definition 5 (Domain)
- Definition 6 (Codomain)
- Definition 7 (Image)
- Definition 8 (Preimage, inverse image)
- Definition 9 (Range)
- Definition 10 (Graph of a function)
- Definition 11 (Composition)
- Definition 12 (Inner function)
- Definition 13 (Outer function)
- Definition 14 (Inverse function)
- Definition 15 (Elementwise application of a function to a vector)
- Definition 16 (Operator)
- Definition 17 (Functional)
- Definition 18 (Sequence)
- Definition 19 (Term of a sequence)
- Definition 20 (Finite sequence)
- Definition 21 (Closed under an operation)
- Definition 22 (Logistic function, sigmoid, expit)
- Definition 23 (Finite set)
- Definition 24 (Cardinality)
- Definition 25 (Infinite set)
- Definition 26 (Countable set)
- Definition 27 (Countably infinite set)
References
Halmos, Paul R. 1974. Naive Set Theory. Undergraduate Texts in Mathematics. Springer. https://doi.org/10.1007/978-1-4757-1645-0.
Wikipedia contributors. 2026a. Binary Relation — Wikipedia, the Free Encyclopedia. https://en.wikipedia.org/wiki/Binary_relation.
Wikipedia contributors. 2026b. Cantor’s Diagonal Argument — Wikipedia, the Free Encyclopedia. https://en.wikipedia.org/wiki/Cantor%27s_diagonal_argument.
Wikipedia contributors. 2026c. Cardinality — Wikipedia, the Free Encyclopedia. https://en.wikipedia.org/wiki/Cardinality.
Wikipedia contributors. 2026d. Closure (Mathematics) — Wikipedia, the Free Encyclopedia. https://en.wikipedia.org/wiki/Closure_(mathematics).
Wikipedia contributors. 2026e. Codomain — Wikipedia, the Free Encyclopedia. https://en.wikipedia.org/wiki/Codomain.
Wikipedia contributors. 2026f. Countable Set — Wikipedia, the Free Encyclopedia. https://en.wikipedia.org/wiki/Countable_set.
Wikipedia contributors. 2026g. Domain of a Function — Wikipedia, the Free Encyclopedia. https://en.wikipedia.org/wiki/Domain_of_a_function.
Wikipedia contributors. 2026h. Finite Set — Wikipedia, the Free Encyclopedia. https://en.wikipedia.org/wiki/Finite_set.
Wikipedia contributors. 2026i. Function Composition — Wikipedia, the Free Encyclopedia. https://en.wikipedia.org/wiki/Function_composition.
Wikipedia contributors. 2026j. Function (Mathematics) — Wikipedia, the Free Encyclopedia. https://en.wikipedia.org/wiki/Function_(mathematics).
Wikipedia contributors. 2026k. Functional (Mathematics) — Wikipedia, the Free Encyclopedia. https://en.wikipedia.org/wiki/Functional_(mathematics).
Wikipedia contributors. 2026l. Graph of a Function — Wikipedia, the Free Encyclopedia. https://en.wikipedia.org/wiki/Graph_of_a_function.
Wikipedia contributors. 2026m. Image (Mathematics) — Wikipedia, the Free Encyclopedia. https://en.wikipedia.org/wiki/Image_(mathematics).
Wikipedia contributors. 2026n. Infinite Set — Wikipedia, the Free Encyclopedia. https://en.wikipedia.org/wiki/Infinite_set.
Wikipedia contributors. 2026o. Inverse Function — Wikipedia, the Free Encyclopedia. https://en.wikipedia.org/wiki/Inverse_function.
Wikipedia contributors. 2026p. Logistic Function — Wikipedia, the Free Encyclopedia. https://en.wikipedia.org/wiki/Logistic_function.
Wikipedia contributors. 2026q. Operator (Mathematics) — Wikipedia, the Free Encyclopedia. https://en.wikipedia.org/wiki/Operator_(mathematics).
Wikipedia contributors. 2026r. Range of a Function — Wikipedia, the Free Encyclopedia. https://en.wikipedia.org/wiki/Range_of_a_function.
Wikipedia contributors. 2026s. Sequence — Wikipedia, the Free Encyclopedia. https://en.wikipedia.org/wiki/Sequence.