ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 27 Feb 2013 22:46:46 -0600Formatting inequalities displayhttps://ask.sagemath.org/question/9861/formatting-inequalities-display/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`?Wed, 27 Feb 2013 12:14:13 -0600https://ask.sagemath.org/question/9861/formatting-inequalities-display/Answer by ndomes for <p>When solving inequalities of the type
$$x^2-1>0$$
I use the code <code>solve(x^2-1<0,x)</code>
to obtain the answer <code>[[x > -1, x < 1]]</code>.</p>
<p>Question 1: Is there a way to make Sage display this solution as <code>-1<x<1</code>? </p>
<p>Question 2: Is there an already implemented way to change the display of the inequality <code>x>1</code> to <code>1<x</code>?</p>
https://ask.sagemath.org/question/9861/formatting-inequalities-display/?answer=13434#post-id-13434In 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))Wed, 27 Feb 2013 22:46:46 -0600https://ask.sagemath.org/question/9861/formatting-inequalities-display/?answer=13434#post-id-13434