How to define equations and inequations in giacpy

jocaps
Messages : 118
Inscription : lun. avr. 17, 2017 4:32 pm

How to define equations and inequations in giacpy

Message par jocaps » sam. déc. 09, 2017 4:00 pm

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.

parisse
Messages : 5731
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: How to define equations and inequations in giacpy

Message par parisse » sam. déc. 09, 2017 4:18 pm

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.

jocaps
Messages : 118
Inscription : lun. avr. 17, 2017 4:32 pm

Re: How to define equations and inequations in giacpy

Message par jocaps » dim. déc. 10, 2017 10:08 am

I do not think it is possible to use === in python. Equal works though, thanks for the suggestion.

Répondre