Processing math: 100%
Ask Your Question
0

Formatting inequalities display

asked 12 years ago

RPC gravatar image

When solving inequalities of the type x21>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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 12 years ago

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))
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: 289 times

Last updated: Feb 28 '13