Ask Your Question
0

How to represent the answer of linear programming in Rational mode

asked 2012-10-02 01:00:17 +0200

jialrs gravatar image

updated 2012-10-02 03:02:53 +0200

Hi everyone:

I use COIN in sage to solve a linear programming. And I need the answer to be in fraction, but the default is not factional. That's to say I need the answer

\frac{1}{3}

not

`0.3333....` ,

so, how can I get the answer I need ?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2012-10-02 11:24:13 +0200

DSM gravatar image

updated 2012-10-02 11:24:29 +0200

You can't in general, without making some further assumptions -- how do you know that the answer really isn't 33333/100000?

If you want a sort of best-guess fraction, you can use the Farey sequence and the Sage function farey:

sage: farey(0.3333, 1)
(0, 1)
sage: farey(0.3333, 2)
(0, 1)
sage: farey(0.3333, 3)
(1, 3)
sage: farey(0.3333, 100)
(1, 3)
edit flag offensive delete link more
3

answered 2012-10-02 11:47:23 +0200

Volker Braun gravatar image

The arbitrary precision linear programming backend is not yet merged, but you can get it from http://trac.sagemath.org/12533

edit flag offensive delete link more

Comments

This will give the OP more 3s, but won't return an answer in QQ, unless I'm missing something (always possible, of course.)

DSM gravatar imageDSM ( 2012-10-02 17:12:06 +0200 )edit

According to http://www.sagemath.org/doc/reference/sage/libs/ppl.html (to which the above link points), PPL computes in QQ.

Robert Samal gravatar imageRobert Samal ( 2012-10-04 12:55:11 +0200 )edit

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: 2012-10-02 01:00:17 +0200

Seen: 208 times

Last updated: Oct 02 '12