write a computer program ( C++ ) that gives roots of an equation by newton raphson's methode.
The coding is done based on your requirement and is given below with sample output :
code:
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
double f(double x); //declare the function for the given
equation
double f(double x) //define the function here, ie give the
equation
{
double a=pow(x,3.0)-x-11.0; //write the equation whose roots are to
be determined
return a;
}
double fprime(double x);
double fprime(double x)
{
double b=3*pow(x,2.0)-1.0; //write the first derivative of the
equation
return b;
}
int main()
{
double x,x1,e,fx,fx1;
cout.precision(4); //set the precision
cout.setf(ios::fixed);
cout<<"Enter the initial guess\n"; //take an intial
guess
cin>>x1;
cout<<"Enter desired accuracy\n"; //take the desired
accuracy
cin>>e;
fx=f(x);
fx1=fprime(x);
cout <<"x{i}"<<" "<<"x{i+1}"<<"
"<<"|x{i+1}-x{i}|"<<endl;
do
{
x=x1; /*make x equal to the last calculated value of x1*/
fx=f(x); //simplifying f(x)to fx
fx1=fprime(x); //simplifying fprime(x) to fx1
x1=x-(fx/fx1); /*calculate x{1} from x, fx and fx1*/
cout<<x<<" "<<x1<<"
"<<abs(x1-x)<<endl;
}while (fabs(x1-x)>=e); /*if |x{i+1}-x{i}| remains greater than
the desired accuracy, continue the loop*/
cout<<"The root of the equation is
"<<x1<<endl;
return 0;
}
Sample Output:

Hope this Helps, if you have any doubs please comment i
will get back to you and please thumbs up, thank you.
write a computer program ( C++ ) that gives roots of an equation by newton raphson's...
Write a program in Java to find the roots of the equation x^3 - 18 = 0 Using the bisection method and Newton-Raphson Method. Compare the two solutions.
question number 2
1. Write a computer program to solve the equation x = tan x by means of Newton's method. Find the roots nearest 4.5 and 7.7. ( 2. (Continuation) Write and test a program to compute the first ten roots of the equation tan x =x. (This is much more difficult than the preceding computer problem.) Cultural note: If a1, a2, ... are all the positive roots of this equation, then Zie A2 = 1/10. (Amer. Math. Monthly,...
. Write a program using C++ that used a function call Roots which will find the roots of the second degree equation your function supposed to receive the three coefficient of the second degree equation and return the two roots of the equation after checking what type of roots.
CSC 211 - Lab-2 Write a C++ program to find the roots of a quadratic equation ax +bx+c=0. The roots are given by the formula, x=-b I56²-4ac 2a x = -b+ √b²-4ac 2. x2 = -b-√6²-4ac 2a Instructions: 1. Type, compile, and run the program in an online C++ compiler. 2. Open a word document and copy the following items onto it: a. The source code b. Screenshot of your program's result 3. Save the word document as lastnameFirstname_Lab2.docx (for...
C++ The roots of the quadratic equation ax² + bx + c = 0, a ≠ 0 are given by the following formula: In this formula, the term b² - 4ac is called the discriminant. If b² - 4ac = 0, then the equation has a single (repeated) root. If b² - 4ac > 0, the equation has two real roots. If b² - 4ac < 0, the equation has two complex roots. Instructions Write a program that prompts the...
Quadratic roots. Write a program, quadroots.m, for finding the roots of the second- order polynomial ax2 + bx + c. Use the quadratic equation. The inputs are the coefficients a,b, and c and the outputs are z1 and z2. The program should produce (exactly) the following output in the Command window when run with (a, b, c) = (1, 2, −3): ==================== Quadratic Solver coefficients a=1 b=2 c = -3 roots z1 = 1 z2 = -3
The roots of the quadratic equation ax2 + bx + c = 0, a following formula: 0 are given by the In this formula, the term i2 - 4ac is called the discriminant. If b4ac 0 then the equation has a single (repeated) root. If -4ac > 0, th equation complex roots. Write a program that prompts the user to input the value of a (the coefficient of ), b (the coefficient of x), and c (the n has two...
Write a C program, to solve the quadratic equation a x2 + b x + c = 0 of given coefficients a, b and c. When running the program, it prompts for the input of coefficients a,b,c as floating numbers. After inputting three floating numbers, it computes and prints out the solutions, then prompts for another round of input. Your program will quit when getting input 0,0,0. Your program should handle four situations: (1) a=0, not a quadratic equation; (2)...
Write a C++ program to compute both roots of the quadratic equation when the user provides the three coefficients A, B, and C. Specifically, A. Display “Your Name” B. Display “Project_2 Problem_1” C. Display “This program computes both roots of a quadratic equation” D. Display “given the coefficients A, B, and C” E. Real_1 = 0 F. Real_2 = 0 G. Imag = 0 H. D = 0 I. DD =0 J. Flag = ‘Y’ K. DO a. A =...
Use
C++, visual studio format. Please
Write a program to solve the quadratic equation and find only the real and equal roots. the program should test for three types of roots tell the users the roots type and then calculate the real roots. the user enters the values of a ,b and c. you calculate r1 and r2. c