integral
The region under a function, shaded, with its signed area; in space, the solid under a surface, with its volume.
integralxyxyzplaneOn this page


#Area under a curve
integral(of: #bell; from: -1; to: 1) shades the area under a curve in the same graph between two limits, and publishes it as area. of: may be an expression instead, of: x^2, and nothing else need be drawn. The limits may be expressions of parameters, so a slider sweeps the region while the reader watches area change. Both are required; without to:, 'integral' on the xy plane is the area between two limits — it needs 'to:'.
The area is taken over the limits met with the curve's own domain, never the visible window, so panning does not change it. base: is what the region closes down to: the axis, another curve (base: #supply), or an expression (base: 6), and area is then the area between. A region a path in t encloses is that curve's fill-style.
area.#Riemann sums
n: draws the Riemann sum instead: n rectangles across the limits, each as tall as the function at the middle of its cell, or at its lower or upper end with sample:. area is then the sum, and exact is the integral it approximates, so the two can be set side by side. A slider on n re-divides it.
graph{
integral#sum(of: x^2; from: 0; to: 2; n: k; label: {{round(#sum.area, 3)}} of {{round(#sum.exact, 3)}})
slider:k(range: [1, 32]; default: 4; step: 1; name: rectangles)
}#Volume in space
In space an integral is the volume under a surface, of: #hill or an expression in x and y, drawn as the solid. The region is written as the bounds of its iterated integral, the inner bound free to read the outer variable: x: [0, 2]; y: [0, 1 - x], or polar, theta: [0, 2pi]; r: [0, 2 cos(theta)]. from and to are refused there, and n: draws an n by n grid of boxes. It publishes volume where the plane publishes area, the sum where there are boxes, and exact is the volume. The argand and polar planes take no integral.
#Attributes
of#id for a curve on the line or a surface in space in this environment, or an expression written out, y = f(x) on the line and z = f(x, y) in space.surface-ofcurve, underCan be written as shorthand: integral:valuefroma, starttob, endx[0, 2], or [0, y] when x is the inner variable.region-boundy[0, 1 - x] — the inner bound may read the outer variable.region-boundtheta[0, 2pi].region-boundr[0, 2 cos(theta)].region-boundbase#id, or an expression (base: 6). The published numbers are then the area or volume between.surface-ofdown-to, floor, abovensamplelower) or farthest from it (upper).midpointloweruppermidpointcolourpaintcolorblueopacitystylesolid, hatched, dotted or outlined. One value for the whole integral.solidhatcheddottedoutlinedsolidedgestruelabel$maths$ renders.hiddenfalselocklockedfalselayergroupgroup: Early sown, Projected. It is drawn in the colour of the first that has one and the style of the first the graph's key: gives one, unless it writes its own colour: or style, and the footer's key names every group.#Derived attributes
Computed while the element renders — read one with #id.name in attribute position or {{#id.name}} in prose, never set.
exactn is — the area on the plane, the volume in space — which is what a Riemann sum is set beside: {{#sum.area}} against {{#sum.exact}}.xyplanearean: draws rectangles; signed, so a stretch below the base counts against it. A dash where a limit or the function does not resolve.xyzplanevolumen: draws them. A dash where the surface or a bound does not resolve.#Allowed in
#Examples


graph{
curve#bell(expression: exp(-x^2 / 2))
integral(of: #bell; from: -1; to: 1; label: $0.68$)
}(
x-domain: [-3, 3]
)

graph{
integral(of: x^2; from: 0; to: 2; colour: teal)
}(
x-domain: [-1, 3]
y-domain: [0, 5]
)

graph{
curve#velocity(expression: 2 + x - x^2 / 10)
integral(of: #velocity; from: 0; to: 5; opacity: 0.2; !edges)
}(
x-domain: [0, 6]
y-domain: [0, 6]
)

graph{
curve#parabola(expression: x^2)
integral(of: #parabola; from: 0; to: 2; n: 8)
}(
x-domain: [0, 2]
y-domain: [0, 4]
)

graph:xyz{
integral(of: 4 - x - y; x: [0, 2]; y: [0, 2 - x])
}(
x domain: [0, 2]
y domain: [0, 2]
z domain: [0, 4]
)

graph:xyz{
integral(of: 3 * e^(-(x^2 + y^2) / 2); theta: [0, 2pi]; r: [0, 1.5]; colour: purple; opacity: 0.8)
}(
x domain: [-2, 2]
y domain: [-2, 2]
z domain: [0, 3]
)![Sixteen boxes under z = 16 − x² − 2y² over [0, 2] × [0, 2], each as tall as the surface at its midpoint, inside the solid they approximate.](/_next/image?url=%2Fmanual-figures%2Fexample-integral-7.light.jpg&w=3840&q=90&dpl=dpl_CBrU4MbWhbfSBSWrUGDvQXzUkqv9)
![Sixteen boxes under z = 16 − x² − 2y² over [0, 2] × [0, 2], each as tall as the surface at its midpoint, inside the solid they approximate.](/_next/image?url=%2Fmanual-figures%2Fexample-integral-7.dark.jpg&w=3840&q=90&dpl=dpl_CBrU4MbWhbfSBSWrUGDvQXzUkqv9)
graph:xyz{
integral(of: 16 - x^2 - 2 * y^2; x: [0, 2]; y: [0, 2]; opacity: 0.2)
integral(of: 16 - x^2 - 2 * y^2; x: [0, 2]; y: [0, 2]; n: 4; colour: orange)
}(
x domain: [0, 2]
y domain: [0, 2]
z domain: [0, 16]
)

graph:xyz{
surface(expression: 16 - x^2 - 2 * y^2; opacity: 0.3)
integral(of: 16 - x^2 - 2 * y^2; x: [0, 2]; y: [0, 2]; n: 8; sample: lower; colour: teal)
}(
x domain: [0, 2]
y domain: [0, 2]
z domain: [0, 16]
)#Notes
- The region is sampled from
of:, so it follows an animated expression, and a parameter in any limit or bound.
#Writing guidance
- Reading computed values in prose — A number the canvas computes is read from the construct with a {{…}} expression, and rounded for the claim.