Define functions of two or more variables and understand their notation
Determine the domain and range of multivariable functions
Visualize functions of two variables as surfaces in 3D space
Interpret level curves (contour maps) and understand what they reveal about a function
Describe level surfaces for functions of three variables
Connect multivariable functions to applications in physics, economics, and machine learning
The Big Picture: Beyond Single Variables
"The real world rarely depends on just one quantity. Temperature varies with position and time. Profit depends on price, marketing, and production costs. Machine learning models have thousands of parameters."
Until now, we have studied functions of a single variable: y=f(x). But most real phenomena depend on multiple independent variables:
🌡️ Temperature Distribution
The temperature T(x,y,z,t) at a point in a room depends on three spatial coordinates and time — four independent variables!
📈 Economics: Cobb-Douglas
Production output Q(L, K) = AL^\\alpha K^\\beta depends on labor (L) and capital (K). This fundamental model guides resource allocation decisions.
🎯 Optimization
Finding the best solution to engineering problems often means minimizing a cost function C(x1,x2,ldots,xn) that depends on many design parameters.
🤖 Neural Networks
A neural network's loss function L(theta1,theta2,ldots,thetan) depends on millions of parameters. Understanding multivariable calculus is essential for training these models.
The Jump to Multiple Variables
Moving from one variable to two is conceptually huge — we go from curves to surfaces, from derivatives to gradients, from integrals to double integrals. But the underlying intuition of rate of change and accumulation remains the same.
Historical Context: The Need for Higher Dimensions
The study of functions of several variables emerged from pressing practical needs and deep mathematical questions.
The Heat Equation (1822)
Joseph Fourier developed the heat equation to describe how temperatureT(x,y,z,t) evolves in a solid body. This partial differential equation became one of the first major applications of multivariable calculus:
Joseph-Louis Lagrange developed methods for optimizing functions subject to constraints — a problem that naturally involves multiple variables. His method of Lagrange multipliers (which we'll study later) remains a cornerstone of constrained optimization.
Modern Applications
Today, functions of many variables are everywhere: from weather prediction to financial modeling, from computer graphics to machine learning. The mathematical framework developed over centuries now powers our digital world.
Defining Functions of Several Variables
Definition: Function of Two Variables
A function of two variables is a rule that assigns to each ordered pair (x,y) in a set D (the domain) a unique real number denoted f(x,y).
We write:
z=f(x,y)
where x and y are independent variables and z is the dependent variable.
Notation and Terminology
Notation
Meaning
f(x, y)
The value of f at the point (x, y)
z = f(x, y)
z is the output when inputs are x and y
D or dom(f)
The domain - set of valid (x, y) pairs
Range(f)
The set of all output values f(x, y)
f: D → ℝ
f maps points in D to real numbers
Example: Evaluating Multivariable Functions
Consider f(x,y)=x2+xy+y2−3. Let's evaluate it at several points:
f(1, 2):12+(1)(2)+22−3=1+2+4−3=4
f(0, 0):0+0+0−3=−3
f(-1, 1):(−1)2+(−1)(1)+12−3=1−1+1−3=−2
f(a, a):a2+acdota+a2−3=3a2−3
Functions of Three or More Variables
Definition: Function of n Variables
A function of n variables is a rule that assigns to each n-tuple (x1,x2,ldots,xn) in a domain DsubseteqmathbbRn a unique real number:
Neural network loss: L(theta1,ldots,thetan) (millions of variables)
Domain and Range
Finding the Domain
The domain of a multivariable function consists of all input points where the function is defined. We apply the same rules as for single-variable functions, but now our domain is aregion in the plane (for two variables) or higher-dimensional space.
Common domain restrictions:
Division: Denominator ≠ 0
Square roots: Radicand ≥ 0
Logarithms: Argument > 0
Inverse trig: Argument in proper range
Example: Domain Analysis
Example 1: Find the domain of f(x,y)=sqrt9−x2−y2.
Solution: We need 9−x2−y2geq0, which means x2+y2leq9.
Domain: The closed disk of radius 3 centered at the origin (including the boundary circle).
Geometrically, this is all points at distance ≤ 3 from the origin.
Example 2: Find the domain of g(x,y)=ln(x−y).
Solution: We need x−y>0, which means x>y or y<x.
Domain: The half-plane below the line y=x.
Range of Multivariable Functions
The range is the set of all output values. Finding the range can be more challenging than finding the domain.
Example: Find the range of f(x,y)=x2+y2.
Solution: Since x2geq0 and y2geq0 for all real x and y, we have f(x,y)geq0.
The minimum value 0 is achieved at (0,0).
As we move away from the origin, f can be made arbitrarily large.
Range:[0,infty)
Graphs as Surfaces in 3D
For a function of two variables z=f(x,y), the graph is the set of all points (x,y,z) in three-dimensional space where z=f(x,y):
Graph of z = f(x, y)
textGraph(f)=(x,y,z)inmathbbR3:z=f(x,y),(x,y)inD
This graph is typically a surface in 3D space. The shape of the surface reveals important properties of the function:
Function
Surface Type
Key Features
z = x² + y²
Paraboloid
Bowl opening upward, minimum at origin
z = x² - y²
Saddle (hyperbolic paraboloid)
Curves up in x, down in y
z = √(1 - x² - y²)
Hemisphere
Upper half of unit sphere
z = sin(x)cos(y)
Egg-crate surface
Periodic peaks and valleys
z = 1/(x² + y²)
Funnel
Approaches infinity at origin
Interactive: Explore 3D Surfaces
Use the visualization below to explore how different functions create different surfaces. Rotate, zoom, and probe specific points to understand how the surface encodes the function's behavior.
Loading 3D visualization...
Reading 3D Surfaces
The height of the surface above (or below) the xy-plane at any point (x,y) gives the value f(x,y). The shape of the surface tells us about rates of change, extrema, and other properties.
Level Curves and Contour Maps
While 3D surfaces are intuitive, they can be hard to work with. A powerful alternative is the contour map or level curve representation.
Definition: Level Curves
The level curves of a function f(x,y) are the curves in the xy-plane where the function has a constant value:
f(x,y)=c
for various constants c.
The Topographic Map Analogy
Level curves work exactly like contour lines on a topographic map. Each contour line represents a constant elevation. The closer the lines, the steeper the terrain.
Close Contours = Steep Slope
When level curves are close together, the function value changes rapidly. This indicates a steep slope on the surface.
Perpendicular Direction = Steepest Change
Moving perpendicular to a level curve gives the direction of steepest ascent. This is the gradient direction (to be studied soon).
Examples of Level Curves
Example 1: Paraboloidf(x,y)=x2+y2
Setting x2+y2=c for various c>0 gives circles of radius sqrtc centered at the origin.
As c increases, the circles grow larger. The level curves are concentric circles.
Example 2: Saddle Surfacef(x,y)=x2−y2
Setting x2−y2=c:
For c>0: hyperbolas opening left-right
For c<0: hyperbolas opening up-down
For c=0: the lines y=pmx (the asymptotes)
Example 3: Linear Functionf(x,y)=2x+3y
Setting 2x+3y=c gives parallel lines with slope −2/3.
For a linear function, all level curves are parallel lines. The gradient (direction of steepest ascent) is the same everywhere.
Interactive: Level Curve Explorer
Explore how different functions produce different level curve patterns. Move your cursor over the plot to see exact function values.
Loading visualization...
Level Curves and Optimization
Level curves are essential for understanding optimization. Local maxima and minima occur where level curves form closed loops (or single points). Saddle points occur where level curves cross or meet.
Level Surfaces (Three Variables)
For functions of three variables w=f(x,y,z), we cannot draw the graph (it would require 4D). Instead, we study level surfaces.
Definition: Level Surfaces
The level surfaces of a function f(x,y,z) are the surfaces in 3D space where the function has a constant value:
f(x,y,z)=c
Examples of Level Surfaces
Function
Level Surface f = c
Description
f(x,y,z) = x² + y² + z²
Spheres of radius √c
Concentric spheres
f(x,y,z) = x² + y² - z²
Hyperboloids
One-sheet (c<0) or two-sheet (c>0)
f(x,y,z) = x + 2y + 3z
Parallel planes
All with normal vector (1,2,3)
f(x,y,z) = x² + y²
Cylinders
Circular cylinders around z-axis
Temperature Distribution
If T(x,y,z) represents temperature at each point in a room, then level surfaces T=c are called isothermal surfaces — surfaces of constant temperature. Heat flows perpendicular to these surfaces.
Real-World Applications
1. Thermodynamics: Ideal Gas Law
The ideal gas law PV=nRT relates pressure P, volume V, and temperature T. For a fixed amount of gas, we can express pressure as a function of two variables:
P(V,T)=fracnRTV
The level curves P=textconstant are called isobars, and they show how volume and temperature must change together to maintain constant pressure.
2. Economics: Production Functions
The Cobb-Douglas production function models output as a function of labor and capital:
Q(L, K) = AL^\\alpha K^\\beta
Level curves Q=textconstant are called isoquants — they show different combinations of labor and capital that produce the same output.
3. Electrostatics: Electric Potential
The electric potential V(x,y,z) due to a point charge at the origin is:
V(x,y,z)=frackqsqrtx2+y2+z2
Level surfaces are spheres centered at the origin. The electric field points perpendicular to these surfaces — in the direction of steepest potential decrease.
Machine Learning Applications
In machine learning, functions of many variables appear constantly. Understanding their geometry is essential for training models effectively.
1. Loss Functions as Surfaces
When training a neural network, the loss function L(boldsymboltheta) depends on all model parameters boldsymboltheta=(theta1,theta2,ldots,thetan). Even for a simple linear regression y=wx+b, the mean squared error loss is:
L(w,b)=frac1nsumi=1n(wxi+b−yi)2
This is a function of two variables (w and b). Gradient descent navigates this surface to find the minimum.
2. High-Dimensional Landscapes
Real neural networks have millions of parameters, creating loss surfaces in million-dimensional space. Key insights from multivariable calculus:
Saddle points are extremely common in high dimensions (more common than local minima)
The gradient points toward the direction of steepest ascent
Level sets help visualize the loss landscape in lower dimensions
3. Feature Spaces
In classification, data points live in high-dimensional feature spaces. Decision boundaries are level surfaces of the form f(mathbfx)=0, separating different classes.
The Curse of Dimensionality
As dimension increases, the volume of a fixed-radius ball relative to the enclosing cube shrinks exponentially. This has profound implications for data density and distance-based algorithms. Understanding multivariable functions is the first step toward understanding these phenomena.
Python Implementation
Creating and Visualizing Multivariable Functions
Functions of Two Variables in Python
🐍multivariable_functions.py
Explanation(4)
Code(78)
5The Paraboloid
f(x, y) = x² + y² defines a paraboloid opening upward. Every point on the surface has z equal to the sum of squared distances from the x and y axes.
EXAMPLE
At (1, 2): f(1, 2) = 1 + 4 = 5, so the point (1, 2, 5) is on the surface.
17The Saddle Surface
f(x, y) = x² - y² has different behavior in different directions. Moving along the x-axis, z increases (bowl shape). Moving along the y-axis, z decreases (inverted bowl).
27The 2D Gaussian
The Gaussian function creates a bell-shaped surface with maximum at the origin. The parameter σ controls the width - larger σ means a flatter, wider bell.
37Creating the Grid
meshgrid creates a 2D array of (x, y) coordinate pairs, enabling us to evaluate the function at every point simultaneously using vectorized operations.
74 lines without explanation
1import numpy as np
2import matplotlib.pyplot as plt
3from mpl_toolkits.mplot3d import Axes3D
45deff(x, y):6"""
7 A function of two variables: f(x, y) = x² + y²
89 This is the classic paraboloid - a bowl-shaped surface
10 that appears everywhere in optimization (it's the simplest
11 convex function in 2D with a unique minimum at the origin).
1213 In machine learning, this shape represents an ideal loss
14 surface where gradient descent will always find the minimum.
15 """16return x**2+ y**21718defsaddle(x, y):19"""
20 The saddle surface: f(x, y) = x² - y²
2122 This hyperbolic paraboloid has a saddle point at the origin -
23 it's a local minimum in the x-direction but a local maximum
24 in the y-direction. Saddle points are critical in understanding
25 why optimization in high dimensions is challenging.
26 """27return x**2- y**22829defgaussian(x, y, sigma=1.0):30"""
31 The 2D Gaussian: f(x, y) = exp(-(x² + y²)/(2σ²))
3233 This bell-shaped surface is fundamental to:
34 - Probability (normal distribution in 2D)
35 - Machine learning (RBF kernels, Gaussian processes)
36 - Signal processing (smoothing filters)
37 - Heat diffusion (the heat kernel)
38 """39return np.exp(-(x**2+ y**2)/(2* sigma**2))4041# Create a grid of (x, y) points42x = np.linspace(-3,3,100)43y = np.linspace(-3,3,100)44X, Y = np.meshgrid(x, y)4546# Evaluate functions on the grid47Z_paraboloid = f(X, Y)48Z_saddle = saddle(X, Y)49Z_gaussian = gaussian(X, Y)5051# Visualize all three surfaces52fig = plt.figure(figsize=(15,5))5354ax1 = fig.add_subplot(131, projection='3d')55ax1.plot_surface(X, Y, Z_paraboloid, cmap='viridis', alpha=0.8)56ax1.set_title('Paraboloid: f(x,y) = x² + y²')57ax1.set_xlabel('x'); ax1.set_ylabel('y'); ax1.set_zlabel('z')5859ax2 = fig.add_subplot(132, projection='3d')60ax2.plot_surface(X, Y, Z_saddle, cmap='coolwarm', alpha=0.8)61ax2.set_title('Saddle: f(x,y) = x² - y²')62ax2.set_xlabel('x'); ax2.set_ylabel('y'); ax2.set_zlabel('z')6364ax3 = fig.add_subplot(133, projection='3d')65ax3.plot_surface(X, Y, Z_gaussian, cmap='plasma', alpha=0.8)66ax3.set_title('Gaussian: f(x,y) = exp(-(x²+y²)/2)')67ax3.set_xlabel('x'); ax3.set_ylabel('y'); ax3.set_zlabel('z')6869plt.tight_layout()70plt.show()7172# Evaluate at specific points73print("\n=== Function Evaluation ===")74print(f"f(1, 2) = 1² + 2² = {f(1,2)}")75print(f"f(-1, -1) = (-1)² + (-1)² = {f(-1,-1)}")76print(f"saddle(1, 1) = 1² - 1² = {saddle(1,1)}")77print(f"saddle(2, 1) = 2² - 1² = {saddle(2,1)}")78print(f"gaussian(0, 0) = {gaussian(0,0):.4f}")# Maximum at origin
Creating Contour Plots
Level Curves with Matplotlib
🐍contour_plots.py
Explanation(3)
Code(64)
4Contour Plot Purpose
Contour plots project a 3D surface onto 2D by drawing curves of constant height. This is exactly how topographic maps work - each contour line represents a specific elevation.
30Filled Contours
contourf fills the regions between level curves with colors, creating a heat map effect. The color indicates the function value at each point.
32Contour Line Labels
clabel adds numeric labels to contour lines showing the function value. This helps identify specific level curves like f(x,y) = 0 or f(x,y) = 5.
61 lines without explanation
1import numpy as np
2import matplotlib.pyplot as plt
34defcreate_contour_plots():5"""
6 Contour plots (level curves) are 2D representations of 3D surfaces.
78 Each curve connects points where f(x, y) = c for some constant c.
9 These are like topographic maps where contour lines show elevation.
1011 Key insights from contour plots:
12 - Closer contours = steeper slope (faster rate of change)
13 - Perpendicular to contours = direction of steepest ascent
14 - Closed contours often indicate local extrema
15 """16 x = np.linspace(-3,3,200)17 y = np.linspace(-3,3,200)18 X, Y = np.meshgrid(x, y)1920# Define several functions21 funcs ={22'Paraboloid': X**2+ Y**2,23'Saddle': X**2- Y**2,24'Linear':2*X +3*Y,25'Waves': np.sin(X)+ np.sin(Y)26}2728 fig, axes = plt.subplots(2,2, figsize=(12,12))29 axes = axes.flatten()3031for ax,(name, Z)inzip(axes, funcs.items()):32# Filled contour plot33 cf = ax.contourf(X, Y, Z, levels=20, cmap='viridis')34# Contour lines35 cs = ax.contour(X, Y, Z, levels=20, colors='white', linewidths=0.5)36 ax.clabel(cs, inline=True, fontsize=8, fmt='%.1f')3738 ax.set_title(name)39 ax.set_xlabel('x')40 ax.set_ylabel('y')41 ax.set_aspect('equal')42 plt.colorbar(cf, ax=ax, shrink=0.8)4344 plt.tight_layout()45 plt.show()4647# Analyze the level curves48print("=== Level Curve Analysis ===")49print("\nParaboloid (x² + y²):")50print(" - Level curves: x² + y² = c → circles of radius √c")51print(" - All level curves are concentric circles")52print(" - Closer circles near origin = steeper near minimum")5354print("\nSaddle (x² - y²):")55print(" - Level curves: x² - y² = c → hyperbolas")56print(" - c = 0 gives the lines y = ±x (asymptotes)")57print(" - Curves open left/right for c > 0, up/down for c < 0")5859print("\nLinear (2x + 3y):")60print(" - Level curves: 2x + 3y = c → parallel lines")61print(" - All have slope -2/3")62print(" - Equal spacing = constant gradient magnitude")6364create_contour_plots()
Loss Surfaces in Machine Learning
Visualizing ML Loss Landscapes
🐍loss_surface.py
Explanation(3)
Code(96)
4Loss as Multivariable Function
In machine learning, the loss function L(θ₁, θ₂, ..., θₙ) depends on all model parameters. For simple linear regression with y = wx + b, this means L(w, b) is a function of two variables.
19MSE Loss Definition
Mean Squared Error measures the average squared difference between predictions and actual values. For each (w, b) pair, we get a single loss value - this defines the surface.
53Gradient Descent
Gradient descent computes the gradient ∇L = (∂L/∂w, ∂L/∂b) and moves in the opposite direction. The path traces a curve on the loss surface, descending toward the minimum.
93 lines without explanation
1import numpy as np
2import matplotlib.pyplot as plt
34defloss_surface_visualization():5"""
6 In machine learning, loss functions are functions of model parameters.
78 For a simple linear regression y = wx + b:
9 - The loss L(w, b) measures how well the model fits the data
10 - This is a function of TWO variables (w and b)
11 - Gradient descent navigates this surface to find minimum
1213 Understanding loss surfaces as functions of several variables
14 is essential for understanding optimization in ML.
15 """16# Generate synthetic data: y = 2x + 1 + noise17 np.random.seed(42)18 X_data = np.random.randn(50)19 y_data =2* X_data +1+0.5* np.random.randn(50)2021defmse_loss(w, b, X=X_data, y=y_data):22"""Mean Squared Error loss function"""23 predictions = w * X + b
24return np.mean((predictions - y)**2)2526# Create parameter grid27 w_range = np.linspace(-1,5,100)28 b_range = np.linspace(-2,4,100)29 W, B = np.meshgrid(w_range, b_range)3031# Compute loss at each point32 L = np.zeros_like(W)33for i inrange(W.shape[0]):34for j inrange(W.shape[1]):35 L[i, j]= mse_loss(W[i, j], B[i, j])3637# Find minimum38 min_idx = np.unravel_index(np.argmin(L), L.shape)39 w_opt, b_opt = W[min_idx], B[min_idx]4041# Visualize42 fig, axes = plt.subplots(1,2, figsize=(14,6))4344# 3D surface45 ax1 = fig.add_subplot(121, projection='3d')46 ax1.plot_surface(W, B, L, cmap='viridis', alpha=0.8)47 ax1.scatter([w_opt],[b_opt],[L[min_idx]], color='red', s=100,48 label=f'Minimum at w={w_opt:.2f}, b={b_opt:.2f}')49 ax1.set_xlabel('Weight (w)')50 ax1.set_ylabel('Bias (b)')51 ax1.set_zlabel('Loss')52 ax1.set_title('MSE Loss Surface')53 ax1.legend()5455# Contour plot with gradient descent path56 ax2 = axes[1]57 cf = ax2.contourf(W, B, L, levels=30, cmap='viridis')58 ax2.contour(W, B, L, levels=30, colors='white', linewidths=0.3)59 ax2.plot(w_opt, b_opt,'r*', markersize=15, label='Minimum')6061# Simulate gradient descent62 w, b =4.0,3.0# Starting point63 learning_rate =0.164 path_w, path_b =[w],[b]6566for _ inrange(50):67# Compute gradients (analytically for linear regression)68 dL_dw =2* np.mean((w * X_data + b - y_data)* X_data)69 dL_db =2* np.mean(w * X_data + b - y_data)7071# Update parameters72 w -= learning_rate * dL_dw
73 b -= learning_rate * dL_db
74 path_w.append(w)75 path_b.append(b)7677 ax2.plot(path_w, path_b,'r.-', linewidth=2, markersize=5,78 label='Gradient Descent Path')79 ax2.set_xlabel('Weight (w)')80 ax2.set_ylabel('Bias (b)')81 ax2.set_title('Loss Contours with Optimization Path')82 ax2.legend()83 plt.colorbar(cf, ax=ax2, shrink=0.8)8485 plt.tight_layout()86 plt.show()8788print("=== ML Loss Surface Analysis ===")89print(f"\nTrue parameters: w=2, b=1")90print(f"Found minimum: w={w_opt:.3f}, b={b_opt:.3f}")91print(f"Final GD result: w={path_w[-1]:.3f}, b={path_b[-1]:.3f}")92print(f"\nThe loss L(w, b) is a function of TWO variables.")93print("Gradient descent navigates this surface by following")94print("the direction opposite to the gradient (steepest descent).")9596loss_surface_visualization()
Domain Analysis
Visualizing Function Domains
🐍domain_analysis.py
Explanation(2)
Code(82)
4Domain Restrictions
The domain is determined by the requirements of all operations in the function. Multiple restrictions create composite domain conditions.
27Visualizing Domains
We use contourf to shade valid regions. This makes it easy to see which (x, y) pairs are in the domain and which are excluded.
80 lines without explanation
1import numpy as np
2import matplotlib.pyplot as plt
34defanalyze_domain():5"""
6 The domain of a function f(x, y) is the set of all (x, y)
7 pairs where f is defined. Common restrictions:
89 1. Division by zero: denominators must be nonzero
10 2. Square roots: radicand must be non-negative
11 3. Logarithms: argument must be positive
12 4. Inverse trig: argument in appropriate interval
1314 Understanding domains is crucial for:
15 - Defining valid input regions
16 - Identifying singularities and boundaries
17 - Setting up integration limits in calculus
18 """1920# Example 1: f(x, y) = 1/√(9 - x² - y²)21# Domain: 9 - x² - y² > 0, i.e., x² + y² < 9 (inside circle)2223# Example 2: f(x, y) = ln(xy)24# Domain: xy > 0, i.e., quadrants I and III2526 x = np.linspace(-4,4,400)27 y = np.linspace(-4,4,400)28 X, Y = np.meshgrid(x, y)2930 fig, axes = plt.subplots(1,3, figsize=(15,5))3132# Domain 1: x² + y² < 933 domain1 = X**2+ Y**2<934 axes[0].contourf(X, Y, domain1.astype(float), levels=[0.5,1.5],35 colors=['white','lightblue'], alpha=0.7)36 axes[0].add_patch(plt.Circle((0,0),3, fill=False, color='blue', linewidth=2))37 axes[0].set_title('Domain of f(x,y) = 1/√(9-x²-y²)\nx² + y² < 9')38 axes[0].set_xlabel('x'); axes[0].set_ylabel('y')39 axes[0].set_aspect('equal')40 axes[0].set_xlim(-4,4); axes[0].set_ylim(-4,4)4142# Domain 2: xy > 0 (quadrants I and III)43 domain2 = X * Y >044 axes[1].contourf(X, Y, domain2.astype(float), levels=[0.5,1.5],45 colors=['white','lightgreen'], alpha=0.7)46 axes[1].axhline(0, color='black', linewidth=0.5)47 axes[1].axvline(0, color='black', linewidth=0.5)48 axes[1].set_title('Domain of f(x,y) = ln(xy)\nxy > 0')49 axes[1].set_xlabel('x'); axes[1].set_ylabel('y')50 axes[1].set_aspect('equal')51 axes[1].set_xlim(-4,4); axes[1].set_ylim(-4,4)5253# Domain 3: y > x² (above parabola)54 domain3 = Y > X**255 axes[2].contourf(X, Y, domain3.astype(float), levels=[0.5,1.5],56 colors=['white','lightyellow'], alpha=0.7)57 x_parabola = np.linspace(-2,2,100)58 axes[2].plot(x_parabola, x_parabola**2,'orange', linewidth=2)59 axes[2].set_title('Domain of f(x,y) = √(y-x²)\ny > x²')60 axes[2].set_xlabel('x'); axes[2].set_ylabel('y')61 axes[2].set_aspect('equal')62 axes[2].set_xlim(-4,4); axes[2].set_ylim(-4,4)6364 plt.tight_layout()65 plt.show()6667print("=== Domain Analysis ===")68print("\n1. f(x,y) = 1/√(9 - x² - y²)")69print(" Requires: 9 - x² - y² > 0")70print(" Domain: open disk of radius 3 centered at origin")71print(" Boundary: circle x² + y² = 9 (excluded)")7273print("\n2. f(x,y) = ln(xy)")74print(" Requires: xy > 0")75print(" Domain: {(x,y) : x>0 and y>0} ∪ {(x,y) : x<0 and y<0}")76print(" This is quadrants I and III")7778print("\n3. f(x,y) = √(y - x²)")79print(" Requires: y - x² ≥ 0")80print(" Domain: all points on or above the parabola y = x²")8182analyze_domain()
Test Your Understanding
Summary
Functions of several variables extend single-variable calculus to handle the complexity of the real world. They provide the foundation for partial derivatives, gradients, and optimization — tools that power modern science and machine learning.
Key Concepts
Concept
Description
Function of n variables
f(x₁, x₂, ..., xₙ) maps n inputs to one output
Domain
Set of all valid input points (region in ℝⁿ)
Range
Set of all output values
Graph (2 variables)
Surface z = f(x, y) in 3D space
Level curves
Curves where f(x, y) = c (contour lines)
Level surfaces
Surfaces where f(x, y, z) = c
Key Takeaways
Multivariable functions take multiple inputs and produce a single output value
The domain is a region in the plane (or higher-dimensional space) where the function is defined
For two variables, the graph is a surface in 3D space
Level curves show where the function has constant value — like contour lines on a map
In machine learning, loss functions are functions of many variables, and understanding their geometry is crucial for optimization
The Essence of Multivariable Functions:
"A function of several variables maps points in space to numbers, creating a landscape that we navigate through contour maps, gradients, and optimization."
Coming Next: In the next section, we'll explore limits and continuity for functions of several variables. The concepts are natural extensions of single-variable ideas, but the geometry becomes richer — we can approach a point from infinitely many directions!