Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions 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 ?
expand button
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.
expand button
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
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education