Question: Question 5. Loop Application: Finding Roots Example: Write a program to find the roots of y=sin(3x) between - 2/t and 2It with an accuracy of

 Question 5. Loop Application: Finding Roots Example: Write a program to

Question 5. Loop Application: Finding Roots Example: Write a program to find the roots of y=sin(3x) between - 2/t and 2It with an accuracy of 1000 . A rule of thumb is that when a root exists, the sign of y changes either from negative to positive or vice versa. Here is a code: clc clear x1=-2*pi % initial x y1=sin(3*x1); % initial y for i=-2*pi:pi/1000:2*pi y2=sin(3*i); % The value of y for if sign(y2)~=sign(y1) root=i; fprintf("% f is a root\\',i) end y1=y2;% calculated value will be an initial value for the next iteration end -5. 23389im root 4. 18774Baroot -3. 14159Be root 2 . 09230ilsa root -1. 046150m root 0. 0000 0De root 0 . 00314paroot 1. 049292- root 2. 09544is root 3. 1447 3ila root 4 . 1908 8faroot 5. 23703faroot Modify the above program to find the roots of X'cosxtx+5 between -2/ and 2n with an accuracy of 1000

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!