1 | initial version |
Well looking at [a^n for n in range(10)]
it's obviously a linear recurrence with the coefficients (5,2) the coefficients of mp
, and this generalizes to any polynomial. So, your question concerns two things:
lucas_number1
There may be an algebraic solution but, alas, I'm not an algebraist.
2 | No.2 Revision |
Well looking at [a^n for n in range(10)]
it's obviously a linear recurrence with the coefficients (5,2) the coefficients of mp
,
a^n mod mp = p(n)*a+q(n), where p(n)=A015535(n), q(n)=2p(n-1)
and this generalizes to any polynomial. So, your question concerns two things:
lucas_number1
There may be an algebraic solution but, alas, I'm not an algebraist.
3 | No.3 Revision |
Well looking at [a^n for n in range(10)]
it's obviously a linear recurrence with the coefficients (5,2) the coefficients of mp
,
a^n mod mp = p(n)*a+q(n), where p(n)=A015535(n), q(n)=2p(n-1)
and this generalizes to any polynomial. So, your question concerns two things:
lucas_number1
There may be an algebraic solution but, alas, I'm not an algebraist.
4 | No.4 Revision |
Well looking at [a^n for n in range(10)]
it's obviously a linear recurrence with the coefficients (5,2) the coefficients of mp
,
a^n mod mp = p(n)*a+q(n), where p(n)=A015535(n), q(n)=2p(n-1)
and this generalizes to any polynomial. So, your question concerns two things:
lucas_number1
but this is no general solution, and it's not a symbolic function in Sage, so it cannot be part of a returned expressionThere may be an algebraic solution but, alas, I'm not an algebraist.
5 | No.5 Revision |
Well looking at [a^n for n in range(10)]
it's obviously a linear recurrence with the coefficients (5,2) the coefficients of mp
,
a^n mod mp = p(n)*a+q(n), where p(n)=A015535(n), q(n)=2p(n-1)
and this generalizes to any polynomial. So, your question concerns two things:
lucas_number1
but this is no general solution, and it's not a symbolic function in Sage, so it cannot be part of a returned expressionThere may be an algebraic solution but, alas, I'm not an algebraist.
Short of an immediate solution, you can use the general Binet formula with 2-degree polynomials and 2x2 matrices to get the closed form in terms of elementary functions:
def GBinet(c,d,a0,a1,n):
r1=2*d/(-c+sqrt(c^2+4*d))
r2=2*d/(-c-sqrt(c^2+4*d))
return ((a1-c*a0+a0*r1)*r1^n-(a1-c*a0+a0*r2)*r2^n)/sqrt(c^2+4*d)
sage: n=var('n')
sage: p(n)=GBinet(5,2,0,1,n)
sage: p(n)
-1/33*sqrt(33)*((-4/(sqrt(33) + 5))^n - (4/(sqrt(33) - 5))^n)
sage: p(5).n()
779.000000000000