Page 1 sur 1

How to define equations and inequations in giacpy

Publié : sam. déc. 09, 2017 4:00 pm
par jocaps
I want to use linsolve to solve a linear system of equations (in giacpy). I have already several values in python (pygen types) for the variables (say x,y and z) and I know how to write some equations like 2*x+3*y+4 etc. But what is the best way to write equalities and put them in linsolve. I cannot write 2*x+3*y+4=5 in python, I could use strings but I am sure there is a more elegant way. Any suggestions would be appreciated.

Edit: Thankfully I realized in linsolve I do not need to write equality so writing

Code : Tout sélectionner

linsolve([2*x+y+z-1,x+y+2*z-1,x+2*y+z-4],[x,y,z])
works perfectly assuming that the equations are equal to 0.

Re: How to define equations and inequations in giacpy

Publié : sam. déc. 09, 2017 4:18 pm
par parisse
Is it possible to define infix === in Python? Because that's the way I decided to implement expression equality in the Python compatibility mode of Xcas. Otherwise equal() prefixed could be redefined to do that.

Re: How to define equations and inequations in giacpy

Publié : dim. déc. 10, 2017 10:08 am
par jocaps
I do not think it is possible to use === in python. Equal works though, thanks for the suggestion.