Commit 694b3e5c authored by Ignacio Labarca Figueroa's avatar Ignacio Labarca Figueroa

Feedback Ex.2

parent 73642cc8
#include <iostream>
#include <vector>
/* Ignacio:
Looks good! Well done :)
Please register or sign in to reply
For the static approach:
Consider the case n > n_max
  • You mean only to print out something like "Insert a number n <= n_max". I just committed a change with this line.

Please register or sign in to reply
*/
int main() {
int n_max = 10;
......
......@@ -3,6 +3,12 @@
#include <cassert>
#define _USE_MATH_DEFINES
/* Ignacio:
Did you test your Simpson rule?
  • I added a test_function that checks the integral from 0 to 1 of x*(1-x) and it seems good to me. Am I missing something?

Please register or sign in to reply
It seems that something is wrong when N is odd.
*/
double integration(double a, double b, int N, double (*my_func)(double x)) {
assert(N>0);
assert(b > a);
......@@ -20,4 +26,3 @@ double integration(double a, double b, int N, double (*my_func)(double x)) {
result += my_func(b);
return result*delta/3.0;
}
/* Ignacio:
Use const when it is possible!
Please register or sign in to reply
All of the arguments should be of this type
*/
double integration(double a, double b, int N, double (*my_func)(double x));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment