-
Notifications
You must be signed in to change notification settings - Fork 0
/
documentation.txt
274 lines (246 loc) · 6.65 KB
/
documentation.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
C++ Numerical Analysis methods
This directory contains numerical methods introduced on the course MS-C1650. They are also tested and errors
are computed. Each file also contains more documentation for it's functions.
The layout of the directory:
main.cpp - this file is used to choose test parameters and to run tests using error functions
/src/ - folder containing all other necessary files
/src/functions.h - header file containing the definitions of all numerical method functions, which are:
/src/arctanx.cpp - contains a function that returns the value of pi it uses, and another function
which is an approximation for arctanx
/src/lagrange.cpp - contains all the necessary functions to construct and compute the barycentric
form of Lagrange interpolation
/src/quadhermite.cpp - contains a function which gives the coefficients for quadratic Hermite interpolation
and a function that contructs the Bernstein polynomials and the final interpolation polynomial
/src/montecarlo.cpp - contains a function which returns the Monte Carlo approximation of the ratio between
a unit ball's volume and a unit cube's volume
/src/heun.cpp - contains a function that forms the time vector based on the endpoints and n, also contains
a function implementing Heun's method on a given derivative function and initial value
/src/fd.ccp - contains 3 functions to present a differential equation for Euler or Heun's method, one returns the
errorless initial value, one returns the derivative and one returns the analytical solution which is used
for testing error
/src/errors.h - header file containing functions for computing the errors of the methods
/src/errors.cpp - contains error functions for each method
Results when we compile and run main.cpp:
Current n:
100
Arctan approximation
Maximum error:
1.0724754417879012e-13
Average error:
1.9623088907369881e-14
Lagrange interpolation
Uniform points maximum error:
0.91637614345709117
Uniform points average error:
0.22539394618326777
Chebyshev points maximum error:
0.049074945034855127
Chebyshev points average error:
0.0036542888138823811
Quadratic hermite interpolation
Maximum error:
1.4426137599999997
Average error:
0.53300329999999974
Monte Carlo ellipsoid volume and pi approximations
Ellipsoid volume error:
2.0927412287183458
Pi approximation:
2.8799999999999999
Pi error:
0.26159265358979322
Heun method
Maximum error without epsilon:
902004186469.62683
Average error without epsilon:
32746026571.491405
Maximum error with epsilon:
1578507326321.8528
Average error with epsilon:
57305546500.119659
Current n:
1000
Arctan approximation
Maximum error:
1.113553693699032e-13
Average error:
2.0025802259453281e-14
Lagrange interpolation
Uniform points maximum error:
0.91637614345709117
Uniform points average error:
0.22881384307716579
Chebyshev points maximum error:
0.07369186718562741
Chebyshev points average error:
0.0041068702594774424
Quadratic hermite interpolation
Maximum error:
1.4427190684159998
Average error:
0.53330003330000064
Monte Carlo ellipsoid volume and pi approximations
Ellipsoid volume error:
0.31674122871834243
Pi approximation:
3.1020000000000003
Pi error:
0.039592653589792803
Heun method
Maximum error without epsilon:
0.0078431372549020439
Average error without epsilon:
0.007720230557600803
Maximum error with epsilon:
0.0080342124163044204
Average error with epsilon:
0.0078052166967429344
Current n:
10000
Arctan approximation
Maximum error:
1.1191048088221578e-13
Average error:
2.0024622145566982e-14
Lagrange interpolation
Uniform points maximum error:
0.91637690681624062
Uniform points average error:
0.22905232102373224
Chebyshev points maximum error:
0.07369186718562741
Chebyshev points average error:
0.0041277778675474852
Quadratic hermite interpolation
Maximum error:
1.4427190929851037
Average error:
0.53333000033330047
Monte Carlo ellipsoid volume and pi approximations
Ellipsoid volume error:
0.26885877128165703
Pi approximation:
3.1752000000000002
Pi error:
0.033607346410207128
Heun method
Maximum error without epsilon:
0.0067681895093040234
Average error without epsilon:
0.0066765818915974903
Maximum error with epsilon:
0.0070402362712806421
Average error with epsilon:
0.0067447709462161122
Current n:
100000
Arctan approximation
Maximum error:
1.1202150318467829e-13
Average error:
2.0028118898267379e-14
Lagrange interpolation
Uniform points maximum error:
0.91637748274810038
Uniform points average error:
0.22907365055175838
Chebyshev points maximum error:
0.073692597711760482
Chebyshev points average error:
0.0041287410830122932
Quadratic hermite interpolation
Maximum error:
1.4427190999636381
Average error:
0.53333300000333395
Monte Carlo ellipsoid volume and pi approximations
Ellipsoid volume error:
0.0085812287183451019
Pi approximation:
3.14052
Pi error:
0.0010726535897931377
Heun method
Maximum error without epsilon:
0.0066766816892092351
Average error without epsilon:
0.0065875264239913384
Maximum error with epsilon:
0.0069539100778021612
Average error with epsilon:
0.0066543427104462233
Current n:
1000000
Arctan approximation
Maximum error:
1.1202150318467829e-13
Average error:
2.0028474744719844e-14
Lagrange interpolation
Uniform points maximum error:
0.91637748274810038
Uniform points average error:
0.229075731674798
Chebyshev points maximum error:
0.073692616116414561
Chebyshev points average error:
0.0041287959688119423
Quadratic hermite interpolation
Maximum error:
1.4427190999915842
Average error:
0.53333330000004031
Monte Carlo ellipsoid volume and pi approximations
Ellipsoid volume error:
0.0015252287183429303
Pi approximation:
3.1414020000000002
Pi error:
0.00019065358979286628
Heun method
Maximum error without epsilon:
0.0066676668168876851
Average error without epsilon:
0.0065787513439494096
Maximum error with epsilon:
0.0069453898871407183
Average error with epsilon:
0.0066454329468075618
Current n:
10000000
Arctan approximation
Maximum error:
1.1213252548714081e-13
Average error:
2.0028466872594722e-14
Lagrange interpolation
Uniform points maximum error:
0.91637748280117393
Uniform points average error:
0.22907593842693316
Chebyshev points maximum error:
0.073692616214829504
Chebyshev points average error:
0.0041288002520976485
Quadratic hermite interpolation
Maximum error:
1.4427190999915842
Average error:
0.53333332999993954
Monte Carlo ellipsoid volume and pi approximations
Ellipsoid volume error:
0.0030468287183431642
Pi approximation:
3.1412118000000002
Pi error:
0.00038085358979289552
Heun method
Maximum error without epsilon:
0.0066667666685036042
Average error without epsilon:
0.0065778751184278408
Maximum error with epsilon:
0.0069445389774690502
Average error with epsilon:
0.0066445432785103833
These results seem good. The errors decrease when n increases and cap at their theoretical limits.