## How to run the program ### Compile and run program with the following commands ``` mkdir build/ cd build cmake .. make ./src/main arg1 arg2 arg3 arg4 ``` * `arg1` can be either `pi` or `arithmetic` depending on what you want to calculate * `arg2` can be either `write` or `print` depending on if you want to write to file or print to screen * `arg3` can be either any integer representing precision of output * `arg4` can be either `comma` or `pipe` or `space` (anything other than `comma` or `pipe` will be interpreted as `space`) and represents the separator used in writing to file. When printing to screen only `space` is used as it does not make sense (in terms of readability) to use any other separator when printing to screen Plotting of convergence of the pi calculation can be acccomplished by running python script `plotting.py` in the `homework2/src/` directory as follows: `python3 plotting.py filename` where filename is the name of the output file (e.g., `out.csv` which is located in the `build/` directory) ### Example In `homework2/build/src/`: `./main pi write 8 comma` or, for example, `./main arithmetic write 10 pipe` In `homework2/src/`: `python3 plotting.py out.csv` or, for example, `python3 plotting.py out.psv` ### Notes * Note that `WriteSeries` has been removed due to `PrintSeries` is now able to both print to screen and write to file. Thus no need for `WriteSeries` any more as all functionality is in `PrintSeries`. You can check out the git history if you're interested. * Since `Series`, `ComputePi` and `ComputeArithmetic` are rather small classes (i.e., have simple member functions) we chose not to separate declarations and definitions into `.hh` and `.cc` file for readability. In other words, the definitions of the member functions are found in the respective `.hh` files. ## Answer to Exercise 2.1: What is the best way/strategy to divide the work among yourselves? - Define the subsets of parts which can be (mostly) independent and divide them in a suitable way between each members. Work on the independent parts (1) of the same task/project (2). (1) : To minimize overlaps/collisions ( // parallel process) (2) : To be able to debug and adapt regularly the growing project and understand the problems of each others. ( // iterative process) - Brainstorm, discuss and think (with+without the members) on how to solve the most complexe tasks/parts. - Assemble and adapt each piece of the project step by step. ### Answer to Exercise 5.1: Evaluate the previous global complexity of your program. From the main.cc file, we can observe that we execute 1x the method compute and 1x the method print_obj.dump(). The first one has a complexity of O(n) and the second has a complexity of O(n^2*frequency) in the first implementation of the code and O(n*frequency) in the second. n : is the size of the loop where operations are done frequency : is the number of term we want to print (i.e. 1/2 if we want to skip next member of the serie after each member). T(n) = O(n^2) ### Answer to Exercise 5.4: Evaluate the new global complexity of your program. T(n) = O(n) ### Answer to Exercise 5.5: If you want to reduce the rounding errors over floating point operation by summing terms reversely, ### What is the best complexity you can achieve ? T(n) = O(n) Reversing the summation order to reduce the rounding errors will not change the complexity. The min complexity that is possible to achieve is then of the order of O(n).