ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 21 Feb 2012 03:05:08 +0100How to get an integer from a complex expression?https://ask.sagemath.org/question/8720/how-to-get-an-integer-from-a-complex-expression/Hi, `(22/3*sqrt(2)*sqrt(3) + 485/27)^(1/3) + 1/9/(22/3*sqrt(2)*sqrt(3) + 485/27)^(1/3) + 20/3` equals 10. But how can I get 10 as an integer, as the complex expression has more complex solutions?Fri, 17 Feb 2012 17:33:35 +0100https://ask.sagemath.org/question/8720/how-to-get-an-integer-from-a-complex-expression/Comment by Rolandb for <p>Hi, <code>(22/3*sqrt(2)*sqrt(3) + 485/27)^(1/3) + 1/9/(22/3*sqrt(2)*sqrt(3) + 485/27)^(1/3) + 20/3</code> equals 10. But how can I get 10 as an integer, as the complex expression has more complex solutions?</p>
https://ask.sagemath.org/question/8720/how-to-get-an-integer-from-a-complex-expression/?comment=20271#post-id-20271Thanks for your reply. The complex expression is the solution found by solve, and from theory I know the answer must be an integer. I can use *.n() but that is a real/complex number coincidently equal to 10. What I'm looking for is a solution which is really an integer e.g. is_integer should be True.Tue, 21 Feb 2012 03:05:08 +0100https://ask.sagemath.org/question/8720/how-to-get-an-integer-from-a-complex-expression/?comment=20271#post-id-20271Comment by Shashank for <p>Hi, <code>(22/3*sqrt(2)*sqrt(3) + 485/27)^(1/3) + 1/9/(22/3*sqrt(2)*sqrt(3) + 485/27)^(1/3) + 20/3</code> equals 10. But how can I get 10 as an integer, as the complex expression has more complex solutions?</p>
https://ask.sagemath.org/question/8720/how-to-get-an-integer-from-a-complex-expression/?comment=20279#post-id-20279Can you explain what you mean by "get 10 as an integer"? you can use n() to get 10.Fri, 17 Feb 2012 18:17:24 +0100https://ask.sagemath.org/question/8720/how-to-get-an-integer-from-a-complex-expression/?comment=20279#post-id-20279Comment by Shashank for <p>Hi, <code>(22/3*sqrt(2)*sqrt(3) + 485/27)^(1/3) + 1/9/(22/3*sqrt(2)*sqrt(3) + 485/27)^(1/3) + 20/3</code> equals 10. But how can I get 10 as an integer, as the complex expression has more complex solutions?</p>
https://ask.sagemath.org/question/8720/how-to-get-an-integer-from-a-complex-expression/?comment=20278#post-id-20278I still don't get it. What do you mean by 10 as an integer. ((22/3*sqrt(2)*sqrt(3) + 485/27)^(1/3) + 1/9/(22/3*sqrt(2)*sqrt(3) + 485/27)^(1/3) + 20/3).n() = 10.00. What do you want to use the answer for?Fri, 17 Feb 2012 22:29:10 +0100https://ask.sagemath.org/question/8720/how-to-get-an-integer-from-a-complex-expression/?comment=20278#post-id-20278Answer by bk322 for <p>Hi, <code>(22/3*sqrt(2)*sqrt(3) + 485/27)^(1/3) + 1/9/(22/3*sqrt(2)*sqrt(3) + 485/27)^(1/3) + 20/3</code> equals 10. But how can I get 10 as an integer, as the complex expression has more complex solutions?</p>
https://ask.sagemath.org/question/8720/how-to-get-an-integer-from-a-complex-expression/?answer=13282#post-id-13282You can get 10 by `.rhs()` (it stands for "right hand side"):
((22/3*sqrt(2)*sqrt(3) + 485/27)^(1/3) + 1/9/(22/3*sqrt(2)*sqrt(3) + 485/27)^(1/3) + 20/3 == 10).rhs()Mon, 20 Feb 2012 10:58:43 +0100https://ask.sagemath.org/question/8720/how-to-get-an-integer-from-a-complex-expression/?answer=13282#post-id-13282