dydx 0.1.2 → 0.1.3
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.
- data/README.md +94 -53
- data/dydx.gemspec +2 -2
- data/lib/dydx.rb +36 -25
- data/lib/dydx/algebra/formula.rb +9 -14
- data/lib/dydx/algebra/inverse.rb +3 -10
- data/lib/dydx/algebra/operator/parts/formula.rb +9 -5
- data/lib/dydx/algebra/operator/parts/general.rb +2 -2
- data/lib/dydx/algebra/operator/parts/symbol.rb +1 -1
- data/lib/dydx/algebra/set/num.rb +0 -4
- data/lib/dydx/algebra/set/sin.rb +3 -2
- data/lib/dydx/helper.rb +14 -6
- data/lib/dydx/version.rb +1 -1
- data/spec/dydx_spec.rb +2 -2
- data/spec/lib/algebra/operator/parts/formula_spec.rb +9 -2
- data/spec/lib/function_spec.rb +2 -2
- data/spec/lib/helper_spec.rb +5 -0
- data/spec/lib/integrand_spec.rb +4 -8
- metadata +33 -19
- checksums.yaml +0 -7
data/README.md
CHANGED
@@ -1,88 +1,129 @@
|
|
1
|
-
# Dydx
|
2
|
-
|
1
|
+
# Dydx is new math DSL in Ruby
|
2
|
+
|
3
|
+
### Since you report a bug, I will fix it within 24 hours.
|
4
|
+
|
5
|
+
The most important thing in this DSL is
|
6
|
+
|
7
|
+
we can handle math in the same sense sense of the math on paper.
|
8
|
+
|
9
|
+
ex. limit, trigonometric functions and logarithmic.
|
10
|
+
|
3
11
|
|
4
12
|
After `inlcude Dydx` , ruby become like other language.
|
5
13
|
|
6
|
-
|
14
|
+
## Outline
|
15
|
+
```ruby:
|
7
16
|
require 'dydx'
|
8
17
|
include Dydx
|
9
18
|
|
10
|
-
#
|
11
|
-
|
12
|
-
( d/dx(x^2) ).to_s
|
13
|
-
=> "( 2 * x )"
|
19
|
+
# Define the function. syntax is not good enough...
|
20
|
+
f(x) <= x ^ 2
|
14
21
|
|
15
|
-
|
16
|
-
=>
|
22
|
+
f(3)
|
23
|
+
=> 9
|
17
24
|
|
18
|
-
|
19
|
-
(
|
20
|
-
=> "( e ^ x )"
|
25
|
+
f(x).to_s
|
26
|
+
=> "( x ^ 2 )"
|
21
27
|
|
22
|
-
|
28
|
+
f(x) == eval('f(x).to_s')
|
29
|
+
=> true
|
23
30
|
|
24
|
-
|
31
|
+
# Differentiate
|
32
|
+
g(x) <= d/dx(f(x))
|
25
33
|
|
26
|
-
|
34
|
+
g(3)
|
35
|
+
=> 6
|
27
36
|
|
28
|
-
|
37
|
+
g(x).to_s
|
38
|
+
=> '2 * x'
|
29
39
|
|
40
|
+
# Integrate
|
41
|
+
S(f(x), dx)[0, 1]
|
42
|
+
=> 0.3333333333333334
|
30
43
|
```
|
31
|
-
x + x
|
32
|
-
=> #<Dydx::Algebra::Formula:0x007fb0a4039fb0 @f=#<Dydx::Algebra::Set::Num:0x007fb0a48169e0 @n=2>, @operator=:*, @g=:x>
|
33
44
|
|
34
|
-
e
|
35
|
-
=> #<Dydx::Algebra::Set::E:0x007fb0a383e9f0>
|
36
45
|
|
37
|
-
|
38
|
-
|
39
|
-
```
|
46
|
+
#### limit, trigonometric functions and logarithmic.
|
47
|
+
```ruby:
|
40
48
|
|
41
|
-
|
49
|
+
f(z) <= log(z)
|
50
|
+
S(f(z), dz)[0,1]
|
51
|
+
=> -Infinity
|
42
52
|
|
43
|
-
|
44
|
-
(
|
45
|
-
=> "( x * ( y + z ) )"
|
53
|
+
( d/dx(log(x)) ).to_s
|
54
|
+
=> "( 1 / x )"
|
46
55
|
|
47
|
-
(
|
48
|
-
=> "(
|
56
|
+
( d/dx(cos(x)) ).to_s
|
57
|
+
=> "( - sin( x ) )"
|
49
58
|
|
50
|
-
(
|
51
|
-
=> "(
|
52
|
-
```
|
59
|
+
( d/dx(e ^ x) ).to_s
|
60
|
+
=> "( e ^ x )"
|
53
61
|
|
54
|
-
|
62
|
+
f(x) <= sin(x)
|
63
|
+
S(f(x), dx)[0, Math::PI/2]
|
64
|
+
=> 1.000000000021139
|
55
65
|
|
66
|
+
# standard normal distribution;
|
67
|
+
f(x) <= (1.0 / ( ( 2.0 * pi ) ^ 0.5 ) ) * ( e ^ (- (x ^ 2) / 2) )
|
68
|
+
S(f(x), dx)[-oo, oo]
|
69
|
+
=> 0.9952054164466917
|
56
70
|
```
|
57
|
-
# pretermit '#to_s'
|
58
71
|
|
59
|
-
|
60
|
-
=> "( 1 / z )"
|
72
|
+
#### it's like a magic...
|
61
73
|
|
62
|
-
|
63
|
-
|
74
|
+
```ruby:
|
75
|
+
f(x) <= x ^ 2
|
64
76
|
|
65
|
-
|
66
|
-
|
67
|
-
=> "( - sin( x ) )"
|
77
|
+
f(a + b).to_s
|
78
|
+
=> "( ( a + b ) ^ 2 )"
|
68
79
|
|
69
|
-
|
70
|
-
|
71
|
-
=> "( a * t )"
|
80
|
+
#↓it"s magic!!!
|
81
|
+
g(a, b) <= f(a + b)
|
72
82
|
|
73
|
-
|
74
|
-
=>"a"
|
83
|
+
g(a, b).to_s
|
84
|
+
=> "( ( a + b ) ^ 2 )"
|
75
85
|
|
76
|
-
(
|
77
|
-
=>
|
86
|
+
g(2, 2)
|
87
|
+
=> 16
|
78
88
|
|
79
|
-
((
|
80
|
-
=> "( 2 *
|
89
|
+
( d/da(g(a, b)) ).to_s
|
90
|
+
=> "( 2 * ( a + b ) )"
|
81
91
|
|
92
|
+
# simplify
|
93
|
+
((x * y) + (z * x)).to_s
|
94
|
+
=> "( x * ( y + z ) )"
|
95
|
+
|
96
|
+
((x ^ y) / (x ^ z)).to_s
|
97
|
+
=> "( x ^ ( y - z ) )"
|
98
|
+
|
99
|
+
(x + x).to_s
|
100
|
+
=> "( 2 * x )"
|
82
101
|
```
|
83
102
|
|
84
103
|
|
85
|
-
|
104
|
+
## Documents
|
105
|
+
I'm going to write now...cominng soon....
|
106
|
+
|
107
|
+
### Module, class configuration
|
108
|
+
|
109
|
+
```
|
110
|
+
Dydx
|
111
|
+
|- Algebra
|
112
|
+
| |- Set
|
113
|
+
| | |- Num
|
114
|
+
| | |- ....
|
115
|
+
| |
|
116
|
+
| |- Operator
|
117
|
+
| | |- Interface
|
118
|
+
| | |- ....
|
119
|
+
| |
|
120
|
+
| |- Formula
|
121
|
+
| |- inverse
|
122
|
+
|
|
123
|
+
|- Function
|
124
|
+
|- Delta
|
125
|
+
|- Integrand
|
126
|
+
```
|
86
127
|
|
87
128
|
## Installation
|
88
129
|
|
@@ -115,6 +156,6 @@ Or install it yourself as:
|
|
115
156
|
run `bundle exec rake spec`
|
116
157
|
|
117
158
|
```
|
118
|
-
Finished in
|
119
|
-
|
159
|
+
Finished in 3.23 seconds
|
160
|
+
309 examples, 0 failures
|
120
161
|
```
|
data/dydx.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["gogotanaka"]
|
10
10
|
spec.email = ["qlli.illb@gmail.com"]
|
11
11
|
spec.homepage = "https://github.com/gogotanaka"
|
12
|
-
spec.summary = %q{We can enjoy the
|
13
|
-
spec.description = %q{
|
12
|
+
spec.summary = %q{We can enjoy the math.}
|
13
|
+
spec.description = %q{Dydx is new math DSL in Ruby. The most important thing in this DSL is we can handle math in the same sense sense of the math on paper.}
|
14
14
|
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
data/lib/dydx.rb
CHANGED
@@ -6,33 +6,18 @@ require 'dydx/integrand'
|
|
6
6
|
|
7
7
|
module Dydx
|
8
8
|
include Algebra
|
9
|
-
# TODO: Refactor
|
10
9
|
%w(f g h).each do |functioner|
|
11
10
|
define_method(functioner) do |*vars|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
.gsub('pi', 'Math::PI')
|
23
|
-
else
|
24
|
-
string = function.algebra.to_s
|
25
|
-
end
|
26
|
-
function.vars.each_with_index do |var, i|
|
27
|
-
string.gsub!(var.to_s, vars[i].to_s)
|
28
|
-
end
|
29
|
-
eval(string)
|
30
|
-
else
|
31
|
-
function
|
32
|
-
end
|
33
|
-
else
|
34
|
-
eval("$#{functioner} = Function.new(*vars)")
|
35
|
-
end
|
11
|
+
function = eval("$#{functioner}")
|
12
|
+
return eval("$#{functioner} = Function.new(*vars)") unless function
|
13
|
+
|
14
|
+
raise ArgumentError, "invalid number of values (#{vars.count} for #{function.vars.count})" unless function.vars.count == vars.count
|
15
|
+
return function if function.vars == vars
|
16
|
+
return function unless function.algebra
|
17
|
+
|
18
|
+
string = substitute(vars, function)
|
19
|
+
string = rename_for_calc(string) if all_vars_num?(vars)
|
20
|
+
eval(string)
|
36
21
|
end
|
37
22
|
end
|
38
23
|
|
@@ -44,6 +29,10 @@ module Dydx
|
|
44
29
|
Delta.new
|
45
30
|
end
|
46
31
|
|
32
|
+
def reset
|
33
|
+
$f, $g, $h = nil, nil, nil
|
34
|
+
end
|
35
|
+
|
47
36
|
def method_missing(method, *args, &block)
|
48
37
|
method_name = method.to_s
|
49
38
|
if method_name =~ /^d.$/
|
@@ -54,4 +43,26 @@ module Dydx
|
|
54
43
|
super
|
55
44
|
end
|
56
45
|
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def substitute(vars, function)
|
50
|
+
string = function.algebra.to_s
|
51
|
+
function.vars.each_with_index { |var, i| string.gsub!(var.to_s, vars[i].to_s) }
|
52
|
+
string
|
53
|
+
end
|
54
|
+
|
55
|
+
def all_vars_num?(vars)
|
56
|
+
vars.all? { |v| v.is_a?(Numeric) }
|
57
|
+
end
|
58
|
+
|
59
|
+
def rename_for_calc(string)
|
60
|
+
# TODO: need more refactoring...
|
61
|
+
string.gsub!('cos', 'Math.cos')
|
62
|
+
string.gsub!('sin', 'Math.sin')
|
63
|
+
string.gsub!('log', 'Math.log')
|
64
|
+
string.gsub!(' e ', ' Math::E ')
|
65
|
+
string.gsub!('pi', 'Math::PI')
|
66
|
+
string
|
67
|
+
end
|
57
68
|
end
|
data/lib/dydx/algebra/formula.rb
CHANGED
@@ -5,15 +5,14 @@ module Dydx
|
|
5
5
|
attr_accessor :f, :operator, :g
|
6
6
|
|
7
7
|
def initialize(f, g, operator)
|
8
|
+
g, f = f, g if g.is_num? && operator.commutative?
|
8
9
|
@f, @g, @operator = f, g, operator
|
9
10
|
end
|
10
11
|
|
11
12
|
def differentiate(sym=:x)
|
12
13
|
case @operator
|
13
|
-
when :+
|
14
|
-
|
15
|
-
when :*
|
16
|
-
(f.d(sym) * g) + (f * g.d(sym))
|
14
|
+
when :+ then f.d(sym) + g.d(sym)
|
15
|
+
when :* then (f.d(sym) * g) + (f * g.d(sym))
|
17
16
|
when :^
|
18
17
|
# TODO:
|
19
18
|
if g.is_num?
|
@@ -30,18 +29,14 @@ module Dydx
|
|
30
29
|
alias_method :d, :differentiate
|
31
30
|
|
32
31
|
def to_s
|
33
|
-
if (
|
32
|
+
if (formula?(:*) && (f.is_minus1? || g.is_minus1?) )
|
34
33
|
"( - #{g.to_s} )"
|
35
|
-
elsif
|
36
|
-
"( #{f.to_s}
|
37
|
-
elsif
|
38
|
-
"( #{g.to_s}
|
39
|
-
elsif addition? && g.inverse?(:+)
|
40
|
-
"( #{f.to_s} - #{g.x.to_s} )"
|
41
|
-
elsif addition? && f.inverse?(:+)
|
42
|
-
"( #{g.to_s} - #{f.x.to_s} )"
|
34
|
+
elsif g.inverse?(operator)
|
35
|
+
"( #{f.to_s} #{inverse_ope(operator)} #{g.x.to_s} )"
|
36
|
+
elsif f.inverse?(operator)
|
37
|
+
"( #{g.to_s} #{inverse_ope(operator)} #{f.x.to_s} )"
|
43
38
|
else
|
44
|
-
"( #{f.to_s} #{
|
39
|
+
"( #{f.to_s} #{operator} #{g.to_s} )"
|
45
40
|
end
|
46
41
|
end
|
47
42
|
|
data/lib/dydx/algebra/inverse.rb
CHANGED
@@ -9,12 +9,9 @@ module Dydx
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def to_s
|
12
|
-
# sym = {'*'=>'/', '+'=>'-'}[operator.to_s]
|
13
12
|
case operator
|
14
|
-
when :+
|
15
|
-
|
16
|
-
when :*
|
17
|
-
"( 1 / #{x} )"
|
13
|
+
when :+ then "( - #{x} )"
|
14
|
+
when :* then "( 1 / #{x} )"
|
18
15
|
end
|
19
16
|
end
|
20
17
|
|
@@ -27,10 +24,6 @@ module Dydx
|
|
27
24
|
end
|
28
25
|
end
|
29
26
|
alias_method :d, :differentiate
|
30
|
-
|
31
|
-
def ==(x)
|
32
|
-
to_s == x.to_s
|
33
|
-
end
|
34
27
|
end
|
35
28
|
end
|
36
|
-
end
|
29
|
+
end
|
@@ -13,6 +13,8 @@ module Dydx
|
|
13
13
|
else
|
14
14
|
super(x)
|
15
15
|
end
|
16
|
+
elsif formula?(sub_ope(operator)) && openable?(operator, x)
|
17
|
+
f.send(operator, x).send(sub_ope(operator), g.send(operator, x))
|
16
18
|
elsif formula?(super_ope(operator)) && x.formula?(super_ope(operator))
|
17
19
|
w1, w2 = common_factors(x)
|
18
20
|
return super(x) unless (w1 && w2) && (super_ope(operator).commutative? || w1 == w2)
|
@@ -49,11 +51,13 @@ module Dydx
|
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
52
|
-
|
53
|
-
|
54
|
-
(
|
55
|
-
|
56
|
-
|
54
|
+
%w(^).map(&:to_sym).each do |operator|
|
55
|
+
define_method(operator) do |x|
|
56
|
+
if formula?(sub_ope(operator)) && openable?(operator, x)
|
57
|
+
f.send(operator, x).send(sub_ope(operator), g.send(operator, x))
|
58
|
+
else
|
59
|
+
super(x)
|
60
|
+
end
|
57
61
|
end
|
58
62
|
end
|
59
63
|
end
|
data/lib/dydx/algebra/set/num.rb
CHANGED
data/lib/dydx/algebra/set/sin.rb
CHANGED
data/lib/dydx/helper.rb
CHANGED
@@ -61,10 +61,9 @@ module Dydx
|
|
61
61
|
def combinable?(x, operator)
|
62
62
|
case operator
|
63
63
|
when :+
|
64
|
-
self == x ||
|
65
64
|
(is_num? && x.is_num?) ||
|
66
|
-
(
|
67
|
-
|
65
|
+
(formula?(:*) && (f.is_num? || g.is_num?)) && x.is_num? ||
|
66
|
+
like_term?(x) ||
|
68
67
|
inverse?(:+, x)
|
69
68
|
when :*
|
70
69
|
self == x ||
|
@@ -75,6 +74,18 @@ module Dydx
|
|
75
74
|
end
|
76
75
|
end
|
77
76
|
|
77
|
+
def like_term?(x)
|
78
|
+
boolean = if self == x
|
79
|
+
elsif formula?(:*) && include?(x)
|
80
|
+
elsif x.formula?(:*) && x.include?(self)
|
81
|
+
elsif ((formula?(:*) && formula?(:*)) && (([f, g] & [x.f, x.g]).any?{|x| x.is_a?(Symbol)}))
|
82
|
+
else
|
83
|
+
true
|
84
|
+
end
|
85
|
+
|
86
|
+
!boolean
|
87
|
+
end
|
88
|
+
|
78
89
|
def is_multiple_of(x)
|
79
90
|
if is_0?
|
80
91
|
e0
|
@@ -100,9 +111,6 @@ module Dydx
|
|
100
111
|
([:f, :g] - [f_or_g]).first
|
101
112
|
end
|
102
113
|
|
103
|
-
def commutative?
|
104
|
-
end
|
105
|
-
|
106
114
|
def distributable?(operator)
|
107
115
|
end
|
108
116
|
|
data/lib/dydx/version.rb
CHANGED
data/spec/dydx_spec.rb
CHANGED
@@ -17,8 +17,8 @@ describe Dydx do
|
|
17
17
|
$b = (:x ^ (:x * 2))
|
18
18
|
let(:d1){ db/dx }
|
19
19
|
let(:d2){ d/dx($b) }
|
20
|
-
it{ expect(d1.to_s).to eq('( (
|
21
|
-
it{ expect(d2.to_s).to eq('( (
|
20
|
+
it{ expect(d1.to_s).to eq('( ( 2 * x ) * ( x ^ ( ( 2 * x ) - 1 ) ) )') }
|
21
|
+
it{ expect(d2.to_s).to eq('( ( 2 * x ) * ( x ^ ( ( 2 * x ) - 1 ) ) )') }
|
22
22
|
end
|
23
23
|
|
24
24
|
context 'ex3' do
|
@@ -47,10 +47,17 @@ describe Dydx::Algebra::Operator::Parts::Formula do
|
|
47
47
|
it{ expect((:y - (:x - :y)).to_s).to eq('( ( 2 * y ) - x )') }
|
48
48
|
it{ expect((:y - (:y - :x)).to_s).to eq('x') }
|
49
49
|
|
50
|
-
it{ expect((
|
50
|
+
it{ expect((x + 3) * 2).to eq(x * 2 + 6) }
|
51
|
+
# it{ expect((x - 3) * 2).to eq(x * 2 - 6) }
|
52
|
+
it{ expect((x + 3) * 2).to eq(x * 2 + 6) }
|
53
|
+
it{ expect((x + 3) * 2).to eq(x * 2 + 6) }
|
54
|
+
|
55
|
+
it{ expect(((:x * 2) ^ 2).to_s).to eq('( 4 * ( x ^ 2 ) )') }
|
51
56
|
it{ expect(((:x / 2) ^ 2).to_s).to eq('( ( x ^ 2 ) / 4 )') }
|
52
57
|
|
58
|
+
it{ expect((3*x + 4*(x^2)+ 4*x).to_s).to eq('( ( 7 * x ) + ( 4 * ( x ^ 2 ) ) )') }
|
59
|
+
|
53
60
|
# TODO:
|
54
|
-
it{ expect((2 ^ (:x * 2)).to_s).to eq('( 2 ^ (
|
61
|
+
it{ expect((2 ^ (:x * 2)).to_s).to eq('( 2 ^ ( 2 * x ) )') }
|
55
62
|
it{ expect((2 ^ (:x / 2)).to_s).to eq('( 2 ^ ( x / 2 ) )') }
|
56
63
|
end
|
data/spec/lib/function_spec.rb
CHANGED
@@ -28,8 +28,8 @@ describe Dydx:Function do
|
|
28
28
|
|
29
29
|
it{ expect(h(a, b, c) <= d/db(g(a, b))).to eq(h(a, b, c)) }
|
30
30
|
it{ expect(h(a, b, c) <= d/db(g(a, b))).to eq($h) }
|
31
|
-
it{ expect(h(a, b, c)).to eq(( ( 2 * b )
|
32
|
-
it{ expect(h(a, b, c).algebra).to eq(( ( 2 * b )
|
31
|
+
it{ expect(h(a, b, c)).to eq(( a + ( 2 * b ) )) }
|
32
|
+
it{ expect(h(a, b, c).algebra).to eq(( a + ( 2 * b ) )) }
|
33
33
|
|
34
34
|
it 'ex.4' do
|
35
35
|
$f = nil
|
data/spec/lib/helper_spec.rb
CHANGED
@@ -25,6 +25,11 @@ describe Helper do
|
|
25
25
|
it{ expect((:x * :y).is_multiple_of(:z)).to be_false }
|
26
26
|
end
|
27
27
|
|
28
|
+
context '#like_term?' do
|
29
|
+
it{ expect(x.like_term?(x)).to be_true }
|
30
|
+
it{ expect((2 * x).like_term?((3 * x))).to be_true }
|
31
|
+
end
|
32
|
+
|
28
33
|
context '#combinable?' do
|
29
34
|
it{ expect(:x.combinable?(:x, :+)).to be_true }
|
30
35
|
it{ expect(:x.combinable?(2 * :x, :+)).to be_true }
|
data/spec/lib/integrand_spec.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Dydx:Integrand do
|
4
|
+
before(:each) do
|
5
|
+
reset
|
6
|
+
end
|
7
|
+
|
4
8
|
it 'ex1' do
|
5
|
-
$f = nil
|
6
9
|
f(x, y) <= x * y
|
7
10
|
integrand = S(f(x, y), dx)
|
8
11
|
expect(integrand.function).to eq(f(x, y))
|
@@ -11,31 +14,26 @@ describe Dydx:Integrand do
|
|
11
14
|
end
|
12
15
|
|
13
16
|
it 'ex2' do
|
14
|
-
$f = nil
|
15
17
|
f(x) <= x * x
|
16
18
|
expect(S(f(x), dx)[0, 1]).to eq(0.3333333333333334)
|
17
19
|
end
|
18
20
|
|
19
21
|
it 'ex3' do
|
20
|
-
$f = nil
|
21
22
|
f(x) <= sin(x)
|
22
23
|
expect(S(f(x), dx)[0, Math::PI/2]).to eq(1.000000000021139)
|
23
24
|
end
|
24
25
|
|
25
26
|
it 'ex4' do
|
26
|
-
$f = nil
|
27
27
|
f(x) <= cos(x)
|
28
28
|
expect(S(f(x), dx)[0, Math::PI]).to eq(7.440786129085082e-17)
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'ex5' do
|
32
|
-
$f = nil
|
33
32
|
f(x) <= log(x)
|
34
33
|
expect(S(f(x), dx)[0, 1]).to eq(-oo)
|
35
34
|
end
|
36
35
|
|
37
36
|
it 'ex6' do
|
38
|
-
$f = nil
|
39
37
|
f(x) <= e ^ (- (x ^ 2))
|
40
38
|
expect(f(0)).to eq(1)
|
41
39
|
expect(f(1)).to eq(1.0/Math::E)
|
@@ -44,13 +42,11 @@ describe Dydx:Integrand do
|
|
44
42
|
end
|
45
43
|
|
46
44
|
it 'ex7' do
|
47
|
-
$f = nil
|
48
45
|
f(x) <= (1.0 / ( ( 2.0 * Math::PI ) ^ 0.5 ) ) * ( e ^ (- (x ^ 2) / 2) )
|
49
46
|
expect(S(f(x), dx)[-1000, 1000, 1000]).to eq(0.9952054164466917)
|
50
47
|
end
|
51
48
|
|
52
49
|
it 'ex8' do
|
53
|
-
$f = nil
|
54
50
|
f(x) <= (1.0 / ( ( 2.0 * pi ) ^ 0.5 ) ) * ( e ^ (- (x ^ 2) / 2) )
|
55
51
|
expect(S(f(x), dx)[-oo, oo, 1000]).to eq(0.9952054164466917)
|
56
52
|
end
|
metadata
CHANGED
@@ -1,68 +1,75 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dydx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- gogotanaka
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
12
|
+
date: 2014-05-28 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- -
|
19
|
+
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '1.6'
|
20
22
|
type: :development
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '1.6'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: rake
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- -
|
35
|
+
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: '0'
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- -
|
43
|
+
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: '0'
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: rspec
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- -
|
51
|
+
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: '0'
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
|
-
description:
|
56
|
-
|
62
|
+
description: Dydx is new math DSL in Ruby. The most important thing in this DSL is
|
63
|
+
we can handle math in the same sense sense of the math on paper.
|
57
64
|
email:
|
58
65
|
- qlli.illb@gmail.com
|
59
66
|
executables: []
|
60
67
|
extensions: []
|
61
68
|
extra_rdoc_files: []
|
62
69
|
files:
|
63
|
-
-
|
64
|
-
-
|
65
|
-
-
|
70
|
+
- .gitignore
|
71
|
+
- .rspec
|
72
|
+
- .travis.yml
|
66
73
|
- Gemfile
|
67
74
|
- LICENSE.txt
|
68
75
|
- README.md
|
@@ -125,27 +132,34 @@ files:
|
|
125
132
|
homepage: https://github.com/gogotanaka
|
126
133
|
licenses:
|
127
134
|
- MIT
|
128
|
-
metadata: {}
|
129
135
|
post_install_message:
|
130
136
|
rdoc_options: []
|
131
137
|
require_paths:
|
132
138
|
- lib
|
133
139
|
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
134
141
|
requirements:
|
135
|
-
- -
|
142
|
+
- - ! '>='
|
136
143
|
- !ruby/object:Gem::Version
|
137
144
|
version: '0'
|
145
|
+
segments:
|
146
|
+
- 0
|
147
|
+
hash: 1610563563432672313
|
138
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
none: false
|
139
150
|
requirements:
|
140
|
-
- -
|
151
|
+
- - ! '>='
|
141
152
|
- !ruby/object:Gem::Version
|
142
153
|
version: '0'
|
154
|
+
segments:
|
155
|
+
- 0
|
156
|
+
hash: 1610563563432672313
|
143
157
|
requirements: []
|
144
158
|
rubyforge_project:
|
145
|
-
rubygems_version:
|
159
|
+
rubygems_version: 1.8.23
|
146
160
|
signing_key:
|
147
|
-
specification_version:
|
148
|
-
summary: We can enjoy the
|
161
|
+
specification_version: 3
|
162
|
+
summary: We can enjoy the math.
|
149
163
|
test_files:
|
150
164
|
- spec/dydx_spec.rb
|
151
165
|
- spec/lib/algebra/formula_spec.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 05d9adcc67c3ad1cbaf217f11bf2d71a5926588a
|
4
|
-
data.tar.gz: bd230293d17b20bf98ab7b6af22d03a544454f15
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 96db75da9bb34f1dd34b4f7dc725d380031fd3092d93062e7d9289a41c35132612521ece1e3770ed0649f3c936ebd0daea965b13465a9c060f7b63258e7aa882
|
7
|
-
data.tar.gz: 47038bba5523d403d3f07153e22236e6f71d15846256d9f2db0772bf679834ac4c0b3ec9a16bd2b86f953ad268ee831e9fb9c6257529e4fe2b35046befafebd5
|