# Memory-free multivariate polynomials

**URL:** https://discourse.julialang.org/t/memory-free-multivariate-polynomials/117361
**Category:** Package Announcements
**Tags:** polynomials, coordinate-transform
**Created:** [July 22, 2024, 7:55pm UTC](https://discourse.julialang.org/t/memory-free-multivariate-polynomials/117361 "2024-07-22T19:55:31Z")
**Posts on this page:** 7
**Page:** 2

<div class="post-metadata">

### Author: ![RainerHeintzmann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rainerheintzmann/32/19726_2.png) [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)
#### Post date: [August 3, 2024, 2:52pm UTC](https://discourse.julialang.org/t/memory-free-multivariate-polynomials/117361/21 "2024-08-03T14:52:37Z")

</div>

Thanks! This is very helpful. I would have had no idea how to construct a basis and use it.  
If I compare the performance with `EvalMultiPoly.jl` using only orders up to 3, `EvalMultiPoly.jl` is significantly faster (81µs for order 3, compared to 2.8 ms for `SmolyakParameters(2, 2)`) but then this is not a fair comparison. However, with order 4 or more `EvalMultiPoly.jl` starts to allocate and then the performance get really bad.  
If you can add a `TensorBasis` that would allow to create simple mutivariate polynomials similar to `valMultiPoly.jl`, this may be a nice addition!

---

<div class="post-metadata">

### Author: ![RainerHeintzmann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rainerheintzmann/32/19726_2.png) [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)
#### Post date: [August 12, 2024, 2:19pm UTC](https://discourse.julialang.org/t/memory-free-multivariate-polynomials/117361/22 "2024-08-12T14:19:59Z")

</div>

… another thing is that `linear_combination` leads to a different way that the order of the multivariate polynomial is limited than one would typically limit the order in a multivariate expansion (e.g. `yx^2` not being part of the second order multivariate polynomial, but `x^2` being part of it). Any idea how to handle this?

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [December 9, 2024, 2:44pm UTC](https://discourse.julialang.org/t/memory-free-multivariate-polynomials/117361/23 "2024-12-09T14:44:22Z")

</div>

Sorry for the late reply. The package implements the Smolyak sparse family, which has this property, and is generally considered to have some other nice ones.

If you want to include polynomials x\_1^{n\_1} x\_2^{n\_2} \dots such that \sum n\_i \le K, that is a different family. I could add it if needed — I am currently refactoring the package. Note however that generally this family does not have the polynomial complexity of Smolyak, so you still get a mild curse of dimensionality. [I know that historically, it is widely used.]

---

<div class="post-metadata">

### Author: ![RainerHeintzmann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rainerheintzmann/32/19726_2.png) [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)
#### Post date: [December 9, 2024, 10:22pm UTC](https://discourse.julialang.org/t/memory-free-multivariate-polynomials/117361/24 "2024-12-09T22:22:57Z")

</div>

Thanks. Sounds interesting to switch to this family of limited polynomials. Any progress on the `TensorBasis`?

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [December 10, 2024, 12:01pm UTC](https://discourse.julialang.org/t/memory-free-multivariate-polynomials/117361/25 "2024-12-10T12:01:52Z")

</div>

I will be finishing the refactoring I am working on first, but then it should be trivial to add. One thing I am not sure about is how much unrolling and static code generation one wants to use: as opposed to Smolyak, tensor bases get large really fast so unrolling becomes a liability at very small dimensions.

I can still get allocation-free loops, just not unrolled. I am coding up a hybrid approach that switches between the two at some dimension.

What are your dimensions, ie degree of polynomial along each dimension, and the total number of dimensions? Is it 200^2 or something else?

---

<div class="post-metadata">

### Author: ![RainerHeintzmann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rainerheintzmann/32/19726_2.png) [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)
#### Post date: [December 10, 2024, 12:22pm UTC](https://discourse.julialang.org/t/memory-free-multivariate-polynomials/117361/26 "2024-12-10T12:22:51Z")

</div>

The degree of the polynomial is in practical situations very small. E.g. multivariate (2 dimensions X, Y) and 3 orders (e.g YX^2 being one of the highest order terms). So the number of dimensions is typically up to 3. Maybe in crazy cases 4. This polynomial is then applied to millions of coordinates to transform, but this has nothing to do with the dimensions of the polynomial. However allocation-free becomes very important upon application to millions of pixels or voxels.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [December 10, 2024, 12:26pm UTC](https://discourse.julialang.org/t/memory-free-multivariate-polynomials/117361/27 "2024-12-10T12:26:41Z")

</div>

Thanks, this was informative. This is the use case I am targeting with unrolling.

[Previous page](https://discourse.julialang.org/t/memory-free-multivariate-polynomials/117361.md?page=1)
