Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a matlab m-file (called bisection.m) implementing the bisection method for solving f(x) := fun(x) = 0. Note that the bisection routine depends on n,a,b,fun

Write a matlab m-file (called bisection.m) implementing the bisection method for solving f(x) := fun(x) = 0. Note that the bisection routine depends on n,a,b,fun where n is the desired number of steps (or iterations), a and b are the initial interval endpoints and fun is the function. These values are to be defined on the command line one at a time before the m-file is invoked (when you type bisection on the command line). Thus, you can make runs with different values for n,a,b, and fun by redefining them on the command line and re-invoking the 1 2 m-file. Note that you must be executing matlab in the directory where you created the bisection.m file. From the plot of P(x), we see that the intervals [-2,-1], [-1,0], [0,.4], [.4,1] bracket the four roots. Run the bisection method over these intervals to obtain approximations to the four roots. Report the results of your iteration (an + bn)/2 for n = 20 for each interval. Now make the same runs but with n = 30. This will give you a rough idea about the accuracy, i.e., it is approximately the error between the results for n = 20 and n = 30.

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_2

Step: 3

blur-text-image_3

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

Mastering Big Data Interview 751 Comprehensive Questions And Expert Answers

Authors: Mr Bhanu Pratap Mahato

1st Edition

B0CLNT3NVD, 979-8865047216

More Books

Students also viewed these Databases questions