Rewriting a symbolic expression as a linear combination of others

I'm trying to solve something that might not be too hard (mathematically), but I'm a bit lost and want to do it with SymPy. I

Two variables are listed here X

, Y

(they are symbolic, I do not have access to any of the values) and known constants a

, b

..., g

. In a piece of existing software that I cannot change, from these

X' = a * X + b
Y' = c * Y + d
Z' = e * X * Y + f

      

... In other other existing software which I cannot change, I have different values, similar calculation is done. I'm simplifying it a lot for the purposes of this question, but to get the idea:

X' and Y' like above
Z_ = (a * x + b) * ( c * y + d) - g

      

To connect between Z'

, and Z_

I want to express z_ as a linear combination of X'

, Y'

, Z'

and 1:

Z_ == 𝛂 * X' + 𝛃 * Y' + 𝛄 * Z' + 𝛅.

      

How can I solve it for 𝛂

, 𝛃

, 𝛄

, 𝛅

using Sympy?

I know that I could have probably avoided SymPy, expressing each of the variables X'

, Y'

, Z'

, Z_

linear combinations X

, Y

, X*Y

and 1, and making matrix algebra. But since my problem is actually more complex and the details may change in the future, I would really appreciate some software help.

+3


source to share





All Articles