Find out the solution for the given equation
iteratively that at which integer value this
equation will get balance.
? = ?
? − ? ∗ ?
Teacher i need solution in c++ and python thanks
CODE:
#include<iostream>
#include<math.h>
//The given code implements the Newton Raphson iterative scheme for
finding the root of the equation 2-2x
using namespace std;
double fun(double x) //Given function 2-2x
{
double f=2-2*x;
return f;
}
double fund(double x) //Derivative of the function -2
{
double fd=-2;
return fd;
}
main()
{
double errmax=0.0001; //Defining maximum error
double x=0,xn; //Taking initial guess of root as
0
while(true)
{
xn=x-fun(x)/fund(x);
if((fabs(xn-x)<errmax))
break;
x=xn;
}
cout<<"Root is: "<<xn;
}
Get Answers For Free
Most questions answered within 1 hours.