0

I have an assignment due for my LabVIEW class that involves a Fibonacci sequence, here is the exact question:

Create a VI that uses a WHILE loop to keep calculating iterations of a Fibonacci sequence until the ratio of |fib(n-1)/fib(n) - fib(n-2)/fib(n-1)| converges. Inputs should include the first two elements of the sequence and the magnitude of the convergence. The output should be the number of iterations required to converge.

I looked on Wikipedia, that didn't help. I have done some Googling around and still nothing. I don't understand what a Fibonacci sequence is nor do I know how to make it converge. Where do the two user inputed elements come in and what of the magnitude. I can code it but I don't what I am to code. If you understand please explain it to me.

To be clear I don't really want you to give me the code, just clarification; thanks.

Jakub Czaplicki
  • 1,787
  • 2
  • 28
  • 50
Umdoobby
  • 105
  • 1
  • 5
  • 11
  • The Fibonacci sequence is generated by beginning with 1, 1, 2, 3 and continuing so that subsequent terms are the sum of the two previous numbers. Stackoverflow is not for such questions ask on http://math.stackexchange.com/ – Jakub Czaplicki Apr 05 '13 at 08:09

2 Answers2

2

You probably need something in that style. Try translating the following Python code into LabVIEW. Use shift registers in while loop. :

import math
ordofmag = 4
result = 1
n = 0
while result >= ( 10 ** (-ordofmag) ):
  n = n + 1
  if n == 1 or n==2:
    x0 = 1.0     # fib(n)
    x1 = 1.0     # fib(n+1)
    x2 = x1 + x0 # fib(n+2)
    result = math.fabs(x1/x2 - x0/x1)  
  elif n > 2:
    x2 = x1 + x0
    result = math.fabs(x1/x2 - x0/x1)  
    x0 = x1
    x1 = x2
  print int(x1), round(result,ordofmag)
Jakub Czaplicki
  • 1,787
  • 2
  • 28
  • 50
0

Use for loop inside a while loop. on the for loop, put a shift register and add an element to the shift register. create a numerical control on each element. put addition and division signs in the for loop, wire two elements of the shift regiter to the addition sign. on the other end of the addition sign, wire it up to opposite shift register on the right, after the addition sign wire output, wire it to the top connection of division sign, the other input part of your division sign, wire it to the top input of the addition sign. By doing so your output from addition is passed to the shift register and shifted around the loop back to top input and the previous element which was in you top input will then passed to the bottom element, passed to the addition sign and the out put divided by the previuos shifted element now the current top input. Out put from addition are fibonacci numbers the out put from division sign will be you golden numbers. then you have to put the numerical indicators and graph inside the for loop, build arrays with feedback nodes and itialise them and specify the number of iteration to be run, this can be done by creating a constant on the blue N on top left corner of the for floop. while loop will then to continously running or if you want to generate them once remove while loop. Any further help email. hope it will help and im not too late.