Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using matlab Use a while loop control structure and an incremental direct search

ID: 3787954 • Letter: U

Question

Using matlab Use a while loop control structure and an incremental direct search algorithm m approximate value for the first positive (i e. x > 0) root^1 of the equation y = a* sin (bx^2 + cx + d). Your program should be in the form of a MAUAB function m-file denned as follows: function root = search (a, b, c, d, delta x) in which del tax is the increment of x to be used in your search. You may assume that the values of all input arguments passed to your function are valid double precision real numbers (i.e., you don't have to worry about error checking the input arguments for this program) and that a positive root for the function does exist (i.e., you don't have to worry about an infinite loop). You may assume that the input value of delta x is sufficiently sxuall that the search interval will contain at most one root The output argument root renimed by your program is defined as the midpoint of the final del tax interval that contains the root Within these assumptions your program must be genera] m the sense that it will work for any combination of values fold f b, c, and d Name your submitted file search.

Explanation / Answer

Answer :

#Fuction with the while loop to search for the root

function root = search(a,b,c,d,x)
y1 = a*sin(b*x^2+c*x+d);
precision = 1;
m = x + precision;
y2 = a*sin(b*m^2+c*m+d);
while(y1*y2 > 0)
y1 = a*sin(b*m^2+c*m+d);
m = m + precision;
y2 = a*sin(b*m^2+c*m+d);
end
root = y2;
end

disp(search(2,2,3,4,5));

Comments : You can increment or decrement the precision value to get the nearest to zero value.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote