First time here? Check out the FAQ!

Ask Your Question
0

How to represent the answer of linear programming in Rational mode

asked 12 years ago

jialrs gravatar image

updated 12 years ago

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 ?

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
3

answered 12 years ago

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

Preview: (hide)
link

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 ( 12 years ago )

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 ( 12 years ago )
0

answered 12 years ago

DSM gravatar image

updated 12 years ago

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)
Preview: (hide)
link

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: 12 years ago

Seen: 317 times

Last updated: Oct 02 '12