Question

4. One interesting property of a Fibonacci sequence is that the ratio of the values of adjacent members of the sequence appro

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the code below::::

1)

clc
clear
num1 = input('Please enter first sequence : ');
num2 = input('Please enter second sequence : ');
tmp1 = num1+num2;
ratio = 0;
fprintf('Sequences are as below\n');
while true
diff1 = tmp1/num2;
diff2 = num2/num1;
ratio = abs(diff1 - diff2);
fprintf("Next Sequence : %d Ratio : %.3f\n",tmp1,ratio);
if ratio<=0.001
break;
end
num1 = num2;
num2 = tmp1;
tmp1 = num1+num2;
  
end

2)

clc

clear

a = input('number ');

x = input('guess ');

tol = 0.000001;

dif=inf;

while dif>=tol

y=(1/a)*x^2;

n = ((x/8)*(15-y*(10-3*y)));

dif= (abs(n-x));

disp(n)

x=n;

end

disp(n)

BREAKPOINTS RUN anguage_workspace matlab staticClass2 Editor - C:Users Mohammad Shahrukh\Desktop\c language_workspace\ matlab

output:

ablstaticClass2 harrleys Command Window Please enter number 400 Square root of 400 is 20.00

Add a comment
Know the answer?
Add Answer to:
4. One interesting property of a Fibonacci sequence is that the ratio of the values of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (loops, conditional) Edmond Halley (of comet fame) invented a fast algorithm for computing the squareroot of...

    (loops, conditional) Edmond Halley (of comet fame) invented a fast algorithm for computing the squareroot of a number. Given a number A greaterthanorequalto 1, Halley's algorithm calculates Squareroot A in the following manner: Start with an initial guess for the squareroot , given as x_1 Calculate the intermediate step y_a = 1/A x^n^2, where n is the iteration number Calculate the next interation approximation x_n + 1 = x_n/8 (15 - y_n (10 - 3y_n)) Repeat from [2] until the...

  • Fibonacci Sequence The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5,...

    Fibonacci Sequence The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... The next number is found by adding up the two numbers before it. The 2 is found by adding the two numbers before it (1+1) The 3 is found by adding the two numbers before it (1+2), And the 5 is (2+3), and so on!         Example: the next number in the sequence above is 21+34 = 55 Source:...

  • this is Matlab. Three images are consecutive and connected. I NEED PROBLEM 2 Chapter 6 Programming in Matlab Week 6 THE ALTERNATING HARMONIC SERIES The alternating harmonic series converges to the na...

    this is Matlab. Three images are consecutive and connected. I NEED PROBLEM 2 Chapter 6 Programming in Matlab Week 6 THE ALTERNATING HARMONIC SERIES The alternating harmonic series converges to the natural log of 2 +--...-In(2) = 0.6931471806 -1--+ Because of this, we can use the alternating harmonic series to approximate the In(2). But how far out do you have to take the series to get a good approximation of the final answer? We can use a while loop to...

  • clearvars close all clc tol = 0.0001; % this is the tolerance for root identification xold...

    clearvars close all clc tol = 0.0001; % this is the tolerance for root identification xold = 0.5; % this is the initial guess test = 1; % this simply ensures we have a test value to enter the loop below. %If we don't preallocate this, MATLAB will error when it trys to start the %while loop below k = 1; %this is the iteration counter. Similar to "test" we need to preallocate it %to allow the while loop to...

  • import java.util.Arrays; import java.util.Random; import java.util.Scanner; /** * TODO Write a summary of the role of...

    import java.util.Arrays; import java.util.Random; import java.util.Scanner; /** * TODO Write a summary of the role of this class in the * MasterMind program. * * @author TODO add your name here */ public class MasterMind { /** * Prompts the user for a value by displaying prompt. * Note: This method should not add a new line to the output of prompt. * * After prompting the user, the method will consume an entire * line of input while reading...

  • Newton's Method in MATLAB During this module, we are going to use Newton's method to compute...

    Newton's Method in MATLAB During this module, we are going to use Newton's method to compute the root(s) of the function f(x) = x° + 3x² – 2x – 4 Since we need an initial approximation ('guess') of each root to use in Newton's method, let's plot the function f(x) to see many roots there are, and approximately where they lie. Exercise 1 Use MATLAB to create a plot of the function f(x) that clearly shows the locations of its...

  • Data clustering and the k means algorithm. However, I'm not able to list all of the...

    Data clustering and the k means algorithm. However, I'm not able to list all of the data sets but they include: ecoli.txt, glass.txt, ionoshpere.txt, iris_bezdek.txt, landsat.txt, letter_recognition.txt, segmentation.txt vehicle.txt, wine.txt and yeast.txt. Input: Your program should be non-interactive (that is, the program should not interact with the user by asking him/her explicit questions) and take the following command-line arguments: <F<K><I><T> <R>, where F: name of the data file K: number of clusters (positive integer greater than one) I: maximum number...

  • In this project, you will write a complete program that allows the user to play a...

    In this project, you will write a complete program that allows the user to play a game of Mastermind against the computer. A Mastermind game has the following steps: 1. The codebreaker is prompted to enter two integers: the code length n, and the range of digits m. 2. The codemaker selects a code: a random sequence of n digits, each of which is in the range [0,m-1]. 3. The codebreaker is prompted to enter a guess, an n-digit sequence....

  • I need the report like this (idea) *Sorting Algorithms: A sorting algorithm is an algorithm that...

    I need the report like this (idea) *Sorting Algorithms: A sorting algorithm is an algorithm that puts elements of a list in a certain order. The most-used orders are numerical order and lexicographical order. Efficient sorting is important for optimizing the use of other algorithms (such as search and merge algorithms) which require input data to be in sorted lists; it is also often useful for canonical zing data and for producing human-readable output. More formally, the output must satisfy...

  • python 2..fundamentals of python 1.Package Newton’s method for approximating square roots (Case Study 3.6) in a...

    python 2..fundamentals of python 1.Package Newton’s method for approximating square roots (Case Study 3.6) in a function named newton. This function expects the input number as an argument and returns the estimate of its square root. The script should also include a main function that allows the user to compute square roots of inputs until she presses the enter/return key. 2.Convert Newton’s method for approximating square roots in Project 1 to a recursive function named newton. (Hint: The estimate of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT