Write a C++ program to solve the following system of three non-linear equations
ID: 3771591 • Letter: W
Question
Write a C++ program to solve the following system of three non-linear equations in three variables, using the Method of Newton-Raphson: x^3 + 3y = 1/sin^2(2 theta) y = e^-x y = x + ln(theta) Start the iterations with the following initial guesses: {1,1,1}^T Evaluate the partial derivatives required by the Jacobian Matrix using a centered finite difference approximation Solve for the errors of each variable using simple Gaussian Elimination Proceed with the iterations until the following equation is satisfied: sigma all variables abs(epsilon) LE 10^-5 Your program must display the Jacobian matyrix and the "current" value of each of the variables at every iteration.Explanation / Answer
Hi..
Following is the snippet for Newton-Raphson method. You can use the same to enter your three equations (or n equations) . This would then provide with accurate results.
int main()
{
char initial = 'c';
double E;
int i=0,s=1,r=1;
double N = 12;
double a,b,c,d;
double fx,fpx,y,y;
while(initial == 'q')
{
printf("Enter the values of a, b, c and d");
cin>>a;
cin>>b;
cin>>c;
cin>>d;
if(a == 0)
break; // exit
cout<<"Enter the value of y ";
cin>>y;
cout<<"Enter the value of E: ";
cin>>E;
y= y;
fx = a*y*y*y +b*y*y +c*y +d;
i=0;
while(i<N)
{
i=i+1;
fx = a*y*y*y +b*y*y +c*y +d;
fpx = 3*a*y*y +2*b*y +c;
y= y - (fx/fpx);
cout<<"Values"<< r1<< y;
}
cin>>initial;
cout<<"'q' to quit: ";
cin>>initial;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.