Table of Contents
Introduction to Function Composition
Function composition is a way of combining two or more functions to create a new function. In mathematical terms, if you have two functions \( f(x) $\)and \( g(x) \), their composition is denoted as \( (f \circ g)(x) = f(g(x)) \).
Basic Concepts
Definition
The composition of two functions \( f $\)and \( g $\)is defined as: \( (f \circ g)(x) = f(g(x)) \) It means, first apply \( g \), and then apply \( f $\)to the result of \( g \).
Notation
Function composition is denoted by a small circle between functions: \( f \circ g \).
Examples
Example 1: Basic Composition
Let's consider two functions \( f(x) = x^2 $\)and \( g(x) = x + 1 \). Find the composition \( (f \circ g)(x) \).
Solution:
\begin{align*} (f \circ g)(x) &= f(g(x)) \ &= f(x + 1) \ &= (x + 1)^2 \end{align*}
Example 2: Using R for Composition
We will define two functions in R and compute their composition.
f <- function(x) x^2
g <- function(x) x + 1
# Define the composition of f and g
composition <- function(x) f(g(x))
# Plot the composition
x_vals <- seq(-10, 10, by = 0.1)
plot(x_vals, sapply(x_vals, composition), type = 'l', main = "Plot of (f \\circ g)(x)", xlab = "x", ylab = "(f \\circ g)(x)")