08-Oct-2025 14:09:31 quadrature_least_squares_test(): MATLAB/Octave version 6.4.0 Test quadrature_least_squares(). quadrature_least_squares_test01(): weights_ls() computes the weights for a least squares quadrature rule. W1 = classical Newton Cotes weights, N = 5 W2 = least squares weights, D = 4, N = 5 I X(i) W1(i) W2(i) 1 -1.0000 0.155556 0.155556 2 -0.5000 0.711111 0.711111 3 0.0000 0.266667 0.266667 4 0.5000 0.711111 0.711111 5 1.0000 0.155556 0.155556 W1 = classical Newton Cotes weights, N = 9 W2 = least squares weights, D = 4, N = 9 I X(i) W1(i) W2(i) 1 -1.0000 0.0697707 0.0960373 2 -0.7500 0.415379 0.270085 3 -0.5000 -0.0654674 0.280963 4 -0.2500 0.740459 0.242113 5 0.0000 -0.320282 0.221601 6 0.2500 0.740459 0.242113 7 0.5000 -0.0654674 0.280963 8 0.7500 0.415379 0.270085 9 1.0000 0.0697707 0.0960373 quadrature_least_squares_test02(): weights_ls() computes the weights for a least squares quadrature rule. Pick 50 random values in [-1,+1]. Compare Monte Carlo (equal weight) integral estimate to least squares estimates of degree D = 0, 1, 2, 3, 4. For low values of D, the least squares estimate improves. As D increases, the estimate can deteriorate. Rule Estimate Error MC 2.63014 0.116658 LS 0 2.63014 0.116658 LS 1 2.62944 0.117363 LS 2 2.52689 0.21991 LS 3 2.53054 0.216259 LS 4 2.57973 0.167068 LS 5 2.67322 0.0735837 LS 6 2.60139 0.145413 LS 7 2.48999 0.256814 LS 8 2.83414 0.0873371 LS 9 3.1205 0.373699 LS10 2.46709 0.279715 LS11 2.22062 0.52618 LS12 3.11275 0.365946 LS13 3.82433 1.07752 LS14 2.4617 0.285099 LS15 1.30588 1.44092 EXACT 2.7468 0 quadrature_least_squares_test(): Normal end of execution. 08-Oct-2025 14:09:31