HP42s first major program (Double Integral) Best way to approach?
|
06-04-2020, 07:06 PM
(This post was last modified: 06-09-2020 01:25 PM by Albert Chan.)
Post: #53
|
|||
|
|||
RE: HP42s first major program (Double Integral) Best way to approach?
Hi, Werner
I added your suggested changes. Thanks. (06-03-2020 06:45 PM)Albert Chan Wrote: There is still an issue of AGM convergence. For EK(2), this involved calculating: b = sqrt(1-m) = 1j x1, y1 = agm2(1+b, 2*sqrt(b)) = agm2(1+1j, sqrt(2)*(1+1j)) We can scale away 1+1j, and get x1,y1, like this: x2, y2 = agm2(1, sqrt(2)) ≈ (1.1981, 0.91389) x1 = (1+1j) * x2 ≈ 1.1981 + 1.1981j y1 = (1+1j)**2 * y2 = 2j * y2 ≈ 1.8278j → K(2) = pi / x1 ≈ 1.3110 - 1.3110j → E(2) = K(2) * y1/4 ≈ 0.59907 + 0.59907j We have y1 as purely imaginary complex number. However, with rounding errors, directly go for y1 might have tiny real part. Since we test for ACC equality, going directly for y1 might not work. This is my idea ... by going up the agm2 chain. x0, y0 = agm2(1,b), b ≠ 0 x0 = agm(1,b) = agm((1+b)/2, sqrt(b)) = x1 / 2 y1 = (1+b)^2 - 2*((1+b)/2 - sqrt(b))^2 - 4*gap2^2 - 8*gap3^2 - ... 2 y0 = 2*1^2 - (1-b)^2 - 2*((1+b)/2 - sqrt(b))^2 - 4*gap2^2 - 8*gap3^2 - ... → y1 - 2 y0 = (1+b)^2 - 2 + (1-b)^2 = 2 b^2 → y1 = 2*(y0 + b^2) x0, y0 = agm2(1, 1j) ≈ (0.59907 + 0.59907j, 1.0000 + 0.91389j) → K(2) = pi / (2*x0) ≈ 1.3110 - 1.3110j → E(2) = K(2) * (y0 + b^2)/2 ≈ 0.59907 + 0.59907j This is my new version, getting EK(m) using AGM(1,b), b = sqrt(1-m) Code: 00 { 181-Byte Prgm } 2 XEQ "EK" → E ≈ 0.59907 + 0.59907i, K ≈ 1.3110 - 1.3110i Update: replace EK(m = (d/D)^2) as EK(m = d^2/D^2) Possibly more accurate m, and saved 1 byte of code. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)