Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program, named bisection.h , containing the following functions. Function float horner(float *p, int n, float x) (similar to question 2, but using

Write a C program, named bisection.h, containing the following functions.

  1. Function float horner(float *p, int n, float x) (similar to question 2, but using pointers for array operations).
  2. Function float bisection(float *p, int n, float a, float b) computes a real root of the polynomial function f(x) = p[0]xn-1 + p[1]xn-2 ++ p[n-2]x1 + p[n-1]x0 between interval [a, b] by bisection method when f(a)*f(b) < 0. Use the fault tolerant 1e-6 (or 0.000001) as a stop condition, i.e., if x0 is the actual root and x is a approximate to x0, stop the iteration if |x-x0|<1e-6 or |f(x)| < 1e-6.

Use the provided main program to test the above functions.

Main Program

#include "bisection.h" int main(int argc, char* args[]) { float p[] = {1, 2, 3, 4}; int n = 4; float a = -2, b = 2; float pa = horner(p, n, a); float pb = horner(p, n, b); printf("f(%f): %f ", a, pa); printf("f(%f): %f ", b, pb); if (pa * pb < 0) { float r = bisection(p, n, a, b); printf("root: %f ", r); printf("f(%f): %f ", r, horner(p, n, r)); } return 0; } 

public test

 f(-2.000000): -2.000000 f(2.000000): 26.000000 root: -1.650629 f(-1.650629): 0.000001

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

Navigating The Supply Chain Maze A Comprehensive Guide To Optimize Operations And Drive Success

Authors: Michael E Kirshteyn Ph D

1st Edition

B0CPQ2RBYC, 979-8870727585

More Books

Students also viewed these Databases questions

Question

Develop a program for effectively managing diversity. page 303

Answered: 1 week ago

Question

List the common methods used in selecting human resources. page 239

Answered: 1 week ago