Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c programming language: In this task, a simple implementation of the bisection method for finding roots of continuous functions is to be developed. Let

c programming language: In this task, a simple implementation of the bisection method for finding roots of continuous functions is to be developed. Let \(f: [a, b]\to \mathbb{R}\) be a continuous function with \(a < b\) and \(f(a)- f(b)<0\). According to the intermediate value theorem, \(f\) has at least one root in \([a, b]\). The bisection method works as follows:1. Set \(L = a, R = b\).2. If the condition \(f(L)\cdot f(R)<0\) is not met, terminate. Otherwise:3. Test whether \(R - L <\text{TOL}\), where \(\text{TOL}\) is user tolerance (e.g.,\(\text{TOL}=10^{-7}\)). If yes, there is a root in \([L, R]\); otherwise,4. Continue with subintervals \([L,(L+R)/2]\) and \([(L+R)/2, R]\) following step 2.Write a recursive function `void bisect(double L, double R, double TOL)` implementing the bisection method, and a `double` function `f(double x)` returning \(f(x)\). Test your implementation with various functions and intervals, outputting the intervals containing roots and the function values at the midpoint. For instance, running with \(f(x)=13x^4-1\) and \(L =0, R =7\) might produce output like:"A root of f lies in [4.044723e+00,4.044723e+00] f((L+R)/2)-2.074738e-08."For \(f(x)=\sin(x)\), you might get output similar to:"A root of f lies in [0.000000e+00,5.215406e-08] f((L+R)/2)-2.607703e-08""A root of f lies in [3.141593e+00,3.141593e+00] f((L+R)/2)=-1.741103e-09""A root of f lies in [6.283185e+00,6.283185e+00] f((L+R)/2)--2.259483e-08."

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Demystified

Authors: Andrew Oppel

1st Edition

0072253649, 9780072253641

More Books

Students also viewed these Databases questions

Question

What do you see as your biggest strength/weakness?

Answered: 1 week ago

Question

Discuss the six purposes of performance management. page 340

Answered: 1 week ago