pyProximation Documentation Release 1.3.2

Mehdi Ghasemi

January 09, 2017

Contents

1 Introduction 3 1.1 Requirements and dependencies...... 3 1.2 Download...... 3 1.3 Installation...... 3 1.4 License...... 4

2 Symbolic toolkits 5 2.1 SymPy...... 5 2.2 Sage...... 6 2.3 SymEngine...... 7

3 Measures 9 3.1 Density ...... 9 3.2 ...... 10 3.3 p-norms...... 11 3.4 Drawing samples...... 11

4 Hilbert Spaces 13 4.1 Orthonormal system of functions...... 13 4.2 OrthSystem...... 14 4.3 Approximation...... 16 4.4 Rational Approximation...... 19

5 Interpolation 21 5.1 Lagrange interpolation...... 21 5.2 퐿2-approximation with discrete measures...... 23

6 Collocation 25 6.1 Integro-differential equations...... 25 6.2 Collocation method...... 25 6.3 Collocation class...... 25

7 Distributing over subregions 33

8 Graphics 35 8.1 Two Dimensional Plots...... 36 8.2 Three Dimensional Plots...... 39

9 Code Documentation 43

i 10 Indices and tables 49

Python Module Index 51

ii pyProximation Documentation, Release 1.3.2

Contents:

Contents 1 pyProximation Documentation, Release 1.3.2

2 Contents CHAPTER 1

Introduction

This is a brief documentation for using pyProximation. pyProximation was originally written to solve systems of integro-differential equations via collocation method in arbitrary number of variables. The current implementation of the method is based on a finite dimensional orthogonal system of functions.

1.1 Requirements and dependencies

Since this is a python package, so clearly one needs have python available. pyProximation relies on the following packages: • for numerical calculation: – numpy, – scipy, • for symbolic computation, either: – sympy or, – sage or, – symengine, • for visualization: – mathplotlib, – mayavi. For the symbolic computation, pyProximation need the presence of either sympy or sage.

1.2 Download pyProximation can be obtained from https://github.com/mghasemi/pyProximation.

1.3 Installation

To install pyProximation, run the following in terminal:

3 pyProximation Documentation, Release 1.3.2

sudo python setup.py install

1.3.1 Documentation

The documentation of pyProximation is prepaqred via sphinx.

1.4 License pyProximation is distributed under MIT license:

1.4.1 MIT License

Copyright (c) 2016 Mehdi Ghasemi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associ- ated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARIS- ING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

4 Chapter 1. Introduction CHAPTER 2

Symbolic toolkits

The ‘pyProximation’ library performs symbolic computations as well as numerical calculations. To perform numer- ical calculations, it relies on the excelent libraries ‘NumPy’ and ‘SciPy’. There are various toolkits that are able to handel symbolic computations and each one is suitable for certain purposes. ‘pyProximation’ takes advantage of three different toolkits: 1. sympy 2. sage 3. symengine

2.1 SymPy

SymPy is a Python library for symbolic computation. It provides computer capabilities either as a standalone application, as a library to other applications, or live on the web as SymPy Live or SymPy Gamma. SymPy is trivial to install and to inspect because is written entirely in Python with few dependencies. This ease of access combined with a simple and extensible code base in a well known language make SymPy a system with a relatively low barrier to entry. SymPy includes features ranging from basic symbolic to , algebra, and quan- tum physics. It is capable of formatting the result of the computations as LaTeX code. SymPy is and is licensed under New BSD License. The lead developers are Ondrejˇ Certíkˇ and Aaron Meurer.

2.1.1 Usage

Sympy can be imported by: from sympy import *

To introduce a symbolic variable called x, use: x= Symbol('x') and to define a symbolic function y depending in symbolic variables x, t, use: y= Function('y')(x, t)

To introduce an equation like 푦(푥, 푡) = 푥푡, use Eq:

5 pyProximation Documentation, Release 1.3.2

equation= Eq(y, x *t)

휕푛푦 For differentiation of y with respect to x of order n, i.e. 휕푥푛 , enter: diff(y, x, n)

For integration of y with respect to x, i.e., ∫︀ 푦푑푥, write: integrate(y, x)

∫︀ 푏 and for definite 푎 푦푑푥 write: integrate(y, (x, a, b))

2.2 Sage

SageMath (previously Sage or SAGE, System for Algebra and Geometry Experimentation) is a free open-source mathematics software system licensed under the GPL with features covering many aspects of mathematics, including algebra, combinatorics, numerical mathematics, , and calculus. It builds on top of many existing open- source packages: NumPy, SciPy, , Sympy, , GAP, FLINT, R and many more. Access their combined power through a common, Python-based language or directly via interfaces or wrappers.

2.2.1 Usage

When present, Sage can be imported by: from sage.all import *

To introduce a symbolic variable called x, use: x= var('x') and to define a symbolic function y depending in symbolic variables x, t, use: y= function('y')(x, t)

To introduce an equation like 푦(푥, 푡) = 푥푡, use ==: equation= (y ==x *t)

휕푛푦 For differentiation of y with respect to x of order n, i.e. 휕푥푛 , enter: diff(y, x, n)

For integration of y with respect to x, i.e., ∫︀ 푦푑푥, write: integral(y, x)

∫︀ 푏 and for definite integral 푎 푦푑푥 write: integral(y, (x, a, b))

6 Chapter 2. Symbolic toolkits pyProximation Documentation, Release 1.3.2

2.3 SymEngine

SymEngine is a standalone fast C++ symbolic manipulation library. Optional thin wrappers allow usage of the library from other languages, e.g.: • C wrappers allow usage from C, or as a basis for other wrappers; • Python wrappers allow easy usage from Python and integration with SymPy and Sage; • Ruby wrappers; • Julia wrappers; • Haskell wrappers. It is licensed under MIT license.

2.3.1 Usage

SymEngine can be imported by: from symengine import *

To introduce a symbolic variable called x, use: x= Symbol('x') and to define a symbolic function y depending in symbolic variables x, t, use: y= function_symbol('y', x, t)

SymEngine does not have specific command for defining an equation, so work with equations, one should always equalities with 0. To introduce an equation like 푦(푥, 푡) = 푥푡, use: equation=y-x *t

휕푦 For differentiation of y with respect to x, i.e. 휕푥 , enter: diff(y, x)

To achieve a certain order, repeat the above code as many times as necessary. The current version of SymEngine does not support integration.

2.3. SymEngine 7 pyProximation Documentation, Release 1.3.2

8 Chapter 2. Symbolic toolkits CHAPTER 3

Measures

3.1 Density function

The pyProximation implements two different scenarios for measure spaces:

