Giter VIP home page Giter VIP logo

evenly-spaced-piecewise-linear-interpolation-py's Introduction

Evenly-spaced Piecewise Linear Interpolation

This repository features a python script for computing evenly spaced piecewise linear interpolations of mathematical functions represented in the following form:

def func(x):
  return x + x**2 - 1 #replace this with any real-valued mathematical function of x

Discretization Parameters

The code features floats start, end, and delta as discretization parameters.

  • Mathematically, $[start, end]$ is the real interval in which the algorithm limits the input domain of the resulting function to.
  • The float delta denotes the magnitude by which each input point for which the output is directly evaluated differ.
  • If start and end are defined, delta must be chosen so that the maximal index is a natural number. If start or end is defined but not both, along with delta, then the undefined parameter must be defined so that the maximal index is a natural number. The program might not function as intended should the maximal index not be a natural.
  • The execution of max_index() returns the maximal index.
  • The variable start must be strictly smaller than end for any meaningful usage of the program.

Indexing

Any real $x$ corresponds to an index through the following formula

$x = start + index * delta$

Functions relating to indexing

  • index2value(i): Returns the value corresponding to the index $i$ through a direct application of the aforementioned formula.
  • value2index(x): Returns the index corresponding to the value x through a rearrangement of the indexing formula. The inverse function of index2value(i).
  • index2func(i): Returns the function evaluated at the value corresponding to the $i$th index. A composition of func(x) to index2value(i).
  • No value2func(x) is needed given that func(x) is essentially such a function and serves such purpose.

Central functions

  • compute_slopes(): Computes the pertinent slopes for the sake of interpolation, storing values in the global list slopes.
  • slopepoint_func(x): Returns the evaluation of the interpolation at the value of $x$. Computes slopes if empty.

evenly-spaced-piecewise-linear-interpolation-py's People

Contributors

ecsolticia 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.