Loading [MathJax]/jax/output/HTML-CSS/jax.js

First time here? Check out the FAQ!

Ask Your Question
0

solving a set of equations involving both inequalities and equalities

asked 11 years ago

REKHA BISWAL gravatar image

updated 11 years ago

How to write a code in sage to find solutions of a set of equalities and inequalities in more than one variables.for example i want to find solutions for the equations 1i3xi=10 , x_1 < x_2 < x_3 .

Preview: (hide)

Comments

Your commentary below seems to indicate that this question needs some serious clarification/correction.

rickhg12hs gravatar imagerickhg12hs ( 11 years ago )

2 Answers

Sort by » oldest newest most voted
2

answered 11 years ago

Volker Braun gravatar image

updated 11 years ago

Since everything is linear your solution set is a polyhedron. For simplicity, lets take it closed (use <= instead of <). Then:

sage: P = Polyhedron(eqns=[(-10,1,1,1)], ieqs=[(0,-1,1,0), (0,0,-1,1)])
sage: P.Hrepresentation()
(An equation (1, 1, 1) x - 10 == 0,
 An inequality (-1, 1, 0) x + 0 >= 0,
 An inequality (-1, -2, 0) x + 10 >= 0)

Edit: Lattice points with all variables being positive as well (which is probably what the question is about)

sage: P = Polyhedron(eqns=[(-10,1,1,1)], ieqs=[(0,-1,1,0), (0,0,-1,1), (0,1,0,0)])
sage: P.Hrepresentation()
(An equation (1, 1, 1) x - 10 == 0,
 An inequality (-1, 1, 0) x + 0 >= 0,
 An inequality (-1, -2, 0) x + 10 >= 0,
 An inequality (1, 0, 0) x + 0 >= 0)
sage: P.integral_points()
((0, 0, 10),
 (0, 1, 9),
 (0, 2, 8),
 (0, 3, 7),
 (0, 4, 6),
 (0, 5, 5),
 (1, 1, 8),
 (1, 2, 7),
 (1, 3, 6),
 (1, 4, 5),
 (2, 2, 6),
 (2, 3, 5),
 (2, 4, 4),
 (3, 3, 4))
Preview: (hide)
link

Comments

Is there any way to define polyhedron in terms of equations rather than points since the number of equations and number of variables might be too large in which case it would not be possible to write all equations in terms of tuples.?

REKHA BISWAL gravatar imageREKHA BISWAL ( 11 years ago )
0

answered 11 years ago

rickhg12hs gravatar image

Using your example:

sage: var('x_1 x_2 x_3')
(x_1, x_2, x_3)
sage: solve([x_1+x_2+x_3==10, x_1 < x_2, x_2 < x_3], x_1, x_2, x_3)
[[x_1 == -x_2 - x_3 + 10, -1/2*x_3 + 5 < x_2, x_2 < x_3, (10/3) < x_3]]
Preview: (hide)
link

Comments

I want solutions in terms of tuples of integers not in terms of same equations in different form.

REKHA BISWAL gravatar imageREKHA BISWAL ( 11 years ago )
1

You didn't mention in your original question that you want integer solutions (and probably only positive integer solutions). In general, the solution given by solve is not "in terms of the same equations". It is giving you general solutions where the solutions for x1 and x2 depend on the value x3 takes. For *positive* integer solutions what you really want is partitions of 10. Then use the [Partitions class](http://www.sagemath.org/doc/reference/combinat/sage/combinat/partition.html) in Sage. After you get the solutions, eliminate those solutions that have repeated values in them. Alternatively, use the arguments in the `Partitions` command itself to impose such strict monotonicity properties.

ppurka gravatar imageppurka ( 11 years ago )

sorry for the inconvenience.Actually i want to find all the lattice points of the polytope given by 20 equations.since i can not write all those 20 equations,hence i wanted to know if there is any code with which i can write equations in stead of tuples.

REKHA BISWAL gravatar imageREKHA BISWAL ( 11 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 11 years ago

Seen: 1,200 times

Last updated: May 04 '13