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 and are functions, their composition is:
Apply first, then .
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 .
Then use it to build a triple composition helper that chains three functions: compose3(f, g, h) returns .