# With DynamicPolynomials and non-commutative variables, (x+y)\*z does not work

**URL:** <https://discourse.julialang.org/t/with-dynamicpolynomials-and-non-commutative-variables-x-y-z-does-not-work/139046>\
**Category:** General Usage\
**Tags:** question, package\
**Created:** [August 26, 2026, 10:12am UTC](https://discourse.julialang.org/t/with-dynamicpolynomials-and-non-commutative-variables-x-y-z-does-not-work/139046 "2026-08-26T10:12:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![The\_Suffocated](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/the_suffocated/32/216809_2.png) [@The\_Suffocated](https://discourse.julialang.org/u/The_Suffocated)\
**Post date:** [August 26, 2026, 10:12am UTC](https://discourse.julialang.org/t/with-dynamicpolynomials-and-non-commutative-variables-x-y-z-does-not-work/139046/1 "2026-08-26T10:12:58Z")

</div>

How to right-multiply x+y by z in DynamicPolynomials when x, y, z are non-commutative? I have tried (x+y)\*z, but Julia returns an **ERROR:** MethodError: no method matching map\_exponents(::typeof(+), ::MonomialVector{…}, ::Variable{…})

Strangely, z\*(x+y) yields the result zy + zx properly. The documentation for DynamicPolynomials is terse and it does not indicate anything special about right-multiplication by a single variable.

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [August 26, 2026, 1:43pm UTC](https://discourse.julialang.org/t/with-dynamicpolynomials-and-non-commutative-variables-x-y-z-does-not-work/139046/2 "2026-08-26T13:43:49Z")

</div>

You can cheat a bit with a polynomial equal to the variable e.g. `@ncpolyvar x y z; (x+y)*(z+0)`. The `MethodError` seems to warrant filing an issue; even if intentional, the API should be clarified and ideally documented.

---

<div class="post-metadata">

**Author:** ![The\_Suffocated](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/the_suffocated/32/216809_2.png) [@The\_Suffocated](https://discourse.julialang.org/u/The_Suffocated)\
**Post date:** [August 26, 2026, 1:52pm UTC](https://discourse.julialang.org/t/with-dynamicpolynomials-and-non-commutative-variables-x-y-z-does-not-work/139046/3 "2026-08-26T13:52:35Z")

</div>

It works! Many thanks.

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [August 28, 2026, 5:46am UTC](https://discourse.julialang.org/t/with-dynamicpolynomials-and-non-commutative-variables-x-y-z-does-not-work/139046/4 "2026-08-28T05:46:29Z")

</div>

This got patched with a new method and released in v0.6.7: [Pull Request #205 · JuliaAlgebra/DynamicPolynomials.jl](https://github.com/JuliaAlgebra/DynamicPolynomials.jl/pull/205). It’s still a little odd because the _commutative_ right-multiplication still uses the `MultivariatePolynomials` method that caused this problem, but maybe that just happens to be what it could support for `DynamicPolynomials` types.

---

<div class="post-metadata">

**Author:** ![The\_Suffocated](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/the_suffocated/32/216809_2.png) [@The\_Suffocated](https://discourse.julialang.org/u/The_Suffocated)\
**Post date:** [August 30, 2026, 3:51pm UTC](https://discourse.julialang.org/t/with-dynamicpolynomials-and-non-commutative-variables-x-y-z-does-not-work/139046/5 "2026-08-30T15:51:52Z")

</div>

**Update.** I have reported another related [issue](https://github.com/JuliaAlgebra/DynamicPolynomials.jl/issues/206): `z*(x+y)` is correctly evaluated but `2z*(x+y)`, `-z*(x+y)`, `-2z*(x+y)` etc. are not. Your workaround still works: `(2z+0)*(x+y)` yields a correct answer.
