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

Finding Coefficients of Cross Terms #1056

Closed
Umut-Can-Physics opened this issue Feb 14, 2024 · 3 comments
Closed

Finding Coefficients of Cross Terms #1056

Umut-Can-Physics opened this issue Feb 14, 2024 · 3 comments

Comments

@Umut-Can-Physics
Copy link

When I try to run the following code, the print function always returns the integer 0 (zero). However, you can easily see that the coefficient of the z[1] * z[2] term equals -2. The Symbolics.jl module is robust for just single variables, such as coefficients of z[1]^2 and z[2]^2.

using Symbolics

@variables z[1:2]

Ψ = z[1]^2 - 2 * z[1] * z[2] + z[2]^2

# Extract coefficient
coeff_value = Symbolics.coeff(Ψ, z[1]*z[2])

println(coeff_value)

But interestingly Symbolics.coeff(Ψ,z[2]^0*z[1]^2) coefficient is true. The module doesn’t work for Symbolics.coeff(Ψ, z[1]*z[2]) Why?

@Umut-Can-Physics
Copy link
Author

Anyone who solve this problem?

@zengmao
Copy link
Contributor

zengmao commented Aug 26, 2024

Duplicate of #1041

@ChrisRackauckas
Copy link
Member

Fixed in #1240

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

3 participants