newtons-method

Finding the square root using Newton's method (errors!)

强颜欢笑 提交于 2019-11-27 07:20:46
问题 I'm working to finish a math problem that approximates the square root of a number using Newton's guess and check method in Python. The user is supposed to enter a number, an initial guess for the number, and how many times they want to check their answer before returning. To make things easier and get to know Python (I've only just started learning the language a couple of months ago) I broke it up into a number of smaller functions; the problem now, though, is that I'm having trouble

Conversion between RGB and RYB color spaces

时光怂恿深爱的人放手 提交于 2019-11-26 22:51:50
问题 I am currently trying to convert colours between RGB (red, green, blue) colour space and RYB (red, yellow, blue) colour space and back again. Based on the details in the following paper, I am able to convert from RYB to RGB using trilinear interpolation - where the parametric weightings (s,t,u) are the RYB colors, and the vertices of the cube are 3d points in RGB space. Paint Inspired Color Mixing and Compositing for Visualisation - Gossett and Chen - Section 2.1 - Realization Details My

Writing your own square root function

橙三吉。 提交于 2019-11-26 11:04:14
How do you write your own function for finding the most accurate square root of an integer? After googling it, I found this (archived from its original link ), but first, I didn't get it completely, and second, it is approximate too. Assume square root as nearest integer (to the actual root) or a float. Fredrik Johansson The following computes floor(sqrt(N)) for N > 0: x = 2^ceil(numbits(N)/2) loop: y = floor((x + floor(N/x))/2) if y >= x return x x = y This is a version of Newton's method given in Crandall & Pomerance, "Prime Numbers: A Computational Perspective". The reason you should use

Writing your own square root function

霸气de小男生 提交于 2019-11-26 02:17:05
问题 How do you write your own function for finding the most accurate square root of an integer? After googling it, I found this (archived from its original link), but first, I didn\'t get it completely, and second, it is approximate too. Assume square root as nearest integer (to the actual root) or a float. 回答1: The following computes floor(sqrt(N)) for N > 0: x = 2^ceil(numbits(N)/2) loop: y = floor((x + floor(N/x))/2) if y >= x return x x = y This is a version of Newton's method given in