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
feat: Created composite Simpson's numerical integration method #1773
Conversation
Also created midpoint numerical method for integral approximation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see the comments by @ayaankhan98.
#include <iostream> | ||
#include <cmath> | ||
#include <cstdlib> | ||
#include <cassert> | ||
#include <functional> | ||
#include <map> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a one-line description of what the library/header is for (see the example below).
#include <iostream> /// for IO operations
#include <cassert> /// for assert
* | ||
* Add sample function by replacing one of the f, g, k, l and the assert | ||
* | ||
* @author ggkogkou |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @author ggkogkou | |
* @author [ggkogkou](https://github.com/ggkogkou) |
/** | ||
* @namespace simpson_method | ||
* @brief Contains the Simpson's method implementation | ||
*/ | ||
namespace simpson_method{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | |
* @namespace simpson_method | |
* @brief Contains the Simpson's method implementation | |
*/ | |
namespace simpson_method{ | |
/** | |
* @namespace numerical_methods | |
* @brief Numerical algorithms/methods | |
*/ | |
namespace numerical_methods { | |
/** | |
* @namespace simpson_method | |
* @brief Contains Simpson's method implementation | |
*/ | |
namespace simpson_method { |
* @returns the result of the integration | ||
*/ | ||
double evaluate_by_simpson(int N, double h, double a, std::function<double (double)> func); | ||
} // simspon_method end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} // simspon_method end | |
} // namespace simpson_method | |
} // namespace numerical_methods |
I updated documentation and namespace as asked to |
Co-authored-by: David Leal <[email protected]>
Co-authored-by: David Leal <[email protected]>
Co-authored-by: David Leal <[email protected]>
Co-authored-by: David Leal <[email protected]>
Co-authored-by: David Leal <[email protected]>
Co-authored-by: David Leal <[email protected]>
Changes done |
Co-authored-by: David Leal <[email protected]>
Co-authored-by: David Leal <[email protected]>
Co-authored-by: David Leal <[email protected]>
Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. Please fix the issue below.
test.cpp: In function ‘void test(int, double, double, double, bool)’:
test.cpp:96:87: error: ‘f’ was not declared in this scope; did you mean ‘numerical_methods::simpson_method::f’?
96 | double result_f = numerical_methods::simpson_method::evaluate_by_simpson(N, h, a, f);
| ^
| numerical_methods::simpson_method::f
test.cpp:68:8: note: ‘numerical_methods::simpson_method::f’ declared here
68 | double f(double x){
| ^
test.cpp:100:87: error: ‘g’ was not declared in this scope; did you mean ‘numerical_methods::simpson_method::g’?
100 | double result_g = numerical_methods::simpson_method::evaluate_by_simpson(N, h, a, g);
| ^
| numerical_methods::simpson_method::g
test.cpp:72:8: note: ‘numerical_methods::simpson_method::g’ declared here
72 | double g(double x){
| ^
test.cpp:104:87: error: ‘k’ was not declared in this scope; did you mean ‘numerical_methods::simpson_method::k’?
104 | double result_k = numerical_methods::simpson_method::evaluate_by_simpson(N, h, a, k);
| ^
| numerical_methods::simpson_method::k
test.cpp:76:8: note: ‘numerical_methods::simpson_method::k’ declared here
76 | double k(double x){
| ^
test.cpp:108:87: error: ‘l’ was not declared in this scope; did you mean ‘numerical_methods::simpson_method::l’?
108 | double result_l = numerical_methods::simpson_method::evaluate_by_simpson(N, h, a, l);
| ^
| numerical_methods::simpson_method::l
test.cpp:80:8: note: ‘numerical_methods::simpson_method::l’ declared here
80 | double l(double x){
| ^
shell returned 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything else is looking great!
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description of Change
Created the composite Simpson's numerical method for integrals approximation (wiki: https://en.wikipedia.org/wiki/Simpson%27s_rule#Composite_Simpson's_rule).
Checklist
Notes:
Numerical method for integral evaluation implementation