Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program to solve the following system of three non-liear equations i

ID: 3763498 • Letter: W

Question

Write a C++ program to solve the following system of three non-liear equations in three variables, using the Method of Newton-Raphson: 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: Your program must display the Jacobian matrix and the "current" value of each of the variables at every iteration.

Explanation / Answer

Code

int main()
{
   char command = 'c';
   double E;
   int i=0,s=1,r=1;
   double N = 12;
   double a,b,c,d;
   double fx,fpx,X0,x;

   while(command == 'c')
   {
       printf("Enter the values of a, b, c and d (separated by space): ");
       scanf("%lf %lf %lf %lf",&a,&b,&c,&d);

       if(a == 0)
           break;

       printf("Enter the value of X0 (initial guess): ");
       scanf("%lf",&X0);

       printf("Enter the value of convergence limit: ");
       scanf("%lf",&E);

       x= X0;
       fx = x*x*x+3 y(x)-1/(sin*sin(2 Q))
       y'(x) = x^3+3 y(x) = csc^2(2 Q)
       i=0;

       while(i<N)
       {
           i=i+1;

           fx = x*x*x+3 y(x)-1/(sin*sin(2 Q));
           fpx = x*x*x+3*y-csc*csc2(2*Q);
           x= x - (fx/fpx);

           printf("After iteration %d, root = %f ",r++,x);
       }

       scanf("%c",&command);

       printf("Press 'c' to continue or 'q' to quit: ");

       scanf("%c",&command);
   }

   system("pause");
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote