(12C) Square Root
|
06-08-2021, 03:36 PM
(This post was last modified: 06-09-2021 11:24 AM by Albert Chan.)
Post: #7
|
|||
|
|||
RE: (12C) Square Root
Inspired by ∫(1/(a - cos(x)), x=0..pi) = pi/√(a²-1), I find another way to get 1/√(a²-1) For x = 0 to pi, cos(x) = 1 to -1, we can approximate integral without cos(x) term: ∫(1/(a - cos(x)), x=0..pi) ≈ pi/a → 1/√(a²-1) ≈ 1/a ∫(1/(a - cos(x)), x=0..pi) = ∫(1/(a - cos(x)) + 1/(a + cos(x)), x=0 .. pi/2); // fold the integral = 2*a * ∫(1/ (a² - cos(x)²), x = 0..pi/2) = 4*a * ∫(1/ (2*a² - (1 + cos(2*x))), x = 0..pi/2); // let y = 2*x = 2*a * ∫(1/ (a2-cos(y)), y = 0..pi); // let a2=2*a²-1 Again, dropping cos(y), we have: ∫(1/(a - cos(x)), x=0..pi) ≈ 2*a/a2 * pi → 1/√(a²-1) ≈ (1/a)·(1+1/a2) Rinse and repeat, let ak = 2*ak-1² - 1, we have 1/√(a²-1) = (1/a)·(1+1/a2)·(1+1/a3) ... Convergence is quadratic, example, with a=2 1/√3 = (1/2)·(1+1/7)·(1+1/97)·(1+1/18817)·(1+1/708158977) ... Or, we flip both side: √3 = 2·(1-1/8)·(1-1/98)·(1-1/18818)·(1-1/708158978) ... function seq(a) -- sequence converging to sqrt(a*a-1), a > 1 local t = a return function() a=2*a*a; t=t-t/a; a=a-1; return t end end lua> g = seq(2) lua> for i=1,4 do print(i, g()) end 1 1.75 2 1.7321428571428572 3 1.7320508100147276 4 1.7320508075688774 This is equivalent to Newton's method for √N, N=a*a-1, guess x=a: lua> N, x = 3, 2 lua> for i=1,4 do x=(x+N/x)/2; print(i, x) end 1 1.75 2 1.7321428571428572 3 1.7320508100147274 4 1.7320508075688772 |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(12C) Square Root - Gamo - 10-02-2019, 10:23 AM
RE: (12C) Square Root - Albert Chan - 10-02-2019, 02:36 PM
RE: (12C) Square Root - Albert Chan - 09-28-2020, 05:18 PM
RE: (12C) Square Root - Albert Chan - 09-28-2020, 07:14 PM
RE: (12C) Square Root - Gamo - 10-03-2019, 02:01 AM
RE: (12C) Square Root - SlideRule - 09-28-2020, 09:45 PM
RE: (12C) Square Root - Albert Chan - 06-08-2021 03:36 PM
RE: (12C) Square Root - depor - 12-21-2023, 11:50 PM
RE: (12C) Square Root - Dave Hicks - 12-23-2023, 01:48 AM
RE: (12C) Square Root - Thomas Klemm - 12-23-2023, 04:26 AM
|
User(s) browsing this thread: 1 Guest(s)