dydx 0.1.31 → 0.1.314

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +22 -59
  3. data/lib/dydx.rb +7 -4
  4. data/lib/dydx/algebra.rb +0 -66
  5. data/lib/dydx/algebra/formula.rb +15 -2
  6. data/lib/dydx/algebra/inverse.rb +14 -0
  7. data/lib/dydx/algebra/set.rb +253 -19
  8. data/lib/dydx/helper.rb +5 -0
  9. data/lib/dydx/integrand.rb +7 -2
  10. data/lib/dydx/version.rb +1 -1
  11. data/spec/dydx_spec.rb +10 -29
  12. data/spec/lib/algebra/formula_spec.rb +6 -0
  13. data/spec/lib/algebra/set_spec.rb +227 -0
  14. data/spec/lib/delta_spec.rb +26 -0
  15. data/spec/lib/function_spec.rb +61 -33
  16. data/spec/lib/integrand_spec.rb +2 -2
  17. metadata +4 -40
  18. data/lib/dydx/algebra/operator.rb +0 -5
  19. data/lib/dydx/algebra/set/base.rb +0 -9
  20. data/lib/dydx/algebra/set/cos.rb +0 -22
  21. data/lib/dydx/algebra/set/e.rb +0 -16
  22. data/lib/dydx/algebra/set/fixnum.rb +0 -14
  23. data/lib/dydx/algebra/set/float.rb +0 -14
  24. data/lib/dydx/algebra/set/log.rb +0 -22
  25. data/lib/dydx/algebra/set/log10.rb +0 -22
  26. data/lib/dydx/algebra/set/log2.rb +0 -22
  27. data/lib/dydx/algebra/set/num.rb +0 -22
  28. data/lib/dydx/algebra/set/pi.rb +0 -16
  29. data/lib/dydx/algebra/set/sin.rb +0 -22
  30. data/lib/dydx/algebra/set/symbol.rb +0 -14
  31. data/lib/dydx/algebra/set/tan.rb +0 -17
  32. data/spec/lib/algebra/set/cos_spec.rb +0 -18
  33. data/spec/lib/algebra/set/e_spec.rb +0 -27
  34. data/spec/lib/algebra/set/fixnum_spec.rb +0 -65
  35. data/spec/lib/algebra/set/float_spec.rb +0 -65
  36. data/spec/lib/algebra/set/log10_spec.rb +0 -16
  37. data/spec/lib/algebra/set/log2_spec.rb +0 -16
  38. data/spec/lib/algebra/set/log_spec.rb +0 -15
  39. data/spec/lib/algebra/set/num_spec.rb +0 -23
  40. data/spec/lib/algebra/set/pi_spec.rb +0 -25
  41. data/spec/lib/algebra/set/sin_spec.rb +0 -14
  42. data/spec/lib/algebra/set/symbol_spec.rb +0 -22
  43. data/spec/lib/algebra/set/tan_spec.rb +0 -13
@@ -1,65 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Float do
4
- describe '#to_s' do
5
- it{ expect(1.0.to_s).to eq('1.0') }
6
- end
7
-
8
- describe '#differentiate' do
9
- it{ expect(3.0.d(:x).to_s).to eq('0') }
10
- end
11
-
12
- describe 'Calculate' do
13
- context 'With Formula' do
14
- let(:formula) { (:x + :y) }
15
- it{ expect((0.0 + formula).to_s).to eq(formula.to_s) }
16
- it{ expect((0.0 - formula).to_s).to eq('( - ( x + y ) )') }
17
- it{ expect((0.0 * formula).to_s).to eq('0') }
18
- it{ expect((1.0 * formula).to_s).to eq(formula.to_s) }
19
- it{ expect((0.0 / formula).to_s).to eq('0') }
20
- it{ expect((1.0 / formula).to_s).to eq('( 1 / ( x + y ) )') }
21
- it{ expect((0.0 ^ formula).to_s).to eq('0') }
22
- it{ expect((1.0 ^ formula).to_s).to eq('1') }
23
- end
24
-
25
- context 'With Symbol' do
26
- it{ expect(0.0 + :x).to eq(:x) }
27
- it{ expect((0.0 - :x).to_s).to eq('( - x )') }
28
- it{ expect((0.0 * :x).to_s).to eq('0') }
29
- it{ expect(1.0 * :x).to eq(:x) }
30
- it{ expect((0.0 / :x).to_s).to eq('0') }
31
- it{ expect((1.0 / :x).to_s).to eq('( 1 / x )') }
32
- it{ expect((0.0 ^ :x).to_s).to eq('0') }
33
- it{ expect((1.0 ^ :x).to_s).to eq('1') }
34
- end
35
-
36
- context 'With Float' do
37
- it{ expect(0.0 + 3.0).to eq(3.0) }
38
- it{ expect(3.0 + 0.0).to eq(3.0) }
39
- it{ expect(2.0 + 3.0).to eq(5.0) }
40
-
41
- it{ expect(0.0 - 3.0).to eq(-3.0) }
42
- it{ expect(3.0 - 0.0).to eq(3.0) }
43
- it{ expect(2.0 - 3.0).to eq(-1.0) }
44
-
45
- it{ expect(0.0 * 3.0).to eq(0.0) }
46
- it{ expect(3.0 * 0.0).to eq(0.0) }
47
- it{ expect(1.0 * 3.0).to eq(3.0) }
48
- it{ expect(3.0 * 1.0).to eq(3.0) }
49
- it{ expect(3.0 * 2.0).to eq(6.0) }
50
-
51
- it{ expect(0.0 / 3.0).to eq(0.0) }
52
- it{ expect(3.0 / 0.0).to eq(oo) }
53
- it{ expect(3.0 / 1.0).to eq(3.0) }
54
- # TODO:
55
- it{ expect(2.0 / 3.0).to eq(0.6666666666666666) }
56
-
57
-
58
- it{ expect(0.0 ^ 3.0).to eq(0.0) }
59
- it{ expect(3.0 ^ 0.0).to eq(1.0) }
60
- it{ expect(1.0 ^ 3.0).to eq(1.0) }
61
- it{ expect(3.0 ^ 1.0).to eq(3.0) }
62
- it{ expect(3.0 ^ 2.0).to eq(9.0) }
63
- end
64
- end
65
- end
@@ -1,16 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dydx::Algebra::Set::Log10 do
4
- it { expect(log10(1)).to eq(_(0)) }
5
- it { expect(log10(10)).to eq(_(1)) }
6
- it { expect(log10(10 ^ :n)).to eq(:n) }
7
- it { expect(log10(3 ^ :n).to_s).to eq('( n * log10( 3 ) )') }
8
-
9
- describe '#to_s' do
10
- end
11
- describe '#differentiate' do
12
- it { expect(log10(:x).d(:x).to_s).to eq('( 1 / ( x * log( 10 ) ) )') }
13
- end
14
- describe 'Calculate' do
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dydx::Algebra::Set::Log2 do
4
- it { expect(log2(1)).to eq(_(0)) }
5
- it { expect(log2(2)).to eq(_(1)) }
6
- it { expect(log2(2 ^ :n)).to eq(:n) }
7
- it { expect(log2(3 ^ :n).to_s).to eq('( n * log2( 3 ) )') }
8
-
9
- describe '#to_s' do
10
- end
11
- describe '#differentiate' do
12
- it { expect(log2(:x).d(:x).to_s).to eq('( 1 / ( x * log( 2 ) ) )') }
13
- end
14
- describe 'Calculate' do
15
- end
16
- end
@@ -1,15 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dydx::Algebra::Set::Log do
4
- it{ expect(log(1)).to eq(_(0)) }
5
- it{ expect(log(e)).to eq(_(1)) }
6
- it{ expect(log(e ^ :n)).to eq(:n) }
7
-
8
- describe '#to_s' do
9
- end
10
- describe '#differentiate' do
11
- it{ expect(log(:x).d(:x).to_s).to eq('( 1 / x )') }
12
- end
13
- describe 'Calculate' do
14
- end
15
- end
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dydx::Algebra::Set::Num do
4
- it{ expect(_(1)).to eq(_(1)) }
5
- it{ expect(_(-1)).to eq(_(-1)) }
6
- it{ expect(e0).to eq(e0) }
7
- it{ expect(e1).to eq(e1) }
8
-
9
- describe '#to_s' do
10
- it{ expect(_(1).to_s).to eq('1') }
11
- end
12
-
13
- describe '#differentiate' do
14
- it{ expect(_(1).d(:x).to_s).to eq(_(0).to_s) }
15
- end
16
-
17
- describe '#==' do
18
- it{ expect(_(1) == _(1)).to be_true }
19
- end
20
-
21
- describe 'Calculate' do
22
- end
23
- end
@@ -1,25 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dydx::Algebra::Set::Pi do
4
- it{ expect(pi).to eq(pi) }
5
-
6
- describe '#to_s' do
7
- it{ expect(pi.to_s).to eq('pi') }
8
- end
9
-
10
- describe '#differentiate' do
11
- it{ expect(pi.d(:x).to_s).to eq(_(0).to_s) }
12
- end
13
-
14
- describe 'Calculate' do
15
- context 'With Fixnum' do
16
- it{ expect(pi + 0).to eq(pi) }
17
- it{ expect(pi - 0).to eq(pi) }
18
- it{ expect((pi * 0).to_s).to eq('0') }
19
- it{ expect(pi * 1).to eq(pi) }
20
- it{ expect{(pi / 0).to_s}.to raise_error(ZeroDivisionError) }
21
- it{ expect(pi / 1).to eq(pi) }
22
- it{ expect((pi ^ 0).to_s).to eq('1') }
23
- end
24
- end
25
- end
@@ -1,14 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dydx::Algebra::Set::Sin do
4
- it{ expect(sin(pi)).to eq(_(0)) }
5
-
6
- describe '#to_s' do
7
- it{ expect(sin(:x).to_s).to eq('sin( x )') }
8
- end
9
- describe '#differentiate' do
10
- it{ expect(sin(:x).d.to_s).to eq('cos( x )') }
11
- end
12
- describe 'Calculate' do
13
- end
14
- end
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Symbol do
4
- describe '#to_s' do
5
- it{ expect(:x.to_s).to eq('x') }
6
- end
7
- describe '#differentiate' do
8
- it{ expect(:x.d(:x).to_s).to eq('1') }
9
- end
10
- describe 'Calculate' do
11
- context 'With Fixnum' do
12
- it{ expect(:x + 0).to eq(:x) }
13
- it{ expect(:x - 0).to eq(:x) }
14
- it{ expect((:x * 0).to_s).to eq('0') }
15
- it{ expect(:x * 1).to eq(:x) }
16
- it{ expect{(:x / 0).to_s}.to raise_error(ZeroDivisionError) }
17
- it{ expect(:x / 1).to eq(:x) }
18
- it{ expect((:x ^ 0).to_s).to eq('1') }
19
- it{ expect(:x ^ 1).to eq(:x) }
20
- end
21
- end
22
- end
@@ -1,13 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Dydx::Algebra::Set::Tan do
4
- describe '#to_s' do
5
- it{ expect(tan(:x).to_s).to eq('tan( x )') }
6
- end
7
-
8
- describe '#differentiate' do
9
- end
10
-
11
- describe 'Calculate' do
12
- end
13
- end