MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: How can I get the previous Fibonacci calculated

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100397] Re: [mg100312] Re: How can I get the previous Fibonacci calculated
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Tue, 2 Jun 2009 06:47:54 -0400 (EDT)
  • Reply-to: hanlonr at cox.net

Fibonacci number is not restricted to Integer arguments

Fibonacci[Pi] // N

2.11703

Fibonacci[Pi] == Fibonacci[Pi - 1] + Fibonacci[Pi - 2] // FullSimplify

True

prevFib[x_] := Module[{m, n, x2},
  x2 = SetPrecision[x, 120];
  If[x > 10^15, N[x/GoldenRatio],
   m = (n /. FindRoot[Fibonacci[n] - x2 == 0, {n, 100},
        WorkingPrecision -> 100]) - 1;
   If[Abs[m - Round[m]] < 10^-10,
    Fibonacci[Round[m]],
    N[Fibonacci[m]]]]]

Table[x = 10^n*Pi; prevFib[Fibonacci[x]] == 
  Fibonacci[x - 1], {n, 0, 2}]

{True,True,True}

Fibonacci is not even restricted to real arguments, although prevFib will not handle complex arguments.

Fibonacci[Pi + E*I] // N

-45.13963322822449 - 246.04041318893496*I

Fibonacci[Pi + E*I] == 
  Fibonacci[Pi + E*I - 1] + Fibonacci[Pi + E*I - 2] // FullSimplify

True


Bob Hanlon

---- "David W. Cantrell" <DWCantrell at sigmaxi.net> wrote: 

=============
Bob Hanlon <hanlonr at cox.net> wrote:
> prevFib[x_] := Module[{m, n, x2},
>   x2 = SetPrecision[x, 100];
>   If[x > 10^15,
>    N[x/GoldenRatio],
>    m = (n /. FindRoot[Fibonacci[n] - x2 == 0, {n, 100},
>         WorkingPrecision -> 100]) - 1;
>    If[Abs[m - Round[m]] < 10^-10,
>     Fibonacci[Round[m]],
>     N[Fibonacci[m]]]]]
>
> prevFib[13]
>
> 8
>
> prevFib[Fibonacci[50]] == Fibonacci[49]
>
> True
>
> prevFib[Fibonacci[10000]] == Fibonacci[9999]
>
> True
>
> prevFib[Fibonacci[20000]] == Fibonacci[19999]
>
> True
>
> prevFib[234.34*^10]
>
> 1.4483008492365037*^12

But that's not a Fibonacci number! I suggest

In[7]:=
n = 234.34*^10;
inv = Round[Log[GoldenRatio, Sqrt[(Sqrt[5]*n + Sqrt[5*n^2 - 4])*
        (Sqrt[5]*n + Sqrt[5*n^2 + 4])]/2]];
Fibonacci[inv - 1]

Out[7]=
1548008755920

I am guessing that the OP actually wants to find the Fibonacci number which
immediately precedes a given _Fibonacci number_. If that guess is correct,
that is, if n is actually supposed to be a Fibonacci number, then my inv
will always work correctly for n >= 2.

But CAUTION:  If n is not a Fibonacci number, then my method may give an
incorrect answer. In the example, 234.34*^10 is not a Fibonacci number and
so there was no guarantee that my method would give the correct result,
although it happened to do so.

David W. Cantrell


> ---- ratulloch at gmail.com wrote:
>
> =============
> Greetings
>
> How can I get a previous Fibonacci calculated number in a specific
> range.  I can calculate the previous number of phi see below
>
> phi1 =(1+sqrt(5))/2
>
> 13/phi1
>
> I tested it with 13 and got 8.034441857 .....so that works
>
> but how can I get only the previous numbers of Fibonacci in a
> specified range from 20 to 20000 if I input a large number like
> 234.34e10
>
> tia sal2


--

Bob Hanlon



  • Prev by Date: Re: Sidebar Tools
  • Next by Date: Reverse Geocoding code
  • Previous by thread: Re: How can I get the previous Fibonacci calculated
  • Next by thread: Re: RandomReal gets stuck