JuliaSymbolics / Symbolics.jl

Symbolic programming for the next generation of numerical software
https://symbolics.juliasymbolics.org/stable/
Other
1.34k stars 149 forks source link

Symbolics & left + right inverses? #871

Open B-LIE opened 1 year ago

B-LIE commented 1 year ago

I noticed that Symbolics seems to handle A*x=b via x = A\b when A and b are symbolic arrays. However, with x*A=b, x=b/A does not work, and I have to write x=b*inv(A).

Is this the way it should be, or do you plan to include the / operator in the future?

shashi commented 1 year ago

Yeah we should include / in the future...

aravindh-krishnamoorthy commented 1 year ago

Hello, I'm new to Julia and Symbolics development, but took a shot at implementing this feature here: https://github.com/aravindh-krishnamoorthy/Symbolics.jl/commit/868b93789ffbc2574127aaa13eda23c4d2040409 + https://github.com/aravindh-krishnamoorthy/Symbolics.jl/commit/9b984c396a78553cdf7f64a1e8dded6779cd8b57

Test: https://github.com/aravindh-krishnamoorthy/Symbolics.jl/commit/ecde0b85d6e232bf3a8d16545d209243f8882c64

I still don't understand a few things: (1) Why Symbolics.substitute only works with reshape(b,1,3), (2) Why the reshape trick doesn't work for M in b/M, (3) Why using complex numbers for b and M results in Julia errors. Nevertheless, the simple tests seem to pass.

shashi commented 1 year ago

@aravindh-krishnamoorthy that's pretty good! :) The reshape functionality is not all there. it uses the generic ReshapedArrays if I remember correctly. I would accept a PR with these changes, and you could open more issues about the reshape and substitute issues.

aravindh-krishnamoorthy commented 1 year ago

Thank you very much for the positive comment. The PR is #881

I will soon analyse and raise the issues for reshape and substitute.