Connect via MCP →

Enter Calculation

Formula

Advertisement

Results

Approximate integral
1.57079633
ab g(x) dx
Method Gauss-Chebyshev (second kind)
Nodes n 20
Interval [-1, 1]
Integrand g(x) = sqrt(1-x^2)

What this calculator does

This tool numerically approximates the definite integral of a function \(g(x)\) over a finite interval \((a, b)\) using Gauss-Chebyshev quadrature of the second kind. Gaussian quadrature evaluates the integrand at a small set of carefully chosen points (nodes) and combines them with matching weights, giving high accuracy for smooth functions with very few evaluations. It is pure mathematics, so there are no units and no country-specific rules.

How to use it

Enter your integrand as an expression in x (for example sqrt(1-x^2), exp(x), 1/(1+x^2) or sin(x)). Supported functions include sin, cos, tan, asin, acos, atan, exp, ln/log, sqrt, abs, powers with ^, plus the constants pi and e. Then set the lower limit \(a\), the upper limit \(b\), and the number of nodes \(n\). Larger \(n\) generally improves accuracy for smooth integrands; values of 30-60 work well for unweighted functions.

The formula explained

The second-kind rule is built on the canonical identity over [-1, 1] with weight \(\sqrt{1 - x^2}\). Its closed-form nodes are \(x_i = \cos\!\left(\frac{i\,\pi}{n+1}\right)\) and weights \(w_i = \frac{\pi}{n+1}\cdot\sin^2\!\left(\frac{i\,\pi}{n+1}\right)\). To integrate an unweighted \(g\) over a general interval, we map [-1,1] to [a,b] (Jacobian \(\frac{b-a}{2}\)) and divide by \(\sqrt{1 - x_i^2}\). That division cancels analytically, leaving the effective weight \(W_i = \frac{\pi}{n+1}\cdot\sin\!\left(\frac{i\,\pi}{n+1}\right)\). The final practical formula is

$$\int_{a}^{b} g(x)\,dx \approx \frac{b-a}{2}\cdot\sum_{i} W_i\cdot g(\text{node}_i)$$

which expands to

$$\int_{a}^{b} g(x)\,dx \approx \frac{b-a}{2}\cdot\frac{\pi}{n+1}\sum_{i=1}^{n} \sin^{2}\!\left(\frac{i\,\pi}{n+1}\right) f(x_i)$$

where

$$\left\{ \begin{aligned} x_i &= \frac{a+b}{2} + \frac{b-a}{2}\cos\!\left(\frac{i\,\pi}{n+1}\right) \\ f(x) &= \frac{g(x)}{\sqrt{1-t_i^{2}}},\quad t_i=\cos\!\left(\frac{i\,\pi}{n+1}\right) \\ n &= \text{Nodes} \end{aligned} \right.$$
Advertisement
Semicircle showing Chebyshev nodes as projections of equally spaced angles onto the x-axis
Second-kind Chebyshev nodes are projections of equally spaced angles, clustering toward the interval center.

Worked example

Take \(g(x) = \sqrt{1 - x^2}\) on \((-1, 1)\) with \(n = 4\). The exact value is the area of a unit half-disk, \(\frac{\pi}{2} \approx 1.5707963\). The four contributions sum to about \(1.5708358\) — matching the true value to four decimals with only four nodes.

Function curve with shaded area and sample nodes used to approximate the integral
The quadrature evaluates g(x) at weighted nodes to approximate the area under the curve.

FAQ

What happens if \(a = b\)? The interval has zero width, so the result is exactly 0.

What if \(b\) is less than \(a\)? The rule still works and returns the signed value, consistent with the integral from a to b being the negative of the integral from b to a.

Why might I get an "undefined at a node" message? If \(g\) produces NaN or infinity at any quadrature node (for example taking ln of a negative number or dividing by zero), the result cannot be computed; adjust the function or interval.

Last updated: