This algorithm help compute the sum formula of known function.
python .\sumfor.py -h
Output:
usage: sumfor.py [-h] [-f FORMULA] [-v] [-s START] [-t STEP]
optional arguments:
-h, --help show this help message and exit
-f FORMULA, --formula FORMULA
Sum formula of function
-v, --version show version
-s START, --start START
Start point (default = 1)
-t STEP, --step STEP Step (default = 1)
To use the algorithm, use the following syntax:
python .\sumfor.py -f <formula input> -s <start point> -t <step>
The form of the input formula is a dictionary string with keys being the exponent and the values being the coefficient of that exponent. Example input form of '{0:1,2:-2/3,3:1}'
(dictionary's keys order isn't matter).
For example, we have to compute the sum formula of the
Running algorithm by the following syntax to find the sum formula.
python .\sumfor.py -f '{3:1,2:-2,0:1}'
Result:
+2/3*x^1-3/4*x^2-1/6*x^3+1/4*x^4
So the sum formula of
It means:
If we need to compute the sum formula of the
Similarly, we execute the following syntax:
python .\sumfor.py -f '{2:1,0:1}' -s -1
Output:
3*x^0+7/6*x^1+1/2*x^2+1/3*x^3
Mean:
Were we have to find a Hit Sum Function following:
It means calculating the sum of formula
python .\sumfor.py -f '{3:1,2:-2,0:1}' -s -1 -t 2
Output:
-13/8*x^0-1/6*x^1-1/2*x^2+1/6*x^3+1/8*x^4
That mean:
$$\left. {{S_2}} \right|{{ - 1}}^x\left( {{x^3} - 2{x^2} + 1} \right) = \frac{{ - 13}}{8} - \frac{1}{6}{x^1} - \frac{1}{2}{x^2} + \frac{1}{6}{x^3} + \frac{1}{8}{x^4}$$
Base on the Triagle matrix of polinomial sum was created before. Apply a simple rule about the formula for the sum of sum functions:
-
With
$k_0,k_1,\ldots,k_n$ are the coefficients of the corresponding exponent. -
$\sum {{x^0}},\sum {{x^1}},\ldots,\sum {{x^n}}$ can be computed easily in matrix the Triagle matrix.
- Processing input data
- Determine the largest power exponent
- Multiply coefficients by the corresponding sum formula
- Add the sum formulas together
The Hit Sum Function is just the generality form of the Sigma Sum Function with the additional element is the step.
With the step equal to 1, Hit Sum Function is Sigma Sum.
$$\left. {{S_1}} \right|a^bf\left( x \right) = \sum\limits{x = a}^b {f(x)}$$
To calculate the Hit Sum Function, it is necessary to use the step conversion rule of the Hit Sum Function to convert it to a Sigma Sum Function.
The step conversion rule is:
$$\left. {{S_n}} \right|a^bf(x) = \left. {{S_m}} \right|{_{a.\frac{m}{n}}}^{^{b.\frac{m}{n}}}f(x.\frac{n}{m})$$
Therefore,
$$\left. {{S_n}} \right|a^bf(x) = \sum\limits{_{\frac{a}{n}}}^{\frac{x}{n}} {f(n.x)}$$
From here we can calculate the rule as mentioned in the basic section and then change the variable
- Formal Regression: from the value points, regression to the polynomial function that generates those values