Write a user-defined function with function call m = midpoint_ seq(a,b,tol) wher
ID: 3785900 • Letter: W
Question
Write a user-defined function with function call m = midpoint_ seq(a,b,tol) where a and b are constants such that a < b, and tol is a specified tolerance. The function first calculates the midpoint m1 of the interval [a, b], then the midpoint m2 of [a, m1], then the midpoint m3 of [a, m2], and so on. The process terminates when two successive midpoints are within tol of each other. Allow a maximum of 20 iterations. The output of the function is the sequence m1, m2, m3, . . . . Execute the function for a = 4, b = 10, tol = 10^3
Explanation / Answer
As you didn't mention in which language you need the function. So, I am writing in C as it is the basic language.Hope,it would be helpful to you.I have written the code below and the user defined function is in bolded font.
Code:
Hope,my answer is helpful to you.Any further doubts,feel free to ask us.We love to help you
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.