Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy multiplication of polynomials #55

Open
mforets opened this issue Feb 3, 2020 · 1 comment
Open

Lazy multiplication of polynomials #55

mforets opened this issue Feb 3, 2020 · 1 comment

Comments

@mforets
Copy link
Contributor

mforets commented Feb 3, 2020

When computing with intervals (ref. IntervalArithmetic), the order in which an evaluation is performed matters. A simple example is

julia> using IntervalArithmetic

julia> a, b = -1..1, 2..3
[-1, 1]

julia> (a+b)*b
[2, 12]

julia> a*b + b*b
[1, 12]

The example shows that evaluating the factored expression gives a better (tighter) result than using the expanded expression.

Have you considered a "lazy" multiplication of polynomials within this package, such that the expression is hold until asked to be evaluated (i mean expanded symbolically)? A "factor" function would also help, but if it exists, i didn't see it. There is this related issue, but it hasn't received much attention.

To illustrate my use case in a concrete example, consider:

julia> using DynamicPolynomials

julia> @polyvar M[1:2, 1:2]
(PolyVar{true}[M₁₋₁ M₁₋₂; M₂₋₁ M₂₋₂],)

julia> first(M^3) # expands everything
M₁₋₁³ + 2M₁₋₁M₂₋₁M₁₋₂ + M₂₋₁M₁₋₂M₂₋₂

julia> using SymEngine

julia> M = convert(Matrix{SymEngine.Basic}, ["M₁₁" "M₁₂"; "M₂₁" "M₂₂"])
2×2 Array{Basic,2}:
 M₁₁  M₁₂
 M₂₁  M₂₂

julia> first(M^3) # keeps the terms factored
(M₂₁*M₁₂ + M₁₁^2)*M₁₁ + (M₂₁*M₁₁ + M₂₂*M₂₁)*M₁₂
@blegat
Copy link
Member

blegat commented Feb 3, 2020

There is no feature like that that I know of. This is the kind of features that could be built on top of the MultivariatePolynomials API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants