matlab program in 3- piont guassian quadrature to evaluate integral f(x)= sin(x/10)
조회 수: 4 (최근 30일)
이전 댓글 표시
답변 (1개)
Umang Pandey
2023년 10월 5일
As per my understanding it appears that you are trying to evaluate the integral of sin(x/10) using Gaussian quadrature 3-point formula.
Here’s how you can do it:
% Define the function
f = @(x) sin(x/10);
% Define the integration interval
a = 0; % Lower limit of integration
b = pi; % Upper limit of integration
% Define the 3-point Gaussian quadrature points and weights
x = [-sqrt(3/5), 0, sqrt(3/5)];
w = [5/9, 8/9, 5/9];
% Map the Gaussian quadrature points from the interval [-1, 1] to [a, b]
x_mapped = 0.5 * ((b - a) * x + a + b);
% Evaluate the function at the mapped Gaussian quadrature points
f_values = f(x_mapped);
% Calculate the integral using 3-point Gaussian quadrature
integral = ((b - a) / 2) * sum(w .* f_values);
% Display the result
disp(integral);
Best,
Umang
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!