
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
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 ?](https://content.bartleby.com/qna-images/question/b8058d91-61cb-4e04-a092-9a6fff19c84b/725ded76-c803-47c1-b870-03e5eab68d94/dxieaug_thumbnail.png)
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 ?

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

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

Knowledge Booster
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
- Two n-digit integers (leading zeros allowed) are considered equivalent if one is a rearrangement of the other (for example 12033, 20331 and 01332 are considered equivalent five digit integers.) a) We need to find the number of five digit integers that are not equivalent. b)We need to find the number of non equivalent five digit integers if the digits 1, 3 and 7 can appear at most once. c) When all three digits (1,3,7) appear once.arrow_forwardes remaining 8. Consider the function f:NxN-N defined recursively by: 1) Base case: Let meN and define (0,m) = 0 2) Recursive case: For any x,meN, x>0, define f(x,m) = (x-1,m) + (m+m) Prove the following theorem holds using proof by induction: Thereom: For any n,meN, m>0 we have (n.m) I m = n+n Fill in your answer here 9 Help BIU X, x L - ɔE =N E X Formatarrow_forwardWorking with users in pythonarrow_forward
- A problem called S reduces to a problem called T if a T solver can be used as a subroutine to solve S. In pseudocode: Solves(...): ... SolveT(...) ... Assuming that this reduction is correct, answer the following questions regarding what the reduction tells us. If we know that an algorithm exists for solving Problem S, what does that tell us about Problem T? [ Select] If we know that an algorithm cannot exist for solving Problem S, what does that tell us about Problem T? [ Select] If we know that an algorithm exists for solving Problem T, what does that tell us about Problem S? [ Select ] [ Select ] An algorithm cannot exist for solving Problem S,r solving Problem T, what does that tell us about Nothing An algorithm exists for solving Problem Sarrow_forwardd) for (k0; k=0; t = t-1) printf("B"); for-t: TC1iter) = Change of var: Σ/repetitions, Closed form: for-k: TC1iter) =. Change of var: Σ/repetitions Closed form: dependent / independent of loop variable dependent / independent of loop variable e(arrow_forwardy f(x)=x+4 10 Use the figures to calculate the left and right Riemann sums for f on the given interval and the given value of n. f(x)=x+4 on [2,7]; n = 5 The left Riemann sum is The right Riemann sum is 864 C 2 4 6 (Simplify your answer.) (Simplify your answer.) LV f(x)=x+4 N- 2 4 6 Axarrow_forward
- You have to run Prim's algorithm for the problem defined by adjacency matrix: 1 2 3 4 5 6 7 8 9 1 0 10 9 999 999 17 999 999 999 2 3 69 10 0 14 4 2 999 999 13 999 14 0 7 999 999 999 999 999 4 999 4 7 0 999 2 8 999 999 5 999 2 999 999 0 6 999 1 999 6 17 999 999 2 6 0 999 7 999 7 999 999 999 8 999 999 0 11 4 8 999 13 999 999 1 7 11 9 999 999 999 999 999 999 4 80 8 0 1. We started from the vertex vl, so initially we have Y = {v1}: initial 1 2 3 4 5 6 7 8 9 nearest 1 1 1 1 1 1 1 1 1 distance -1 10 9 999 999 17 999 999 999 Print out the values stored in the nearest and distance arrays after first iteration of Prim's algorithm. Specify the value of vnear and the next vertex that has to be added to Y Hint: use (copy) the table above to record your answer.arrow_forwardrefer to imagearrow_forwardUse pythonarrow_forward
- Another recursive algorithm is applied to some data A = (a₁, ..., am) where m = 2* (i.e. 2, 4, 8,16 ...) where x is an integer ≥ 1. The running time T is characterised using the following recurrence equations: T(1) = c when the size of A is 1 T(m) = 2T (2) + c otherwise Determine the running time complexity of this algorithm.arrow_forwardUsing recursion, write a function sum that takes a single argument n and computes the sum of all integers between 0 and n inclusive. Do not write this function using a while or for loop. Assume n is non-negative. def sum(n): """Using recursion, computes the sum of all integers between 1 and n, inclusive. Assume n is positive. >>> sum(1) 1 >>> sum(5) # 1 + 2 + 3+ 4+ 5 15 "*** YOUR CODE HERE ***"arrow_forwardWrite a fraction calculator program that adds, subtracts, multiplies, and di-vides fractions. Your program should check for the division by 0, have and use the following functions (a) reduce - reduces a given fraction.(b) flip - reduces a given fraction and flips the sign if the denominator is negative.(c) add - finds the reduced sum of a pair of given fractions.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

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)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education