GithubHelp home page GithubHelp logo

approximation's Introduction

approximation

Approximation of points by a polynomial of arbitrary power

Usage

Main functions:

  1. approximate
    • Arguments:

      1. x: list — coordinates of points on the x-axis
      2. y: list — coordinates of points on the x-axis
      3. p: int — power of the polynomial
    • Returns:

      1. polynomial_coefficients: list
        The obtained coefficients are from the smallest to the largest power.
        Example:
        If you get these coefficients: [2.0, 3.0, 4.0]
        This means that the polynom will look like this:
        2x^0 + 3x^1 + 4x^2
    • Notes:

      1. len(x) == len(y) must be True.
        Else you will get an error!
  2. create_polynom
    • Argument:

      1. polynomial_coefficients: list coefficients of the polynom.
        Obtained from the approximate
    • Returns:

      1. A polynom.
        Example: 4x^2 + 3x^1 + 2

Code Example:

from approximation import create_polynom, approximate


if __name__ == "__main__":
    print("Some example cases:")

    x = [1, 2, 3]
    y = [2, 5, 10]
    p = 2
    print(f"\nCase 1:\nx = {x},\ny = {y},\np = {p}\nPolynom: {create_polynom( approximate(x, y, p) )}")

    x = [-2, -1, 0, 1, 2]
    y = [0, 5, 0, 10, 4]
    p = 4
    print(f"\nCase 2:\nx = {x},\ny = {y},\np = {p}\nPolynom: {create_polynom( approximate(x, y, p) )}")

    x = [-3, -2, -1, 0, 1, 2]
    y = [-10, 0, 5, 0, 10, 4]
    p = 5
    print(f"\nCase 3:\nx = {x},\ny = {y},\np = {p}\nPolynom: {create_polynom( approximate(x, y, p) )}")

approximation's People

Contributors

maximzayats avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.