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.

359 questions
3
votes
1 answer

Newton's Basins of Attraction

I am trying to plot the Newton's Basins of Attraction for the polynomial z^3-1 using python. I am using Newton-Raphson Iterative method to plot the graph. Till now, I am able to plot this: What I want to generate is something like this: Could…
Pratanu Mandal
  • 548
  • 6
  • 21
3
votes
1 answer

Newton's method with recursion in Java

I was just curious I have this piece of Java code. My question is what is the reason to return 1.0 * the recursive call? in the else portion of the code My 2nd question is when I declare the E variable as 0.0000001 AND A , X variables as doubles in…
linyu21
  • 81
  • 9
3
votes
1 answer

Matlab - find intersection points between two elipses - newtons method - weird result

Im trying to write a matlab program that is supposed to find intersection point between one elipse and one crooked elipse. ((x − 4)^2/a^2)+((y-2)^2/2)=1 - equation for elipse 0.4x^2+y^2-xy = 10 - equation for crooked elipse r =…
Jakob Svenningsson
  • 3,625
  • 5
  • 19
  • 26
3
votes
3 answers

Computing fractional exponents in C

I'm trying to evaluate a^n, where a and n are rational numbers. I don't want to use any predefined functions like sqrt() or pow() So I'm trying to use Newton's Method to get an approximate solution using this approach: 3^0.2 = 3^(1/5) , so if x…
user3787097
  • 181
  • 2
  • 12
3
votes
1 answer

TypeError: can only concatenate tuple (not "float") to tuple

I'm new to python, so the question might be easy, anyway, thanks for your patience: As I was trying to call the newton-raphson method to calculate the implied volatility in Black-Scholes formula for call/put option pricing, First thing is, the…
StayFoolish
  • 285
  • 1
  • 9
  • 25
3
votes
2 answers

Why `x = x*(1.5f-(xhalf*x*x));` can be a Newton Method iteration?

Ok, by far, I guess many people know the famous fast inverse square root (see more on Writing your own square root function and 0x5f3759df) Here is the code float FastInvSqrt(float x) { float xhalf = 0.5f * x; int i = *(int*)&x; // evil…
Jackson Tale
  • 23,820
  • 29
  • 135
  • 251
3
votes
3 answers

Given f, is there an automatic way to calculate fprime for Newton's method?

The following was ported from the pseudo-code from the Wikipedia article on Newton's method: #! /usr/bin/env python3 # https://en.wikipedia.org/wiki/Newton's_method import sys x0 = 1 f = lambda x: x ** 2 - 2 fprime = lambda x: 2 * x tolerance =…
Noctis Skytower
  • 19,237
  • 15
  • 73
  • 103
3
votes
1 answer

Speeding up newton-raphson in pandas/python

I'm currently iterating through a very large set of data ~85GB (~600M lines) and simply using newton-raphson to compute a new parameter. As of right now my code is extremely slow, any tips on how to speed it up? The methods from BSCallClass &…
ast4
  • 771
  • 7
  • 18
2
votes
1 answer

Newton-Raphson Division For Floating Point Divide?

I am trying to implement the Newton-Raphson Division Algorithm Wikipedia entry to implement a IEEE-754 32-bit floating point divide on a processor which has no hardware divide unit. My memory locations are 32-bit two's complement word and I have…
Veridian
  • 3,278
  • 10
  • 38
  • 73
2
votes
3 answers

ZeroDivisionError: float division

I have got this code to solve Newton's method. But it gives a zero division error. I cannot figure out what is wrong. Thank you. import copy tlist = [0.0, 0.12, 0.16, 0.2, 0.31, 0.34] # list of start time for the phonemes w = w1 = w2 = w3 =…
zingy
  • 791
  • 8
  • 18
  • 33
2
votes
1 answer

Error in bigdecimal/newton for XIRR implementation

I would like to use the bigdecimal/newton module in Ruby for an implementation of XIRR. I have written a script to try it out by following this example. When I run the code (Ruby 1.9.2 on Mac OS X 10.6), I get the following…
wk2752
  • 147
  • 7
2
votes
1 answer

Implementing Multivariate Newton's Method in Julia

I am attempting to implement the multivariate Newton's method in Julia, but have run into a "no metehod matching" error. Below is my implementation and the code I use to call it. function newton(f::Vector, J::Matrix, x::Vector) h = Inf64 …
K. Claesson
  • 447
  • 4
  • 11
2
votes
1 answer

Update step in PyTorch implementation of Newton's method

I'm trying to get some insight into how PyTorch works by implementing Newton's method for solving x = cos(x). Here's a version that works: x = Variable(DoubleTensor([1]), requires_grad=True) for i in range(5): y = x - torch.cos(x) …
2
votes
1 answer

R loop to approximate square root of a positive real number with Newton's method

I am new to R and I'm working on a homework question which asks me to use a repeat loop using Newton's method for square root approximation. Here is what I have so far: x = 2 a = 10 tol = 1e-04 repeat { (abs(x^2 - a) > tol) (x = 0.5 * (a/x +…
Bkk
  • 77
  • 1
  • 5
2
votes
1 answer

Python: Newton, Hessian, Jacobian Method

Hi I am trying to use newton method to minimise a function but I keep getting this error when I run the code and I don't know why. Any help is much appreciated. Thanks! Error: ValueError: shapes (2,1) and (2,1) not aligned: 1 (dim 1) != 2 (dim 0) …
Nu2prog
  • 19
  • 4
1 2
3
23 24