01 May 2022 03:34:30 PM hypersphere_test(): C version Test hypersphere(). TEST01 Test the coordinate conversion routines: CARTESIAN_TO_HYPERSPHERE: X -> R,Theta HYPERSPHERE_TO_CARTESIAN: R,Theta -> X. Pick a random X, and compute X2 by converting X to hypersphere and back. Consider norm of difference. M || X - X2 || 1 0 1 0 1 0 1 0 1 6.93889e-18 2 5.92859e-17 2 1.69136e-17 2 2.81004e-16 2 5.82167e-17 2 6.7318e-16 3 0 3 0 3 6.20634e-17 3 1.24127e-16 3 1.57009e-16 4 1.77722e-16 4 1.04083e-17 4 1.57009e-16 4 1.80445e-16 4 1.57009e-16 5 1.24127e-16 5 4.55225e-16 5 2.66945e-16 5 1.27381e-16 5 6.20634e-17 TEST02 HYPERSPHERE_01_SURFACE_UNIFORM samples uniformly from the surface of the unit hypersphere Random hypersphere point: 1 Random hypersphere point: -1 Random hypersphere point: 1 Random hypersphere point: 0.770686 0.637215 Random hypersphere point: -0.666173 -0.745798 Random hypersphere point: -0.950157 0.311771 Random hypersphere point: 0.0262807 -0.894727 0.44584 Random hypersphere point: -0.1243 0.169395 0.977678 Random hypersphere point: 0.14063 -0.21901 0.965535 Random hypersphere point: 0.527168 -0.323123 -0.46844 0.63107 Random hypersphere point: -0.0632185 0.585015 -0.748625 -0.305485 Random hypersphere point: -0.753564 0.225138 -0.504373 -0.356457 Random hypersphere point: 0.0552638 -0.764025 0.225495 0.523923 -0.296426 Random hypersphere point: -0.300054 0.355691 -0.184445 -0.812472 -0.298865 Random hypersphere point: 0.113546 -0.224028 -0.233026 -0.926416 0.156113 TEST03: HYPERSPHERE_01_AREA evaluates the area of the unit hypersphere in M dimensions. M Exact Computed Area Area 1 2.0000 2.0000 2 6.2832 6.2832 3 12.5664 12.5664 4 19.7392 19.7392 5 26.3189 26.3189 6 31.0063 31.0063 7 33.0734 33.0734 8 32.4697 32.4697 9 29.6866 29.6866 10 25.5016 25.5016 11 20.7251 20.7251 12 16.0232 16.0232 13 11.8382 11.8382 14 8.3897 8.3897 15 5.7216 5.7216 16 3.7653 3.7653 17 2.3967 2.3967 18 1.4786 1.4786 19 0.8858 0.8858 20 0.5161 0.5161 TEST04: HYPERSPHERE_01_VOLUME evaluates the area of the unit hypersphere in M dimensions. HYPERSPHERE_01_VOLUME_VALUES returns some test values. M Exact Computed Volume Volume 1 2.0000 2.0000 2 3.1416 3.1416 3 4.1888 4.1888 4 4.9348 4.9348 5 5.2638 5.2638 6 5.1677 5.1677 7 4.7248 4.7248 8 4.0587 4.0587 9 3.2985 3.2985 10 2.5502 2.5502 11 1.8841 1.8841 12 1.3353 1.3353 13 0.9106 0.9106 14 0.5993 0.5993 15 0.3814 0.3814 16 0.2353 0.2353 17 0.1410 0.1410 18 0.0821 0.0821 19 0.0466 0.0466 20 0.0258 0.0258 TEST05 For a hypersphere in M dimensions: HYPERSPHERE_AREA computes the area HYPERSPHERE_VOLUME computes the volume. Notice that both quantities eventually decrease We use a radius of R = 1.5 M Area Volume Area / Volume 1 2 3 0.666667 2 9.42478 7.06858 1.33333 3 28.2743 14.1372 2 4 66.6198 24.9824 2.66667 5 133.24 39.9719 3.33333 6 235.454 58.8635 4 7 376.726 80.7271 4.66667 8 554.775 104.02 5.33333 9 760.835 126.806 6 10 980.369 147.055 6.66667 11 1195.12 162.97 7.33333 12 1385.96 173.245 8 13 1535.96 177.226 8.66667 14 1632.8 174.943 9.33333 15 1670.32 167.032 10 16 1648.8 154.575 10.6667 17 1574.24 138.903 11.3333 18 1456.83 121.403 12 19 1309.13 103.353 12.6667 20 1144.19 85.8145 13.3333 TEST06 Test the stereographic mapping: HYPERSPHERE_STEREOGRAPH maps hypersphere points to the plane. HYPERSPHERE_STEREOGRAPH_INVERSE inverts the mapping. Pick a random X1 on the hypersphere. Map it to a point X2 on the plane. Map it back to a point X3 on the hypersphere. Consider norm of difference. M || X1 - X3 || 2 5.55112e-17 2 1.11022e-16 2 1.11022e-16 2 0 2 0 3 7.97973e-17 3 1.24127e-16 3 2.96348e-16 3 1.57009e-16 3 1.67111e-16 4 1.35974e-16 4 1.11022e-16 4 2.00148e-16 4 1.38778e-16 4 2.02064e-16 5 1.01032e-16 5 5.55112e-17 5 2.0015e-16 5 1.38778e-17 5 7.47342e-17 hypersphere_test(): Normal end of execution. 01 May 2022 03:34:30 PM