Connect symbols to numbersLesson 44 of 48 · 8 min

Evaluate a curve on an array

Use a NumPy-backed symbolic function to plot a domain-labelled curve.

Maths refresher: A graph samples a function

A graph places input on one axis and output on the other. A numerical grid evaluates only its selected inputs.

f(x)=e−x,f(0)=1,f(x)→0 as x→∞f(x)=e^{-x},\qquad f(0)=1,\qquad f(x)\to0\text{ as }x\to\infty
Worked example

Sampling between 0 and 4 shows part of the decay. It does not display every nonnegative input or prove a long-time limit.

Maths prerequisite map ↗

A NumPy-backed lambdified function can evaluate many inputs in one call. This connects a symbolic derivation with numerical arrays and plots. Preserve the domain and units when selecting the input grid.

See the mathematics
01234-0.050.250.550.851.15xy
01234-0.050.250.550.851.15xy
f(x)=e−x,x≥0f(x)=e^{-x},\quad x\ge0
Starter reference. A reference curve for the authored model. Running the Python below produces a separate plot from your own numerical array.

The example plots a known response e−xe^{-x} for nonnegative x. The symbolic expression remains available for exact values, while the plotted samples are floating-point evaluations. A grid is a set of sampled locations, not the whole continuous function.

Plots are useful for interpretation and catching surprising behaviour, but a smooth-looking curve is not a proof of continuity, an identity or exhaustive root coverage. Check exact boundaries and singularities from the symbolic model rather than relying on a finite grid to reveal them.

Does a plot on 200 points examine every input between the endpoints?

Write a prediction (optional)

Symbolic curve and sampled numerical values

Select Run Python with the code unchanged.

Tools
About Python

Python and the course packages can load while you read. Each run starts with fresh user variables; imported modules stay loaded. Stop replaces the worker. Runtime details ↗

Ctrl+Enter or ⌘+Enter runs Python.

Compare with the worked example

Executed from the published Python during the site build. Your own run appears above. Build environment ↗

Symbolic curve
e−xe^{- x}
Exact starting value
11
Sampled endpoint
0.01831563888873420.0183156388887342
Grid points
200200
Worked text output
Symbolic curve: exp(-x)
Exact starting value: 1
Sampled endpoint: 0.01831563888873418
Grid points: 200
Plot generated by the executed Python example. Read its labelled axes and the lesson explanation together.
Open full-size figure ↗

Read the starter result

The plot comes from the current numerical samples. Exact starting value comes from symbolic substitution. Sampled endpoint comes from the last point in the floating-point grid.

Edit and compare

Replace expression = sp.exp(-x) with expression = sp.sin(x) and end = 4 with end = 2*sp.pi. Change the x-axis label string to "x (radians)". Select Run Python. Then change points = 200 to points = 25 and select Run Python again. Compare the plots, Grid points and Sampled endpoint.

Return to the editor

Scope. Finite plotting grids can conceal singularities and narrow features; this smooth bounded example deliberately avoids those difficulties.

Try a fresh case

A plotted curve seems to cross zero once. What further work supports a claim about all roots?

Choose an answer
Need a hint?
Hint 1

Think about what lies between grid points.

Hint 2

Use the formula and domain, not just the drawing.

Your notesNotes save in this browser when storage is available.