What this calculator does
This tool approximates a definite integral using Gauss-Chebyshev quadrature of the first kind, the Gaussian rule associated with the Chebyshev weight function \(w(x) = 1/\sqrt{1 - x^2}\) on the interval \([-1, 1]\). Its great advantage is that the nodes and weights have a simple closed form, so no lookup table is needed: the nodes are cosines of equally spaced angles and every weight equals \(\pi/n\).
How to use it
Pick an integrand type. In the default g(x) over [a,b] mode, enter any plain function \(g(x)\), a lower limit \(a\), an upper limit \(b\), and the number of division points \(n\). The calculator maps \([-1, 1]\) onto \([a, b]\) and multiplies by \(\sqrt{1 - x_i^2}\) to cancel the implicit Chebyshev weight, giving an estimate of the ordinary integral. In f(x) over [-1,1] mode, the function is treated as the integrand of the weighted integral and the limits are fixed to \([-1, 1]\). Supported syntax includes + - * / ^, parentheses, and sin, cos, tan, asin, acos, atan, exp, ln, log, sqrt, abs, plus the constants \(\pi\) and \(e\). Trigonometric functions use radians.
The formula explained
With \(\text{step} = \pi/(2n)\) and \(\theta_i = (2i-1)\cdot\text{step}\), the node is \(x_i = \cos(\theta_i)\) and \(\sin(\theta_i) = \sqrt{1 - x_i^2}\). For a plain integral the rule is the sum of \((b-a)/2\) times \(\pi/n\) times \(\sin(\theta_i)\) times \(g\) of the mapped point. The weighted \([-1,1]\) integral is simply \((\pi/n)\) times the sum of \(f\) at the nodes.
$$\int_{a}^{b} f(x)\,dx \approx \frac{b-a}{2}\cdot\frac{\pi}{n} \sum_{i=1}^{n} \sqrt{1-x_i^{2}}\; f\!\left(\frac{b-a}{2}x_i + \frac{a+b}{2}\right)$$$$\text{where}\quad \left\{ \begin{aligned} x_i &= \cos\!\left(\frac{(2i-1)\pi}{2n}\right) \\ n &= \text{Number of nodes} \end{aligned} \right.$$
Worked example
Integrate \(g(x) = x^2\) from 0 to 1 with \(n = 3\). The three nodes give terms \(0.4352563\), \(0.25\) and \(0.0022436\), summing to \(0.6874999\). Multiply by \((b-a)/2 = 0.5\) and by \(\pi/3 = 1.0471976\) to get about \(0.359957\). The true value is \(1/3\); raising \(n\) to 10 yields roughly \(0.33408\), converging toward \(0.3333\).
FAQ
Why does my polynomial result not match exactly? Dividing out the Chebyshev weight via the sqrt factor makes convergence slower than Gauss-Legendre. Increase \(n\) for smooth functions.
Can a equal b? Yes; the \((b-a)/2\) factor makes the result 0. If \(a\) is greater than \(b\), the sign flips automatically.
What if the function blows up at the limits? Nodes lie strictly inside the interval, so endpoint singularities are usually avoided, but an undefined value at any node yields a non-finite result.