mersenneforum.org  

Go Back   mersenneforum.org > Math Stuff > Computer Science & Computational Number Theory > PARI/GP

Reply
 
Thread Tools
Old 2011-02-07, 15:46   #2157
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
well it will return 1 for aredisjoint([],[]) it would also do that if only one is empty as we know the empty set is not disjoint from any set.
What's the problem?
CRGreathouse is offline   Reply With Quote
Old 2011-02-07, 15:57   #2158
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
What's the problem?
if we take away the if statement on the outside then it tries to find the first element of a 0 element set since that's impossible it would skip to the end and return 1 regardless if they are the same or the fact that [] is a subset of every set.

Last fiddled with by science_man_88 on 2011-02-07 at 15:57
science_man_88 is offline   Reply With Quote
Old 2011-02-07, 16:16   #2159
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
if we take away the if statement on the outside then it tries to find the first element of a 0 element set
No it doesn't. How many times does for(i=1,#A, ...) execute?
CRGreathouse is offline   Reply With Quote
Old 2011-02-07, 16:32   #2160
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
No it doesn't. How many times does for(i=1,#A, ...) execute?
that doesn't matter because the check I have inside checks with indexes if it's not an index it won't be checked which means if i take away the if it can only return 1.
science_man_88 is offline   Reply With Quote
Old 2011-02-07, 16:42   #2161
axn
 
axn's Avatar
 
Jun 2003

5,087 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
if we take away the if statement on the outside then it tries to find the first element of a 0 element set since that's impossible it would skip to the end and return 1 regardless if they are the same or the fact that [] is a subset of every set.
So? If one or both of the sets are empty, they _are_ disjoint. Disjoint means "no common element". If one of them is empty, how can there be a common element?
axn is offline   Reply With Quote
Old 2011-02-07, 16:49   #2162
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

Quote:
Originally Posted by axn View Post
So? If one or both of the sets are empty, they _are_ disjoint. Disjoint means "no common element". If one of them is empty, how can there be a common element?
I was told the empty is part of every set unless that's false [],[] can only return 0 because they have something in common [],set or set,[] have the same reason to return 0 but my code can't work with 0 elements unless I have that outer statement if the statement isn't there it returns 1 (true) that all these are disjoint but everything I've been told makes that a bad result.
science_man_88 is offline   Reply With Quote
Old 2011-02-07, 17:32   #2163
axn
 
axn's Avatar
 
Jun 2003

117378 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
I was told the empty is part of every set
Empty set is a _subset_ of every set. It is not an _element_ of every set. "Part of" is not a mathematically meaningful term.

Quote:
Originally Posted by science_man_88 View Post
unless that's false [],[] can only return 0 because they have something in common [],set or set,[] have the same reason to return 0 but my code can't work with 0 elements unless I have that outer statement if the statement isn't there it returns 1 (true) that all these are disjoint but everything I've been told makes that a bad result.
Please restate the definition of disjoint sets before proceeding any further. You've hit a conceptual "wrong turn" here.
axn is offline   Reply With Quote
Old 2011-02-07, 20:47   #2164
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

This is the empty set (as we're representing it with PARI vectors): []

This is a set containing the empty set as a member: [[]]

This is another set containing the empty set as a member: [1, 2, 3, 4, 5, [], 6]

aredisjoint([], [[]]) should return 1 because they are disjoint: the first set has no members and so there are no common members.

aredisjoint([1, 2, 3, 4, 5, [], 6], [[]]) should return 0 because they aren't disjoint: [] is a member of both.
CRGreathouse is offline   Reply With Quote
Old 2011-02-08, 13:18   #2165
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
This is the empty set (as we're representing it with PARI vectors): []

This is a set containing the empty set as a member: [[]]

This is another set containing the empty set as a member: [1, 2, 3, 4, 5, [], 6]

aredisjoint([], [[]]) should return 1 because they are disjoint: the first set has no members and so there are no common members.

aredisjoint([1, 2, 3, 4, 5, [], 6], [[]]) should return 0 because they aren't disjoint: [] is a member of both.
point taken.
science_man_88 is offline   Reply With Quote
Old 2011-02-10, 15:35   #2166
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default ispower

Code:
(11:29)>?ispower
ispower(x,{k},{&n}): if k > 0 is given, return true (1) if x is a k-th power, false (0) if not. If k is omitted, return the maximal k >= 2 such that x =
n^k is a perfect power, or 0 if no such k exist. If n is present, and the function returns a non-zero result, set n to the k-th root of x.

(11:31)>ispower(4,,2)
  ***   expected character: '&': ispower(4,,2)
                                            ^--
(11:31)>ispower(4,,&2)
  ***   syntax error, unexpected KINTEGER, expecting KENTRY: ispower(4,,&2)
                                                                         ^--
(11:31)>ispower(4,,{&2})
  ***   syntax error, unexpected KINTEGER, expecting KENTRY: ispower(4,,&2)
                                                                         ^--
(11:31)>ispower(4,,{&2})
  ***   syntax error, unexpected KINTEGER, expecting KENTRY: ispower(4,,&2)
                                                                         ^--
(11:32)>ispower(4,,{2&})
  ***   syntax error, unexpected ')': ispower(4,,2&)
                                                   ^-
(11:32)>ispower(4,,&2)
  ***   syntax error, unexpected KINTEGER, expecting KENTRY: ispower(4,,&2)
                                                                         ^--
(11:32)>ispower(4,2,&2)
  ***   syntax error, unexpected KINTEGER, expecting KENTRY: ispower(4,2,&2)
                                                                          ^--
(11:32)>ispower(4,,&2)
  ***   syntax error, unexpected KINTEGER, expecting KENTRY: ispower(4,,&2)
                                                                         ^--
(11:32)>ispower(4,,2)
  ***   expected character: '&': ispower(4,,2)
                                            ^--
(11:32)>ispower(4,,&)
  ***   syntax error, unexpected ')', expecting KENTRY: ispower(4,,&)
                                                                    ^-
(11:33)>ispower(4,,&"2")
  ***   syntax error, unexpected KSTRING, expecting KENTRY: ispower(4,,&"2")
                                                                          ^--
(11:33)>ispower(4,,&2)
  ***   syntax error, unexpected KINTEGER, expecting KENTRY: ispower(4,,&2)
                                                                         ^--
(11:33)>ispower(4,,{2})
  ***   expected character: '&': ispower(4,,2)
                                            ^--
(11:33)>ispower(4,,&{2})
  ***   syntax error, unexpected KINTEGER, expecting KENTRY: ispower(4,,&2)
                                                                         ^--
(11:33)>ispower(4,,&})
  ***   unexpected closing brace.
(11:33)>ispower(4,,&}
  ***   unexpected closing brace.
(11:33)>ispower(4,,&2}
  ***   unexpected closing brace.
(11:33)>ispower(4,,&2)
  ***   syntax error, unexpected KINTEGER, expecting KENTRY: ispower(4,,&2)
                                                                         ^--
(11:34)>ispower(4,,{2})
  ***   expected character: '&': ispower(4,,2)
                                            ^--
(11:34)>ispower(4,,2)
  ***   expected character: '&': ispower(4,,2)
                                            ^--
(11:34)>ispower(4,,2)
science_man_88 is offline   Reply With Quote
Old 2011-02-10, 18:57   #2167
axn
 
axn's Avatar
 
Jun 2003

5,087 Posts
Default

Code:
? n=0
%12 = 0
? ispower(1024,,&n)
%13 = 10
? n
%14 = 2
You must pass a variable as the third parameter so that the function can pass back the "base".
axn is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why do I sometimes see all the <> formatting commands when I quote or edit? cheesehead Forum Feedback 3 2013-05-25 12:56
Passing commands to PARI on Windows James Heinrich Software 2 2012-05-13 19:19
Ubiquity commands Mini-Geek Aliquot Sequences 1 2009-09-22 19:33
64-bit Pari? CRGreathouse Software 2 2009-03-13 04:22
Are these commands correct? jasong Linux 2 2007-10-18 23:40

All times are UTC. The time now is 15:31.


Fri Aug 6 15:31:39 UTC 2021 up 14 days, 10 hrs, 1 user, load averages: 2.36, 2.72, 2.83

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.