silicium 0.0.14 → 0.0.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +4 -0
  3. data/.gitignore +13 -11
  4. data/.rakeTasks +8 -0
  5. data/.travis.yml +17 -3
  6. data/CODE_OF_CONDUCT.md +74 -74
  7. data/Gemfile +8 -4
  8. data/LICENSE.txt +21 -21
  9. data/Makefile +269 -0
  10. data/README.md +588 -44
  11. data/Rakefile +17 -10
  12. data/bin/console +14 -14
  13. data/bin/setup +8 -8
  14. data/docs/Object.html +117 -0
  15. data/docs/README_md.html +142 -0
  16. data/docs/Silicium/Combinatorics.html +270 -0
  17. data/docs/Silicium/Dice/Polyhedron.html +315 -0
  18. data/docs/Silicium/Dice/PolyhedronSet.html +321 -0
  19. data/docs/Silicium/Dice.html +99 -0
  20. data/docs/Silicium/Error.html +106 -0
  21. data/docs/Silicium/Geometry/Line2dCanon.html +243 -0
  22. data/docs/Silicium/Geometry/VariablesOrderException.html +106 -0
  23. data/docs/Silicium/Geometry.html +940 -0
  24. data/docs/Silicium/GraphVisualizer.html +226 -0
  25. data/docs/Silicium/Graphs/GraphError.html +106 -0
  26. data/docs/Silicium/Graphs/OrientedGraph.html +901 -0
  27. data/docs/Silicium/Graphs/UnorientedGraph.html +237 -0
  28. data/docs/Silicium/Graphs.html +374 -0
  29. data/docs/Silicium/IntegralDoesntExistError.html +106 -0
  30. data/docs/Silicium/NumericalIntegration.html +521 -0
  31. data/docs/Silicium/Optimization.html +629 -0
  32. data/docs/Silicium/Plotter/Image.html +297 -0
  33. data/docs/Silicium/Plotter.html +186 -0
  34. data/docs/Silicium.html +101 -0
  35. data/docs/created.rid +9 -0
  36. data/docs/css/fonts.css +167 -0
  37. data/docs/css/rdoc.css +619 -0
  38. data/docs/fonts/Lato-Light.ttf +0 -0
  39. data/docs/fonts/Lato-LightItalic.ttf +0 -0
  40. data/docs/fonts/Lato-Regular.ttf +0 -0
  41. data/docs/fonts/Lato-RegularItalic.ttf +0 -0
  42. data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
  43. data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
  44. data/docs/images/add.png +0 -0
  45. data/docs/images/arrow_up.png +0 -0
  46. data/docs/images/brick.png +0 -0
  47. data/docs/images/brick_link.png +0 -0
  48. data/docs/images/bug.png +0 -0
  49. data/docs/images/bullet_black.png +0 -0
  50. data/docs/images/bullet_toggle_minus.png +0 -0
  51. data/docs/images/bullet_toggle_plus.png +0 -0
  52. data/docs/images/date.png +0 -0
  53. data/docs/images/delete.png +0 -0
  54. data/docs/images/find.png +0 -0
  55. data/docs/images/loadingAnimation.gif +0 -0
  56. data/docs/images/macFFBgHack.png +0 -0
  57. data/docs/images/package.png +0 -0
  58. data/docs/images/page_green.png +0 -0
  59. data/docs/images/page_white_text.png +0 -0
  60. data/docs/images/page_white_width.png +0 -0
  61. data/docs/images/plugin.png +0 -0
  62. data/docs/images/ruby.png +0 -0
  63. data/docs/images/tag_blue.png +0 -0
  64. data/docs/images/tag_green.png +0 -0
  65. data/docs/images/transparent.png +0 -0
  66. data/docs/images/wrench.png +0 -0
  67. data/docs/images/wrench_orange.png +0 -0
  68. data/docs/images/zoom.png +0 -0
  69. data/docs/index.html +134 -0
  70. data/docs/js/darkfish.js +84 -0
  71. data/docs/js/navigation.js +105 -0
  72. data/docs/js/navigation.js.gz +0 -0
  73. data/docs/js/search.js +110 -0
  74. data/docs/js/search_index.js +1 -0
  75. data/docs/js/search_index.js.gz +0 -0
  76. data/docs/js/searcher.js +229 -0
  77. data/docs/js/searcher.js.gz +0 -0
  78. data/docs/table_of_contents.html +697 -0
  79. data/lib/algebra.rb +452 -0
  80. data/lib/algebra_diff.rb +258 -0
  81. data/lib/geometry/figure.rb +62 -0
  82. data/lib/geometry.rb +290 -0
  83. data/lib/geometry3d.rb +270 -0
  84. data/lib/graph/dfs.rb +41 -0
  85. data/lib/graph/kruskal.rb +36 -0
  86. data/lib/graph/scc.rb +97 -0
  87. data/lib/graph.rb +350 -0
  88. data/lib/graph_visualizer.rb +286 -0
  89. data/lib/ml_algorithms.rb +181 -0
  90. data/lib/numerical_integration.rb +184 -0
  91. data/lib/optimization.rb +208 -0
  92. data/lib/plotter.rb +258 -0
  93. data/lib/polynomial_division.rb +132 -0
  94. data/lib/polynomial_interpolation.rb +94 -0
  95. data/lib/regression.rb +120 -0
  96. data/lib/silicium/adding.rb +37 -0
  97. data/lib/silicium/conversions.rb +23 -0
  98. data/lib/silicium/multi.rb +82 -0
  99. data/lib/silicium/sparse.rb +76 -0
  100. data/lib/silicium/sugar.rb +37 -0
  101. data/lib/silicium/trans.rb +26 -0
  102. data/lib/silicium/version.rb +3 -3
  103. data/lib/silicium.rb +29 -6
  104. data/lib/theory_of_probability.rb +240 -0
  105. data/lib/topological_sort.rb +50 -0
  106. data/oriented_graph.png +0 -0
  107. data/plot.png +0 -0
  108. data/silicium.gemspec +4 -3
  109. metadata +122 -12
@@ -0,0 +1,106 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>class Silicium::IntegralDoesntExistError - RDoc Documentation</title>
8
+
9
+ <script type="text/javascript">
10
+ var rdoc_rel_prefix = "../";
11
+ var index_rel_prefix = "../";
12
+ </script>
13
+
14
+ <script src="../js/navigation.js" defer></script>
15
+ <script src="../js/search.js" defer></script>
16
+ <script src="../js/search_index.js" defer></script>
17
+ <script src="../js/searcher.js" defer></script>
18
+ <script src="../js/darkfish.js" defer></script>
19
+
20
+ <link href="../css/fonts.css" rel="stylesheet">
21
+ <link href="../css/rdoc.css" rel="stylesheet">
22
+
23
+
24
+
25
+
26
+ <body id="top" role="document" class="class">
27
+ <nav role="navigation">
28
+ <div id="project-navigation">
29
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
30
+ <h2>
31
+ <a href="../index.html" rel="home">Home</a>
32
+ </h2>
33
+
34
+ <div id="table-of-contents-navigation">
35
+ <a href="../table_of_contents.html#pages">Pages</a>
36
+ <a href="../table_of_contents.html#classes">Classes</a>
37
+ <a href="../table_of_contents.html#methods">Methods</a>
38
+ </div>
39
+ </div>
40
+
41
+ <div id="search-section" role="search" class="project-section initially-hidden">
42
+ <form action="#" method="get" accept-charset="utf-8">
43
+ <div id="search-field-wrapper">
44
+ <input id="search-field" role="combobox" aria-label="Search"
45
+ aria-autocomplete="list" aria-controls="search-results"
46
+ type="text" name="search" placeholder="Search" spellcheck="false"
47
+ title="Type to search, Up and Down to navigate, Enter to load">
48
+ </div>
49
+
50
+ <ul id="search-results" aria-label="Search Results"
51
+ aria-busy="false" aria-expanded="false"
52
+ aria-atomic="false" class="initially-hidden"></ul>
53
+ </form>
54
+ </div>
55
+
56
+ </div>
57
+
58
+
59
+
60
+ <div id="class-metadata">
61
+
62
+ <div id="parent-class-section" class="nav-section">
63
+ <h3>Parent</h3>
64
+
65
+
66
+ <p class="link">RuntimeError
67
+
68
+ </div>
69
+
70
+
71
+
72
+
73
+ </div>
74
+ </nav>
75
+
76
+ <main role="main" aria-labelledby="class-Silicium::IntegralDoesntExistError">
77
+ <h1 id="class-Silicium::IntegralDoesntExistError" class="class">
78
+ class Silicium::IntegralDoesntExistError
79
+ </h1>
80
+
81
+ <section class="description">
82
+
83
+ </section>
84
+
85
+
86
+ <section id="5Buntitled-5D" class="documentation-section">
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+ </section>
97
+
98
+ </main>
99
+
100
+
101
+ <footer id="validator-badges" role="contentinfo">
102
+ <p><a href="https://validator.w3.org/check/referer">Validate</a>
103
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.0.
104
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
105
+ </footer>
106
+
@@ -0,0 +1,521 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>class Silicium::NumericalIntegration - RDoc Documentation</title>
8
+
9
+ <script type="text/javascript">
10
+ var rdoc_rel_prefix = "../";
11
+ var index_rel_prefix = "../";
12
+ </script>
13
+
14
+ <script src="../js/navigation.js" defer></script>
15
+ <script src="../js/search.js" defer></script>
16
+ <script src="../js/search_index.js" defer></script>
17
+ <script src="../js/searcher.js" defer></script>
18
+ <script src="../js/darkfish.js" defer></script>
19
+
20
+ <link href="../css/fonts.css" rel="stylesheet">
21
+ <link href="../css/rdoc.css" rel="stylesheet">
22
+
23
+
24
+
25
+
26
+ <body id="top" role="document" class="class">
27
+ <nav role="navigation">
28
+ <div id="project-navigation">
29
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
30
+ <h2>
31
+ <a href="../index.html" rel="home">Home</a>
32
+ </h2>
33
+
34
+ <div id="table-of-contents-navigation">
35
+ <a href="../table_of_contents.html#pages">Pages</a>
36
+ <a href="../table_of_contents.html#classes">Classes</a>
37
+ <a href="../table_of_contents.html#methods">Methods</a>
38
+ </div>
39
+ </div>
40
+
41
+ <div id="search-section" role="search" class="project-section initially-hidden">
42
+ <form action="#" method="get" accept-charset="utf-8">
43
+ <div id="search-field-wrapper">
44
+ <input id="search-field" role="combobox" aria-label="Search"
45
+ aria-autocomplete="list" aria-controls="search-results"
46
+ type="text" name="search" placeholder="Search" spellcheck="false"
47
+ title="Type to search, Up and Down to navigate, Enter to load">
48
+ </div>
49
+
50
+ <ul id="search-results" aria-label="Search Results"
51
+ aria-busy="false" aria-expanded="false"
52
+ aria-atomic="false" class="initially-hidden"></ul>
53
+ </form>
54
+ </div>
55
+
56
+ </div>
57
+
58
+
59
+
60
+ <div id="class-metadata">
61
+
62
+ <div id="parent-class-section" class="nav-section">
63
+ <h3>Parent</h3>
64
+
65
+
66
+ <p class="link"><a href="../Object.html">Object</a>
67
+
68
+ </div>
69
+
70
+
71
+
72
+ <!-- Method Quickref -->
73
+ <div id="method-list-section" class="nav-section">
74
+ <h3>Methods</h3>
75
+
76
+ <ul class="link-list" role="directory">
77
+
78
+ <li ><a href="#method-c-left_rect_integration">::left_rect_integration</a>
79
+
80
+ <li ><a href="#method-c-left_rect_integration_n">::left_rect_integration_n</a>
81
+
82
+ <li ><a href="#method-c-middle_rectangles">::middle_rectangles</a>
83
+
84
+ <li ><a href="#method-c-middle_rectangles_with_a_segment">::middle_rectangles_with_a_segment</a>
85
+
86
+ <li ><a href="#method-c-simpson_integration">::simpson_integration</a>
87
+
88
+ <li ><a href="#method-c-simpson_integration_with_a_segment">::simpson_integration_with_a_segment</a>
89
+
90
+ <li ><a href="#method-c-three_eights_integration">::three_eights_integration</a>
91
+
92
+ <li ><a href="#method-c-three_eights_integration_n">::three_eights_integration_n</a>
93
+
94
+ <li ><a href="#method-c-trapezoid">::trapezoid</a>
95
+
96
+ <li ><a href="#method-c-trapezoid_with_a_segment">::trapezoid_with_a_segment</a>
97
+
98
+ </ul>
99
+ </div>
100
+
101
+ </div>
102
+ </nav>
103
+
104
+ <main role="main" aria-labelledby="class-Silicium::NumericalIntegration">
105
+ <h1 id="class-Silicium::NumericalIntegration" class="class">
106
+ class Silicium::NumericalIntegration
107
+ </h1>
108
+
109
+ <section class="description">
110
+
111
+ <p>A class providing numerical integration methods</p>
112
+
113
+ </section>
114
+
115
+
116
+ <section id="5Buntitled-5D" class="documentation-section">
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+ <section id="public-class-5Buntitled-5D-method-details" class="method-section">
127
+ <header>
128
+ <h3>Public Class Methods</h3>
129
+ </header>
130
+
131
+
132
+ <div id="method-c-left_rect_integration" class="method-detail ">
133
+
134
+ <div class="method-heading">
135
+ <span class="method-name">left_rect_integration</span><span
136
+ class="method-args">(left_p, right_p, eps = 0.0001, &amp;block)</span>
137
+
138
+ <span class="method-click-advice">click to toggle source</span>
139
+
140
+ </div>
141
+
142
+
143
+ <div class="method-description">
144
+
145
+ <p>Left Rectangle Method and Right Rectangle Method</p>
146
+
147
+
148
+
149
+
150
+ <div class="method-source-code" id="left_rect_integration-source">
151
+ <pre><span class="ruby-comment"># File lib/numerical_integration.rb, line 48</span>
152
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">left_rect_integration</span>(<span class="ruby-identifier">left_p</span>, <span class="ruby-identifier">right_p</span>, <span class="ruby-identifier">eps</span> = <span class="ruby-value">0.0001</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
153
+ <span class="ruby-identifier">splits</span> = <span class="ruby-value">1</span>
154
+ <span class="ruby-identifier">res1</span> = <span class="ruby-identifier">left_rect_integration_n</span>(<span class="ruby-identifier">left_p</span>, <span class="ruby-identifier">right_p</span>, <span class="ruby-value">1</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
155
+ <span class="ruby-identifier">res2</span> = <span class="ruby-identifier">left_rect_integration_n</span>(<span class="ruby-identifier">left_p</span>, <span class="ruby-identifier">right_p</span>, <span class="ruby-value">5</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
156
+ <span class="ruby-keyword">while</span> (<span class="ruby-identifier">res1</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">res2</span>).<span class="ruby-identifier">abs</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">eps</span>
157
+ <span class="ruby-identifier">res1</span> = <span class="ruby-identifier">left_rect_integration_n</span>(<span class="ruby-identifier">left_p</span>, <span class="ruby-identifier">right_p</span>, <span class="ruby-identifier">splits</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
158
+ <span class="ruby-identifier">splits</span> <span class="ruby-operator">*=</span> <span class="ruby-value">5</span>
159
+ <span class="ruby-identifier">res2</span> = <span class="ruby-identifier">left_rect_integration_n</span>(<span class="ruby-identifier">left_p</span>, <span class="ruby-identifier">right_p</span>, <span class="ruby-identifier">splits</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
160
+ <span class="ruby-keyword">end</span>
161
+ (<span class="ruby-identifier">res1</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">res2</span>) <span class="ruby-operator">/</span> <span class="ruby-value">2.0</span>
162
+ <span class="ruby-keyword">end</span></pre>
163
+ </div>
164
+
165
+ </div>
166
+
167
+
168
+
169
+
170
+ </div>
171
+
172
+
173
+ <div id="method-c-left_rect_integration_n" class="method-detail ">
174
+
175
+ <div class="method-heading">
176
+ <span class="method-name">left_rect_integration_n</span><span
177
+ class="method-args">(left_p, right_p, splits, &amp;block)</span>
178
+
179
+ <span class="method-click-advice">click to toggle source</span>
180
+
181
+ </div>
182
+
183
+
184
+ <div class="method-description">
185
+
186
+ <p>Left Rectangle Auxiliary Method and Right Rectangle Auxiliary Method</p>
187
+
188
+
189
+
190
+
191
+ <div class="method-source-code" id="left_rect_integration_n-source">
192
+ <pre><span class="ruby-comment"># File lib/numerical_integration.rb, line 61</span>
193
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">left_rect_integration_n</span>(<span class="ruby-identifier">left_p</span>, <span class="ruby-identifier">right_p</span>, <span class="ruby-identifier">splits</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
194
+ <span class="ruby-identifier">dx</span> = (<span class="ruby-identifier">right_p</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">left_p</span>) <span class="ruby-operator">/</span> <span class="ruby-identifier">splits</span>.<span class="ruby-identifier">to_f</span>
195
+ <span class="ruby-identifier">result</span> = <span class="ruby-value">0</span>
196
+ <span class="ruby-identifier">i</span> = <span class="ruby-value">0</span>
197
+ <span class="ruby-keyword">while</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">splits</span>
198
+ <span class="ruby-identifier">result</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">left_p</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">dx</span>)
199
+ <span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
200
+ <span class="ruby-keyword">end</span>
201
+ <span class="ruby-identifier">result</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">dx</span>
202
+ <span class="ruby-keyword">end</span></pre>
203
+ </div>
204
+
205
+ </div>
206
+
207
+
208
+
209
+
210
+ </div>
211
+
212
+
213
+ <div id="method-c-middle_rectangles" class="method-detail ">
214
+
215
+ <div class="method-heading">
216
+ <span class="method-name">middle_rectangles</span><span
217
+ class="method-args">(a, b, eps = 0.0001, &amp;block)</span>
218
+
219
+ <span class="method-click-advice">click to toggle source</span>
220
+
221
+ </div>
222
+
223
+
224
+ <div class="method-description">
225
+
226
+ <p>Middle Rectangles Method with specified accuracy</p>
227
+
228
+
229
+
230
+
231
+ <div class="method-source-code" id="middle_rectangles-source">
232
+ <pre><span class="ruby-comment"># File lib/numerical_integration.rb, line 86</span>
233
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">middle_rectangles</span>(<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>, <span class="ruby-identifier">eps</span> = <span class="ruby-value">0.0001</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
234
+ <span class="ruby-identifier">wrapper_method</span>([<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>], <span class="ruby-identifier">eps</span>, <span class="ruby-value">:middle_rectangles_with_a_segment</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
235
+ <span class="ruby-keyword">end</span></pre>
236
+ </div>
237
+
238
+ </div>
239
+
240
+
241
+
242
+
243
+ </div>
244
+
245
+
246
+ <div id="method-c-middle_rectangles_with_a_segment" class="method-detail ">
247
+
248
+ <div class="method-heading">
249
+ <span class="method-name">middle_rectangles_with_a_segment</span><span
250
+ class="method-args">(a, b, n, &amp;block)</span>
251
+
252
+ <span class="method-click-advice">click to toggle source</span>
253
+
254
+ </div>
255
+
256
+
257
+ <div class="method-description">
258
+
259
+ <p>Middle Rectangles Method with a segment</p>
260
+
261
+
262
+
263
+
264
+ <div class="method-source-code" id="middle_rectangles_with_a_segment-source">
265
+ <pre><span class="ruby-comment"># File lib/numerical_integration.rb, line 74</span>
266
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">middle_rectangles_with_a_segment</span>(<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>, <span class="ruby-identifier">n</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
267
+ <span class="ruby-identifier">dx</span> = (<span class="ruby-identifier">b</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">a</span>) <span class="ruby-operator">/</span> <span class="ruby-identifier">n</span>.<span class="ruby-identifier">to_f</span>
268
+ <span class="ruby-identifier">result</span> = <span class="ruby-value">0</span>
269
+ <span class="ruby-identifier">i</span> = <span class="ruby-value">0</span>
270
+ <span class="ruby-identifier">n</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span>
271
+ <span class="ruby-identifier">result</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">a</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">dx</span> <span class="ruby-operator">*</span> (<span class="ruby-identifier">i</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span> <span class="ruby-operator">/</span> <span class="ruby-value">2</span>)) <span class="ruby-operator">*</span> <span class="ruby-identifier">dx</span>
272
+ <span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
273
+ <span class="ruby-keyword">end</span>
274
+ <span class="ruby-identifier">result</span>
275
+ <span class="ruby-keyword">end</span></pre>
276
+ </div>
277
+
278
+ </div>
279
+
280
+
281
+
282
+
283
+ </div>
284
+
285
+
286
+ <div id="method-c-simpson_integration" class="method-detail ">
287
+
288
+ <div class="method-heading">
289
+ <span class="method-name">simpson_integration</span><span
290
+ class="method-args">(a, b, eps = 0.0001, &amp;block)</span>
291
+
292
+ <span class="method-click-advice">click to toggle source</span>
293
+
294
+ </div>
295
+
296
+
297
+ <div class="method-description">
298
+
299
+ <p>Simpson integration with specified accuracy</p>
300
+
301
+
302
+
303
+
304
+ <div class="method-source-code" id="simpson_integration-source">
305
+ <pre><span class="ruby-comment"># File lib/numerical_integration.rb, line 43</span>
306
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">simpson_integration</span>(<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>, <span class="ruby-identifier">eps</span> = <span class="ruby-value">0.0001</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
307
+ <span class="ruby-identifier">wrapper_method</span>([<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>], <span class="ruby-identifier">eps</span>, <span class="ruby-value">:simpson_integration_with_a_segment</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
308
+ <span class="ruby-keyword">end</span></pre>
309
+ </div>
310
+
311
+ </div>
312
+
313
+
314
+
315
+
316
+ </div>
317
+
318
+
319
+ <div id="method-c-simpson_integration_with_a_segment" class="method-detail ">
320
+
321
+ <div class="method-heading">
322
+ <span class="method-name">simpson_integration_with_a_segment</span><span
323
+ class="method-args">(a, b, n, &amp;block)</span>
324
+
325
+ <span class="method-click-advice">click to toggle source</span>
326
+
327
+ </div>
328
+
329
+
330
+ <div class="method-description">
331
+
332
+ <p>Simpson integration with a segment</p>
333
+
334
+
335
+
336
+
337
+ <div class="method-source-code" id="simpson_integration_with_a_segment-source">
338
+ <pre><span class="ruby-comment"># File lib/numerical_integration.rb, line 30</span>
339
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">simpson_integration_with_a_segment</span>(<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>, <span class="ruby-identifier">n</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
340
+ <span class="ruby-identifier">dx</span> = (<span class="ruby-identifier">b</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">a</span>) <span class="ruby-operator">/</span> <span class="ruby-identifier">n</span>.<span class="ruby-identifier">to_f</span>
341
+ <span class="ruby-identifier">result</span> = <span class="ruby-value">0</span>
342
+ <span class="ruby-identifier">i</span> = <span class="ruby-value">0</span>
343
+ <span class="ruby-keyword">while</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">n</span>
344
+ <span class="ruby-identifier">result</span> <span class="ruby-operator">+=</span> (<span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">a</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">dx</span>) <span class="ruby-operator">+</span> <span class="ruby-value">4</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>(((<span class="ruby-identifier">a</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">dx</span>) <span class="ruby-operator">+</span>
345
+ (<span class="ruby-identifier">a</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">i</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">dx</span>)) <span class="ruby-operator">/</span> <span class="ruby-value">2.0</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">a</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">i</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">dx</span>)) <span class="ruby-operator">/</span> <span class="ruby-value">6.0</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">dx</span>
346
+ <span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
347
+ <span class="ruby-keyword">end</span>
348
+ <span class="ruby-identifier">result</span>
349
+ <span class="ruby-keyword">end</span></pre>
350
+ </div>
351
+
352
+ </div>
353
+
354
+
355
+
356
+
357
+ </div>
358
+
359
+
360
+ <div id="method-c-three_eights_integration" class="method-detail ">
361
+
362
+ <div class="method-heading">
363
+ <span class="method-name">three_eights_integration</span><span
364
+ class="method-args">(a, b, eps = 0.0001, &amp;block)</span>
365
+
366
+ <span class="method-click-advice">click to toggle source</span>
367
+
368
+ </div>
369
+
370
+
371
+ <div class="method-description">
372
+
373
+ <p>Computes integral from <code>a</code> to <code>b</code> of <code>block</code> with accuracy <code>eps</code></p>
374
+
375
+
376
+
377
+
378
+ <div class="method-source-code" id="three_eights_integration-source">
379
+ <pre><span class="ruby-comment"># File lib/numerical_integration.rb, line 10</span>
380
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">three_eights_integration</span>(<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>, <span class="ruby-identifier">eps</span> = <span class="ruby-value">0.0001</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
381
+ <span class="ruby-identifier">wrapper_method</span>([<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>], <span class="ruby-identifier">eps</span>, <span class="ruby-value">:three_eights_integration_n</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
382
+ <span class="ruby-keyword">end</span></pre>
383
+ </div>
384
+
385
+ </div>
386
+
387
+
388
+
389
+
390
+ </div>
391
+
392
+
393
+ <div id="method-c-three_eights_integration_n" class="method-detail ">
394
+
395
+ <div class="method-heading">
396
+ <span class="method-name">three_eights_integration_n</span><span
397
+ class="method-args">(a, b, n, &amp;block)</span>
398
+
399
+ <span class="method-click-advice">click to toggle source</span>
400
+
401
+ </div>
402
+
403
+
404
+ <div class="method-description">
405
+
406
+ <p>Computes integral from <code>a</code> to <code>b</code> of <code>block</code> with <code>n</code> segmentations</p>
407
+
408
+
409
+
410
+
411
+ <div class="method-source-code" id="three_eights_integration_n-source">
412
+ <pre><span class="ruby-comment"># File lib/numerical_integration.rb, line 15</span>
413
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">three_eights_integration_n</span>(<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>, <span class="ruby-identifier">n</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
414
+ <span class="ruby-identifier">dx</span> = (<span class="ruby-identifier">b</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">a</span>) <span class="ruby-operator">/</span> <span class="ruby-identifier">n</span>.<span class="ruby-identifier">to_f</span>
415
+ <span class="ruby-identifier">result</span> = <span class="ruby-value">0</span>
416
+ <span class="ruby-identifier">x</span> = <span class="ruby-identifier">a</span>
417
+ <span class="ruby-identifier">n</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span>
418
+ <span class="ruby-identifier">result</span> <span class="ruby-operator">+=</span>
419
+ (<span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">x</span>) <span class="ruby-operator">+</span> <span class="ruby-value">3</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>((<span class="ruby-value">2</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">x</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">x</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">dx</span>) <span class="ruby-operator">/</span> <span class="ruby-value">3.0</span>) <span class="ruby-operator">+</span>
420
+ <span class="ruby-value">3</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>((<span class="ruby-identifier">x</span> <span class="ruby-operator">+</span> <span class="ruby-value">2</span> <span class="ruby-operator">*</span> (<span class="ruby-identifier">x</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">dx</span>)) <span class="ruby-operator">/</span> <span class="ruby-value">3.0</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">x</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">dx</span>)) <span class="ruby-operator">/</span> <span class="ruby-value">8.0</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">dx</span>
421
+ <span class="ruby-identifier">x</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">dx</span>
422
+ <span class="ruby-keyword">end</span>
423
+ <span class="ruby-identifier">result</span>
424
+ <span class="ruby-keyword">end</span></pre>
425
+ </div>
426
+
427
+ </div>
428
+
429
+
430
+
431
+
432
+ </div>
433
+
434
+
435
+ <div id="method-c-trapezoid" class="method-detail ">
436
+
437
+ <div class="method-heading">
438
+ <span class="method-name">trapezoid</span><span
439
+ class="method-args">(a, b, eps = 0.0001, &amp;block)</span>
440
+
441
+ <span class="method-click-advice">click to toggle source</span>
442
+
443
+ </div>
444
+
445
+
446
+ <div class="method-description">
447
+
448
+ <p>Trapezoid Method with specified accuracy</p>
449
+
450
+
451
+
452
+
453
+ <div class="method-source-code" id="trapezoid-source">
454
+ <pre><span class="ruby-comment"># File lib/numerical_integration.rb, line 105</span>
455
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">trapezoid</span>(<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>, <span class="ruby-identifier">eps</span> = <span class="ruby-value">0.0001</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
456
+ <span class="ruby-identifier">wrapper_method</span>([<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>], <span class="ruby-identifier">eps</span>, <span class="ruby-value">:trapezoid_with_a_segment</span> ,<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
457
+ <span class="ruby-keyword">end</span></pre>
458
+ </div>
459
+
460
+ </div>
461
+
462
+
463
+
464
+
465
+ </div>
466
+
467
+
468
+ <div id="method-c-trapezoid_with_a_segment" class="method-detail ">
469
+
470
+ <div class="method-heading">
471
+ <span class="method-name">trapezoid_with_a_segment</span><span
472
+ class="method-args">(a, b, n, &amp;block)</span>
473
+
474
+ <span class="method-click-advice">click to toggle source</span>
475
+
476
+ </div>
477
+
478
+
479
+ <div class="method-description">
480
+
481
+ <p>Trapezoid Method with a segment</p>
482
+
483
+
484
+
485
+
486
+ <div class="method-source-code" id="trapezoid_with_a_segment-source">
487
+ <pre><span class="ruby-comment"># File lib/numerical_integration.rb, line 92</span>
488
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">trapezoid_with_a_segment</span>(<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>, <span class="ruby-identifier">n</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
489
+ <span class="ruby-identifier">dx</span> = (<span class="ruby-identifier">b</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">a</span>) <span class="ruby-operator">/</span> <span class="ruby-identifier">n</span>.<span class="ruby-identifier">to_f</span>
490
+ <span class="ruby-identifier">result</span> = <span class="ruby-value">0</span>
491
+ <span class="ruby-identifier">i</span> = <span class="ruby-value">1</span>
492
+ (<span class="ruby-identifier">n</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>).<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span>
493
+ <span class="ruby-identifier">result</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">a</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">dx</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">i</span>)
494
+ <span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
495
+ <span class="ruby-keyword">end</span>
496
+ <span class="ruby-identifier">result</span> <span class="ruby-operator">+=</span> (<span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">a</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">b</span>)) <span class="ruby-operator">/</span> <span class="ruby-value">2.0</span>
497
+ <span class="ruby-identifier">result</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">dx</span>
498
+ <span class="ruby-keyword">end</span></pre>
499
+ </div>
500
+
501
+ </div>
502
+
503
+
504
+
505
+
506
+ </div>
507
+
508
+
509
+ </section>
510
+
511
+ </section>
512
+
513
+ </main>
514
+
515
+
516
+ <footer id="validator-badges" role="contentinfo">
517
+ <p><a href="https://validator.w3.org/check/referer">Validate</a>
518
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.0.
519
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
520
+ </footer>
521
+