Numerical foundations

Vectors to Curves

How a computer turns numbers into a graph

FoundationsVideo lessonSample lesson
Uploaded lesson
The idea

What you’ll explore

A computer does not draw a continuous curve in one stroke. It evaluates a function at selected points, stores the results, then connects those samples. This first look traces that simple but powerful idea from a numerical vector to a graph.

Sample points, then evaluate

xi=x0+i Δx,yi=f(xi)x_i = x_0 + i\,\Delta x, \qquad y_i = f(x_i)

Step by step

  1. 01

    Choose a starting value, an ending value, and a step size. Together, they define the x-values the computer will sample.

  2. 02

    Evaluate the function once for each value in the vector. A smaller step creates more samples, which can make a plotted polyline look smoother while increasing the number of calculations.

  3. 03

    Plot each (xᵢ, yᵢ) pair and connect neighboring points. The resulting line is a numerical approximation of the continuous function.

A small code example

MATLAB
xvec = 0.3:0.1:2.0;
y1 = 1 ./ xvec;
y2 = sqrt(4 - xvec.^2);

plot(xvec, y1, xvec, y2)
grid on
Keep exploring

Related lessons