Post Reply 
[VA] SRC #011 - April 1st, 2022 Bizarro Special
04-10-2022, 04:29 PM
Post: #22
RE: [VA] SRC #011 - April 1st, 2022 Bizarro Special
(04-10-2022 09:20 AM)EdS2 Wrote:  It feels to me that uniform sampling would be just as accurate as random sampling, although as it turns out it would more expensive in terms of machinery.

I am not so sure random sampling is accurate at all.
This is like throwing dart to estimate pi. Try running it twice Big Grin

Uniform sampling might not need as many points, if we extrapolate results.
Below, FNA(A,B,C) is Aitken's delta-squared process, extraploate from 3 known points.

No tricks. Just sum all forces pressing the 2 planets, divided up N^3, M^3 tiny cubes
(If either N, M is even, it take advantage of quadrant symmetry, and do just 1 corner)

Code:
10 DEF FNA(A,B,C)=C-(C-B)^2/(C-B-(B-A))
20 INPUT "N,M ? ";N,M
30 N3=1/N @ N1=N3/2 @ N2=.5 @ IF MOD(N,2) THEN N2=1
40 M3=1/M @ M1=M3/2 @ M2=1.5-N2 @ IF MOD(M*N,2) THEN M2=1
50 T=TIME @ S=0
60 FOR X1=N1 TO 1 STEP N3 @ FOR X2=M1 TO 1 STEP M3 @ X=1+X2-X1
70 FOR Y1=N1 TO N2 STEP N3 @ FOR Y2=M1 TO M2 STEP M3 @ Y=Y2-Y1
80 FOR Z1=N1 TO N2 STEP N3 @ FOR Z2=M1 TO M2 STEP M3 @ Z=Z2-Z1
90 S=S+X/(X*X+Y*Y+Z*Z)^1.5
100 NEXT Z2 @ NEXT Z1 @ NEXT Y2 @ NEXT Y1 @ NEXT X2 @ NEXT X1
110 DISP S/(M*N)^3/(N2*M2)^2,TIME-T @ GOTO 20

>RUN
N,M ? 2,2
 .942585572032      .11
N,M ? 4,4
 .929717192068      5.66

>FNA(1, .942585572032, .929717192068)
 .925999798263

We get F required 3 digits accuracy, wth 2^6/4 + 4^6/4 = 16 + 1024 = 1040 points.

With N=M, F is over-estimated (unrealistically many points with cos(θ) = 1)
Extrapolated result removed (most of) this built-in bias.

Because we are doing F(1,1), F(2,2), F(4,4), we can also do Richardson Extrapolation.
Again, we get F required 3 digits accuracy (third column)

1
.942585572032      .923447429376
.929717192068      .925427732080      .925559752260
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [VA] SRC #011 - April 1st, 2022 Bizarro Special - Albert Chan - 04-10-2022 04:29 PM



User(s) browsing this thread: 1 Guest(s)