Re: Fibonacci
- To: mathgroup at smc.vnet.net
- Subject: [mg27644] Re: Fibonacci
- From: "Clifford J. Nelson" <cnelson9 at gte.net>
- Date: Fri, 9 Mar 2001 02:36:00 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
I wrote: > > I get the nth Fibonacci number in this Mathematica > notebook, but it gives different answers than I expected > when n is negative. Are they wrong? > Here is an explanation of the program. I still would not expect the results of fib[n] or Fibonacci[n] for negative n. The square root of five with rational coordinates can be computed for B_5 numbers, so the powers of Phi and phi and division by the square root of five are all computed with exact rational arithmetic. The package RBFields.m is on MathSource linked to at: http://forum.swarthmore.edu/epigone/geometry-research/brydilyum A body with the head B around a list indicates that the list contains the coordinates of a B number to the Mathematica interpreter. For instance the "up-value" statement B[x_] + B[y_] ^:= B[x+y] is evaluated when the statement <<RBFields.m is executed and then B[{a,b,c}] + B[{e,f,g}] will evaluate to B[{a+e,b+f,c+g}]. There are up-values for +,-,*,/,^,Log and Exp in the package RBFields.m. In[1]:= <<RBFields.m Out[1]= {"E"} In[2]:= B[{a,b,c}] +B[{d,e,f}] Out[2]= B[{a + d, b + e, c + f}] Here is B_5 multiplication. In[3]:= B[{a,b,c,d,e}] B[{aa,bb,cc,dd,ee}] Out[3]= B[{(-(c*cc) - bb*d - b*dd - aa*e - a*ee)/5, (-(a*aa) - cc*d - c*dd - bb*e - b*ee)/5, (-(aa*b) - a*bb - d*dd - cc*e - c*ee)/5, (-(b*bb) - aa*c - a*cc - dd*e - d*ee)/5, (-(bb*c) - b*cc - aa*d - a*dd - e*ee)/5}] Here is B_3 number division. The n coordinates of a B_n number must add up to zero and n must be an odd prime number for B_n numbers to be a field with rational coordinates. In[4]:= Simplify[B[{a,b,-a-b}]/B[{c,d,-c-d}]] Out[4]= B[{(b*(-c + d) + a*(c + 2*d))/(c^2 + c*d + d^2), (a*(c - d) + b*(2*c + d))/(c^2 + c*d + d^2), -((a*(2*c + d) + b*(c + 2*d))/ (c^2 + c*d + d^2))}] Unity for B_n numbers is B[Append[Table[1,{n-1}],-(n-1)]]. The nth roots of unity for B_n numbers are the n rotations of the coordinates of unity for B_n numbers if n is a prime number. In[5]:= ?simplex Global`simplex InputForm[simplex[x_, n_] := ] Insert[Table[1, {x - 1}], -x + 1, -n] In[6]:= rootOfUnity[n_] :=B[simplex[n,n]] In[7]:= rootOfUnity[5] Out[7]= B[{-4, 1, 1, 1, 1}] The five fifth roots of unity for B_5 numbers rotate the coordinates of their coefficients. For instance: In[8]:= B[{1,2,3,4,-10}]rootOfUnity[5]^Range[0,4] Out[8]= {B[{1, 2, 3, 4, -10}], B[{-10, 1, 2, 3, 4}], B[{4, -10, 1, 2, 3}], B[{3, 4, -10, 1, 2}], B[{2, 3, 4, -10, 1}]} If r is the primitive nth root of unity the sum of r^(k^2) for k = 0 to n-1 has an absolute value of Sqrt[n] when r is a complex number and n is an odd number. So, the function sr[n] below calculates the analogous sum for B_n numbers. In[9]:= sr[n_] :=Sum[rootOfUnity[n]^(k^2),{k,0,n-1}] sr[5] happens to be a rational coordinate square root of B[{5,5,5,5,-20}] (which is five times unity for B_5 numbers). In[10]:= sqrtfive =sr[5] Out[10]= B[{-5, 5, 5, -5, 0}] In[11]:= sqrtfive^2 Out[11]= B[{5, 5, 5, 5, -20}] The two solutions of the equation x^2-x-1 == 0 are what a non mathematician would call the possible ultimate ratios of a sequence of numbers beginning with the number 1, where the last number is the sum of the previous two. In[12]:= solution =x /.Solve[x^2-x-1 == 0] Out[12]= {(1 - Sqrt[5])/2, (1 + Sqrt[5])/2} I think the solutions are usually called phi and Phi. The statement below assigns the values of the solution to x^2-x-1 == 0 to the variables phi and Phi but it replaces the value Sqrt[5] in the solutions with the B_5 number B[{-5,5,5,-5,0}]. In[13]:= {phi,Phi} =solution/. Sqrt[5] -> sqrtfive General::spell1: Possible spelling error: new symbol name "Phi" is similar to existing symbol "phi". Out[13]= {B[{3, -2, -2, 3, -2}], B[{-2, 3, 3, -2, -2}]} Now the formula for the nth Fibonacci number is defined, fib[n], using B_5 numbers with rational coordinates for Phi, phi, and the square root of five, instead of scalar irrational real numbers. In[14]:= fib[n_] :=(Phi^n -phi^n)/sqrtfive fib[n] computes a sequence like the standard Fibonacci sequence formula, but the B_5 numbers are four dimensional. Here are some tests. In[15]:= fib /@ Range[0,12] Out[15]= {B[{0, 0, 0, 0, 0}], B[{1, 1, 1, 1, -4}], B[{1, 1, 1, 1, -4}], B[{2, 2, 2, 2, -8}], B[{3, 3, 3, 3, -12}], B[{5, 5, 5, 5, -20}], B[{8, 8, 8, 8, -32}], B[{13, 13, 13, 13, -52}], B[{21, 21, 21, 21, -84}], B[{34, 34, 34, 34, -136}], B[{55, 55, 55, 55, -220}], B[{89, 89, 89, 89, -356}], B[{144, 144, 144, 144, -576}]} In[16]:= fib /@ Range[-12,0] Out[16]= {B[{-144, -144, -144, -144, 576}], B[{89, 89, 89, 89, -356}], B[{-55, -55, -55, -55, 220}], B[{34, 34, 34, 34, -136}], B[{-21, -21, -21, -21, 84}], B[{13, 13, 13, 13, -52}], B[{-8, -8, -8, -8, 32}], B[{5, 5, 5, 5, -20}], B[{-3, -3, -3, -3, 12}], B[{2, 2, 2, 2, -8}], B[{-1, -1, -1, -1, 4}], B[{1, 1, 1, 1, -4}], B[{0, 0, 0, 0, 0}]} In[17]:= fib[#]-Fibonacci[#]& /@ Range[-12,12] Out[17]= {B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}], B[{0, 0, 0, 0, 0}]} In[18]:= fib[500]-Fibonacci[500] Out[18]= B[{0, 0, 0, 0, 0}] Cliff Nelson