Ask Your Question
0

How to represent the answer of linear programming in Rational mode

asked 2012-10-01 18:00:17 -0500

jialrs gravatar image

updated 2012-10-01 20:02:53 -0500

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
3

answered 2012-10-02 04:47:23 -0500

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 10:12:06 -0500 )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 05:55:11 -0500 )edit
0

answered 2012-10-02 04:24:13 -0500

DSM gravatar image

updated 2012-10-02 04:24:29 -0500

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

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-01 18:00:17 -0500

Seen: 69 times

Last updated: Oct 02 '12