Iterative Fibonacci (while loop, perils of integer arithmetic) The Fibonacci sequence defined by F=1,1,2, 3, 5, 8, 13, 21, 34, 55, 89, ... where the 4th term is given by F₁ = F₁-1+Fx-2 As k increases, the ratio of two adjacent terms in the sequence approaches the Golden Ratio, F₂ =drp. The goal of this problem is to generate Fibonacci numbers until the absolute value of the difference between subsequent computations of the Golden Ratio falls below a given tolerance. My Solutions E = |x-₁-1- Code has already been provided to define a function named fibGenerator that accepts a single input value into the variable to1GR. Add code that uses a while loop to generate Fibonacci numbers until the error E in subsequent calculations of is less than or equal to the value of to1GR. Your function should assign values to three output variables as follows. 1. Assign the final calculated value of the Golden Ratio to the variable GoldenRatio with default double precision datatype. 2. Assign the largest Fibonacci number generated to the variable lastFib with 32-bit unsigned integer datatype. 3. Assign the number of terms required to meet the tolerance to the variable numTerms with 8-bit unsigned integer datatype. Note the value of to1GR is defined as an input to the function. Do not overwrite this value in your code. Be sure to assign values to each of the function output variables. Use a while loop in your solution.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Function >
1 function [GoldenRatio, lastFib, numTerms] = fibGenerator (tolGR)
%write the commands for your function here.
Code to call your function >
1 [GoldenRatio, lastFib, numTerms] = fibGenerator (1e-3)
Assessment:
>
Is the first output GoldenRatio correct for input of tolGR = 1e-3? (Pretest)
>
Is the second output lastFib correct for input of toIGR = 1e-3? (Pretest)
>
Is the third output num Terms correct for input of tolGR = 1e-3? (Pretest)
Are all three outputs correct for an input of toIGR = 1e-6?
Does solution use a while loop?
Save
C Reset
EEMATLAB Documentation
Run Pretest
C Reset
▶ Run Function ?
Submit ?
Transcribed Image Text:Function > 1 function [GoldenRatio, lastFib, numTerms] = fibGenerator (tolGR) %write the commands for your function here. Code to call your function > 1 [GoldenRatio, lastFib, numTerms] = fibGenerator (1e-3) Assessment: > Is the first output GoldenRatio correct for input of tolGR = 1e-3? (Pretest) > Is the second output lastFib correct for input of toIGR = 1e-3? (Pretest) > Is the third output num Terms correct for input of tolGR = 1e-3? (Pretest) Are all three outputs correct for an input of toIGR = 1e-6? Does solution use a while loop? Save C Reset EEMATLAB Documentation Run Pretest C Reset ▶ Run Function ? Submit ?
Iterative Fibonacci (while loop, perils of integer arithmetic)
The Fibonacci sequence defined by
F=1,1,2,3,5, 8, 13, 21, 34, 55, 89, ...
where the th term is given by
F₁ = F₁-1+F₁-2
As & increases, the ratio of two adjacent terms the sequence approaches the Golden Ratio, :
F₁
· = $x → ·
The goal of this problem is to generate Fibonacci numbers until the absolute value of the difference E between subsequent computations of the Golden Ratio falls below a given
tolerance.
My Solutions >
E = |dx-x-1|-
Code has already been provided to define function named fibGenerator that accepts a single input value into the variable to1GR. Add code that uses a while loop to generate
Fibonacci numbers until the error E in subsequent calculations of is less than or equal to the value of to1GR. Your function should assign values to three output variables as
follows.
1. Assign the final calculated value of the Golden Ratio to the variable GoldenRatio with default double precision datatype.
2. Assign the largest Fibonacci number generated to the variable lastFib with 32-bit unsigned integer datatype.
3. Assign the number of terms required to meet the tolerance to the variable numTerms with 8-bit unsigned integer datatype.
Note the value of to1GR is defined as an input to the function. Do not overwrite this value in your code. Be sure assign values to each of the function output variables.
Use a while loop in your solution.
Transcribed Image Text:Iterative Fibonacci (while loop, perils of integer arithmetic) The Fibonacci sequence defined by F=1,1,2,3,5, 8, 13, 21, 34, 55, 89, ... where the th term is given by F₁ = F₁-1+F₁-2 As & increases, the ratio of two adjacent terms the sequence approaches the Golden Ratio, : F₁ · = $x → · The goal of this problem is to generate Fibonacci numbers until the absolute value of the difference E between subsequent computations of the Golden Ratio falls below a given tolerance. My Solutions > E = |dx-x-1|- Code has already been provided to define function named fibGenerator that accepts a single input value into the variable to1GR. Add code that uses a while loop to generate Fibonacci numbers until the error E in subsequent calculations of is less than or equal to the value of to1GR. Your function should assign values to three output variables as follows. 1. Assign the final calculated value of the Golden Ratio to the variable GoldenRatio with default double precision datatype. 2. Assign the largest Fibonacci number generated to the variable lastFib with 32-bit unsigned integer datatype. 3. Assign the number of terms required to meet the tolerance to the variable numTerms with 8-bit unsigned integer datatype. Note the value of to1GR is defined as an input to the function. Do not overwrite this value in your code. Be sure assign values to each of the function output variables. Use a while loop in your solution.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Lower bounds sorting algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education