[math-fun] Mathematica help: formula manipulation
Despite its bulk, OEIS's Fibonacci article (A000045) could use another formula or two. How about after FORMULA G.f.: x / (1 - x - x^2). F(n) = ((1+sqrt(5))^n-(1-sqrt(5))^n)/(2^n*sqrt(5)). Alternatively, F(n) = ((1/2+sqrt(5)/2)^n-(1/2-sqrt(5)/2)^n)/sqrt(5). F(n) = F(n-1) + F(n-2) = -(-1)^n F(-n). F(n) = round(phi^n/sqrt(5)). ... we add the first order recurrence F(n+1) = F(n)/2 + √((-1)^n + 5 F(n)^2/4), n>=0 ? And for laughs, the World's shortest fibula, F(n+1) = U_n(i/2)/i^n , (U:= Chebyshef 2nd kind) Deriving the former, I got perfectly frustrated by Mathematica. It knows In[267]:= Simplify[(-1)^(2*n), n \[Element] Integers] Out[267]= 1
From In[232]:= 1 + (-1)^n Fibonacci[n]^2 + (-1)^n Fibonacci[n] Fibonacci[1 + n] = = (-1)^n Fibonacci[1 + n]^2
all I wanted was to In[268]:= Assuming[n \[Element] Integers, Solve[%232, Fibonacci[n + 1]]] Out[268]= {{Fibonacci[ 1 + n] -> -(1/2) (-1)^-n (-(-1)^n Fibonacci[n] - I^n Sqrt[4 + 5 (-1)^n Fibonacci[n]^2])}, {Fibonacci[ 1 + n] -> -(1/2) (-1)^-n (-(-1)^n Fibonacci[n] + I^n Sqrt[4 + 5 (-1)^n Fibonacci[n]^2])}} Who ordered i^n? Cosmetics aside, which is the correct root? It depends on n mod 8 ! (n>0). Um, returning to cosmetics, how to punt i^n? In[273]:= Assuming[ n \[Element] Integers, %268 /. x : I^n*Sqrt[_] :> Sqrt[Simplify[Expand[x^2]]]] Out[273]= {{Fibonacci[ 1 + n] -> -(1/2) (-1)^-n (-(-1)^n Fibonacci[n] - Sqrt[ I^(2 n) (4 + 5 (-1)^n Fibonacci[n]^2)])}, {Fibonacci[ 1 + n] -> -(1/2) (-1)^-n (-(-1)^n Fibonacci[n] + Sqrt[ I^(2 n) (4 + 5 (-1)^n Fibonacci[n]^2)])}} OK, the big gun: Assuming[n \[Element] Integers, %268 /. x : I^n*Sqrt[_] :> Sqrt[FullSimplify[Expand[x^2]]]] {{Fibonacci[1 + n] -> -(1/2) (-1)^-n (-(-1)^n Fibonacci[n] - Sqrt[ LucasL[n]^2])}, {Fibonacci[1 + n] -> -(1/ 2) (-1)^-n (-(-1)^n Fibonacci[n] + Sqrt[LucasL[n]^2])}} Wise ass. I got fairly close with In[288]:= %268 /. x : I^n*Sqrt[_] :> Sqrt[Assuming[n \[Element] Integers, Simplify[ComplexExpand[x^2]]]] Out[288]= {{Fibonacci[ 1 + n] -> -(1/ 2) (-1)^-n (-(-1)^n Fibonacci[n] - Sqrt[(-1)^n (4 + 5 (-1)^n Fibonacci[n]^2)])}, {Fibonacci[ 1 + n] -> -(1/ 2) (-1)^-n (-(-1)^n Fibonacci[n] + Sqrt[(-1)^n (4 + 5 (-1)^n Fibonacci[n]^2)])}} but never got that radicand to simplify, except by manually forcing (-1)^(2n)->1. --rwg
participants (1)
-
Bill Gosper