Questions tagged [newtons-method]

In numerical analysis, Newton's method (also known as the Newton–Raphson method) is a method for finding successively better approximations to the roots (or zeroes) of a real-valued function.

In numerical analysis, Newton's method (also known as the Newton–Raphson method) is a method for finding successively better approximations to the roots (or zeroes) of a real-valued function.

Formula:

enter image description here

In this formula xn + 1 is the next closest approximation after xn, f(xn) is the function at xn and f'(xn) is the derivative of the function at xn.

First approximation x0 has to be in interval (a,b) where exact solution x* is situated.

418 questions
0
votes
0 answers

I'm getting a ValueError when writing a method plot for Newton's method

I have an assignment for school. First of all can you help me with confirming I have interpreted the question right? And also does the code seem somewhat ok? There have been other tasks before this like create the class with a two dimensional…
0
votes
1 answer

Solving colebrook (nonlinear) equation with Newton Raphson method in python

I have tried solving the colebrook (nonlinear) equation for frictional factor in python but I keep getting this error: Traceback (most recent call last): File "c:/Users/WWW/Desktop/WWWWWWWW/WWWWWWWWWWW/DDD/WWWWW.py", line 46, in
nebula1
  • 71
  • 4
0
votes
2 answers

Would Newton's method classify as a Gradient Descent Method?

Could be quite a trivial question to answer, but I just wanted to be clearer. From the available literature and the discussion in What is the difference between Gradient Descent and Newton's Gradient Descent?, both methods involve computing a…
Sal
  • 35
  • 8
0
votes
1 answer

Netwon's method without pre-built functions of Python: Calculation of gradient and Hessian

I am trying to write the basic Newton's method without pre-built solvers. This is the function: ## definition of variables x_1, x_2 = sym.symbols("x_1 x_2") a_T=np.array([[0.3],[0.6],[0.2]]) b_T=np.array([5,26,3]) c_T=np.array([40,1,10]) u=…
Jael
  • 369
  • 1
  • 4
  • 13
0
votes
1 answer

Output number of iterations for Newton Method using Scipy

I would like to know how I can output the number of iterations when finding the root using Newtons method. I am calculating the root automatically using Scipy, so I wanted to know if there is a way of knowing how many iterations it took: from…
Prog101
  • 109
  • 2
  • 10
0
votes
0 answers

Implementing Newton's Method in R using a While Loop

g <- function(x) { log(x)/(1+x) } gPrime <- function(x) { (1 + x - x*log(x))/(x^3 + 2*x^2 + x) } guess <- 1.5 tolerance <- .00001 root <- function(g, gPrime, guess, tolerance) { x <- guess while (abs(g(x)) > tolerance) { x <-…
0
votes
1 answer

Finding The Root Using Newtons Method Given A Certain Interval

I can calculate the root of a function using Newtons Method by subtracting the old x-value from the new one and checking for the convergence criterion. Is there a way of doing it when given a closed interval, e.g Given a function and the interval…
Prog101
  • 109
  • 2
  • 10
0
votes
2 answers

How to halt a loop in Julia and printing the ErrorMsg at the same time without using any macros?

I am writing a simple newton method x_(n+1) = x_n - f(x_n) / f_prime(x_n) to find the roots (can be a real number or a complex number) of a quadratic function: f(x) = a*x*x + b*x + c (a, b, c are given constants and are all real numbers). I know…
Tack_Tau
  • 628
  • 1
  • 6
  • 12
0
votes
1 answer

Displaying orbit with vpython using kepler's equation but the planet won't orbit

I've been trying to make some sort of simulation of the solar system, and I came across Kepler's equation in order to give me the position of the planet at any given time. I used the Newton-Raphson method in order to calculate the eccentric anomaly.…
0
votes
1 answer

MATLAB program using Secant Method sometimes seems to output nonsense values

To learn MATLAB, I'm working on a program that finds root of the zero using the Secant Method. Below my code: function [zero, x_vector] = secant_method(fx, x1, x2, nmax, tol) %function that tries to find root of given function using the secant…
Mathbeginner
  • 201
  • 1
  • 8
0
votes
1 answer

How to apply Newton Raphson method for polar function in Python?

I have three dimensional function randomly defined by a user Z=f(x,y) def f(x,y): return ((7*x*y)/(np.exp(x**2+y**2))) I converted this function to polar coordinates by substituting: x_c = r*np.cos(theta)+x1; y_c =…
yahya.k
  • 21
  • 4
0
votes
2 answers

Handling Complex Numbers while returning function values

I am trying to solve to the equation f(x) = cos(x) - sqrt(x) using Newton-Raphson Method in python f'(x) = -sin(x) - (1/2*sqrt(x)) For my starting guess, I'm trying values form 0 to 4. It works fine from the range 0.00001 to 2.45 The graph looks…
Pirate X
  • 3,023
  • 5
  • 33
  • 60
0
votes
1 answer

How do I ask Newton method to try again with different initial guess in Python

I am solving a large problem where the location of the root to my equation changes very rapidly from one value to another. However the function is close to 0, and so Newton method thinks there is a root there, but iterates itself out. I would like…
Patrick Lewis
  • 83
  • 1
  • 1
  • 10
0
votes
2 answers

why this C function (newton raphson method for square root of n) doesnt work correctly?

I'm writing code to find square root of numbers using Newton–Raphson method but I can't get the correct output. When I run this code with any input, I get 0.000003 as result without any errors or alarms. When I change all double keywords to float it…
Siavash TS
  • 41
  • 4
0
votes
1 answer

Newton's method for calculating rate

I am trying to implement the "RATE()" function in Java as Excel does it. After initial research, I saw I needed to use Newton's method to get to the rate since we cannot solve for r explicitly. Payment function => P = r × (PV) /(1 − (1 + r) ^ −n) I…
Morkus
  • 517
  • 7
  • 21