Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,490

Hi;

So then the numbers themeselves are unsigned ints 64 bits wide?

Why not write your own integer square root algorithm ( they're are many on the web, I can post them for you ) otherwise you run the risk of comparing a float to an int?

**In mathematics, you don't understand things. You just get used to them.I have the result, but I do not yet know how to get it.All physicists, and a good many quite respectable mathematicians are contemptuous about proof.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 14,818

Do you think thisbwould work?

int p=floor(sqrt(n));

if (p*p==n||p*(p+2)+1==n) return 1;else return 0;

?

*Last edited by anonimnystefy (2013-01-16 11:02:35)*

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

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,490

I am not saying that it would not, I am only saying that rounding errors may destroy the result. They are rare but unpredictable. What if the sqrt(36) was given as 5.99999999999999?

This is just an example and programmers would all start laughing, "Ho, hoo ahhh," they would exclaim, "my favorite language does not suffer from those type problems!"

**In mathematics, you don't understand things. You just get used to them.I have the result, but I do not yet know how to get it.All physicists, and a good many quite respectable mathematicians are contemptuous about proof.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 14,818

How about the edited code?

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

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,490

Hi;

That might, have you seen any of the posts phrontister and I had about floating point arithmetic?

The problem can remedied in several ways but perhaps the best idea is a more mathematical approach and using Sage. This might be a case of the wrong tool for the right job.

**In mathematics, you don't understand things. You just get used to them.I have the result, but I do not yet know how to get it.All physicists, and a good many quite respectable mathematicians are contemptuous about proof.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 14,818

What kind of mathematical approach?

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

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,490

First by checking the mod 10 of the argument.

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 14,818

Ok.

Here lies the reader who will never open this book. He is forever dead.

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,462

Hi bobbym,

Yes, integer only algorithms will do a good job, I was thinking only about using sqrt function..

Found a few algorithms, thanks.

"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

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,490

Hi gAr;

Let me know how they work.

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,462

Hi,

I found an algorithm after some searching, wiki, attempting to understand it..

However, after finding first few terms, I used WA, which fetched me a g.f.

Is it possible to get a g.f without finding recurrence first?

"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

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,490

Is it possible to get a g.f without finding recurrence first?

I think so?!

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,462

You know of any method?

"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

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,490

Hi;

If you have a sequence you can fit a rational function to it. For instance

by using the first three terms of the sequence, and then testing if the fitted function does the rest.

You can try as many as you like of different forms.

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,462

Hi,

Where do I substitute the terms?

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,462

Hi bobbym,

Thanks for the info.

I just found that there's also a function "ggf" in maxima, nice one! It guessed the g.f as well.

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,490

Hi;

Oh yes, the packages do these easily, much better than a human can.

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,462

Yes!

Anyway, it could not guess catalan numbers' g.f.

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,490

Hi;

No kidding! That is very strange. I will try Mathematica's tomorrow, right now I need to sleep. See you later.

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,462

Okay, see you tomorrow..

I am trying out the function "devine" also.

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,490

Hi gAr;

Mathematica's FindGeneratingFunction command gets it.

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,462

Hi bobbym,

I see.

Meanwhile, I found that axiom's guess implementations are the most powerful among the free CAS out there. I used friCAS 1.1.8 to test, did the job quite well.

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,490

Hi;

Guess is the implementation that both Maple and Mathematica use too.

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,462

Hi,

Yes, read about that. I was going through the implementer's paper in arxiv.

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,490

Hi;

Can I have the link?

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline