mathpack 0.4.8 → 0.4.9
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/.travis.yml +1 -1
- data/Gemfile +2 -0
- data/README.md +27 -0
- data/lib/mathpack/differential_equations.rb +7 -1
- data/lib/mathpack/version.rb +1 -1
- data/spec/differential_equations_spec.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d83a43c2f840fff63926eec5d9548e0f5051fcd
|
4
|
+
data.tar.gz: 949637138199c144e04ce0ed085d8b249d40a4dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 257fe6c5dac7b567ead47d8546aebd2f945a6d32a4cd87f7fb4e14ad4420eadf026a2139dc8770bf8caee294cb946beb250bb80136ce8b9947954ce8f6f2c5d9
|
7
|
+
data.tar.gz: a18a58ed4da327ffdd05f92d88c5f11940346273a16cc2b3d5b33a53f5b9c973ff9d57eee1cb0fc466ce08f46aa610fc7186a901cca741d92476981201ca01a7
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -26,6 +26,7 @@ Or install it yourself as:
|
|
26
26
|
- **Approximation**. Allows to approximate table and analytical functions by polynom
|
27
27
|
- **NonlinearEquations**. Solves unlinear mathematical equations
|
28
28
|
- **IntegralEquations**. Solves integral second order Fredholm and Volter equations
|
29
|
+
- **DifferentialEquations**. Solves system of differential equations with left border initial conditions
|
29
30
|
- **Integration**. Integrates functions
|
30
31
|
- **IO**. Prints data
|
31
32
|
- **Functional**. Lambda functions
|
@@ -197,6 +198,32 @@ Mathpack::IntegralEquations.solve_volter_2(from: 0.0, to: 1.0, lambda: 0.5, eps:
|
|
197
198
|
#=> {: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
|
```
|
199
200
|
|
201
|
+
## DifferentialEquations
|
202
|
+
#### solve_cauchie_system(params={})
|
203
|
+
returns solution of differential equations system as a hash of nodes and values arrays for each function. For example, { x: [], u1: [], u2: [], ... }
|
204
|
+
##### Parameters
|
205
|
+
- ***from*** - left border
|
206
|
+
- ***to*** - right border
|
207
|
+
- ***system*** - array of lambdas representing each row of system
|
208
|
+
- ***y0*** - array of values of derivatives on left border. Starts with first derivative
|
209
|
+
- ***eps*** - accuracy
|
210
|
+
|
211
|
+
### Usage
|
212
|
+
Let we have following system of differential equations
|
213
|
+
|
214
|
+

|
215
|
+
|
216
|
+
where
|
217
|
+
|
218
|
+

|
219
|
+
|
220
|
+
If you want to solve this system with accuracy **1e-6**, you should call
|
221
|
+
```ruby
|
222
|
+
cauchie_problem = [ ->(x, u1, u2) { u2 }, -> (x, u1, u2) { - 1.0 / x * u2 + 1.0 / x**2 * u1 + 3.0 }]
|
223
|
+
Mathpack::DifferentialEquations.solve_cauchie_system(from: 1.0, to: 2.0, eps: 1e-6, system: cauchie_problem, y0: [1.0, 1.0])
|
224
|
+
#=> {:x=>[1.0,..., 2.0], :u1=>[1,...], :u2=>[1,...] }
|
225
|
+
```
|
226
|
+
|
200
227
|
## SLE
|
201
228
|
#### solve(params = {})
|
202
229
|
returns solution of system of linear equations.
|
@@ -60,7 +60,13 @@ module Mathpack
|
|
60
60
|
end
|
61
61
|
break if is_finished
|
62
62
|
end
|
63
|
-
|
63
|
+
generate_result(params, step, u_next)
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.generate_result(params, step, u)
|
67
|
+
result = { x: Mathpack::Approximation.generate_nodes(from: params[:from], to: params[:to], step: step) }
|
68
|
+
u.each_index { |i| result[:"u#{i + 1}"] = u[i] }
|
69
|
+
result
|
64
70
|
end
|
65
71
|
end
|
66
72
|
end
|
data/lib/mathpack/version.rb
CHANGED
@@ -8,7 +8,7 @@ describe 'DifferentialEquation' do
|
|
8
8
|
cauchie_problem = [ ->(x, u1, u2) { u2 }, -> (x, u1, u2) { - 1.0 / x * u2 + 1.0 / x**2 * u1 + 3.0 }]
|
9
9
|
result = Mathpack::DifferentialEquations.solve_cauchie_system(from: 1.0, to: 2.0, eps: eps, system: cauchie_problem, y0: [1.0, 1.0])
|
10
10
|
correct_result = Mathpack::Approximation.fill_f(result[:x]){ |t| t**2 - 0.5 * t + 1.0/(2.0 * t) }
|
11
|
-
expect(Mathpack::IO.count_diff(result[:
|
11
|
+
expect(Mathpack::IO.count_diff(result[:u1], correct_result) <= eps).to eq(true)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- maxmilan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
96
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.4.
|
97
|
+
rubygems_version: 2.4.8
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: Summary
|