You are not logged in.
Sure, arxiv
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
Hi;
Okay, thanks. I will look at it, in the meantime I use mine because I can understand it.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Hi,
Yeah, me too.
I'll use this only when maxima can't obtain a g.f or recurrence, there are too many functions and options in this!
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
Hi gAr;
Sorry, but I need to rest. Wish I could talk with you more.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
No problem, see you later..
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
Hi gAr;
I have some ideas on that square root problem.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Hi bobbym,
What are those ideas?
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
Use the built in square root function, then take the floor and the ceiling of that number. Add one and subtract one to each one. Now square each one and match it to the number you are testing.
That should take care of round off error either way.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Use the built in square root function, then take the floor and the ceiling of that number. Add one and subtract one to each one. Now square each one and match it to the number you are testing.
That should take care of round off error either way.
How is that different from the code code I have proposed?!
Here lies the reader who will never open this book. He is forever dead.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.
Offline
How is that different from the code code I have proposed?!
For one thing, I am proposing testing 4 numbers rather than 2.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Of those 4 numbers, 2 will never be the square root of the given number, with rounding errors or without...
Here lies the reader who will never open this book. He is forever dead.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.
Offline
Hi;
That may not be the case. For instance and this is just an example:
He gets an answer of 35136.000001. Is that round off from the correct 35135.9999998 or from 35136?
I proposed it as a way of being sure by testing 2 smaller and 2 larger.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Hi bobbym
We want our number to be a square of an integer, not a real number... Do you have an example in which my code will not get the correct answer and yours will?
Last edited by anonimnystefy (2013-01-21 22:27:17)
Here lies the reader who will never open this book. He is forever dead.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.
Offline
Hi;
These are just suggestions for gAr to consider.
Do you have an example in which my code will not get the correct answer and yours will?
If you are demanding correctnes you do not even know if your idea would always work.
I would presume that an exhaustive test would have to be done on every square with whatever method he chooses.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Hi bobbym,
Good idea, but I liked your integer only suggestion better since the code dealing with integers would be faster than floating points. Also, that algorithm on wikipedia did not even have integer divisions, only shift operations!
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
Hi;
I was not suggesting rewriting a floating point routine. You would be using the built in square root routine as an estimate. It is probably implemented in the math coprocessor and would not use much time at all.
The integer square root does have the advantage of being verified for any other idea you would have to prove that it never missed. That means checking 4 billion square roots once.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Yes, I know you were talking about using the built-in sqrt, but I'm not sure whether that will be faster than our own integer sqrt.
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
The speed question is secondary. I have no proof that mine will work in every case. It was just a suggestion.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Hi bobbym,
Okay, thanks for the idea..
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
So you will go with the isqrt routine? You wanted more speed than Sage could provide?
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Yes, I wanted more speed, since looping is a lot slower in sage.
But sage does provide with enough terms in reasonable time to get the g.f / recurrence.
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
Perhaps Sage, has a single command that does what you want?
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
You mean, to solve the diophantine equation?
I did not search for it yet.
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
Hi;
No, I meant to determine whether a number is a square or not.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
That's already there, I was concerned about the requirement to loop through each integer.
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline