Skip to content
DeepForgeby svx
All problems
MediumCalculusca-298

Gauss-Legendre 3-Point Integral

Problem

Three-point Gauss-Legendre quadrature on [-1, 1] evaluates a polynomial at the nodes -sqrt(3/5), 0, sqrt(3/5) with weights 5/9, 8/9, 5/9.

Given polynomial coefficients in ascending order, return the quadrature estimate.

Hint

Weighted sum of the polynomial at the three symmetric nodes.

Test cases

case 1
in: [[0,0,1]]
expected: 0.6666666666666667
case 2
in: [[1,2,3]]
expected: 4.000000000000001
case 3
in: [[0,1,0,0,0,1]]
expected: 0
Starter codePython
def gauss_legendre_3_point(coeffs):
    # Your code here
    pass

3 test cases · run your code against them in the editor