1664946660
This Julia package implements the Barycentric formula for polynomial interpolation on equispaced points and Chebyshev points of the first and second kind. The formulae used are taken from the paper of Berrut and Trefethen, SIAM Review, 2004.
This is not a general purpose interpolation package but is intended to be used as a base for other numerical methods, such as numerical collocation. For a general use interpolation package see Interpolations.jl
There are various types of polynomials defined based on the locations of their nodes (zeros).
Equispaced{N}()
) — a common choice when data is equispaced but suffers from Runge phenomenon for high degree polynomials. When used as part of a collocation scheme with Gauss-Legendre collocation points, they provide the benefit of super-convergence. By default the nodes are equispaced over [-1, +1].Chebyshev1{N}()
) — nodes distributed according to cos(π(2j + 1)/(2N + 2)) where N is the degree of the polynomial, for j in [0, N].Chebyshev2{N}()
) — nodes distributed according to cos(πj/N) where N is the degree of the polynomial, for j in [0, N].Legendre{N}()
) — nodes distributed according to the zeros of the corresponding Legendre polynomial where N is the degree of the polynomial.ArbitraryPolynomial(nodes)
) — nodes distributed as specified.By default, each of the polynomials are defined over the range [-1, +1]. This can be modified by specifying a start and stop for the range, e.g., Equispaced{10}(0, 1)
will generate a 10th order polynomial with equispaced nodes over the range [0, 1].
Polynomials with nodes asymptotically clustered towards the end points (such as Chebyshev) are optimal for avoiding the Runge phenomenon (see Trefethen, Spectral Methods in MATLAB, SIAM 2000).
Once a polynomial has been defined it can be used with the nodes(poly)
and weights(poly)
functions to return the locations of the nodes and the values of the Barycentric weights respectively. To interpolate a set of y
values (defined at the nodes) use interpolate(poly, y, x_new)
; x_new
can be either a scalar or a vector. If x_new
is omitted, the interpolate
function returns a function y(x)
which can be used to evaluate the interpolant at any point.
To obtain the interpolant as a linear combination of the y
values, use interpolation_matrix(poly, x)
; this returns a matrix which can be multiplied by a vector of y
values to calculate the interpolated value.
Finally, the derivative of the polynomial at the nodes can be obtained using differentiation_matrix(poly)
. Similar to interpolation_matrix
, this returns a matrix which can be multiplied by a vector of y
values to calculate the derivative of y
.
using BarycentricInterpolation
p = Chebyshev2{20}() # create a Chebyshev type 2 polynomial of order 20
x = nodes(p) # get the nodes
y = sinpi.(x) # generate y values at the nodes
x_new = rand()*2 -1 # a random number in [-1, +1]
println(interpolate(p, y, x_new) ≈ sinpi(x_new)) # hopefully true!
D = differentiation_matrix(p) # get the differentiation matrix
println(interpolate(p, D*y, x_new) ≈ pi*cospi(x_new)) # hopefully true!
For an example with Barycentric.jl applied to the simulation of a PDE (in combination with DifferentialEquations.jl) see https://cityinthesky.co.uk/posts/2018/barycentricinterpolation.jl/.
Author: Dawbarton
Source Code: https://github.com/dawbarton/BarycentricInterpolation.jl
License: View license
1664946660
This Julia package implements the Barycentric formula for polynomial interpolation on equispaced points and Chebyshev points of the first and second kind. The formulae used are taken from the paper of Berrut and Trefethen, SIAM Review, 2004.
This is not a general purpose interpolation package but is intended to be used as a base for other numerical methods, such as numerical collocation. For a general use interpolation package see Interpolations.jl
There are various types of polynomials defined based on the locations of their nodes (zeros).
Equispaced{N}()
) — a common choice when data is equispaced but suffers from Runge phenomenon for high degree polynomials. When used as part of a collocation scheme with Gauss-Legendre collocation points, they provide the benefit of super-convergence. By default the nodes are equispaced over [-1, +1].Chebyshev1{N}()
) — nodes distributed according to cos(π(2j + 1)/(2N + 2)) where N is the degree of the polynomial, for j in [0, N].Chebyshev2{N}()
) — nodes distributed according to cos(πj/N) where N is the degree of the polynomial, for j in [0, N].Legendre{N}()
) — nodes distributed according to the zeros of the corresponding Legendre polynomial where N is the degree of the polynomial.ArbitraryPolynomial(nodes)
) — nodes distributed as specified.By default, each of the polynomials are defined over the range [-1, +1]. This can be modified by specifying a start and stop for the range, e.g., Equispaced{10}(0, 1)
will generate a 10th order polynomial with equispaced nodes over the range [0, 1].
Polynomials with nodes asymptotically clustered towards the end points (such as Chebyshev) are optimal for avoiding the Runge phenomenon (see Trefethen, Spectral Methods in MATLAB, SIAM 2000).
Once a polynomial has been defined it can be used with the nodes(poly)
and weights(poly)
functions to return the locations of the nodes and the values of the Barycentric weights respectively. To interpolate a set of y
values (defined at the nodes) use interpolate(poly, y, x_new)
; x_new
can be either a scalar or a vector. If x_new
is omitted, the interpolate
function returns a function y(x)
which can be used to evaluate the interpolant at any point.
To obtain the interpolant as a linear combination of the y
values, use interpolation_matrix(poly, x)
; this returns a matrix which can be multiplied by a vector of y
values to calculate the interpolated value.
Finally, the derivative of the polynomial at the nodes can be obtained using differentiation_matrix(poly)
. Similar to interpolation_matrix
, this returns a matrix which can be multiplied by a vector of y
values to calculate the derivative of y
.
using BarycentricInterpolation
p = Chebyshev2{20}() # create a Chebyshev type 2 polynomial of order 20
x = nodes(p) # get the nodes
y = sinpi.(x) # generate y values at the nodes
x_new = rand()*2 -1 # a random number in [-1, +1]
println(interpolate(p, y, x_new) ≈ sinpi(x_new)) # hopefully true!
D = differentiation_matrix(p) # get the differentiation matrix
println(interpolate(p, D*y, x_new) ≈ pi*cospi(x_new)) # hopefully true!
For an example with Barycentric.jl applied to the simulation of a PDE (in combination with DifferentialEquations.jl) see https://cityinthesky.co.uk/posts/2018/barycentricinterpolation.jl/.
Author: Dawbarton
Source Code: https://github.com/dawbarton/BarycentricInterpolation.jl
License: View license
1666125240
InterPol
Given values of a function y=y(x) y=[...]
at points x=[...]
we can generate an interpolating polynomial p(x). This package provides two functions: interpolateAt
and interpolateDerivativeAt
. interpolateAt[x,y,x0]
gives the value of the interpolating polynomial p at the point x0. interpolateDerivativeAt[x,y,x0]
evaluates p' at the point x0. For example
julia> interpolateAt([0,1,2],[0,1,4],1)
1.0
julia> interpolateDerivativeAt([0,1,2],[0,1,4],1)
2.0
Author: pwl
Source Code: https://github.com/pwl/InterPol.jl
License: View license
1664942580
getTensorCoef
is a very efficient algorithm to compute approximating coefficients from a tensor product of basis matrices. it is efficient because it never forms the tensor product.knots = vcat(lb,-0.5,0,0,0.5,ub)
is a valid knot vector.
using ApproXD
f(x) = abs.(x).^0.5
lb,ub = (-1.0,1.0)
nknots = 13
deg = 3
# standard case: equally spaced knots
params1 = BSpline(nknots,deg,lb,ub)
nevals = 5 * params1.numKnots # get nBasis < nEvalpoints
# myknots with knot multiplicity at 0
myknots = vcat(range(-1,stop = -0.1,length = 5),0,0,0, range(0.1,stop = 1,length =5))
params2 = BSpline(myknots,deg) # 0: no derivative
# get coefficients for each case
eval_points = collect(range(lb,stop = ub,length = nevals))
c1 = getBasis(eval_points,params1) \ f(eval_points)
c2 = getBasis(eval_points,params2) \ f(eval_points)
# look at errors over entire interval
test_points = collect(range(lb,stop = ub,length = 1000));
truth = f(test_points);
p1 = getBasis(test_points,params1) * c1;
p2 = getBasis(test_points,params2) * c2;
e1 = p1 - truth;
e2 = p2 - truth;
Author: floswald
Source Code: https://github.com/floswald/ApproXD.jl
License: MIT license
1660615380
This is a pure Julia implementation of the Apache Arrow data standard. This package provides Julia AbstractVector
objects for referencing data that conforms to the Arrow standard. This allows users to seamlessly interface Arrow formatted data with a great deal of existing Julia code.
The package can be installed by typing in the following in a Julia REPL:
julia> using Pkg; Pkg.add("Arrow")
or to use the official-apache code that follows the official apache release process, you can do:
julia> using Pkg; Pkg.add(url="https://github.com/apache/arrow", subdir="julia/Arrow.jl")
When developing on Arrow.jl it is recommended that you run the following to ensure that any changes to ArrowTypes.jl are immediately available to Arrow.jl without requiring a release:
julia --project -e 'using Pkg; Pkg.develop(path="src/ArrowTypes")'
This implementation supports the 1.0 version of the specification, including support for:
It currently doesn't include support for:
Third-party data formats:
See the full documentation for details on reading and writing arrow data.
Please see this document for a description of the Arrow memory layout.
Author: Apach
Source Code: https://github.com/apache/arrow-julia
License: View license
1631267007
This package implements a variety of data structures, including
Download Details:
Author: JuliaCollections
The Demo/Documentation: View The Demo/Documentation
Download Link: Download The Source Code
Official Website: https://github.com/JuliaCollections/DataStructures.jl
License:
#julia #programming #developer #scikitlearn