Question

Substituting these formulas, the Newton-Raphson update rule for computing the n root of any value K is: 2+1 = - na-T Writehelp with C++ please

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: If you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

#include <iostream>

using namespace std;
double power(double x,int n)
{
if(n==0)
return 1;
return x*power(x,n-1);
}
double rootN(double x,int n)
{
double x0=x/2.0,t;
for(int i=0;i<20;i++)
{
x0=1.0/(double)n*((double)(n-1)*x0+x/power(x0,n-1));
}
return x0;
}
int main()
{
char ch='y';
while(ch=='y')
{
cout<<"enter value and root: ";
double x;
int n;
cin>>x>>n;
cout<<"root is "<<rootN(x,n)<<endl;
cout<<"continue? (y/n): ";
cin>>ch;
}
return 0;
}

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
help with C++ please Substituting these formulas, the Newton-Raphson update rule for computing the n' root...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C PROGRAM NOT C++ Make sure your program reports out the following: - The polynomial that...

    C PROGRAM NOT C++ Make sure your program reports out the following: - The polynomial that the user has entered - The initial guess that the user has entered - Whether or not the Newton-Raphson algorithm converged to a solution - If successful, the root of the polynomial that the algorithm found - The number of iterations that the Newton-Raphson algorithm required to converge to a solution Also, add any numerical protections to the algorithm that you find necessary HINT:...

  • c++ please (1) Write a program that prompts the user to enter an integer value N...

    c++ please (1) Write a program that prompts the user to enter an integer value N which will rpresent the parameter to be sent to a function. Use the format below. Then write a function named CubicRoot The function will receive the parameter N and return'its cubic value. In the main program print the message: (30 Points) Enter an integer N: [. ..1 The cubic root of I.. ] is 2 update the code om part and write another function...

  • in matlab sthat this n is hardly different from the scalar version in Section 4.3 . The root estimates are stored as columns in an array . The Newton step is calculated using a backslash. The fu...

    in matlab sthat this n is hardly different from the scalar version in Section 4.3 . The root estimates are stored as columns in an array . The Newton step is calculated using a backslash. The function norm is used for the magnitude of a vector, instead magnitude of a scalar. Function 4.5,1 (netonsys) Newron's method for a system of equations function x=newtonsys (f,x1) 2 % NETONSYS Newton's method for a system of equations 3 % Input : function that...

  • Write a program in C++ that gives the temperature of earth at a depth. It must...

    Write a program in C++ that gives the temperature of earth at a depth. It must be in C++ and follow the information below: Problem description Write a program to take a depth in kilometers inside the earth as input data; calculate and display the temperature at this depth in both degrees Celsius and degree Fahrenheit. The formulas are: Celsius temperature at depth in km: celsius = 10 x depth(km) + 20 Convert celsius to fahrenheit: fahrenheit = 1.8 x...

  • Please help me program this in C! Description Given the following equations sets to calculate the...

    Please help me program this in C! Description Given the following equations sets to calculate the value of variables x, y and z, a2+b Write a program that takes values for integers a and b as input and displays the values of the unknown variable triple (x, y and z) generated by the formulas above. Hint: The input variables a and b should be integers. In case you need to find a function from the math.h library, visit cplusplus.com Sample...

  • Update the program in the bottom using C++ to fit the requirements specified in the assignment....

    Update the program in the bottom using C++ to fit the requirements specified in the assignment. Description For this assignment, you will be writing a single program that enters a loop in which each iteration prompts the user for two, single-line inputs. If the text of either one of the inputs is “quit”, the program should immediately exit. If “quit” is not found, each of these lines of input will be treated as a command line to be executed. These...

  • Please help: For this project, you will create a shape drawing program using Turtle graphics. Your...

    Please help: For this project, you will create a shape drawing program using Turtle graphics. Your program will begin by asking the user how many points they would like to enter (# of vertices for the shape). Next, you will use a loop to input each X and Y coordinate and store these coordinates in lists. After inputting all of the coordinates, create a second loop that will draw and fill the shape using the coordinates that were entered. All...

  • Hi. Could you help me write the below program? Please don't use any header other than...

    Hi. Could you help me write the below program? Please don't use any header other than iostream, no Chegg class, no argc/argv. Nothing too advanced. Thank you! For this assignment you are implement a program that can be used to compute the variance and standard deviation of a set of values. In addition your solution should use the functions specified below that you must also implement. These functions should be used wherever appropriate in your solution. With the exception of...

  • please code in basic c++ program Write a program that uses the following formula: n (ax...

    please code in basic c++ program Write a program that uses the following formula: n (ax - ib) i=1 Your program will prompt the user for the number of iterations for the calculation. input values for n, x, a, b, and c. n must be a positive integer, but x, a, b, and c can be any real numbers. Then it will perform the calculation and output the result. Then, it will ask the user if they would like to...

  • C Programming QUESTION 9 Write a program that prompts for and reads four integer input values,...

    C Programming QUESTION 9 Write a program that prompts for and reads four integer input values, then a single character command. Submit your program as a .c file named midterm_prog2.c. Note that, similarly to your programming assignments, some percentage of your grade will depend on proper programming style. Your program will calculate and print a new value based on the command that's entered, as follows: 'A' or 'a': Calculate the average of the four input values 'S' or 's': Calculate...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT