"Comparision of three quadrature formulas
'<hr/>
'Function -'f(x) = sqrt(1 - x^2)
'Theoretical value of the integral - 'I = π/2
'Number of nodes -'n = 5
'<h4>Boole′s rule (Newton-Cotes for n = 4)</h4>
'<hr/>
'Step -'h = 0.5
'<p><strong>Abscissas,  Ordinates</strong></p>
x_1 = -1',  'y_1 = f(x_1)
x_2 = -0.5', 'y_2 = f(x_2)
x_3 = 0',  'y_3 = f(x_3)
'<p><strong>Integral</strong></p>
'Value -'I_B = 2*h/45*(2*7*y_1 + 2*32*y_2 + 12*y_3)
'Error -'δ_B = abs(I_B - I)/I|%
#hide
PlotWidth = 300
PlotHeight = 150
#show
'<p><strong>Scheme</strong></p>
$Plot{f(x) & x_1|0 & x_2|0 & x_3|0 & -x_2|0 & -x_1|0 @ x = -1 : 1}
'<h4>Gauss-Legendre rule</h4>
'<hr/>
'<p><strong>Abscissas, Ordinates and weights</strong></p>
x_1 = -(1/3)*sqrt(5 + 2*sqrt(10/7))', 'y_1 = f(x_1)', 'w_1 = (322 - 13*sqrt(70))/900
x_2 = -(1/3)*sqrt(5 - 2*sqrt(10/7))', 'y_2 = f(x_2)', 'w_2 = (322 + 13*sqrt(70))/900
x_3 = 0','y_3 = f(x_3)','w_3 = 128/225
'<p><strong>Integral</strong></p>
'Value -'I_G = 2*w_1*y_1 + 2*w_2*y_2 + w_3*y_3
'Error -'δ_G = abs(I_G - I)/I|%
'<p><strong>Scheme</strong></p>
$Plot{f(x) & x_1|0 & x_2|0 & x_3|0 & -x_2|0 & -x_1|0 @ x = -1 : 1}
'<h4>Tanh-sinh rule</h4>
'<hr/>
'Boundary of the interval -'t_a = 1
'Step -'h = 2*t_a/(n - 1)
'Parameters -'t(k) = -t_a + (k - 1)*h
'Function for abscissas -'x(k) = tanh(π/2*sinh(t(k)))
'Weight function -'w(k) = π*h*cosh(t(k))/(2*cosh(π/2*sinh(t(k)))^2)
'<p><strong>Abscissas,       Ordinates,         Weights</strong></p>
x_1 = x(1)',  'y_1 = f(x_1)',  'w_1 = w(1)
x_2 = x(2)',  'y_2 = f(x_2)',  'w_2 = w(2)
x_3 = x(3)',      'y_3 = f(x_3)',    'w_3 = w(3)
'<p><strong>Integral</strong></p>
'Value -'I_DE = 2*w_1*y_1 + 2*w_2*y_2 + w_3*y_3
'Error -'δ_DE = abs(I_DE - I)/I|%
'<p><strong>Scheme</strong></p>
$Plot{f(x) & x_1|0 & x_2|0 & x_3|0 & -x_2|0 & -x_1|0 @ x = -1 : 1}
'<h4>Calcpad</h4>
'<hr/>
'Adaptive Tanh-Sinh -'I_ATH = $Integral{f(x) @ x = -1 : 1}
'Error -'δ_ATH = abs(I_ATH - I)/I|%
'Adaptive Gauss-Lobatto -'I_AGL = $Area{f(x) @ x = -1 : 1}
'Error -'δ_AGL = abs(I_AGL - I)/I|%