This class contains common features of all modules.
Returns a list. The list consists of all symbolic tools present among ‘sympy’,’sage’ and ‘symengine’.
- 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
Checks the structure of the box B. Returns True id B is a list of 2-tuples, otherwise it returns False.
Checks the input types and their consistency, according to the __init__ arguments.
Returns the integral of f with respect to the currwnt measure over the support.
Returns the measure of the set S. S must be a list of 2-tuples.
Computes the norm-p of the f with respect to the current measure.
Samples from the support according to the measure.
OrthSystem(variables, var_range, env='sympy')¶
OrthogonalSystemclass produces an orthogonal system of functions according to a suggested basis of functions and a given measure supported on a given region.
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
variablesand the range of each these variables as a list of lists
To specify a particular family of function as a basis, one should call this method with a list
base_setof linearly independent functions.
Call this method to generate the orthogonal basis corresponding to the given basis via
Basismethod. The result will be stored in a property called
OrthBasewhich is a list of function that are orthogonal to each other with respect to the measure
measureover the given range
Generates a Fourier basis from variables consisting of all \(sin\) & \(cos\) functions with coefficients at most n.
Generates a polynomial basis from variables consisting of all monomials of degree at most
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.
To set the measure which the orthogonal system will be computed, simply call this method with the corresponding distribution as its parameter dm; i.e, the parameter is d(m) where m is the original measure.
Sets the orthonormal basis to be the given base.
Takses a list of symbolic bases, each one a list of symbolic expressions and returns the tensor product of them as a list.
Computes the inner product of the two parameters with respect to the measure
Finds the projection of
gwith respect to the inner product induced by the measure
Interpolationclass provides polynomial interpolation routines in multi variate case.
var is the list of symbolic variables and env is the the symbolic tool.
Construct the matrix corresponding to idx‘th point, if idx>0 Otherwise returns the discriminant.
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.
Returns the minimum number of points still required.
Generates the minimal set of monomials for interpolation.
Collocation(variables, ufunc, env='sympy')¶
Collocationclass 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:
- List of independent symbolic variables variables;
- List of unknown functions to be found that depend on the independent variables
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.
List of initial and boundary conditions.
To enter the system of equations, use this meyhod with a list of equations as input.
Finds the region that all variables are defined.
Internal use: plug in collocation points to elliminate independent variables and keep the coefficients.
To approximate the solutions of the system of pdes, the class requires an orthogonal system of functions
OrthSystem. This method accepts such a system.
Solves the collocation equations and keep a dictionary of coefficients in
self.Coeffsand returns a list of functions in the span of orthoginal system.
Internal use: generates the system of equations for coefficients to be used via collocation points.
Sets the measure over the domain for sampling collocation points in case of necessity.
Currently only two solvers are supported:
- 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:
- lm (defauls)
The SubRegion class partitions the region into sub-regions, solve the system of Integro-differential equations on each and glue them together.
- It takes:
- a collocation instance collsys;
- an optional list of positive integers num_parts which shows the number of equal length partitions for each variable.
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.
Compiles a piece-wise defined symbolic function from the solution for func which is an unknown from the original collocation system.
Initializes a set of collocation systems for all subregions.
Solves the collocation system for each region and generates boundary conditions for adjacent regions.
Generates end corner points of the region represented tpl as collocation points (used internally).
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,
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.
Sets the label for X axis
Sets the label for Y axis
Sets the label for Z axis
Sets the title of the graph.
Shows an interavtive demo of the 3D surface, using mayavi, so it requires mayavi for python to be installed.
Saves the outpu of the Graphics object to the file fname.