1. Continuous case, where support of the measure is given as a compact subspace (box) of R푛, and 2. Discrete case, where a finite set of points and their weights are given.

3.1.1 Continuous measure spaces

For the continuous case, generally assume that the support of the measure is a product of closed interval, i.e., ∏︀푛 푖=1[푎푖, 푏푖], where for each i, 푎푖 < 푏푖. Such a set can be defined as a list of ordered pairs of real numbers as [(a1, b1), (a2, b2), ..., (an, bn)]. Moreover, when we speak about a subset of the support, we always refer to a box, defined as a list of 2-tuples. In this case, the measure is given implicitly as a density function 푤(푥). So the measure of a set S is given by ∫︁ 휇(푆) = 푤(푥)푑푥. 푆 For example, the following code defines the Lebesgue measure on [−1, 1] × [−1, 1] and finds the measure of the set [0, 1] × [−1, 0]: # import the Measure class from pyProximation import Measure # define the support of the measure D=[(-1,1), (-1,1)] # define the measure with the constant density 1 M= Measure(D,1) # define a set called S S=[(0,1), (-1,0)] # find the measure of the set S print M.measure(S)

3.1.2 Discrete measure spaces

In this case, the measure is basically a convex combination of Dirac measure. Given a set 푋 = {푥1, . . . , 푥푛} and ∑︀푛 corresponding non-negative weights 푤1, . . . , 푤푛, one defines a measure as 휇 = 푖=1 푤푖훿푥푖 . Then the measure of a

9 pyProximation Documentation, Release 1.3.2

subset 푆 = {푥푖1 , . . . , 푥푖푘 } of X is given by

푘 ∫︁ ∑︁ 휇(푆) = 푑휇 = 푤푖푗 푆 푗=1

The following is a sample code for discrete case: # import the Measure class from pyProximation import Measure # define the support and density D={'x1':1,'x2':.5,'x3':1.1,'x4':.6} # define the measure M= Measure(D) # define a set called S S=['x2','x3'] # find the measure of the set S print M.measure(S)

3.2 Integrals

Suppose that a measure space (푋, 휇) and a measurable function f on X are given. The method integral computes ∫︀ 푋 푓푑휇. If 휇 is discrete, then f can be a dictionary with keys as points of domain and values as evaluation at each . Otherwise, f is simply a numerical function: from pyProximation import Measure from numpy import sqrt # define the density function w= lambda x:1./sqrt(1.-x**2) # define the support D=[(-1,1)] # initiate the measure space M= Measure(D, w) # set f(x) = x^2 f= lambda x: x**2 # integrate f(x) w.r.t. w(x) print M.integral(f)

Or in two dimensions: from pyProximation import Measure from numpy import sqrt # define the density function w= lambda x, y:y**2/sqrt(1.-x**2) # define the support D=[(-1,1), (-1,1)] # initiate the measure space M= Measure(D, w) # set f(x, y) = x^2 + y f= lambda x, y: x**2+y # integrate f(x, y) w.r.t. w(x, y) print M.integral(f)

10 Chapter 3. Measures pyProximation Documentation, Release 1.3.2

3.3 p-norms

Given a measure space (푋, 휇) and a measurable function f, the p-norm of f, for a positive p is defined as:

(︂∫︁ )︂1/푝 푝 ‖푓‖푝 = |푓| 푑휇 . 푋 The method norm(p, f) calculates the above quantity.

3.4 Drawing samples

Suppose that (푋, 휇) is a measure space and one wishes to draw a sample of size n from X according to the distribution 휇. This can be done by the method sample(n) which returns a list of n random points from the support, according to 휇.

3.3. p-norms 11 pyProximation Documentation, Release 1.3.2

12 Chapter 3. Measures CHAPTER 4

Hilbert Spaces

4.1 Orthonormal system of functions

Let X be a topological space and 휇 be a finite Borel measure on X. The bilinear function ⟨·, ·⟩ defined on 퐿2(푋, 휇) as ∫︀ 2 ⟨푓, 푔⟩ = 푋 푓푔푑휇 is an inner product which turns 퐿 (푋, 휇) into a Hilbert space. Let us denote the family of all continuous real valued functions on a non-empty compact space X by C(푋). Suppose that among elements of C(푋), a subfamily A of functions are of particular interest. Suppose that A is a subalgebra of C(푋) containing constants. We say that an element 푓 ∈ C(푋) can be approximated by elements of A, if for every 휖 > 0, there exists 푝 ∈ 퐴 such that |푓(푥) − 푝(푥)| < 휖 for every 푥 ∈ 푋. The following classical results guarantees when every 푓 ∈ C(푋) can be approximated by elements of A.

Note: Stone-Weierstrass: Every element of C(푋) can be approximated by elements of A if and only if for every 푥 ̸= 푦 ∈ 푋, there exists 푝 ∈ 퐴 such that 푝(푥) ̸= 푝(푦).

Despite the strong and important implications of the Stone-Weierstrass theorem, it leaves every computational details out and does not give an specific algorithm to produce an estimator for f with elements of A, given an error tolerance 휖, and the search for a such begins.

Define ‖푓‖∞ (the sup norm of f ) of a given function 푓 ∈ C(푋) by

‖푓‖∞ = sup |푓(푥)|, 푥∈푋

Then the above argument can be read as: For every 푓 ∈ C(푋) and every 휖 > 0, there exists 푝 ∈ 퐴 such that ‖푓 − 푝‖∞ < 휖.

1 Let (푉, ⟨·, ·⟩) be an inner product space with ‖푣‖2 = ⟨푣, 푣⟩ 2 . A basis {푣훼}훼∈퐼 is called an orthonormal basis for V if ⟨푣훼, 푣훽⟩ = 훿훼훽, where 훿훼훽 = 1 if and only if 훼 = 훽 and is equal to 0 otherwise. Every given set of linearly independent vectors can be turned into a set of orthonormal vectors that spans the same sub vector space as the original. The following well-known result gives an algorithm for producing such orthonormal from a set of linearly independent vectors:

Note: Gram–Schmidt 푛 Let (푉, ⟨·, ·⟩) be an inner product space. Suppose {푣푖}푖=1 is a set of linearly independent vectors in V. Let

푣1 푢1 := ‖푣1‖2

13 pyProximation Documentation, Release 1.3.2

and (inductively) let

푘−1 ∑︁ 푤푘 푤 := 푣 − ⟨푣 , 푢 ⟩푢 and 푢 := . 푘 푘 푘 푖 푖 푘 ‖푤 ‖ 푖=1 푘 2

푛 Then {푢푖}푖=1 is an orthonormal collection, and for each k,

푠푝푎푛{푢1, 푢2, ··· , 푢푘} = 푠푝푎푛{푣1, 푣2, ··· , 푣푘}.

Note that in the above note, we can even assume that 푛 = ∞.

Let 퐵 = {푣1, 푣2,... } be an ordered basis for (푉, ⟨·, ·⟩). For any given vector 푤 ∈ 푉 and any initial segment of B, say 퐵푛 = {푣1, . . . , 푣푛}, there exists a unique 푣 ∈ span(퐵푛) such that ‖푤 − 푣‖2 is the minimum:

∑︀ Note: Let 푤 ∈ 푉 and B a finite orthonormal set of vectors (not necessarily a basis). Then for 푣 = 푢∈퐵⟨푢, 푤⟩푢

‖푤 − 푣‖2 = min ‖푤 − 푧‖2. 푧∈span(퐵)

∫︀ Now, let 휇 be a finite measure on X and for 푓, 푔 ∈ C(푋) define ⟨푓, 푔⟩ = 푋 푓푔푑휇. This defines an inner product on the space of functions. The norm induced by the inner product is denoted by ‖·‖2. It is evident that

‖푓‖2 ≤ ‖푓‖∞휇(푋), ∀푓 ∈ C(푋),

which implies that any good approximation in ‖·‖∞ gives a good ‖·‖2-approximation. But generally, our interest is the other way around. Employing Gram-Schmidt procedure, we can find ‖·‖2 within any desired accuracy, but this does not guarantee a good ‖·‖∞-approximation. The situation is favorable in finite dimensional case. Take 퐵 = {푝1, . . . , 푝푛} ⊂ C(푋) and 푓 ∈ C(푋), then there exists 퐾푓 > 0 such that for every 푔 ∈ span(퐵 ∪ {푓}),

퐾푓 ‖푔‖∞ ≤ ‖푔‖2≤‖푔‖∞휇(푋). Since X is assumed to be compact, C(푋) is separable, i.e., C(푋) admits a countable dimensional dense subvector space (e.g. for when X is a closed, bounded interval). Thus for every 푓 ∈ C(푋) and every 휖 > 0 one can find a big enough finite B, such that the above inequality holds. In other words, good enough ‖·‖2-approximations of f give good ‖·‖∞-approximations, as desired.

4.2 OrthSystem

Given a measure space, the OrthSystem class implements the described procedure, symbolically. Therefore, it relies on a symbolic environment. Currently, three such environments are acceptable: 1. sympy 2. sage 3. symengine

4.2.1 Legendre polynomials

Let 푑휇(푥) = 푑푥, the regular Lebesgue measure on [−1, 1] and 퐵 = {1, 푥, 푥2, . . . , 푥푛}. The orthonormal polynomials 푡ℎ constructed from B are called Legendre polynomials. The 푛 Legendre is denoted by 푃푛(푥). The following code generates Legendre polynomials up to a given order:

14 Chapter 4. Hilbert Spaces pyProximation Documentation, Release 1.3.2

# the symbolic package from sympy import * from pyProximation import Measure, OrthSystem # the symbolic variable x= Symbol('x') # set a to the order n=6 # define the measure D=[(-1,1)] M= Measure(D,1) S= OrthSystem([x], D,'sympy') # link the measure to S S.SetMeasure(M) # set B = {1, x, x^2, ..., x^n} B=S.PolyBasis(n) # link B to S S.Basis(B) # generate the orthonormal basis S.FormBasis() # print the result print B.OrthBase

4.2.2 Chebyshev polynomials

Let 푑휇(푥) = √ 푑푥 on [−1, 1] and B as in Legendre polynomials. The orthonormal polynomials associated to this 1−푥2 푡ℎ setting are called Chebyshev polynomials and the 푛 one is denoted by 푇푛(푥). The following code generates Chebyshev polynomials up to a given order: # the symbolic package from sympy import * from numpy import sqrt from pyProximation import Measure, OrthSystem # the symbolic variable x= Symbol('x') # set a limit to the order n=6 # define the measure D=[(-1,1)] w= lambda x: 1./sqrt(1.-x **2) M= Measure(D, w) S= OrthSystem([x], D,'sympy') # link the measure to S S.SetMeasure(M) # set B = {1, x, x^2, ..., x^n} B=S.PolyBasis(n) # link B to S S.Basis(B) # generate the orthonormal basis S.FormBasis() # print the result print S.OrthBase

4.2. OrthSystem 15 pyProximation Documentation, Release 1.3.2

4.3 Approximation

Let (푋, 휇) be a compact Borel measure space and 풪 = {푢1, 푢2,... } an orthonormal basis of function whose span is dense in 퐿2(푋, 휇). Given a function 푓 ∈ 퐿2(푋, 휇), then f can be approximated as

푛 ∑︁ 푓 = lim ⟨푓, 푢푖⟩푢푖 푛→∞ 푖=1

OrthSystem.Series calculates the coefficients ⟨푓, 푢푖⟩:

4.3.1 Truncated Fourier series

Let 푑휇(푥) = 푑푥, the regular Lebesgue measure on [푐, 푐 + 2푙] and 퐵 = {1, sin(휋푥), cos(휋푥), sin(2휋푥), cos(2휋푥),..., sin(푛휋푥), cos(푛휋푥), }. The following code calculates the Fourier series approximation of 푓(푥) = sin(푥)푒푥:

from sympy import * from numpy import sqrt from pyProximation import Measure, OrthSystem # the symbolic variable x= Symbol('x') # set a limit to the order n=4 # define the measure D=[(-1,1)] w= lambda x: 1./sqrt(1.-x **2) M= Measure(D, w) S= OrthSystem([x], D,'sympy') # link the measure to S S.SetMeasure(M) # set B = {1, x, x^2, ..., x^n} B=S.FourierBasis(n) # link B to S S.Basis(B) # generate the orthonormal basis S.FormBasis() # number of elements in the basis m= len(S.OrthBase) # set f(x) = sin(x)e^x f= sin(x) *exp(x) # extract the coefficients Coeffs=S.Series(f) # form the approximation f_app= sum([S.OrthBase[i] *Coeffs[i] for i in range(m)]) print f_app

4.3.2 Fitting Data

푛 Suppose that a set of data points (푥1, 푦1),..., (푥푚, 푦푚) are given, where 푥푖 ∈ R . To fit a curve or surface to data with minimum average square error, one can employ OrthSystem with an arbitrary system of functions to do so. The following example generates random data and fits two surfaces using polynomials and : from random import uniform from sympy import *

16 Chapter 4. Hilbert Spaces pyProximation Documentation, Release 1.3.2

from sympy.utilities.lambdify import lambdify, implemented_function # import the module from pyProximation import Measure, OrthSystem, Graphics x, y, z= symbols('x, y, z') # define dirac function symbolically and numerically dirac= implemented_function( Function('dirac'), lambda a, b:1 * (abs(a- b)<.000001)) # list of random points points= [(uniform(0,1), uniform(0,1)) for _ in range(50)] # container for the support of discrete measure D={} # a symbolic function to represent the random points g=0 # Random values of the function vals=[] for p in points: t= uniform(-.8,1) vals.append(t) g+=t * dirac(x, p[0]) * dirac(y, p[1]) D[p]=1 # The discrete measure supported at random points M= Measure(D) # Orthonormal systems of functions S1= OrthSystem([x, y], [(0,1), (0,1)]) S1.SetMeasure(M)

S2= OrthSystem([x, y], [(0,1), (0,1)]) S2.SetMeasure(M) # polynomial basis B1= S1.PolyBasis(4) # trigonometric basis B2= S2.FourierBasis(3) # link the basis to the orthogonal systems S1.Basis(B1) S2.Basis(B2) # form the orthonormal basis S1.FormBasis() S2.FormBasis() # calculate coefficients cfs1= S1.Series(g) cfs2= S2.Series(g) # orthogonal approximation aprx1= sum([S1.OrthBase[i] * cfs1[i] for i in range(len(S1.OrthBase))]) aprx2= sum([S2.OrthBase[i] * cfs2[i] for i in range(len(S2.OrthBase))]) # the graphic object G1= Graphics('sympy') G2= Graphics('sympy') G1.Plot3D(aprx1, (x,0,1), (y,0,1)) G2.Plot3D(aprx2, (x,0,1), (y,0,1)) P=[] idx=0 for p in points: q= (p[0], p[1], vals[idx]) P.append(q) idx+=1 # link the points to the object G1.Point(P, color='red') G2.Point(P, color='red')

4.3. Approximation 17 pyProximation Documentation, Release 1.3.2

# save to file G1.save('poly.png') G2.save('trig.png')

18 Chapter 4. Hilbert Spaces pyProximation Documentation, Release 1.3.2

4.4 Rational Approximation

Let 푓 : 푋 → R be a continuous function and {푏0, 푏1,... } an orthonormal system of functions over 푋 with respect 푝(푥) ∑︀푚 to a measure 휇. Suppose that we want to approximate 푓 with a function of the form 푞(푥) where 푝 = 푗=0 훼푗푏푗 and ∑︀푛 푞 = 1 + 푗=1 훽푗푏푗. Let 푟(푥) = 푝(푥) − 푞(푥)푓(푥) be the residual. We can find the coefficients 훼푖, 훽푗 such that ‖푟‖2 be minimum. Let 퐿(훼, 훽) = 푟(푥) · 푟(푥). Then the solution satisfies the following equations:

휕 퐿 = 0, 휕훼푖 휕 퐿 = 0, 휕훽푖 which is a system of linear equations. This is implemented in rational.RationalAprox.RatLSQ:

from sympy import * from pyProximation import *

x= Symbol('x') f= sinh(x) * cos(3 * x)+ sin(3 * x) * exp(x) D=[(-pi, pi)] S= OrthSystem([x], D)

4.4. Rational Approximation 19 pyProximation Documentation, Release 1.3.2

B=S.PolyBasis(5)

# link B to S S.Basis(B)

# generate the orthonormal basis S.FormBasis()

# extract the coefficients of approximations Coeffs=S.Series(f)

# form the approximation h= sum([S.OrthBase[i] * Coeffs[i] for i in range(len(S.OrthBase))]) T= RationalAprox(S) g=T.RatLSQ(5,5, f)

G= Graphics('sympy', 100) G.Plot2D(f, (x,-3.2, 3.2), legend='exact') G.Plot2D(g, (x,-3.2, 3.2), color='green', legend='rational') G.Plot2D(h, (x,-3.2, 3.2), color='red', legend='Legendre') G.save('Exm05.png')

20 Chapter 4. Hilbert Spaces CHAPTER 5

Interpolation

5.1 Lagrange interpolation

2 Suppose that a list of 푚 + 1 points {(푥0, 푦0),..., (푥푚, 푦푚)} in R is given, such that 푥푖 ̸= 푥푗, if 푖 ̸= 푗. Then 푚 ∑︁ 푝(x) = 푦푖ℓ푖(x), 푖=0 is a polynomial of degree m which passes through all the given points. Here

∏︁ x − 푥푗 ℓ푖(x) = , 푥푖 − 푥푗 푗̸=푖 are Lagrange Basis Polynomials. This procedure can be extended to multivariate case as well. 푛 Suppose that a list of points {푥1, . . . , 푥휌} in R and a list of corresponding values {푦1, . . . , 푦휌} are given. Let’s denote 푒1 푒푛 e by X the tuple (X1,..., X푛) of variables and X1 ··· X푛 by X , where e = (푒1, . . . , 푒푛). (︀푚+푛)︀ If for some 푚 > 0, we have 휌 = 푚 , then the number of given points matches the number of monomials of degree at most m in the polynomial basis. Denote the exponents of these monomials by e푖, 푖 = 1, . . . , 휌 and let

⎛ e1 e휌 ⎞ 푥1 . . . 푥1 ⎜ . . ⎟ 퐷 = ⎝ . . ⎠ e1 e휌 푥휌 . . . 푥휌 and for 1 ≤ 푗 ≤ 휌: e ⎛ e1 휌 ⎞ 푥1 . . . 푥1 ⎜ . . . ⎟ ⎜ . . . ⎟ ⎜ e1 e휌 ⎟ ⎜ 푥푗−1 . . . 푥푗−1 ⎟ ⎜ e1 e휌 ⎟ 퐷푗 = ⎜ X ... X ⎟ . ⎜ e1 e휌 ⎟ ⎜ 푥 . . . 푥 ⎟ ⎜ 푗+1 푗+1 ⎟ ⎜ . . . ⎟ ⎝ . . . ⎠ e1 e휌 푥휌 . . . 푥휌 Then the polynomial

휌 ∑︁ |퐷푖| 푝(X) = 푦 , 푖 |퐷| 푖=1

21 pyProximation Documentation, Release 1.3.2 interpolates the given list of points and their corresponding values. Here |푀| denotes the of M. The above procedure is implemented in the Interpolation module. The following code provides an example in 2 dimensional case: from sympy import * from pyProximation import Interpolation # define symbolic variables x= Symbol('x') y= Symbol('y') # initiate the interpolation instance Inter= Interpolation([x, y],'sympy') # list of points points=[(-1,1), (-1,0), (0,0), (0,1), (1,0), (1,-1)] # corresponding values values=[-1,2,0,2,1,0] # interpolate p= Inter.Interpolate(points, values) # print the result print p G= Graphics('sympy') points3d=[(-1,1,-1), (-1,0,2), (0,0,0), (0,1,2), (1,0,1), (1,-1,0)] G.Point(points3d, color='red') G.Plot3D(p, (x,-1.1, 1.1), (y,-1.1, 1.1))

This will be the result:

22 Chapter 5. Interpolation pyProximation Documentation, Release 1.3.2

5.2 퐿2-approximation with discrete measures

∑︀푛 Suppose that 휇 = 1 훿푥푖 is a measure with n-points in its support. Then the orthogonal system of polynomials consists of at most n+1 polynomials. Approximation with these n+1 polynomials is essentially same as interpolation: # symbolic variable x= Symbol('x') # function to be approximated g= sin(x) *exp(sin(x)*x)#x*sin(x) # its numerical equivalent g_= lambdify(x, g,'numpy') # number of approximation terms n=6 # half interval length l= 3.1 # interpolation points and values Xs=[[-3], [-2], [-1], [0], [1], [2], [3]] Ys= [g_(Xs[i][0]) for i in range(7)] # a discrete measure supp={-3:1,-2:1,-1:1,0:1,1:1,2:1,3:1} M= Measure(supp) # orthogonal system S= OrthSystem([x], [(-l, l)]) # link the measure S.SetMeasure(M) # polynomial basis B=S.PolyBasis(n) # link the basis to the orthogonal system S.Basis(B) # form the orthonormal basis S.FormBasis() # calculate coefficients cfs=S.Series(g) # orthogonal approximation aprx= sum([S.OrthBase[i] *cfs[i] for i in range(len(B))]) # interpolate Intrp= Interpolation([x]) intr= Intrp.Interpolate(Xs, Ys) # plot the results G= Graphics('sympy', numpoints=100) G.SetTitle("$n = %d$"%(n)) G.Plot2D(g, (x,-l, l), color='blue', legend='Original') G.Plot2D(aprx, (x,-l, l), color='red', legend='Orthogonal', thickness=2) G.Plot2D(intr, (x,-l, l), color='green', legend='Interpolant') G.save('OrthIntrp.png')

5.2. 퐿2-approximation with discrete measures 23 pyProximation Documentation, Release 1.3.2

24 Chapter 5. Interpolation CHAPTER 6

Collocation

6.1 Integro-differential equations

A system of integro-differential equations is a system of equations that involve both integrals and of a function. The general first-order, linear (only with respect to the term involving ) integro- is of the form 푑 ∫︁ 푥 푢(푥) + 푓(푡, 푢(푡))푑푡 = 푔(푥, 푢(푥)), 푢(푥0) = 푢0. 푑푥 푥0

6.2 Collocation method

In collocation method, one assumes that the solution of the equation is of a certain form and tries to exploit information about the assumed solution. More specifically, assume that 푢1, 푢2, . . . , 푢푛 are orthonormal functions and the solution ∑︀ is of the form 푓 = 푖 푎푖푢푖 where 푎푖 are unknowns. Plug f in to the equation and choose n different admissible points. plug those points in to the resulting equation to eliminate x. Then we obtain n equations in terms of 푎1, . . . , 푎푛. Solving the resulted system of algebraic equations gives an approximation for f.

6.3 Collocation class

6.3.1 Single equation

푑푦 The Collocation class implements the above described method. The following example solves the equation 푑푥 + ∫︀ 1 −푥 2푦 + 5 푦푑푥 = 1, 푦(0) = 푦(2휋) = 0 where the exact solution is 2 sin(2푥)푒 : from sympy import * from pyProximation import * # symbolic variable x= Symbol('x') # symbolic function y= Function('y')(x) # number of approximation terms n= 10 # orthogonal system S= OrthSystem([x], [(0,2 *pi)]) # polynomial basis B=S.PolyBasis(n)

25 pyProximation Documentation, Release 1.3.2

# link the basis to the orthogonal system S.Basis(B) # form the orthonormal basis S.FormBasis() # form the equation EQ= Eq(diff(y, x)+2 *y+5 *integrate(y, x),1) # initiate collocation object with x as variable and y as function C= Collocation([x], [y]) # link the orthogonal system to the collocation object and the unknown function `y` C.SetOrthSys(S, y) # link the equation to the collocation object C.Equation([EQ]) # initial and boundary conditions C.Condition(Eq(y,0), [0]) C.Condition(Eq(y,0), [2 *pi]) # set the solver to 'scipy' C.setSolver('scipy') # solve to collocation system and print the solution Apprx=C.Solve() print Apprx[0]

In the above example the Collocation class selects collocation points itself according to the measure chosen for orthogonal system, in this case, the usual Lebesgue measure. Thus, the class samples enough number of points uniformly from the domain. The solution and the exact answer are depicted below:

One can provide prefered collocation points to the solver. The following repeats the previous example where colloca-

26 Chapter 6. Collocation pyProximation Documentation, Release 1.3.2 tion points are selected in a way from the domain within a fixed distance from each other: from sympy import * from pyProximation import * # symbolic variable x= Symbol('x') # symbolic function y= Function('y')(x) # number of approximation terms n= 10 # orthogonal system S= OrthSystem([x], [(0,2 *pi)]) # polynomial basis B=S.PolyBasis(n) # link the basis to the orthogonal system S.Basis(B) # form the orthonormal basis S.FormBasis() # form the equation EQ= Eq(diff(y, x)+2 *y+5 *integrate(y, x),1) # initiate collocation object with x as variable and y as function C= Collocation([x], [y]) # link the orthogonal system to the collocation object and the unknown function `y` C.SetOrthSys(S, y) # link the equation to the collocation object C.Equation([EQ]) # initial and boundary conditions C.Condition(Eq(y,0), [0]) C.Condition(Eq(y,0), [2 *pi]) # a list of collocation points pnts= [[i *2*pi/n] for i in range(1,n)] # link the collocation point to the object C.CollPoints(pnts) # set the solver to 'scipy' C.setSolver('scipy') # solve to collocation system and print the solution Apprx=C.Solve() print Apprx[0]

The result shows slight improvement in the solution:

6.3. Collocation class 27 pyProximation Documentation, Release 1.3.2

Note: Each point of collocation must be given as a list or tuple.

6.3.2 System of equations

The Collocation class is also able to handle systems of equations. Consider the following system of partial differential equations:

