Lesson 1 of 15

Function Composition

Function Composition

In Functional Differential Geometry, mathematical objects like derivatives, coordinate transformations, and vector fields are all functions. The most fundamental operation is composition: chaining functions together.

If ff and gg are functions, their composition is:

(fg)(x)=f(g(x))(f \circ g)(x) = f(g(x))

Apply gg first, then ff.

Why This Matters

Differential geometry is built on composing transformations. A coordinate change on a manifold is a composition of two coordinate functions. The chain rule — the heart of calculus on manifolds — is a rule for differentiating compositions.

Gerald Jay Sussman and Jack Wisdom's Functional Differential Geometry represents geometric objects as functions and operators as higher-order functions. Every concept in this course will build on composition.

In Python

Python's first-class functions let you write composition directly:

def compose(f, g):
    return lambda x: f(g(x))

double = lambda x: 2 * x
inc    = lambda x: x + 1

print(compose(double, inc)(3))   # 2*(3+1) = 8
print(compose(inc, double)(3))   # 2*3 + 1 = 7

Your Task

Implement compose(f, g) that returns the function fgf \circ g.

Then use it to build a triple composition helper that chains three functions: compose3(f, g, h) returns fghf \circ g \circ h.

Python runtime loading...
Loading...
Click "Run" to execute your code.