Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace myfuncs {
- // calculate the power
- double pow(double x, int n) {
- double result = 1;
- for (int i = 0; i < n; i++) {
- result *= x;
- }
- return result;
- }
- double gaussian(double x, double eps) {
- double result = 0;
- double term = 1;
- int n = 0;
- while (term > eps) {
- term = pow(x, 2 * n + 1) / (2 * n + 1);
- result += term;
- n++;
- }
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement