How can i verify that my algorithm has not missed

Assignment Help Data Structure & Algorithms
Reference no: EM13944311

I wrote this program (with a lot of help) that finds multiple roots using bisection. For example, this program found the first 10 roots of cos(5x). Now, I'm supposed to find and store the first 50 roots of
Where
= 50; L = 200; = 0.447; = 4.47
= 25; L= 200; = 0.748; = 1.875
= 15; L= 200; = 0.045; = 19.25

The instructions say: Now we must only modify the variable that determines the number of roots to find. We must also refine (i.e. improve) the bracket search algorithm so that roots that are not evenly spaced can be found. Test your algorithm by finding the roots for at least three different combinations of the parameters and L. How can you verify that your algorithm has not missed any of the roots? HINT: Consider the maximum frequency (dig back to that trig you forgot) to help determine the size of an appropriate bracket for this part of the problem.

(1) I only understand the first sentence of these instructions. How do I modify my program to find those 50 roots and, yes, how can I verify that my algorithm has not missed any of the roots?

(2) Also, could you please describe what each line of the main program is doing? I understand the subprogram, ‘bisection,' pretty well. I know the two programs are similar.
Main Program (for finding first 10 roots of cos(5x))

function root=multibisection(func,j,xtol,ftol)
xlower=0;
xupper=xlower+j;
ylower=feval(func,xlower); %takes func and evaluates xlower into that function
yupper=feval(func,xupper);
i=1;
while i<11
ylower=feval(func,xlower); %takes func and evaluates xlower into that function
yupper=feval(func,xupper);
if abs(ylower)<ftol;
root=xlower;
return
elseif abs(yupper)<ftol;
root=xupper;
return
end

while (yupper*ylower)>0
xlower=xupper;
xupper=xlower+j;
yupper=feval(func,xupper);
ylower=feval(func,xlower);
end
b=bisection(func,xlower,xupper,xtol,ftol);
roots(i)=b;
i=i+1;
xlower=b+j;
xupper=xlower+j;
end
roots
format long


Sub Program
function root=bisection(func,xlower,xupper,xtol,ftol)

xroot=(xlower + xupper)/2;
yroot=feval(func,xroot);
count=0;

while abs(yroot)>ftol;
ylower=feval(func,xlower); %takes func and evaluates xlower into that function
yupper=feval(func,xupper);
if ylower*yroot<0;
xupper=xroot;
yupper=yroot;
else
xlower=xroot;
ylower=yroot;
end

if abs(xupper-xlower)<xtol
root=xroot;
return
end
root=xroot;

xroot=(xlower + xupper)/2;
yroot=feval(func,xroot);

count=count + 1;
if count>500 %max number of iterations
count
range=xupper-xlower
disp ('too many interval halvings, stopping ...')
root=xroot
return
end
end %ends the while loop

Line4 m-file
function y=line4(x)
y=cos(5*x);

Testing:
>> multibisection(@line4,0.314,1e-11,1e-11)

roots =

Columns 1 through 4

0.31415926533914 0.94247779608140 1.57079632675968 2.19911485721864

Columns 5 through 8

2.82743338823505 3.45575191891333 4.08407044967386 4.71238898037956

Columns 9 through 10

5.34070751111268 5.96902604181838

Reference no: EM13944311

Questions Cloud

Human resource management role in organisation : Assessment objective: Explain the significance of the human resource management role in organisations, its different facets and its contribution to the achievement of corporate goals
Standard deviations and interquartile ranges : Q) Construct two sets of numbers with at least five numbers in each set with following characteristics;
Why cultural self-awareness vital for cultural intelligence : Write an essay to critically reflect on why cultural self-awareness is important to develop cultural intelligence. You should first define the term 'cultural self-awareness' and ‘cultural intelligence'.
Devise a preliminary control scheme for the sections : Devise a preliminary control scheme for the sections of the nitric acid plant described in Chapter 2, flow sheet Figure 2.8, which are listed below. Make a practice HAZOP study of each section and revise your preliminary control scheme.
How can i verify that my algorithm has not missed : ) I only understand the first sentence of these instructions. How do I modify my program to find those 50 roots and, yes, how can I verify that my algorithm has not missed any of the roots?
Is the pharmacy likely an unrelated trade or business : An exempt municipal hospital operates a pharmacy that is staffed by a pharmacist 24 hours per day. The pharmacy serves only hospital patients. Is the pharmacy likely an unrelated trade or business? Explain.
How particular school grew of original field of epistemology : Explain who the main contributors were, and the evolution of how this particular school grew out of the original field of epistemology or metaphysics.
Confidence interval for the population mean number : Construct a 95% confidence interval for the population mean number of shares traded per day in 2010. Interpret the confidence interval.
Code for a sequential search and a binary search : I have code for a sequential search and a binary search. I have to "add a counter for every key comparison in each search function and print out the number of key comparisons for each search."

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Water resources engineering

The current practice of a particular part of water resources engineering is supported through a variety of commercial software. Pick a specific domain within water resources engineering.

  Saving contents of the richtextbox by creating a program

Create the statements to save the contents of the RichTextBox named rtbCurrent. Show a SaveFileDialog named sfdCurrent to get the name of the document from the user.

  Implement a queue as a circular array

Implement a queue as a circular array as follows: Use two index variables head and tail that contain the index of the next element to be removed and the next element to be added.

  Difference between workbook and worksheet

Discuss the difference between a workbook and a worksheet and explain why would you want to use individual worksheets when using Excel?

  Question about oracle9i database

Provide every worker in the Local Locale Company the privileges required to query and update the NEWS_ARTICLE table and the CLASSIFIED_AD table.

  Importance of database documentation

Assume your database is performing poorly, and you just started this new job within the past month. You ask to see the documentation for system and are told it does not exist.

  Prove no asynchronous t-byzantine-robust broadcast exists

Prove that no asynchronous t-Byzantine-robust broadcast algorithm exists for t=N/3. Prove that during the execution of Algorithm 14 .6 at most N(3N + 1) messages are sent by correct processes.

  Construct a magic square using a genetic algorithm

Construct a magic square using a genetic algorithm. First, generate an initial population of magic squares with random values. The fitness of each individual square is calculated based on the "flatness", that is, the degree of deviation in the sum..

  Discuss the business problem

Provide a clear statement of the aims and objectives of the data analytics study and the possible outcomes in terms of discovered knowledge and its potential application towards solution of the problem. In this section you need to discuss the busi..

  Design a linear-time algorithm

Design a linear-time algorithm that verifies that the height information in an AVL tree is correctly maintained and that the balance property is in order.

  Write the algorithm which takes as input npda

Write the algorithm (described informally) which takes as input NPDA A and determines whether the language of A is nonempty.

  Singly linked list

Singly Linked List (SLL)Introduce a SLL class with the following functions. Please also introduce a main function that will invoke and verify whether the functions are implemented correctly

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd