Question

In: Computer Science

Modify/write your Newton-Raphson program in c language for single nonlinear equation to solve the following nonlinear...

Modify/write your Newton-Raphson program in c language for single nonlinear equation to solve the following nonlinear system

f1(x,y)=x3+y−1 = 0

f2(x,y)=y3−x+1 = 0

using the Newton-Raphson method with initial solutions x(0) = 0.5 and y(0) = 0.5 and the convergence criterion max(|f1(x, y)|, |f2(x, y)|) < ε = 10−6.

Solutions

Expert Solution

//Program for Newton-Raphson method on Non-linear equations
#include<stdio.h>
#include<math.h>
#define ESP pow(10,-6) //Here the Epsilon value define that is 10^-6
#define X(x,y) pow(x,3) + (y) - 1 //Define the first equation f1(x,y)=x^3+y-1
#define Y(x,y) pow(y,3) - (x) + 1 //Define the second equation f2(x,y)=y^3-(x)+1
#define F1(x,y) 3*(x)*(x) //Here calculate the derivative of first equation with respect to x
#define G1(x,y) -1 //Here calculate the derivative of second equation with respect to x
#define F2(x,y) 1 //Here calculate the derivative of first equation with respect to y
#define G2(x,y) 3*(y)*(y) //Here calculate the derivative of second equation with respect to y


void main()
{
double x1,y1,y2,x2,x,y,f,g,f1,f2,g1,g2;
int i=1;
printf("\nEnter the initial value of x: ");
scanf("%lf",&x);
printf("\nEnter the initial value of y: ");
scanf("%lf",&y);
f=X(x,y);
g=Y(x,y);
printf("\n\nf = %lf",f);
printf("\n\ng = %lf",g);
f1=F1(x,y);
f2=F2(x,y);
g1=G1(x,y);
g2=G2(x,y);
printf("\n\nf1 = %lf",f1);
printf("\n\ng1 = %lf",g1);
printf("\n\nf2 = %lf",f2);
printf("\n\ng2 = %lf",g2);

x1= x-((f*g2-g*f2)/(f1*g2-f2*g1));
y1= y-((g*f1-f*g1)/(f1*g2-f2*g1));
printf("\n\nx = %lf",x1);
printf("\n\ny = %lf",y1);

printf("\n\n");
do
{
f=X(x1,y1);
g=Y(x1,y1);
printf("\n\nf = %lf",f);
printf("\n\ng = %lf",g);

f1=F1(x1,y1);
f2=F2(x1,y1);
g1=G1(x1,y1);
g2=G2(x1,y1);
printf("\n\nf1 = %lf",f1);
printf("\n\ng1 = %lf",g1);
printf("\n\nf2 = %lf",f2);
printf("\n\ng2 = %lf",g2);

x2= x1-((f*g2-g*f2)/(f1*g2-f2*g1));
y2= y1-((g*f1-f*g1)/(f1*g2-f2*g1));
printf("\n\n x = %lf ",x2);
printf("\n\n y = %lf ",y2);
printf("\n\n");

if(fabs(x1-x2)<ESP && fabs(y1-y2)<ESP)
{
printf("\n\nREAL ROOT1 for x value = %.3lf",x1);
printf("\n\nREAL ROOT2 for y value = %.3lf",y1);
i=0;
}
else
{
x1=x2;
y1=y2;
}
}while(i!=0);

}

OUTPUT:-

  


Related Solutions

Determine the roots of the following simultaneous nonlinear equations using multiple-equation Newton Raphson method. Carry out...
Determine the roots of the following simultaneous nonlinear equations using multiple-equation Newton Raphson method. Carry out two iterations with initial guesses of x1(0) =0.6 and x2(0) =1.2. Calculate the approximate relative error εa in each iteration by using maximum magnitude norm (║x║∞). x1 + 1 - x22 = 0 x12 + x22 – 5 = 0
Write a C++ program for all the methods (Bisection, Newton-Raphson, Secant, False-Position, and Modified Secant) for...
Write a C++ program for all the methods (Bisection, Newton-Raphson, Secant, False-Position, and Modified Secant) for locating roots. Make sure that you have clever checks in your program to be warned and stop if you have a divergent solution or stop if the solution is very slowly convergent after a maximum number of iterations.
use newton raphson method to solve the following system of nonlinear equations x1^2+x2^2=50 ; x1*x2=25 stop...
use newton raphson method to solve the following system of nonlinear equations x1^2+x2^2=50 ; x1*x2=25 stop after three iterations. initial guess : (x1,x2) = (2,1)
Consider the Newton-Raphson method for finding root of a nonlinear function ??+1=??−?(??)?′(??), ?≥0. a) Prove that...
Consider the Newton-Raphson method for finding root of a nonlinear function ??+1=??−?(??)?′(??), ?≥0. a) Prove that if ? is simple zero of ?(?), then the N-R iteration has quadratic convergence. b) Prove that if ? is zero of multiplicity ? , then the N-R iteration has only linear convergence.
Write a funtion and apply multi-var. Newton-Raphson method.
Write a funtion and apply multi-var. Newton-Raphson method.
Let . If we use Accelerated Newton-Raphson method to approximate the root of the equation ,...
Let . If we use Accelerated Newton-Raphson method to approximate the root of the equation , which of the following(s) is/are ture: (I)  is multiple root of order (II) Accelerated Newton-Raphson formula is : (III) The sequence  obtained by the Accelerated Newton-Raphson method converge to the root  quadratically.
Write the following in C language for Arduino: Write a program that turns on the LED...
Write the following in C language for Arduino: Write a program that turns on the LED at 25%, 50%, 75%, 100%, and then 0% brightness with a one second delay in between each change. Remember you are going to need to use a PWM pin and use the "analogWrite" command. The maximum value for our Arduino R3 boards is 255 and you need five steps (25%, 50%, 75%, 100%, and 0%) so you will need to determine the values for...
Write a program in MIPS assembly language to perform the calculation of the following equation and...
Write a program in MIPS assembly language to perform the calculation of the following equation and save the result accordingly:    f = 5x + 3y + z Assumptions: - Registers can be used to represent variables x, y, z, and f - Initialize x, y, and z to values of your choice. f can be initialized to zero. - Use comments to specify your register usage and explain your logic
Write a program in C++ Write three new functions, mean() and standard_deviation(). Modify your code to...
Write a program in C++ Write three new functions, mean() and standard_deviation(). Modify your code to call these functions instead of the inline code in your main(). In addition, add error checking for the user input. If the user inputs an incorrect value prompt the user to re-enter the number. The flow of the code should look something like: /** Calculate the mean of a vector of floating point numbers **/ float mean(vector& values) /** Calculate the standard deviation from...
***Please code in Python Write another code Newton (in double precision) implementing the Newton-Raphson Method   (copy...
***Please code in Python Write another code Newton (in double precision) implementing the Newton-Raphson Method   (copy your Bisect code and modify).   Evaluation of F(x) and F'(x) should be done in a subprogram FCN(x).   The code should ask for input of: x0, TOL, maxIT (and should print output similar to Bisect code).   Debug on a simple problem, like x2−3 = 0.   Then use it to find root of F(x) in [1,2] with TOL=1.e-12. Now consider the problem of finding zeros of      ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT