Write a C/C++ program that approximates a root of the equation f(x) = 0 in an interval [a, b] using Newton-Raphson method. The necessary assumptions for application of this method should be explicitly mentioned. Use the method to find one root of the equation: x3 + 4x2 - 19=0.
Here's a C++ program that uses the Newton-Raphson method to approximate a root of the equation f(x) = 0 within a given interval [a, b]. The program will find one root of the equation x^3 + 4x^2 - 19 = 0.
#include
#include
using namespace std;
const double EPSILON = 0.00001;
const int MAX_ITERATIONS = 100;
double f(double x) {
return pow(x, 3) + 4 * pow(x, 2) - 19;
}
double f_prime(double x) {
return 3 * pow(x, 2) + 8 * x;
}
double newtonRaphson(double a, double b) {
double x0 = (a + b) / 2; // Initial guess for the root
for (int i = 0; i < MAX_ITERATIONS; i++) {
_________ __________ ________ ___ __________ _______ ________ _______ ______ _____ ______ ______.
_____ ____ ______ _____ ______ _________ ____.
________ ___ ___ __________ _________ ____ _______ _____.
____ ________ ______ _______ ____ _______ ______ ________ _____.
_________ ______ _________ ___ _______.
________ ___ _________ _______ _____.
_________ ________ ________ _________ ____.
_______ ____ _____ ________ _______ _____ __________ ___ ______ ______.
____ _______ __________ _____ ______ ____ _________ ____ __________.
________ ______ __________ ____ _________ _______ ____ ___ ________ ________ _____.
_________ _______ _______ ________ _________ ____ _________ _______ __________ ________ _______ ____.
_______ ______ ______ _____ _______.
______ __________ ________ __________ __________ ________ _______ ________ ______ ________ _______.
_____ ______ __________ _________ ________ _____ __________.
____ _______ _____ _____ ___ ________ _______ ___ ___ _____.
_________ __________ ____ ________ __________ _________ _____ ___ ____ ___.
__________ ________ _________ ________ _______ ___ ___ _____.
_________ ___ _________ ______ ________ ____ ___.
_____ _______ __________ ______ __________ _________ ___ _____ ________ ___ ________ _____.
________ ______ ___ ___ _____ ________ __________ _____ _______ _______ _________ _________.
_____ _____ _______ ______ __________.
_________ __________ _________ ______ _____ ______ ________ ______.
_____ ________ __________ ______ _________ ______ ________ _____.
_________ _______ ________ ____ _____ ________ __________ _____ __________ ___ __________ ___.
_____ ____ ___ ______ ______ _________ _____ ______ __________ ______ _________ ______.
_____ _______ ___ ______ ______ _________ ________.
___ ______ _________ _______ __________ _____ ___ ___ _____ ______ ___.
______ ____ ____ ________ ________ ___ _____ ________.
_______ __________ ________ _______ ______ _____.
_______ __________ _____ ______ ___ ______ ________.
______ _______ _____ _________ _____ _________ ___ _____ ________ _________.
_______ ____ ____ _____ ________ ______ ________ __________ ______ _________ ___ ______.
_______ _____ _____ ___ ____ __________ ______.
_____ ______ ___ ________ ______ ____ ________ _____.
_________ ______ ________ _________ _______ _______.
________ _________ __________ ____ ________.
________ ___ ______ ________ ______ _____.
____ _______ ________ _____ ____ ____.
__________ ______ ____ _____ ___ ________ _____ __________ _________.
__________ ___ ________ _______ ______ ________ ________ ___.
_____ __________ _____ ___ ____ ___ ______ _____ ________ _____.
________ ___ _________ _________ ______ ____ ______ ___ ________ __________.
________ _____ _______ ______ ___ ____ ______ __________.
_____ _________ ______ __________ ___ ________ __________ _______ ________ ______.
______ _____ ___ ___ ______ _______.
__________ ________ __________ _______ __________ _________ ___ _____.
_____ ___ _________ _____ _____ ______ ________ ______ _______ __________ ______.
_____ ____ _________ _______ ___ _________.
- Solved Assignments
- Study Notes
- Guess Papers
- Question Papers
✓ Unlock up to 60% of the answer
✓ No payment required