matlab program in 3- piont guassian quadrature to evaluate integral f(x)= sin(x/10)

조회 수: 4 (최근 30일)
Rikesh
Rikesh 2022년 8월 10일
답변: Umang Pandey 2023년 10월 5일
n/a

답변 (1개)

Umang Pandey
Umang Pandey 2023년 10월 5일
Hi @Rikesh,
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

카테고리

Help CenterFile 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!

Translated by