Ask Your Question
0

Formatting inequalities display

asked 2013-02-27 12:14:13 -0500

RPC gravatar image

When solving inequalities of the type $$x^2-1>0$$ I use the code solve(x^2-1<0,x) to obtain the answer [[x > -1, x < 1]].

Question 1: Is there a way to make Sage display this solution as -1<x<1?

Question 2: Is there an already implemented way to change the display of the inequality x>1 to 1<x?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-02-27 22:46:46 -0500

ndomes gravatar image

In your case you can use your own function:

def show_result(sol):
    L = [s.rhs() for s in sol[0] ]
    print ' %s < %s < %s ' %(min(L),sol[0][0].variables()[0],max(L) )

show_result(solve(x^2-4<0,x))
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: 2013-02-27 12:14:13 -0500

Seen: 54 times

Last updated: Feb 27 '13