Randomness when using lsolve
Hello everybody I'm new to GiNaC. I'm trying to use it to solve linear algebraic system of equations and running the example from the tutorial https://www.ginac.de/tutorial/Solving-linear-systems-of-equations.html#Solvi... symbol a("a"), b("b"), x("x"), y("y"); lst eqns, vars; eqns = a*x+b*y==3, x-y==b; vars = x, y; cout << lsolve(eqns, vars) << endl; While it works perfectly when I run it several times I get different solutions (they are all equivalent though). For example: {x==(3+b^2)*(a+b)^(-1),y==-(a+b)^(-1)*(-3+a*b)} or {x==(b+a)^(-1)*(3+b^2),y==-(-3+b*a)*(b+a)^(-1)} what is going on there? Is there a way to have a deterministic solution? Thanks in advance. Fede -- I find television very educational. Every time someone switches it on, I go into another room and read a good book.
Good evening,
On Thu, 16 Jan 2014 17:20:31 -0200, Federico Bergero <fedebergero@gmail.com> said:
FB> what is going on there? Is there a way to have a deterministic FB> solution? You cannot force GiNaC to produce always a+b and not b+a. However, this expressions are equal and GiNaC is able to check that. If this is crucial for you for some reasons, you need to write your own filtering output. Best wishes, -- Vladimir V. Kisil email: kisilv@maths.leeds.ac.uk www: http://www.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Transformations http://www.worldscientific.com/worldscibooks/10.1142/p835
Thanks Vladimir. I was just reading the FAQ about that. Best Fede On Thu, Jan 16, 2014 at 4:28 PM, Vladimir V. Kisil <kisilv@maths.leeds.ac.uk> wrote:
Good evening,
On Thu, 16 Jan 2014 17:20:31 -0200, Federico Bergero <fedebergero@gmail.com> said:
FB> what is going on there? Is there a way to have a deterministic FB> solution?
You cannot force GiNaC to produce always a+b and not b+a. However, this expressions are equal and GiNaC is able to check that. If this is crucial for you for some reasons, you need to write your own filtering output.
Best wishes, -- Vladimir V. Kisil email: kisilv@maths.leeds.ac.uk www: http://www.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Transformations http://www.worldscientific.com/worldscibooks/10.1142/p835
-- I find television very educational. Every time someone switches it on, I go into another room and read a good book.
participants (2)
-
Federico Bergero
-
Vladimir V. Kisil