Hey everyone. I am trying to write a program using Newtons Method. I know there is no code here, but that's my problem... I don't know where to start. I know the method is similar to bisection so if anyone could explain either to me or just help me get started, please let me know. Here is my problem:
I am trying to write a program in C++ to find a root of an equation. It starts with an initial guess, x(0), and generates successive approximate roots x(1), x(2), ... x(j), x(j+1) using the formula:
x(j+1) = x(j) - ((fx(j)) / f'x(j))
{x sub j+1 equals x sub j minus f(x sub j) divided by f prime (x sub j)} where f'(x sub j) is the derivative of function f evaluated at x = x(j). The formula generates a new guess, x(j=1), from a previous one, f(j). The program should terminate after 100 trials.
From geometry we get the equation:
(y(j+1) - y(j))/(x(j+1) - x(j)) = m
where m is the slope of the line between points (x(j+1), y(j+1)) and (x(j), y(j)). y(j+1) is zero, y(j) is f(x(j)), and m is f'(x(j)). After rearranging we get:
-f(x(j)) = f'(x(j)) * (x(j+1) - x(j))
Write a program that uses Newtons method to approximate the nth root of a number to 6 decimal places.
If x^n = c thenx^n - c = 0.
Finding the rood of the second equation you get nroot(c).
Test the program on sqroot(2), 3root(7), and 3root(-1).
The program can use c/2 as its initial guess.
That is how I started to set it up. I just don't know where to start... Thanks for any help. :)Code:#include<iostream>
#include<cmath>
using namespace std;
int main(){
return 0;
}