Bürgi's Kunstweg to Calculate Sines
|
05-09-2022, 04:55 PM
Post: #4
|
|||
|
|||
RE: Bürgi's Kunstweg to Calculate Sines
(05-09-2022 01:48 AM)Albert Chan Wrote: Asymmetry of matrix, [2,-1] top, [-2,2] bottom , we should match edge cases coefficients. Another way is to split central difference to 2 steps, forward diff, then backward diff. Below, 1 ≡ 10°, (0-1) ≡ sin(0°) - sin(10°) = -sin(10°) ≡ -1 Code: 0 F B F >>> from numpy import * >>> F = [[-1,0,0,0,0,0,0,0,0], ... [1,-1,0,0,0,0,0,0,0], ... [0,1,-1,0,0,0,0,0,0], ... [0,0,1,-1,0,0,0,0,0], ... [0,0,0,1,-1,0,0,0,0], ... [0,0,0,0,1,-1,0,0,0], ... [0,0,0,0,0,1,-1,0,0], ... [0,0,0,0,0,0,1,-1,0], ... [0,0,0,0,0,0,0,1,-1]] >>> >>> B = [[1,-1,0,0,0,0,0,0,0], ... [0,1,-1,0,0,0,0,0,0], ... [0,0,1,-1,0,0,0,0,0], ... [0,0,0,1,-1,0,0,0,0], ... [0,0,0,0,1,-1,0,0,0], ... [0,0,0,0,0,1,-1,0,0], ... [0,0,0,0,0,0,1,-1,0], ... [0,0,0,0,0,0,0,1,-1], ... [0,0,0,0,0,0,0,0, 2]] >>> >>> M = -matrix(B) * matrix(F) >>> print M [[ 2 -1 0 0 0 0 0 0 0] [-1 2 -1 0 0 0 0 0 0] [ 0 -1 2 -1 0 0 0 0 0] [ 0 0 -1 2 -1 0 0 0 0] [ 0 0 0 -1 2 -1 0 0 0] [ 0 0 0 0 -1 2 -1 0 0] [ 0 0 0 0 0 -1 2 -1 0] [ 0 0 0 0 0 0 -1 2 -1] [ 0 0 0 0 0 0 0 -2 2]] If we apply this M operator, it generated massive cancellation errors. Applying its inverse turn all entries non-negative, without cancellation errors. >>> print linalg.inv(M) [[ 1. 1. 1. 1. 1. 1. 1. 1. 0.5] [ 1. 2. 2. 2. 2. 2. 2. 2. 1. ] [ 1. 2. 3. 3. 3. 3. 3. 3. 1.5] [ 1. 2. 3. 4. 4. 4. 4. 4. 2. ] [ 1. 2. 3. 4. 5. 5. 5. 5. 2.5] [ 1. 2. 3. 4. 5. 6. 6. 6. 3. ] [ 1. 2. 3. 4. 5. 6. 7. 7. 3.5] [ 1. 2. 3. 4. 5. 6. 7. 8. 4. ] [ 1. 2. 3. 4. 5. 6. 7. 8. 4.5]] We can also think of inv(M) as "going back in time", turning divergence into convergence. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Bürgi's Kunstweg to Calculate Sines - Thomas Klemm - 05-07-2022, 11:31 AM
RE: Bürgi's Kunstweg to Calculate Sines - Thomas Klemm - 05-08-2022, 01:19 PM
RE: Bürgi's Kunstweg to Calculate Sines - Albert Chan - 05-09-2022, 01:48 AM
RE: Bürgi's Kunstweg to Calculate Sines - Albert Chan - 05-09-2022 04:55 PM
|
User(s) browsing this thread: 1 Guest(s)