diff --git a/README.md b/README.md
index 03801bf..0b6c7a2 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,4 @@
+
![Boost.Real](doc/other/logo/logo.png)
Boost.Real numerical data type for real numbers representation using range arithmetic.
@@ -19,21 +20,28 @@ Several times, when dealing with complex mathematical calculus, numerical errors
Another major problem when dealing with real numbers is the representation of the irrational number as the number π or eπ, they are not handled by the native number data types causing limitations when calculations are based on those numbers. Normally we define a truncation of those numbers that are good enough for our purposes, but many times, the needed precision depends on the operation to do and to the composition of multiple operations, therefore, we are unable to determine which is the correct precision until we run the program.
+There are a lot of libraries and tools available where we can always specify the initial precision to be used for calculations but in case of problems stated above, where we do not know the precision prior to calculations, our calculations can produce wrong or inconclusive results when precision is less than required or we will use too high precision. So, there should be a tool or library which performs all these operations and controls the precision according to requirements.
+
### The boost::real solution
-Boost::real is a real number representation data type that address the mentioned issues using range arithmetic [1] and defining the precision as dynamical to be determined in run-time. The main goal of this data type is to represent a real number x as a program that returns a finite or infinite set of intervals containing the number x x(k) = [mk - ek, mk + ek], K ∈ N ≥ 0, ek ≥ 0. Where K1 < K2 ⇒ |x(k2)| < |x(k1)|. For this purposes, any Boost::real number has a precision const iterator that iterates the serie of intervals representing the number. The intervals within the serie are sorted from larger to smaller, thus, each time the iterator is increased, the number precision increases due the new calculated interval is smaller than the previous one until the interval is the number itself (if possible).
+Boost::real is a real number representation data type that address the mentioned issues using range arithmetic [1] and defining the precision as dynamical to be determined in run-time. The main goal of this data type is to represent a real number x as a program that returns a finite or infinite set of intervals containing the number x x(k) = [mk - ek, mk + ek], K ∈ N ≥ 0, ek ≥ 0. Where K1 < K2 ⇒ |x(k2)| < |x(k1)|. For this purposes, any Boost::real number has a precision const iterator that iterates over the series of intervals representing the number. The size of intervals within the series are sorted from larger to smaller, thus, each time the iterator is increased, the number precision increases due the new calculated interval is smaller than the previous one until the interval is the number itself (if possible).
Also, to allow representing irrational numbers as π or eπ, boost::real has a constructor that takes as parameter a function pointer, functor (function object with the operator ()) or lambda expression that for any integer n > 0, the function returns the n-th digit of the represented number. For example, the number 1/3 can easily be represented by a program that for any input n > 0, the function returns 3.
-Although it may seem that it is similar to several range/interval arithematic libraries like boost::interval arithematic but goals and features of this library are much more different. We provide a data type which can represent all computable real number, and the goal is to evluate the expression whose required precision for evaluation is unknown in advance. The implementation of interval arithematic comes because every number is represented as a function which returns an interval containing that number, and interval keeps on getting more precise and close to number as we increase the precision of number. In abstract, this is not an pure interval arithematic library, the goal of this library, which is described above will keep on getting clear as you dive more into libray, is to represent numbers using intervals and adjust the precision according to requrement of calculations.
+Although it may seem that it is similar to several range/interval arithematic libraries like boost::interval arithematic but goals and features of this library are much more different. We provide a data type which can represent all computable real numbers, and the goal is to evaluate the expression whose required precision for evaluation is unknown in advance. The implementation of interval arithematic comes because every number is represented as a function which returns an interval containing that number, and interval keeps on getting more precise and close to number as we increase the precision of number. In abstract, this is not an pure interval arithematic library, the goal of this library, which is described above will keep on getting clear as you dive more into libray, is to represent numbers using intervals and adjust the precision according to requrement of calculations.
## The boost::real numbers representation
In boost::real, a number has one of the next three representations:
1. Explicit number: A number is a vector of digits sorted as in the number natural representation. To determine where the integer part ends and the fractional part starts, an integer is used as the exponent of a floating point number and determines where the integer part start and the fractional ends. Also a boolean is used to set the number as positive (True) or negative (False)
2. Algorithmic number: This representation is equal to the Explicit number but instead of using a vector of digits, a lambda function must be provided. The lambda function takes an unsigned integer "n" as parameter and returns the n-th digit of the number.
-3. A number is a composition of two numbers related by an operator (+, -, *), the number creates pointers to the operands and each time the number is used, the operation is evaluated to return the result.
+3. Operation number: A number is a composition of two numbers related by an operator (+, -, *), the number creates pointers to the operands and each time the number is used, the operation is evaluated to return the result.
+4. Integer number: Specific data type for integer type numbers. The use and benefit of this specified type will be explained later.
+5. Rational number: Specific data type to represent rational numbers (in a/b form). It also has some representational and performance benefits which will be explained later, after general structure and working of library is explained.
-Because of the third representation type, a number resulting from a complex calculus is a binary tree where each internal vertex is an operation and the vertex children are its operands. The tree leaves are those numbers represented by either (1) or (2) while the internal vertex are those numbers represented by (3). More information about the used number representation can be found in [3]
+Because of the third representation type, a number resulting from a complex calculus is a binary tree where each internal vertex is an operation and the vertex children are its operands. The tree leaves are those numbers represented by either (1) or (2) or (4) or (5) while the internal vertex are those numbers represented by (3). More information about the used number representation can be found in [3]
+#### Use of specialized types for integer and rational numbers:
+1. They do not create an operation tree or real::operation number when we do any operation between two integer or rational numbers. So, reptitive calculations involving integer and rational number, user should user these specific types so no complex tree is generated. Any operation between two rational or integer numbers will be simply a rational or integer number which is resultant to those two. As at every precision integers are same, there is no need to make precision iterations for those calculations. So, **user should use integer and rational number for small repetitive calculations to optimize space and reduce complexity but should not use them for very large and complex calulcations because they do whole calculation in one go so it may become unnecessary complex expressions to do calculations at full precision when a small precision can give results.**
+2. Some rational numbers can not be represented by a simple string, like 1/3, so we can represent them using this data type. They can be represented as a real operation number between two explicit numbers also.
## The boost::real precision iterator.
The boost::real::const_precision_iterator is a forward iterator [4] that iterates through the number interval precisions. The iterator returns two numbers, a lower and an upper boundary that represent the [mk - ek, mk + ek] limits of the number approximation interval for a given precision. Each time the iterator is incremented, the interval approximation_interval is decreased and a new interval with a better precision is obtained. Normally, there is no need to interact with the precision iterator and it is used by the boost::real operators <<, < and >.
@@ -42,40 +50,48 @@ The boost::real::const_precision_iterator is a forward iterator [4] that iterate
### Constructors and destructors
1. boost::real(const std::string& number)
- 2. boost::real(const initializer_vector digits)
- 3. boost::real(const initializer_vector digits, bool positive)
- 4. boost::real(const initializer_vector digits, int exponent)
- 5. boost::real(const initializer_vector digits, int exponent, bool positive)
- 6. boost::real((unsigned int) -> int digits, int exponent)
- 7. boost::real((unsigned int) -> int digits, int exponent, bool positive)
- 8. boost::real(const boost::real& x)
- 9. boost::~real()
+ 2. boost::real(const std::string& number, std::string type)
+ 3. boost::real(const std::string& number, boost::real::TYPE)
+ 4. boost::real(const initializer_vector digits)
+ 5. boost::real(const initializer_vector digits, bool positive)
+ 6. boost::real(const initializer_vector digits, int exponent)
+ 7. boost::real(const initializer_vector digits, int exponent, bool positive)
+ 8. boost::real((unsigned int) -> int digits, int exponent)
+ 9. boost::real((unsigned int) -> int digits, int exponent, bool positive)
+ 10. boost::real(const boost::real& x)
+ 11. boost::~real()
> (1) **String constructor**
-> Creates a real instance by parsing the string. The string must have a valid number, in other case, the constructor will throw an boost::real::invalid_string_number_exception exception.
+> Creates a real instance by parsing the string. The string must have a valid number, in other case, the constructor will throw an boost::real::invalid_string_number_exception exception. Constructs a number of type real::explicit.
>
-> (2) **Initializer list constructor**
+>(2) **String Constructor (with type of number passed as string)**
+> Creates a real instances of type "explicit", "integer", or "rational" based by parsing the string. The string "type" must have a valid type ("explicit"/"integer"/"rational") and number represented by string should also be a valid number.
+>
+> (3) **String Constructor (with type of number passed as enumerator object)**
+> Creates a real instance of type "explicit", "integer", or "rational" based on type passed by enumerator boost::real::TYPE (TYPE::EXPLICIT/TYPE::INTEGER/TYPE::RATIONAL) and number given by string.
+>
+> (4) **Initializer list constructor**
> Creates a real instance that represents an integer number where all the digits numbers are form the integer part in the same order.
>
-> (3) **Signed initializer list constructor**
+> (5) **Signed initializer list constructor**
>Creates a real instance that represents the number where the positive parameter is used to set the number sign and the elements of the digits parameter list are the number digits in the same order.
>
-> (4) **Initializer list constructor with exponent**
+> (6) **Initializer list constructor with exponent**
> Creates a real instance that represents the number where the exponent is used to set the number integer part and the elements of the digits list are the digits the number in the same order.
>
-> (5) **Initializer list constructor with exponent and sign**
+> (7) **Initializer list constructor with exponent and sign**
> Creates a real instance that represents the number where the exponent is used to set the number integer part and the elements of the digits list are the digits the number in the same order. This constructor uses the sign to determine if the number is positive or negative.
>
-> (6) **Lambda function constructor with exponent**
+> (8) **Lambda function constructor with exponent**
> Creates a real instance that represents the number where the exponent is used to set the number integer part and the lambda function digits is used to know the number digit, this function returns the n-th number digit.
>
-> (7) **Lambda function constructor with exponent and sign**
+> (9) **Lambda function constructor with exponent and sign**
> Creates a real instance that represents the number where the exponent is used to set the number integer part and the lambda function digits is used to know the number digit, this function returns the n-th number digit. This constructor uses the sign to determine if the number is positive or negative.
>
-> (8) **Copy constructor**
+> (10) **Copy constructor**
> Creates a copy of the number x, if the number is an operation, then, the constructor creates new copies of the x operands.
>
-> (9) **Default destructor**
+> (11) **Default destructor**
> If the number is an operator, the destructor destroys its operands.
### Operators
@@ -132,6 +148,32 @@ The boost::real::const_precision_iterator is a forward iterator [4] that iterate
> (4) Sets a new maximum precision. If the set maximum precision is zero, the static default maximum precision will be used instead.
+### Some Functions
+ 1. boost::real power(boost::real number, boost::real power)
+ 2. boost::real sqrt(boost::real number)
+ 3. boost::real exp(boost::real number)
+ 4. boost::real log(boost::real number)
+ 5. boost::real sin(boost::real number)
+ 6. boost::real cos(boost::real number)
+ 7. boost::real tan(boost::real number)
+ 8. boost::real sec(boost::real number)
+ 9. boost::real cosec(boost::real number)
+ 10.boost::real cot(boost::real number)
+>(1) **Power function ( ab )**
+> Takes number and power as input and returns number power as output. Fractional power of a negative number is not supported, as the result is a imaginary number (of form a+ib) and imaginary numbers are not supported in the library. The function will throw "non_integral_power_of_negative_number" exception.
+>
+>(2) **Square Root function**
+> This functions returns square root of the number, number 1/2. Here also, if we feed a negative number, the functions throws an error. As the square root is basically number raised to power 0.5, which is an fractional power so if the number is negative, then the result would be an imaginary number. If negative number is fed to functions, it throws "sqrt_not_defined_for_negative_number" error.
+>
+>(3) **Exponent function ( ex )**
+> Gives exponent of the number fed or return enumber.
+>
+>(4) **Logarithmic funtion**
+> Return loge(number). The logarithm only supports positive number or we can say non negative number (-∞, 0] are out of domain, so if a non negative number is fed then function throws "logarithm_not_defined_for_non_positive_number" error.
+>
+>(5) - (10) **Trigonometric functions**
+> These are trigonometric functions, and their name corresponds to the trigonometric function which they represent.
+
## boost::real::const_precision_iterator interface
### Constructors
@@ -161,6 +203,8 @@ The boost::real::const_precision_iterator is a forward iterator [4] that iterate
## Examples
+### Example 1
+Defining simple real explicit numbers and creating an operation between them.
```cpp
#include
#include
@@ -214,6 +258,110 @@ d: [0.99999899999999999999999999999999999999999999999999999999999999999999999999
g: [0.9999979999999999999999999999999999999999999999999999999999999999999999999999999999999999991629249303, 0.99999799999999999999999999999999999999999999999999999999999999999999999999999999999999999965383428597]
h: [0.00000099999999999999999999999999999999999999999999999999999999999999999999999999999999999968217350127, 0.00000100000000000000000000000000000000000000000000000000000000000000000000000000000000000066399221262]
```
+### Example 2
+Use of specialized data types for integer and rational types of numbers.
+```cpp
+#include
+#include
+#include
+
+int main(){
+ boost::real::real a("4/5", boost::real::TYPE::RATIONAL);
+ boost::real::real b("5", "integer");
+ boost::real::real c = a * b;
+ std::cout<<"(4/5)*5 = "<
+#include
+#include
+
+using real = boost::real::real;
+using type = boost::real::TYPE;
+
+int main(){
+ real a("2", type::INTEGER); // declared as integer data type
+ real b("2"); // declare as real explicit number
+ real c = real::power(a, b);
+ std::cout<<"2^2 = "<