{︂ 휕푥 휕푡 + 푥 + 4푦 = 10 휕푦 푥 − 휕푡 − 푦 = 0, with initial conditions 푥(0) = 4 and 푦(0) = 3. The exact solution to the above system is:

푥(푡) = 2(1 + 푒−푡 cos(2푡) − 푒−푡 sin(2푡)) 푦(푡) = 2 + 푒−푡 cos(2푡) + 푒−푡 sin(2푡)

The following code solves the system and plots the exact and approximate solutions: from sympy import * from pyProximation import * # symbolic variable t= Symbol('t') # symbolic function x= Function('x')(t)

28 Chapter 6. Collocation pyProximation Documentation, Release 1.3.2

y= Function('y')(t) # number of approximation terms n=8 # orthogonal system S= OrthSystem([t], [(0, pi)]) # polynomial basis B=S.PolyBasis(n) # link the basis to the orthogonal system S.Basis(B) # form the orthonormal basis S.FormBasis() # form the equation EQ1= Eq(diff(x, t)+x+4 *y, 10) EQ2= Eq(x- diff(y, t)- y,0) # initiate collocation object with x as variable and y as function C= Collocation([t], [x, y]) # link the orthogonal system to the collocation object and unknown functions C.SetOrthSys(S, x) C.SetOrthSys(S, y) # link the equation to the collocation object C.Equation([EQ1, EQ2]) # initial and boundary conditions C.Condition(Eq(x,4), [0]) C.Condition(Eq(y,3), [0]) # set the solver to 'scipy' C.setSolver('scipy') # solve to collocation system and print the solution Apprx=C.Solve() # print the answers print Apprx[0] print Apprx[1] # the exact solution f=[2 *(1+ exp(-t) *cos(2*t)- exp(-t) *sin(2*t)),2+ exp(-t) *cos(2*t)+ exp(-t) *sin(2*t)] # plot the exact and approximate solutions G= Graphics('sympy', numpoints=200) G.SetTitle("$n = %d$"%(n)) G.ParamPlot2D(f, (t,0, pi), color='blue', legend='Exact') G.ParamPlot2D(Apprx, (t,0, pi), color='red', legend='Approximation') G.save('Plot-%d.png'%(n))

The followings are results for 푛 = 7 and 푛 = 8:

6.3. Collocation class 29 pyProximation Documentation, Release 1.3.2

30 Chapter 6. Collocation pyProximation Documentation, Release 1.3.2

6.3. Collocation class 31 pyProximation Documentation, Release 1.3.2

32 Chapter 6. Collocation CHAPTER 7

Distributing over subregions

Sometimes the system of equations is too complicated and it might be very costly to produce a reasonably good estimation by raising the size of the function basis. A possible solution is to divide the domain into various smaller subregions and try to solve the system for those smaller subregions. Use the partial solutions to force appropriate boundary condition to the remaining subregions in order to get consistent solutions on all subregions. This task is done by use of the SubRegion class.

Note: Currently, this only works with symbolic package sympy.

33 pyProximation Documentation, Release 1.3.2

34 Chapter 7. Distributing over subregions CHAPTER 8

Graphics

This small module provides simple functionality to draw 2D and 3D plots. Since the functions that appear in this package are of three different types, it must be declared to the Graphic class, what type of function it is dealing with. The three different types are: 1. numeric, the default type, 2. sympy, the symbolic sympy functions, 3. sage, the symbolic sage functions The following plots a list of random points in 3D: from random import uniform # import the module from pyProximation import Graphics # list of random points points= [(uniform(-10, 10), uniform(-10, 10), uniform(-10, 10)) for _ in range(100)] # the graphic object G= Graphics() # link the points to the object G.Point(points, color='red') # save to file G.save('points.png')

35 pyProximation Documentation, Release 1.3.2

8.1 Two Dimensional Plots

The method Plot2D is to plot curves in 2 dimensions. The following code shows an example: # chOose the symbolic environment Symbolic='sympy' # define the symbolic variables accordingly if Symbolic =='sympy': from sympy import * x= Symbol('x') y= Function('y')(x) elif Symbolic =='sage': from sage.all import * x= var('x') y= function('y')(x) # import the modules from pyProximation import * # size of basis n=6 # set the measure M= Measure([(-1,1)], lambda x:1./sqrt(1.-x**2)) # Orthogonal system of functions S= OrthSystem([x], [(-1,1)], Symbolic) # link the measure to the orthogonal system

36 Chapter 8. Graphics pyProximation Documentation, Release 1.3.2

S.SetMeasure(M) # monomial basis B=S.PolyBasis(n) # Fourier basis #B = S.FourierBasis(n) # link the basis S.Basis(B) # form the orthogonal system S.FormBasis() # the exact solution Z= sin(pi *x)*exp(x) R= diff(Z, x, x)- diff(Z, x) # the pde if Symbolic =='sympy': EQ1= (Eq(diff(y, x, x)- diff(y, x), R)) elif Symbolic =='sage': EQ1= (diff(y, x, x)- diff(y, x) ==R) # corresponding coefficients series=S.Series(Z) # orthogonal approximation ChAprx= sum([S.OrthBase[i] *series[i] for i in range(m)]) # set up the collocation class C= Collocation([x], [y], Symbolic) # link to the orthogonal system C.SetOrthSys(S) # link the equation C.Equation([EQ1]) # initial conditions if Symbolic =='sympy': C.Condition(Eq(y,0), [0]) C.Condition(Eq(y, sin(-pi)*exp(-1)), [-1]) C.Condition(Eq(y, sin(pi)*exp(1)), [1]) elif Symbolic =='sage': C.Condition(y ==0,[0]) C.Condition(y == sin(-pi)*exp(-1), [-1]) C.Condition(y == sin(pi)*exp(1), [1]) # collocation points m= len(S.OrthBase) pnts=[[-1+i *2./m] for i in range(m)] # link the collocation points C.CollPoints(pnts) # set solver C.setSolver('scipy') # solve Apprx=C.Solve() print Apprx[0] # plot the results G= Graphics(Symbolic) G.Plot2D(Z, (x,-1,1), color='blue', legend='Exact') G.Plot2D(ChAprx, (x,-1,1), color='green', legend='Orth Apprx') G.Plot2D(Apprx[0], (x,-1,1), color='red', legend='Colloc Apprx') G.save('PlotsPoly.png'%(n)) #G.save('PlotsFourier.png'%(n))

8.1. Two Dimensional Plots 37 pyProximation Documentation, Release 1.3.2

38 Chapter 8. Graphics pyProximation Documentation, Release 1.3.2

For an example of parametric plots see this.

8.2 Three Dimensional Plots

To generate static 3 dimensional plots, Graphics implement Plot3D. The following example illustrates the usage of this method: # select the symbolic tool Symbolic='sympy' if Symbolic =='sympy': from sympy import * x= Symbol('x') t= Symbol('t') y= Function('y')(t, x) elif Symbolic =='sage': from sage.all import * t= var('t') x= var('x') y= function('y')(t, x) # import the modules from pyProximation import * # degree of basis n=4 # orthogonal system

8.2. Three Dimensional Plots 39 pyProximation Documentation, Release 1.3.2

S= OrthSystem([t, x], [(0,1), (0,1)]) # monomial basis B=S.PolyBasis(n) # link the basis S.Basis(B) # form the orthonormal basis S.FormBasis() # construct a pde Z=t *sin(pi*x) R= diff(Z, t)- diff(Z, x) if Symbolic =='sympy': EQ1= Eq(diff(y, t)- diff(y, x), R) elif Symbolic =='sage': EQ1= diff(y, t)- diff(y, x) ==R # collocation object C= Collocation([t, x], [y]) # link the orthogonal system C.SetOrthSys(S) # link the equation C.Equation([EQ1]) # some initial & boundary conditions if Symbolic =='sympy': C.Condition(Eq(y,0), [0,0]) C.Condition(Eq(y,0), [0,.3]) C.Condition(Eq(y,0), [1,1]) C.Condition(Eq(y,1), [1,.5]) C.Condition(Eq(y,0), [0,.7]) elif Symbolic =='sage': C.Condition(y ==0,[0,0]) C.Condition(y ==0,[0,.3]) C.Condition(y ==0,[1,1]) C.Condition(y ==1,[1,.5]) C.Condition(y ==0,[0,.7]) # set the solver C.setSolver('scipy') # solve the collocation system Apprx=C.Solve() print Apprx[0] # plot the result G= Graphics(Symbolic) G.SetLabelX("$t$") G.SetLabelY("$x$") G.SetLabelZ("$y(t, x)$") G.Plot3D(Apprx[0], (t,0,1), (x,0,1)) # save the image G.save('PDEplot.png'%(n)) # open the interactive window G.interact()

40 Chapter 8. Graphics pyProximation Documentation, Release 1.3.2

A second method called interact is invoked at the end which called the mayavi library to show an interactive view of the surface.

8.2. Three Dimensional Plots 41 pyProximation Documentation, Release 1.3.2

42 Chapter 8. Graphics CHAPTER 9

Code Documentation

class base.Foundation This class contains common features of all modules. DetSymEnv() Returns a list. The list consists of all symbolic tools present among ‘sympy’,’sage’ and ‘symengine’. class measure.Measure(dom, w=None) An instance of this class is a measure on a given set supp. The support is either • a python variable of type set, or • a list of tuples which represents a box in euclidean space. Initializes a measure object according to the inputs: • dom must be either – a list of 2-tuples – a non-empty dictionary • w must be a – a function if dom defines a region – left blank (None) if dom is a dictionary boxCheck(B) Checks the structure of the box B. Returns True id B is a list of 2-tuples, otherwise it returns False. check(dom, w) Checks the input types and their consistency, according to the __init__ arguments. integral(f ) Returns the integral of f with respect to the currwnt measure over the support. measure(S) Returns the measure of the set S. S must be a list of 2-tuples. norm(p, f ) Computes the norm-p of the f with respect to the current measure. sample(num) Samples from the support according to the measure. class orthsys.OrthSystem(variables, var_range, env=’sympy’) OrthogonalSystem class produces an orthogonal system of functions according to a suggested basis of functions and a given measure supported on a given region.

43 pyProximation Documentation, Release 1.3.2

This basically performs a ‘Gram-Schmidt’ method to extract the orthogonal basis. The inner product is obtained by integration of the product of functions with respect to the given measure (more accurately, the distribution). To initiate an instance of this class one should provide a list of symbolic variables variables and the range of each variable as a list of lists var_range. To initiate an orthogonal system of functions, one should provide a list of symbolic variables variables and the range of each these variables as a list of lists var_range. Basis(base_set) To specify a particular family of function as a basis, one should call this method with a list base_set of linearly independent functions. FormBasis() Call this method to generate the orthogonal basis corresponding to the given basis via Basis method. The result will be stored in a property called OrthBase which is a list of function that are orthogonal to each other with respect to the measure measure over the given range Domain. FourierBasis(n) Generates a Fourier basis from variables consisting of all 푠푖푛 & 푐표푠 functions with coefficients at most n. PolyBasis(n) Generates a polynomial basis from variables consisting of all monomials of degree at most n. Series(f ) Given a function f, this method finds and returns the coefficients of the series that approximates f as a linear combination of the elements of the orthogonal basis. SetMeasure(M) To set the measure which the orthogonal system will be computed, simply call this method with the corre- sponding distribution as its parameter dm; i.e, the parameter is d(m) where m is the original measure. SetOrthBase(base) Sets the orthonormal basis to be the given base. TensorPrd(Bs) Takses a list of symbolic bases, each one a list of symbolic expressions and returns the tensor product of them as a list. inner(f, g) Computes the inner product of the two parameters with respect to the measure measure. project(f, g) Finds the projection of f on g with respect to the inner product induced by the measure measure. class interpolation.Interpolation(var, env=’sympy’) The Interpolation class provides polynomial interpolation routines in multi variate case. var is the list of symbolic variables and env is the the symbolic tool. Delta(idx=-1) Construct the matrix corresponding to idx‘th point, if idx>0 Otherwise returns the discriminant. Interpolate(points, vals) Takes a list of points points and corresponding list of values vals and return the interpolant. Since in multivariate case, there is a constraint on the number of points, it checks for the valididty of the input. In case of failure, describes the type of error occured according to the inputs. MinNumPoints() Returns the minimum number of points still required.

44 Chapter 9. Code Documentation pyProximation Documentation, Release 1.3.2

Monomials() Generates the minimal set of monomials for interpolation. class collocation.Collocation(variables, ufunc, env=’sympy’) The Collocation class tries to approximate the solutions of a system of partial differential equations with respect to an orthogonal system of functions. To initiate an instance of this class one needs to provide two set of parameters: 1. List of independent symbolic variables variables; 2. List of unknown functions to be found that depend on the independent variables ufunc. CollPoints(pnts) Accepts alist of collocation point pnts, to form the algebraic system of equations and find the coefficients of the orthogonal functions from OrthSystem.OrthBase. Each point must be either a list or a tuple. Condition(eq, val) List of initial and boundary conditions. Equation(eq) To enter the system of equations, use this meyhod with a list of equations as input. FindDomain() Finds the region that all variables are defined. PlugPoints() Internal use: plug in collocation points to elliminate independent variables and keep the coefficients. SetOrthSys(obj, func) To approximate the solutions of the system of pdes, the class requires an orthogonal system of functions OrthSystem. This method accepts such a system. Solve() Solves the collocation equations and keep a dictionary of coefficients in self.Coeffs and returns a list of functions in the span of orthoginal system. collocate() Internal use: generates the system of equations for coefficients to be used via collocation points. setSampleMeasure(meas) Sets the measure over the domain for sampling collocation points in case of necessity. setSolver(solver, optn=’lm’) Currently only two solvers are supported: 1.the sage‘s defult solver for rather simple system of algebraic equations. 2. the scipy‘s fsolves to handel more complex and larger systems. It also supports the following solvers from scipy: •hybr •lm (defauls) •broyden1 •broyden2 •anderson •krylov •df-sane

45 pyProximation Documentation, Release 1.3.2 class subregion.SubRegion(collsys, num_parts=[]) The SubRegion class partitions the region into sub-regions, solve the system of Integro-differential equations on each and glue them together. It takes: 1. a collocation instance collsys; 2. an optional list of positive num_parts which shows the number of equal length partitions for each variable. AnalyseConditions() Associates boundary conditions to each sub-collocation system. Starting from one corner, associates boundary conditions to all adjacent subregions based on the solution of the current subregion. ClosedForm(func) Compiles a piece-wise defined symbolic function from the solution for func which is an unknown from the original collocation system. InitMiniSys() Initializes a set of collocation systems for all subregions. Solve() Solves the collocation system for each region and generates boundary conditions for adjacent regions. corners(tpl) Generates end corner points of the region represented tpl as collocation points (used internally). class graphics.Graphics(env=’numeric’, numpoints=50) This class tends to provide basic graphic tools based on matplotlib and mayavi. Accepts one optional argument env which determines the types of the function to be visualized: •numeric: is a numerical function (regular python functions) •sympy: Sympy symbolic function •sage: Sage symbolic function ParamPlot2D(funcs, rng, color=’blue’, legend=’‘, thickness=1) Appends a parametric curve to the Graphics object. The parameters are as follows: •funcs: the tupleof functions to be plotted, •rng: a triple of the form (t, a, b), where t is the funcs‘s independents variable, over the range [a, b], •color: the color of the current curve, •legend: the text for the legend of the current crve. Plot2D(func, xrng, color=’blue’, legend=’‘, thickness=1) Appends a curve to the Graphics object. The parameters are as follows: •func: the function to be plotted, •xrng: a triple of the form (x, a, b), where x is the func‘s independents variable, over the range [a, b], •color: the color of the current curve, •legend: the text for the legend of the current crve. Plot3D(func, xrng, yrng) Sets a surface to the Graphics object. The parameters are as follows: •func: the function to be plotted,

46 Chapter 9. Code Documentation pyProximation Documentation, Release 1.3.2

•xrng: a triple of the form (x, a, b), where x is the first func‘s independents variable, over the range ‘[a, b], •yrng: a triple of the form (y, c, d), where x is the second func‘s independents variable, over the range [c, d]. Point(pnts, color=’blue’, marker=’o’, legend=’‘) Adds a list of points to the plot. SetLabelX(lbl) Sets the label for X axis SetLabelY(lbl) Sets the label for Y axis SetLabelZ(lbl) Sets the label for Z axis SetTitle(ttl) Sets the title of the graph. interact() Shows an interavtive demo of the 3D surface, using mayavi, so it requires mayavi for python to be installed. save(fname=’fig.png’) Saves the outpu of the Graphics object to the file fname.

47 pyProximation Documentation, Release 1.3.2

48 Chapter 9. Code Documentation CHAPTER 10

Indices and tables

• genindex • modindex • search

49 pyProximation Documentation, Release 1.3.2

50 Chapter 10. Indices and tables Python Module Index

b base, 43 c collocation, 45 g graphics, 46 i interpolation, 44 m measure, 43 o orthsys, 43 s subregion, 45

51 pyProximation Documentation, Release 1.3.2

52 Python Module Index Index

A interact() (graphics.Graphics method), 47 AnalyseConditions() (subregion.SubRegion method), 46 Interpolate() (interpolation.Interpolation method), 44 Interpolation (class in interpolation), 44 B interpolation (module), 44 base (module), 43 M Basis() (orthsys.OrthSystem method), 44 boxCheck() (measure.Measure method), 43 Measure (class in measure), 43 measure (module), 43 C measure() (measure.Measure method), 43 MinNumPoints() (interpolation.Interpolation method), 44 check() (measure.Measure method), 43 Monomials() (interpolation.Interpolation method), 44 ClosedForm() (subregion.SubRegion method), 46 collocate() (collocation.Collocation method), 45 Collocation (class in collocation), 45 N collocation (module), 45 norm() (measure.Measure method), 43 CollPoints() (collocation.Collocation method), 45 Condition() (collocation.Collocation method), 45 O corners() (subregion.SubRegion method), 46 orthsys (module), 43 OrthSystem (class in orthsys), 43 D Delta() (interpolation.Interpolation method), 44 P DetSymEnv() (base.Foundation method), 43 ParamPlot2D() (graphics.Graphics method), 46 Plot2D() (graphics.Graphics method), 46 E Plot3D() (graphics.Graphics method), 46 Equation() (collocation.Collocation method), 45 PlugPoints() (collocation.Collocation method), 45 Point() (graphics.Graphics method), 47 F PolyBasis() (orthsys.OrthSystem method), 44 project() (orthsys.OrthSystem method), 44 FindDomain() (collocation.Collocation method), 45 FormBasis() (orthsys.OrthSystem method), 44 Foundation (class in base), 43 S FourierBasis() (orthsys.OrthSystem method), 44 sample() (measure.Measure method), 43 save() (graphics.Graphics method), 47 G Series() (orthsys.OrthSystem method), 44 SetLabelX() (graphics.Graphics method), 47 Graphics (class in graphics), 46 SetLabelY() (graphics.Graphics method), 47 graphics (module), 46 SetLabelZ() (graphics.Graphics method), 47 I SetMeasure() (orthsys.OrthSystem method), 44 SetOrthBase() (orthsys.OrthSystem method), 44 InitMiniSys() (subregion.SubRegion method), 46 SetOrthSys() (collocation.Collocation method), 45 inner() (orthsys.OrthSystem method), 44 setSampleMeasure() (collocation.Collocation method), integral() (measure.Measure method), 43 45

53 pyProximation Documentation, Release 1.3.2 setSolver() (collocation.Collocation method), 45 SetTitle() (graphics.Graphics method), 47 Solve() (collocation.Collocation method), 45 Solve() (subregion.SubRegion method), 46 SubRegion (class in subregion), 45 subregion (module), 45 T TensorPrd() (orthsys.OrthSystem method), 44

54 Index