Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gaussian_quadrature #662

Closed
wants to merge 13 commits into from
Closed

Conversation

todi-mih
Copy link

This algorithm implements Gaussian Quadrature, a numerical integration technique, to approximate the definite integral of a given function over a specified interval. The gaussian_quadrature function takes the interval [a, b], a function f(x) to integrate, and the number of points to use in the quadrature.

@codecov-commenter
Copy link

codecov-commenter commented Jan 18, 2024

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (338c386) 94.66% compared to head (1d2e6f9) 94.65%.

Files Patch % Lines
src/math/gaussian_quadrature.rs 92.30% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #662      +/-   ##
==========================================
- Coverage   94.66%   94.65%   -0.01%     
==========================================
  Files         290      291       +1     
  Lines       23161    23200      +39     
==========================================
+ Hits        21925    21961      +36     
- Misses       1236     1239       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@todi-mih
Copy link
Author

sorry about all the commits guys i was rushing

Comment on lines +17 to +28
fn get_gaussian_quadrature_points_weights(num_points: usize) -> (Vec<f64>, Vec<f64>) {
// Hardcoded values for Gaussian Quadrature points and weights
match num_points {
1 => (vec![0.0], vec![2.0]),
2 => (vec![-1.0 / 3.0, 1.0 / 3.0], vec![1.0, 1.0]),
3 => (
vec![-0.7745966692414834, 0.0, 0.7745966692414834],
vec![0.5555555555555556, 0.8888888888888888, 0.5555555555555556],
),
_ => unimplemented!("Gaussian Quadrature not implemented for this number of points"),
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would highly suggest to generalize it for any number of points/order. It also seems that it uses Legendre polynomials. It also could be more general.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm,i am kinda cofused here ,can you please tell me more information about what i should add?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's start with basic stuff: it would be great to call gaussian_quadrature with order being 20 and obtain a valid result.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, i see what you mean,sorry for being late ,been kinda busy,thanks for the explanation my man.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i keep trying to add the options but the result just keeps getting more complicated and wrong ,my purpose in here wat to give an example of another numerical approach to integrals,after some research 3 is the most command order for this method (and most accurate) ,mind if i leave it like this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should go for the general case.

@vil02
Copy link
Member

vil02 commented Jan 26, 2024

@todi-mih are you still working on this? If not, please close this PR.

Copy link

This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Feb 26, 2024
Copy link

github-actions bot commented Mar 4, 2024

Please ping one of the maintainers once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to ask for help in our Gitter channel. Thank you for your contributions!

@github-actions github-actions bot closed this Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants