Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/antononcube/raku-math-polynomial-chebyshev

Raku package for functionalities based on Chebyshev polynomials.
https://github.com/antononcube/raku-math-polynomial-chebyshev

chebyshev-polynomials orthogonal-polynomials polynomials raku rakulang

Last synced: 15 days ago
JSON representation

Raku package for functionalities based on Chebyshev polynomials.

Awesome Lists containing this project

README

        

# Math::Polynomial::Chebyshev

Raku package for functionalities based on Chebyshev polynomials.

------

## Installation

From Zef ecosystem:

```
zef install Math::Polynomial::Chebyshev
```

From GitHub:

```
zef install https://github.com/antononcube/Raku-Math-Polynomial-Chebyshev.git
```

-------

## Usage examples

Evaluate the numerical value of the Chebyshev polynomial of first kind $T_2(3)$:

```perl6
use Math::Polynomial::Chebyshev;

chebyshev-t(2, 0.3)
```

The default method is "recursive":

```perl6
chebyshev-t(2, 6, method => 'recursive')
```

Here is an invocation of the "trigonometric" method:

```perl6
chebyshev-t(2, 3, method => 'trigonometric')
```

**Remark:** Currently, the trigonometric method is implemented only for the Chebyshev polynomials of first kind
(Chebyshev-T.)

Plot the 7th Chebyshev-T polynomial:

```perl6
use Text::Plot;

my @x = (-1, -0.99 ... 1);
text-list-plot(@x, chebyshev-t(6, @x), width => 60)
```

Here we make a Chebyshev-T function:

```perl6
chebyshev-u(4)
```

A list of Chebyshev polynomials can be used as a basis for the models in
["Math::Fitting"](), [AAp2].
Here is an example:

```perl6
use Math::Fitting;

my @basis = (^4).map({ chebyshev-t($_) });
my @data = [2.rand - 1, 10.rand] xx 20;

my &lm = linear-model-fit(@data, :@basis);
```

Here is a plot of the data and the fit:

```perl6
my @fit = (-1, -0.98 ... 1).map({ [$_, &lm($_)] });
say Z=> <* □>;
say text-list-plot([@fit, @data])
```

--------

## References

### Articles

[WK1] Wolfram Koepf,
["Efficient Computation of Chebyshev Polynomials in Computer Algebra"](https://www.researchgate.net/publication/2321141_Efficient_Computation_of_Chebyshev_Polynomials_in_Computer_Algebra).
(1999),
Computer Algebra Systems: A Practical Guide. 79-99.

[Wk1] Wikipedia entry, [Chebyshev polynomials](https://en.wikipedia.org/wiki/Chebyshev_polynomials).

### Packages

[AAp1] Anton Antonov,
[Text::Plot Raku package](https://github.com/antononcube/Raku-Text-Plot),
(2022-2023),
[GitHub/antononcube](https://github.com/antononcube).

[AAp2] Anton Antonov,
[Math::Fitting Raku package](https://github.com/antononcube/Raku-Math-Fitting),
(2024),
[GitHub/antononcube](https://github.com/antononcube).

[SFp1] Solomon Foster,
[Math::ChebyshevPolynomial Raku package](https://github.com/colomon/Math-ChebyshevPolynomial),
(2013-2015),
[GitHub/colomon](https://github.com/colomon).