Giter Site home page Giter Site logo

pychebfun's Introduction

pychebfun - Python Chebyshev Functions

Build Status Coverage Status Python version

About

The Chebfun system is designed to perform fast and accurate functional computations. The system incorporates the use of Chebyshev polynomial expansions, Lagrange interpolation with the barycentric formula, and Clenshaw–Curtis quadrature to perform fast functional evaluation, integration, root-finding, and other operations.

To learn more about pychebfun, have a look at the IPython notebook illustrating the original paper by Battles and Trefethen.

Getting Started

This is a minimal documentation about pychebfun.

As a minimal example, you can run the following:

import numpy as np; from pychebfun import *
# define a function
f = Chebfun.from_function(lambda x:np.tan(x+1/4) + np.cos(10*x**2 + np.exp(np.exp(x))))
# evaluate at some point in [-1, 1]
f(.5)
f(np.linspace(-.5, .5, 200))
# plot it:
plot(f)

Example

One can also use the general constructor chebfun:

f = chebfun(lambda x:np.tan(x+1/4) + np.cos(10*x**2 + np.exp(np.exp(x))))

Note that one can could have defined the function f in a more intuitive manner by

x = Chebfun.identity()
f = np.tan(x+1/4) + np.cos(10*x**2 + np.exp(np.exp(x)))

It is possible to multiply, add, subtract chebfuns between themselves and also with scalars:

g = 2*np.sin(10*np.pi*x)
f+g
1+f
f-g
2*f*g - 1

One can find all the roots of a function with roots:

f.roots() # all the roots of f on [-1, 1]

One can compute the integral of f:

f.sum() # integral of f from -1 to 1
f.dot(g) # integral of f.g from -1 to 1

An arbitrary function can be differentiated and integrated:

f.differentiate() # derivative of f
f.integrate() # primitive of f: ∫_0^x f(y) dy

You can see in this example how to compute the maxima and minima of an arbitrary function by computing the zeros of its derivative. Extrema

One can also have vector coefficients:

def circle(x):
	return np.array([np.cos(np.pi*x), np.sin(np.pi*x)],).T
c = Chebfun.from_function(circle)
plot(c)

Example

If you are interested in experimenting with the innards of chebfun, you should be aware of the following functions:

Chebfun.basis(10) # Chebyshev polynomial of degree 10
Chebfun.from_coeff([0.,1,2]) # Chebfun with prescribed chebcoeffs
Chebfun.interpolation_points(10) # 10 Chebyshev interpolation points in [-1, 1]
Chebfun.polyfit([1.,2]) # compute Chebyshev coefficients given values at Chebyshev points
Chebfun.polyval([1., 2.]) # compute values at Chebyshev points given Chebyshev coefficients

You should also take a look at the examples bundled with this project. Example

The pychebfun project is based on the mathematical work of Battles and Trefethen et. al. yet is optimized to take advantage of the tools in the Numpy/Scipy and Sage libraries. This project is solely for the educational purposes of the owner and is not meant to compete with the Matlab library created by Battles and Trefethen. Any questions regarding the Chebfun package for Matlab should be directed towards the Chebfun team.

Pychebfun was started by Chris Swierczewski from the Applied Mathematics department at the University of Washington in Seattle, Washington, and is currently maintained by Olivier Verdier.

This work is licensed under the GNU General Public License v2.

Installation

See 'INSTALL' located in this directory.

Current Maintainer

Contributors

Repository

pychebfun is hosted at http://github.com/pychebfun/pychebfun.

pychebfun's People

Contributors

olivierverdier avatar markrichardson avatar cswiercz avatar ghpotter avatar rmlopes avatar

Watchers

James Cloos avatar bithelin 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.