diff --git a/Homework2/README.md b/Homework2/README.md index 1b8bef2..b1f3f80 100644 --- a/Homework2/README.md +++ b/Homework2/README.md @@ -1,112 +1,112 @@ # SP4E - Homework 2 ---- ## General Info This file provides a brief documentation and information related to the second Homework of the course "Scientific Programming for Engineers", fall 2019. This homework is done by **O. Ashtari** and **A. Sieber**. Last update: 10.30.2019 ---- ## Project Description The aim of this project is to implement a familly of objects intended to compute two types of series: an arithmetic series and a series to approximate the value of pi number. The user can then decide how to dump the results by either printing them to the screen or writing them to a file. If the later option is chosen, a python file is available to plot the results stored in the file. ---- ## Requirements ---- ## Installation ---- ## Running ### Post-Processing with Python -The idea was writing mother classes as interfaces first. This task was done at the exercise session: structure of two classes `Series` and `DumperSeries`, including their virtual functions, was formed and written. To be abale to work remotely, each of us took one of the daughters of `Series` (namely `compute_arithmetic` and `compute_pi`) and one of the daughters of `DumperSeries` (namely `PrintSeries` and `WriteSeries`) to work on. Moreover, two other major tasks of writing a python script for visualization and modifying `Series` class to avoid re-calculations were split between authors. Each of us developed his own part and worked on his own `main.cc`. Finally, `main`s were merged and the project reviewed. +A 'output_reader.py' post-processing routine is implemented in the `src` folder. It is intended to plot the series data written to file. idea was writing mother classes as interfaces first. This task was done at the exercise session: structure of two classes `Series` and `DumperSeries`, including their virtual functions, was formed and written. To be abale to work remotely, each of us took one of the daughters of `Series` (namely `compute_arithmetic` and `compute_pi`) and one of the daughters of `DumperSeries` (namely `PrintSeries` and `WriteSeries`) to work on. Moreover, two other major tasks of writing a python script for visualization and modifying `Series` class to avoid re-calculations were split between authors. Each of us developed his own part and worked on his own `main.cc`. Finally, `main`s were merged and the project reviewed. ---- ## Work separtion between the authors The idea was writing mother classes as interfaces first. This task was done at the exercise session: structure of two classes `Series` and `DumperSeries`, including their virtual functions, was formed and written. To be abale to work remotely, each of us took one of the daughters of `Series` (namely `compute_arithmetic` and `compute_pi`) and one of the daughters of `DumperSeries` (namely `PrintSeries` and `WriteSeries`) to work on. Moreover, two other major tasks of writing a python script for visualization and modifying `Series` class to avoid re-calculations were split between authors. Each of us developed his own part and worked on his own `main.cc`. Finally, `main`s were merged and the project reviewed. ---- ## Concluding remarks ### Complexity of the program #### Arithmetic Series In the arithmetic series, summing from 1 to N needs N adding (+) operations, thus to print or write the result for different values of N from 1 to m, number of operations will be: ``` write num. of operations --- ------------------ 1 1 2 2 3 3 4 4 m m --- ------------------ sum1: m*(m+1)/2 ``` However, if we keep track of the latest N as well as the corresponding value of summation, the program needs to only add one term to the available value. So, number of operations will be: ``` write num. of operations --- ------------------ 1 1 2 1 3 1 4 1 m 1 --- ------------------ sum2: m ``` Therefore, for a large m the ratio `sum1/sum2` tends to `0.5*m`. #### PI Series For pi calculation, the problem is more complicated. to add each term like `1.0/(i*i)` to the summation, one multiplying operation (*), one inversion operation (/), and one adding operation (+) (totally three operations) is required. Finally, to clculate the approximation for pi, square root of the summation multiplied by 6 is returned, which means two more operations. Hence, number of operations will be: ``` write num. of operations --- ------------------ 1 1*(3)+2 2 2*(3)+2 3 3*(3)+2 4 4*(3)+2 m m*(3)+2 --- ------------------ sum2: m*(3*m+7)/2 ``` However, if we keep track of the latest N as well as the corresponding value of summation (without square root), the program needs to only add one term to the available value (three operations), multiply the result by 6, then claculate the square root. So, number of operations will be: ``` write num. of operations --- ------------------ 1 3+2=5 2 3+2=5 3 3+2=5 4 3+2=5 m 3+2=5 --- ------------------ sum2: 5*m ``` Therefore, for a large m the ratio of `sum1/sum2` tends to `0.3*m`. ### Re-calculations vs. round-off errors ----