Post a reply
Username:
Note:If not registered, provide any username. For more comfort, register here.
Subject:
Message body:
Enter your message here, it may contain no more than 60000 characters. 

Smilies
:D :) :( :o :shock: :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:
Font size:
Font colour
Options:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Disable BBCode
Disable smilies
Do not automatically parse URLs
Confirmation of post
To prevent automated posts the board requires you to enter a confirmation code. The code is displayed in the image you should see below. If you are visually impaired or cannot otherwise read this code please contact the %sBoard Administrator%s.
Confirmation code:
Enter the code exactly as it appears. All letters are case insensitive, there is no zero.
   

Topic review - Square Roots and Perfect Squares
Author Message
  Post subject:   Reply with quote
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)
{
int answer;
if (n==0)
{
answer=1;
}
else
{
def R=basering;
ring r=0,x,dp;
poly f=x2-n;
ideal I=factorize(f,1);
answer=size(I)-1;
setring R;
}
return(answer);
}


> 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
Post Posted: Thu Sep 08, 2005 12:12 pm
  Post subject:  Square Roots and Perfect Squares  Reply with quote
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
Post Posted: Thu Aug 11, 2005 5:32 pm


It is currently Fri May 13, 2022 10:57 am
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group