From 64d3044c5ee718db57bd16443f25cbd3a40949b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Thu, 28 May 2026 13:57:51 +0200 Subject: [PATCH 1/2] Fix univariate_mul for trigonometric basis --- src/trigonometric.jl | 2 +- test/trigonometric.jl | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/trigonometric.jl b/src/trigonometric.jl index f0bd8ea..8624f00 100644 --- a/src/trigonometric.jl +++ b/src/trigonometric.jl @@ -59,7 +59,7 @@ function univariate_mul!(::Type{Trigonometric}, exps, coefs, var, a, b) push!(exps, _increment(exps[i], _sin_id(da + db), var)) exps[i] = _increment!(exps[i], _sin_id(abs(da - db)), var) coefs[i] = MA.operate!!(/, coefs[i], 2) - push!(coefs, MA.copy_if_mutable(MP.coefficient(terms[i]))) + push!(coefs, MA.copy_if_mutable(coefs[i])) if da < db coefs[i] = MA.operate!!(*, coefs[i], -1) end diff --git a/test/trigonometric.jl b/test/trigonometric.jl index d209e7a..763c649 100644 --- a/test/trigonometric.jl +++ b/test/trigonometric.jl @@ -17,4 +17,10 @@ using DynamicPolynomials ) e = MB.algebra_element(MB.sparse_coefficients(1//1 * x^0), full) @test a * d == a * e + # sin(ωt) * cos(2ωt) = (sin(3ωt) - sin(ωt)) / 2 + # Exponents: sin(ωt) -> x^2, sin(3ωt) -> x^6, cos(2ωt) -> x^3 + s1 = MB.algebra_element(MB.sparse_coefficients(1//1 * x^2), full) + c2 = MB.algebra_element(MB.sparse_coefficients(1//1 * x^3), full) + @test (s1 * c2).coeffs == + MB.sparse_coefficients(-1//2 * x^2 + 1//2 * x^6) end From c46a1821e817ed30f61c5baf9e89d34778812914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Thu, 28 May 2026 13:58:21 +0200 Subject: [PATCH 2/2] Fix format --- test/trigonometric.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/trigonometric.jl b/test/trigonometric.jl index 763c649..3111982 100644 --- a/test/trigonometric.jl +++ b/test/trigonometric.jl @@ -21,6 +21,5 @@ using DynamicPolynomials # Exponents: sin(ωt) -> x^2, sin(3ωt) -> x^6, cos(2ωt) -> x^3 s1 = MB.algebra_element(MB.sparse_coefficients(1//1 * x^2), full) c2 = MB.algebra_element(MB.sparse_coefficients(1//1 * x^3), full) - @test (s1 * c2).coeffs == - MB.sparse_coefficients(-1//2 * x^2 + 1//2 * x^6) + @test (s1 * c2).coeffs == MB.sparse_coefficients(-1//2 * x^2 + 1//2 * x^6) end