Skip to main content
20-Turquoise
December 23, 2014
Solved

How to correct the Pell(n) function ? (for n = 181)

  • December 23, 2014
  • 2 replies
  • 7859 views

Hello Everyone,

Pell%28181%29.PNG

How to correct the Pell(n) function ? ( for n = 181)

Thanks in advance for your time and help.

Regards.

Best answer by Werner_E

For some N (like 2,5,10) m is just 1 (second element of C is already greater than the root of N) and so your calculation of the rearranged vector c fails. Either include another if-statement to cope with that case (then c<--C) or do it completely different like in the attached.

1.png

0.png

2 replies

23-Emerald V
December 24, 2014

Looking at Numerical Recipes, I think you need to add a correction factor in for when w[0,1 is zero.

Stuart

lvl10720-TurquoiseAuthor
20-Turquoise
December 25, 2014
23-Emerald V
December 26, 2014

Unfortunately, I'm Mathcadless for a week or so, but you can define your function as follows.

Rename my function to PellA.

Define

Pell(n):=p <-PellA(n, infinity)

stack (p[1, p[2)

thenPell(P181).

Stuart

lvl10720-TurquoiseAuthor
20-Turquoise
January 4, 2015

Hello Everyone again,

1.PNG

2.PNG

Now I need help with correcting the Pell_Test(N) function, the above. ("This array index is invalid for this array")

Thanks in advance for your time and help.

Best Regards.

Werner_E25-Diamond IAnswer
25-Diamond I
January 4, 2015

For some N (like 2,5,10) m is just 1 (second element of C is already greater than the root of N) and so your calculation of the rearranged vector c fails. Either include another if-statement to cope with that case (then c<--C) or do it completely different like in the attached.

1.png

0.png

lvl10720-TurquoiseAuthor
20-Turquoise
January 4, 2015

I greatly appreciate your help. The answer is very neat . Many, many thanks, Werner.

3.PNG

By the way, I need help with how to type "the thin equal sign" (the green circle) in Mathcad 14.

Best Regards.

Message was edited by: Loi Le