Giter VIP home page Giter VIP logo

forposum's Introduction

Formula of power sum

This algorithm helps to generate the sum equation of the power function:

Usage

usage: posum.py [-h] [-d DEGREE] [-v] [-s SHOW]

optional arguments:
  -h, --help            show this help message and exit
  -d DEGREE, --degree DEGREE
  -v, --version         show version
  -s SHOW, --show SHOW  only showing the formula (f), triagle matrix (m) or both (b)[default]?

If we want to know the equation of the sum function of the nth power, we run the python script and enter the degree n of the sum function.

python posum.py -d <the degree n>

The result consists of the power sum formula of n degree and the triangle matrix. Besides, wanting to show either. Let's use the argument -s

Example

Need help to use

python posum.py -h

To show version of algorithm.

python posum.py -v

For example, when we want to find the sum function of the power of 6, we run the command and enter the degree of the function as 6.

#input
python posum.py -d 6

#output
Sum formula of x^ 6 is:  +1/42*x^1+0*x^2-1/6*x^3+0*x^4+1/2*x^5+1/2*x^6+1/7*x^7

Matrix triagle is:

         1      2     3     4    5    6    7

  0      1
  1    1/2    1/2
  2    1/6    1/2   1/3
  3      0    1/4   1/2   1/4
  4  -1/30      0   1/3   1/2  1/5
  5      0  -1/12     0  5/12  1/2  1/6
  6   1/42      0  -1/6     0  1/2  1/2  1/7

So the equation sum of the power of the sixth power has the form:

The principle of the algorithm

The algorithm works by forming a triangular matrix with each value of the matrix being a coefficient of the sum equation. The coefficients of the equation of degree n are the values of the n-th row of the matrix. Values of the matrix is calculated according to the system of equations:

$$\left{ \begin{array}{l} {a_{01}} = 1\ {a_{ij}} = \frac{i}{j} \times {a_{{(i - 1)(j - 1)}}} {\rm{ ,}}\forall i\ge 1,\forall j\ge 2\ \sum\limits{k = 1}^j {{a_{ik}} = 1{\rm{ ,}}\forall i,j} \end{array} \right.$$

Application

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.