mathpack 0.4.6 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +68 -20
- data/lib/mathpack/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebeda1905dee9fe22d4a6469200537d76d21c432
|
4
|
+
data.tar.gz: b3b71ff00ef7a9ced9dd6855f8ef912329167f0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89c4e920ab56d6dc9ba263d0f04dc6682efba2f2374d01c3afc8f56b809e0a40ec96b9987e64c8ec8e5881b9e29bdd73162b32a15fa18c0bab6b43c0bbb14572
|
7
|
+
data.tar.gz: e19cd9fe1cf1bdc670e5b0ad2f1a2b47f9e6254cf6e4ba9cad9742a7f66ec43bfecf722f7f99919775196ca22a1f9144226762b3c5547e72495c688b9065f8a0
|
data/README.md
CHANGED
@@ -25,6 +25,7 @@ Or install it yourself as:
|
|
25
25
|
- **Functions**. Collects mathematical functions
|
26
26
|
- **Approximation**. Allows to approximate table and analytical functions by polynom
|
27
27
|
- **NonlinearEquations**. Solves unlinear mathematical equations
|
28
|
+
- **IntegralEquations**. Solves integral second order Fredholm and Volter equations
|
28
29
|
- **Integration**. Integrates functions
|
29
30
|
- **IO**. Prints data
|
30
31
|
- **Functional**. Lambda functions
|
@@ -96,8 +97,8 @@ stat.trend(polynom_power: 1) #=> 1.7999999999999996*x - 0.9999999999999987
|
|
96
97
|
#### solve(params = {})
|
97
98
|
returns solution of nonlinear equation.
|
98
99
|
##### Parameters
|
99
|
-
-
|
100
|
-
-
|
100
|
+
- ***start*** - point to start iteration process
|
101
|
+
- ***eps*** - calculations accuraccy
|
101
102
|
|
102
103
|
### Usage
|
103
104
|
Now you have no problems solving nonlinear equations. If you want, for example, to solve equation 
|
@@ -122,10 +123,10 @@ Mathpack::NonlinearEquations.solve(start: 0.01, eps: 0.00001){|x| Math.exp(x-2)
|
|
122
123
|
#### solve_system(params = {})
|
123
124
|
returns solution of system of nonlinear equations by *Newton method*
|
124
125
|
##### Parameters
|
125
|
-
-
|
126
|
-
-
|
127
|
-
-
|
128
|
-
-
|
126
|
+
- ***start*** - vector to start iteration process
|
127
|
+
- ***eps*** - calculations accuraccy
|
128
|
+
- ***f*** - vector of right part lambdas
|
129
|
+
- ***w_matrix*** - matrix *W* in Newton method
|
129
130
|
|
130
131
|
### Usage
|
131
132
|
If you have system of equations 
|
@@ -149,12 +150,59 @@ w = -> x, y { [[1, 1], [2 * x, 2 * y]] }
|
|
149
150
|
Mathpack::NonlinearEquations.solve_system(start: [1, 5], eps: 1e-4, f: f, w_matrix: w) #=> [-1.829420851037002e-12, 3.0000000000018296]
|
150
151
|
```
|
151
152
|
|
153
|
+
## IntegralEquations
|
154
|
+
#### solve_fredholm_2(params={})
|
155
|
+
returns solution of integral equation as a hash of nodes and values arrays.
|
156
|
+
##### Parameters
|
157
|
+
- ***from*** - left border
|
158
|
+
- ***to*** - right border
|
159
|
+
- ***lambda*** - *lambda* parameter
|
160
|
+
- ***k*** - kernel function (2 arguements)
|
161
|
+
- ***f*** - inhomogeneity function (1 arguement)
|
162
|
+
- ***eps*** - accuracy
|
163
|
+
|
164
|
+
### Usage
|
165
|
+
Let we have the following integral equation
|
166
|
+
|
167
|
+

|
168
|
+
|
169
|
+
If you want to solve equation with accuracy **1e-5**, you should call
|
170
|
+
```ruby
|
171
|
+
k = -> x, t { 1.0 / (x + t**2)**0.5 }
|
172
|
+
f = -> x { 2*x + (x + 1)**0.5 - (x + 4)**0.5 }
|
173
|
+
Mathpack::IntegralEquations.solve_fredholm_2(from: 1.0, to: 2.0, lambda: 0.5, eps: 1e-5, k: k, f: f)
|
174
|
+
#=> {:x=>[1.0, 1.125, 1.25, 1.375, 1.5, 1.625, 1.75, 1.875, 2.0], :f=>[1.9999989550044168, 2.2499991010033416, 2.499999229316462, 2.7499993410739187, 2.9999994379022, 3.2499995215457123, 3.4999995936848047, 3.7499996558559117, 3.9999997094242845]}
|
175
|
+
```
|
176
|
+
|
177
|
+
#### solve_volter_2(params{})
|
178
|
+
returns solution of integral equation as a hash of nodes and values arrays.
|
179
|
+
##### Parameters
|
180
|
+
- ***from*** - left border
|
181
|
+
- ***to*** - right border
|
182
|
+
- ***lambda*** - *lambda* parameter
|
183
|
+
- ***k*** - kernel function (2 arguements)
|
184
|
+
- ***f*** - inhomogeneity function (1 arguement)
|
185
|
+
- ***eps*** - accuracy
|
186
|
+
|
187
|
+
### Usage
|
188
|
+
Let we have the following integral equation
|
189
|
+
|
190
|
+

|
191
|
+
|
192
|
+
If you want to solve equation with accuracy **1e-3**, you should call
|
193
|
+
```ruby
|
194
|
+
k = -> x, t { Math.cos(x - t) }
|
195
|
+
f = -> x { 0.75 * Math.exp(x) + 0.25 * Math.cos(x) - 0.25 * Math.sin(x) }
|
196
|
+
Mathpack::IntegralEquations.solve_volter_2(from: 0.0, to: 1.0, lambda: 0.5, eps: 1e-3, k: k, f: f)
|
197
|
+
#=> {:x=>[0.0, 0.0625, 0.125, 0.1875, 0.25, 0.3125, 0.375, 0.4375, 0.5, 0.5625, 0.625, 0.6875, 0.75, 0.8125, 0.875, 0.9375, 1.0], :f=>[1.0, 1.0644951210235056, 1.1331511709098798, 1.2062365414157485, 1.2840369296892897, 1.3668564541117094, 1.455018842114489, 1.5488686946157586, 1.6487728320186184, 1.755121727033003, 1.868331029922017, 1.9888431921348702, 2.117129194673052, 2.2536903879456665, 2.3990604503055315, 2.5538074729214233, 2.718536179135541]}
|
198
|
+
```
|
199
|
+
|
152
200
|
## SLE
|
153
201
|
#### solve(params = {})
|
154
202
|
returns solution of system of linear equations.
|
155
203
|
##### Parameters
|
156
|
-
-
|
157
|
-
-
|
204
|
+
- ***matrix*** - system matrix
|
205
|
+
- ***f*** - right part vector
|
158
206
|
|
159
207
|
### Usage
|
160
208
|
Let's solve some system of linear equations. It can be written as
|
@@ -181,16 +229,16 @@ Mathpack::SLE.solve(matrix: a, f: b) #=> Matrix[[-1.0, 2.0, 4.0]]
|
|
181
229
|
#### approximate_by_polynom(params = {})
|
182
230
|
returns array of coefficients of polynom, approximating given function on [from, to] segment.
|
183
231
|
##### Parameters
|
184
|
-
-
|
185
|
-
-
|
186
|
-
-
|
232
|
+
- ***x*** - array of approximation nodes
|
233
|
+
- ***polynom_power*** - power of approximation polynom
|
234
|
+
- ***f*** - functions values in *x* if you have table function
|
187
235
|
|
188
236
|
#### generate_nodes(params = {})
|
189
237
|
returns nodes for approximation with some step.
|
190
238
|
##### Parameters
|
191
|
-
-
|
192
|
-
-
|
193
|
-
-
|
239
|
+
- ***from*** - first node
|
240
|
+
- ***to*** - last node
|
241
|
+
- ***step*** - step between nodes
|
194
242
|
|
195
243
|
#### print_polynom(coefficients)
|
196
244
|
returns a string representing polynom with given coefficients.
|
@@ -222,8 +270,8 @@ Mathpack::Approximation.print_polynom(result) #=> x^2
|
|
222
270
|
#### integrate(params = {})
|
223
271
|
returns integral value.
|
224
272
|
##### Parameters
|
225
|
-
-
|
226
|
-
-
|
273
|
+
- ***from*** - start of integration
|
274
|
+
- ***to*** - end of integration
|
227
275
|
|
228
276
|
### Usage
|
229
277
|
Let you have the following integral:
|
@@ -246,10 +294,10 @@ Mathpack::Integration.integrate(from: -Float::INFINITY, to: Float::INFINITY){ |x
|
|
246
294
|
#### print_table_function(params = {})
|
247
295
|
writes table function values to file
|
248
296
|
##### Parameters
|
249
|
-
-
|
250
|
-
-
|
251
|
-
-
|
252
|
-
-
|
297
|
+
- ***filename*** - name of output file
|
298
|
+
- ***x*** - arguements array
|
299
|
+
- ***y*** - function values array
|
300
|
+
- ***labels*** - hash of labels names for *x* and *y* column
|
253
301
|
|
254
302
|
#### read_table_function(filename)
|
255
303
|
returns table function values hash, written to **filename**
|
data/lib/mathpack/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mathpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- maxmilan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05
|
11
|
+
date: 2015-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|