# Singular

 Page 1 of 1 [ 2 posts ]
 Print view | E-mail friend Previous topic | Next topic
Author Message
 Post subject: Square Roots and Perfect SquaresPosted: Thu Aug 11, 2005 5:32 pm
Hi,

I am an undergraduate student. I am using Singular to implement the algorithms developed in my Dissertation. In one of this algorithms, I need to check if a real number is a perfect square. So, I would like to know how can I calculate a square root in Singular or how can I directly determine if a number is a perfect square in Singular.

Thank you all very much.

Luis

email: luisms@uol.com.br
Posted in old Singular Forum on: 2004-08-28 01:34:46+02

Top

 Post subject: Posted: Thu Sep 08, 2005 12:12 pm
Hello:
I guess you mean to check if an "integer" number is a
perfect square. Otherwise, every non-negative real number
is a perfect square (or even every real number over the
complex numbers).
Since there is no "sqrt" function in Singular, you can
check it in an indirect way: you define the quadratic
polynomial whose root is the searched square root, and
then you factorize over the rational numbers. If the
integer is a perfect square it will factorize into two
linear factors, and otherwise the quadratic polynomial
is irreducible. For example:

> ring r=0,x,dp;
> poly f=x2-25;
> factorize(f,1);
_[1]=x-5
_[2]=x+5
> poly g=x2-24;
> factorize(g,1);
_[1]=x2-24

You can easily write a procedure like this:

proc perfectSquare (int n)
{
if (n==0)
{
}
else
{
def R=basering;
ring r=0,x,dp;
poly f=x2-n;
ideal I=factorize(f,1);
setring R;
}
}

> Hi,
>
> I am an undergraduate student. I am using Singular to implement the algorithms developed in my Dissertation. In one of this algorithms, I need to check if a real number is a perfect square. So, I would like to know how can I calculate a square root in Singular or how can I directly determine if a number is a perfect square in Singular.
>
> Thank you all very much.
>
> Luis

email: ignfar@eis.uva.es
Posted in old Singular Forum on: 2004-08-30 12:01:09+02

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 2 posts ]

 You can post new topics in this forumYou can reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

 It is currently Sun Oct 21, 2018 5:25 am