dydx 0.1.4 → 0.1.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -3
  3. data/README.md +124 -61
  4. data/Rakefile +8 -5
  5. data/dydx.gemspec +13 -13
  6. data/lib/dydx.rb +25 -23
  7. data/lib/dydx/algebra.rb +76 -8
  8. data/lib/dydx/algebra/formula.rb +38 -71
  9. data/lib/dydx/algebra/inverse.rb +12 -19
  10. data/lib/dydx/algebra/operator/common_parts.rb +3 -0
  11. data/lib/dydx/algebra/operator/formula.rb +4 -0
  12. data/lib/dydx/algebra/operator/general.rb +4 -0
  13. data/lib/dydx/algebra/operator/inverse.rb +4 -0
  14. data/lib/dydx/algebra/operator/num.rb +4 -0
  15. data/lib/dydx/algebra/operator/parts/base.rb +2 -2
  16. data/lib/dydx/algebra/operator/parts/formula.rb +38 -63
  17. data/lib/dydx/algebra/operator/parts/general.rb +31 -84
  18. data/lib/dydx/algebra/operator/parts/interface.rb +22 -0
  19. data/lib/dydx/algebra/operator/parts/inverse.rb +4 -4
  20. data/lib/dydx/algebra/operator/parts/num.rb +11 -16
  21. data/lib/dydx/algebra/operator/parts/symbol.rb +2 -2
  22. data/lib/dydx/algebra/operator/symbol.rb +15 -0
  23. data/lib/dydx/algebra/set.rb +34 -271
  24. data/lib/dydx/algebra/set/base.rb +9 -0
  25. data/lib/dydx/algebra/set/cos.rb +22 -0
  26. data/lib/dydx/algebra/set/e.rb +16 -0
  27. data/lib/dydx/algebra/set/fixnum.rb +14 -0
  28. data/lib/dydx/algebra/set/float.rb +14 -0
  29. data/lib/dydx/algebra/set/log.rb +22 -0
  30. data/lib/dydx/algebra/set/num.rb +26 -0
  31. data/lib/dydx/algebra/set/pi.rb +16 -0
  32. data/lib/dydx/algebra/set/sin.rb +21 -0
  33. data/lib/dydx/algebra/set/symbol.rb +14 -0
  34. data/lib/dydx/algebra/set/tan.rb +17 -0
  35. data/lib/dydx/delta.rb +1 -1
  36. data/lib/dydx/function.rb +1 -1
  37. data/lib/dydx/helper.rb +61 -55
  38. data/lib/dydx/integrand.rb +10 -22
  39. data/lib/dydx/version.rb +1 -1
  40. data/spec/dydx_spec.rb +29 -10
  41. data/spec/lib/algebra/formula_spec.rb +38 -44
  42. data/spec/lib/algebra/operator/parts/base_spec.rb +5 -5
  43. data/spec/lib/algebra/operator/parts/formula_spec.rb +50 -57
  44. data/spec/lib/algebra/operator/parts/inverse_spec.rb +8 -8
  45. data/spec/lib/algebra/set/cos_spec.rb +18 -0
  46. data/spec/lib/algebra/set/e_spec.rb +27 -0
  47. data/spec/lib/algebra/set/fixnum_spec.rb +65 -0
  48. data/spec/lib/algebra/set/float_spec.rb +65 -0
  49. data/spec/lib/algebra/set/log_spec.rb +15 -0
  50. data/spec/lib/algebra/set/num_spec.rb +23 -0
  51. data/spec/lib/algebra/set/pi_spec.rb +25 -0
  52. data/spec/lib/algebra/set/sin_spec.rb +14 -0
  53. data/spec/lib/algebra/set/symbol_spec.rb +22 -0
  54. data/spec/lib/algebra/set/tan_spec.rb +13 -0
  55. data/spec/lib/delta_spec.rb +8 -32
  56. data/spec/lib/function_spec.rb +34 -60
  57. data/spec/lib/helper_spec.rb +49 -47
  58. data/spec/lib/integrand_spec.rb +15 -13
  59. data/spec/spec_helper.rb +1 -2
  60. metadata +39 -9
  61. data/.pryrc +0 -2
  62. data/.rubocop.yml +0 -25
  63. data/spec/lib/algebra/set_spec.rb +0 -263
@@ -0,0 +1,15 @@
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
@@ -0,0 +1,23 @@
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
@@ -0,0 +1,25 @@
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
@@ -0,0 +1,14 @@
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
@@ -0,0 +1,22 @@
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
@@ -0,0 +1,13 @@
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
@@ -1,35 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Dydx::Delta do
4
- it { expect(d.class).to eq(Delta) }
5
- it { expect(dx.class).to eq(Delta) }
6
- it { expect(dx.var).to eq(:x) }
7
- it { expect(dx(y).class).to eq(Delta) }
8
- it { expect(dx(y).var).to eq(:x) }
9
- it { expect(dx(y).function).to eq(:y) }
10
- it { expect { dxy }.to raise_error(NameError) }
11
-
12
- before { reset }
13
-
14
- it 'ex1' do
15
- $y = x ** n
16
- expect(dy/dx).to eq( n * ( x ** ( n - 1 ) ) )
17
- expect(d/dx($y)).to eq( n * ( x ** ( n - 1 ) ) )
18
- end
19
-
20
- it 'ex2' do
21
- $y = x ** (x * 2)
22
- expect(dy/dx).to eq(( 2 * x ) * ( x ** ( ( 2 * x ) - 1 ) ))
23
- expect(d/dx($y)).to eq(( 2 * x ) * ( x ** ( ( 2 * x ) - 1 ) ))
24
- end
25
-
26
- it 'ex3' do
27
- $y = (t ** 2) / 2
28
- expect(dy/dt).to eq(t)
29
- end
30
-
31
- it 'ex4' do
32
- $y = 2 * (e ** (2 * z))
33
- expect(dy/dz).to eq(4 * ( e ** ( 2 * z ) ))
34
- end
3
+ describe Dydx:Delta do
4
+ it{ expect(d.class).to eq(Delta) }
5
+ it{ expect(dx.class).to eq(Delta) }
6
+ it{ expect(dx.var).to eq(:x) }
7
+ it{ expect(dx(y).class).to eq(Delta) }
8
+ it{ expect(dx(y).var).to eq(:x) }
9
+ it{ expect(dx(y).function).to eq(:y) }
10
+ it{ expect{dxy}.to raise_error(NameError) }
35
11
  end
@@ -1,65 +1,39 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Dydx::Function do
4
- before { reset }
5
-
6
- it 'ex1' do
7
- expect(f(x, y)).to eq(f(x, y))
8
- expect(f(x, y)).to eq($f)
9
- expect(f(x, y).algebra).to be_nil
10
- expect(f(x, y).vars).to eq([:x, :y])
11
- expect { f(x, y, z) }.to raise_error(ArgumentError)
12
- expect { f(x) }.to raise_error(ArgumentError)
13
- end
14
-
15
- it 'ex2' do
16
- expect(f(x, y) <= x * y ).to eq(f(x, y))
17
- expect(f(x, y)).to eq(f(x, y))
18
- expect(f(x, y)).to eq($f)
19
- expect(f(x, y).algebra).to eq(x * y)
20
- expect(f(x, y)).to eq(x * y)
21
- expect(f(x, y)).to eq(eval(f(x, y).to_s))
22
- expect(f(a, b)).to eq(a * b)
23
- expect(f(2, x)).to eq(2 * x)
24
- expect(f(2, 3)).to eq(6)
25
- expect(f(a + b, c)).to eq((a + b) * c)
26
- expect(d/dx(f(x, y))).to eq(y)
27
- expect(d/dy(f(x, y))).to eq(x)
28
- expect(d/dz(f(x, y))).to eq(0)
29
- end
30
-
31
- it 'ex3' do
32
- f(x, y) <= x * y
33
- g(a, b) <= f(a + b, b)
34
- expect(g(a, b)).to eq((a + b) * b)
35
- expect(g(a, 3)).to eq(9 + 3 * a)
36
- expect(g(2, 3)).to eq(15)
37
- end
38
-
39
- it 'ex4' do
40
- f(a, b) <= (a + b) * b
41
- h(a, b, c) <= d/db(f(a, b))
42
- expect(h(a, b, c)).to eq(( a + ( 2 * b ) ))
43
- expect(h(a, b, c).algebra).to eq(( a + ( 2 * b ) ))
44
- end
45
-
46
- it 'ex5' do
3
+ describe Dydx:Function do
4
+ # TODO: refactor
5
+ it{ expect(f(x, y)).to eq(f(x, y)) }
6
+ it{ expect(f(x, y)).to eq($f) }
7
+ it{ expect(f(x, y).algebra).to be_nil }
8
+ it{ expect(f(x, y).vars).to eq([:x, :y]) }
9
+ it{ expect{f(x, y, z)}.to raise_error(ArgumentError) }
10
+ it{ expect{f(x)}.to raise_error(ArgumentError) }
11
+ it{ expect(f(x, y) <= x * y ).to eq(f(x, y)) }
12
+ it{ expect(f(x, y)).to eq(f(x, y)) }
13
+ it{ expect(f(x, y)).to eq($f) }
14
+ it{ expect(f(x, y).algebra).to eq(x * y) }
15
+ it{ expect(f(x, y)).to eq(x * y) }
16
+ it{ expect(eval(f(x, y).to_s)).to eq(f(x, y)) }
17
+ it{ expect(f(x, y)).to eq(eval(f(x, y).to_s)) }
18
+ it{ expect(f(a, b)).to eq(a * b) }
19
+ it{ expect(f(2, 3)).to eq(6) }
20
+ it{ expect(f(a + b, c)).to eq((a + b) * c) }
21
+ it{ expect(d/dx(f(x, y))).to eq(y) }
22
+ it{ expect(d/dy(f(x, y))).to eq(x) }
23
+ it{ expect(d/dz(f(x, y))).to eq(0) }
24
+
25
+ it{ expect(g(a, b) <= f(a + b, b)).to eq(g(a, b)) }
26
+ it{ expect(g(a, b)).to eq($g) }
27
+ it{ expect(g(2, 3)).to eq(15) }
28
+
29
+ it{ expect(h(a, b, c) <= d/db(g(a, b))).to eq(h(a, b, c)) }
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 ) + a )) }
32
+ it{ expect(h(a, b, c).algebra).to eq(( ( 2 * b ) + a )) }
33
+
34
+ it 'ex.4' do
35
+ $f = nil
47
36
  f(x) <= log(x)
48
- expect(f(e)).to eq(1)
49
- expect(f(0)).to eq(-oo)
50
- expect(f(y)).to eq(log(y))
51
-
52
- g(x) <= d/dx(f(x))
53
- expect(g(1)).to eq(1)
54
- end
55
-
56
- it 'ex6' do
57
- f(x) <= sin(x)
58
- expect(f(pi)).to eq(0)
59
- expect(f(pi / 2)).to eq(1)
60
- expect(f(y)).to eq(sin(y))
61
-
62
- g(x) <= d/dx(f(x))
63
- expect(g(pi)).to eq(-1)
37
+ expect(f(a)).to eq(log(a))
64
38
  end
65
39
  end
@@ -3,63 +3,65 @@ require 'spec_helper'
3
3
  describe Helper do
4
4
  include Helper
5
5
  context '#is_n?' do
6
- it { expect(0.zero?).to be true }
7
- it { expect(_(0).zero?).to be true }
8
- it { expect(inverse(0, :+).zero?).to be true }
9
- it { expect(1.one?).to be true }
10
- it { expect(_(1).one?).to be true }
11
- it { expect(inverse(1, :*).one?).to be true }
12
- it { expect(-1.minus1?).to be true }
13
- it { expect(_(-1).minus1?).to be true }
6
+ it{ expect(0.is_0?).to be_true }
7
+ it{ expect(_(0).is_0?).to be_true }
8
+ it{ expect(inverse(0, :+).is_0?).to be_true }
9
+ it{ expect(1.is_1?).to be_true }
10
+ it{ expect(_(1).is_1?).to be_true }
11
+ it{ expect(inverse(1, :*).is_1?).to be_true }
12
+ it{ expect(-1.is_minus1?).to be_true }
13
+ it{ expect(_(-1).is_minus1?).to be_true }
14
14
  end
15
15
 
16
- context '#multiple_of?' do
17
- it { expect(0.multiple_of?(x)).to be(true) }
16
+ context '#is_multiple_of' do
17
+ it{ expect(0.is_multiple_of(:x).to_s).to eq('0') }
18
+ it{ expect(_(0).is_multiple_of(:y).to_s).to eq('0')}
18
19
 
19
- it { expect(4.multiple_of?(_(2))).to be(true) }
20
- it { expect(_(4).multiple_of?(2)).to be(true) }
21
- it { expect(_(4).multiple_of?(_(2))).to be(true) }
20
+ it{ expect(:x.is_multiple_of(:x).to_s).to eq('1') }
21
+ it{ expect(:x.is_multiple_of(:y)).to be_false }
22
22
 
23
- it { expect(x.multiple_of?(x)).to be(true) }
24
- it { expect(x.multiple_of?(y)).to be(false) }
25
-
26
- it { expect((x * y).multiple_of?(x)).to be(true) }
27
- it { expect((x * y).multiple_of?(x)).to be(true) }
28
- it { expect((x * y).multiple_of?(z)).to be(false) }
29
- end
30
-
31
- context '#like_term?' do
32
- it { expect(x.like_term?(x)).to be true }
33
- it { expect((2 * x).like_term?((3 * x))).to be true }
23
+ it{ expect((:x * :y).is_multiple_of(:x)).to eq(:y) }
24
+ it{ expect((:x * :y).is_multiple_of(:y)).to eq(:x) }
25
+ it{ expect((:x * :y).is_multiple_of(:z)).to be_false }
34
26
  end
35
27
 
36
28
  context '#combinable?' do
37
- it { expect(:x.combinable?(:x, :+)).to be true }
38
- it { expect(:x.combinable?(2 * :x, :+)).to be true }
39
- it { expect((2 * :x).combinable?(:x, :+)).to be true }
40
- it { expect((2 * :x).combinable?(2 * :x, :+)).to be true }
41
- it { expect(:x.combinable?(:y, :+)).to be false }
42
- it { expect(1.combinable?(2, :+)).to be true }
43
- it { expect(:x.combinable?(:x, :*)).to be true }
44
- it { expect(:x.combinable?(:y, :*)).to be false }
45
- it { expect(1.combinable?(2, :*)).to be true }
46
- it { expect(0.combinable?(:x, :**)).to be true }
47
- it { expect(1.combinable?(:y, :**)).to be true }
29
+ it{ expect(:x.combinable?(:x, :+)).to be_true }
30
+ it{ expect(:x.combinable?(2 * :x, :+)).to be_true }
31
+ it{ expect((2 * :x).combinable?(:x, :+)).to be_true }
32
+ it{ expect((2 * :x).combinable?(2 * :x, :+)).to be_true }
33
+ it{ expect(:x.combinable?(:y, :+)).to be_false }
34
+ it{ expect(1.combinable?(2, :+)).to be_true }
35
+ it{ expect(:x.combinable?(:x, :*)).to be_true }
36
+ it{ expect(:x.combinable?(:y, :*)).to be_false }
37
+ it{ expect(1.combinable?(2, :*)).to be_true }
38
+ it{ expect(0.combinable?(:x, :^)).to be_true }
39
+ it{ expect(1.combinable?(:y, :^)).to be_true }
48
40
  end
49
41
 
50
42
  context '#distributive?' do
51
- it { expect(distributive?(:+, :*)).to be true }
52
- it { expect(distributive?(:+, :/)).to be true }
53
- it { expect(distributive?(:-, :*)).to be true }
54
- it { expect(distributive?(:-, :/)).to be true }
55
- it { expect(distributive?(:*, :**)).to be true }
56
- it { expect(distributive?(:/, :**)).to be true }
57
- it { expect(distributive?(:*, :+)).to be false }
58
- it { expect(distributive?(:**, :*)).to be false }
43
+ it{ expect(distributive?(:+, :*)).to be_true }
44
+ it{ expect(distributive?(:+, :/)).to be_true }
45
+ it{ expect(distributive?(:-, :*)).to be_true }
46
+ it{ expect(distributive?(:-, :/)).to be_true }
47
+ it{ expect(distributive?(:*, :^)).to be_true }
48
+ it{ expect(distributive?(:/, :^)).to be_true }
49
+ it{ expect(distributive?(:*, :+)).to be_false }
50
+ it{ expect(distributive?(:^, :*)).to be_false }
59
51
  end
60
52
 
61
- it { expect(inverse(x, :+).inverse?(:+, x)).to be true }
62
- it { expect(x.inverse?(:+, inverse(x, :+))).to be true }
63
- it { expect(inverse(x, :*).inverse?(:*, x)).to be true }
64
- it { expect(x.inverse?(:*, inverse(x, :*))).to be true }
53
+ let(:addition) { (:x + :y) }
54
+ let(:subtraction) { (:x - :y) }
55
+ let(:multiplication){ (:x * :y) }
56
+ let(:division) { (:x / :y) }
57
+ let(:exponentiation){ (:x ^ :y) }
58
+
59
+ it{ expect(addition.addition?).to be_true }
60
+ it{ expect(multiplication.multiplication?).to be_true }
61
+ it{ expect(exponentiation.exponentiation?).to be_true }
62
+
63
+ it{ expect(inverse(:x, :+).inverse?(:+, :x)).to be_true }
64
+ it{ expect(:x.inverse?(:+, inverse(:x, :+))).to be_true }
65
+ it{ expect(inverse(:x, :*).inverse?(:*, :x)).to be_true }
66
+ it{ expect(:x.inverse?(:*, inverse(:x, :*))).to be_true }
65
67
  end
@@ -1,29 +1,31 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Dydx::Integrand do
4
- before { reset }
3
+ describe Dydx:Integrand do
4
+ before(:each) do
5
+ reset
6
+ end
5
7
 
6
8
  it 'ex1' do
7
9
  f(x, y) <= x * y
8
10
  integrand = S(f(x, y), dx)
9
11
  expect(integrand.function).to eq(f(x, y))
10
12
  expect(integrand.var).to eq(:x)
11
- expect { integrand[4, 3] }.to raise_error(ArgumentError)
13
+ expect{integrand[4, 3]}.to raise_error(ArgumentError)
12
14
  end
13
15
 
14
16
  it 'ex2' do
15
17
  f(x) <= x * x
16
- expect(S(f(x), dx)[0, 1]).to eq(0.33333333)
18
+ expect(S(f(x), dx)[0, 1]).to eq(0.3333333333333334)
17
19
  end
18
20
 
19
21
  it 'ex3' do
20
22
  f(x) <= sin(x)
21
- expect(S(f(x), dx)[0, pi / 2]).to eq(1.0)
23
+ expect(S(f(x), dx)[0, Math::PI/2]).to eq(1.000000000021139)
22
24
  end
23
25
 
24
26
  it 'ex4' do
25
27
  f(x) <= cos(x)
26
- expect(S(f(x), dx)[0, pi]).to eq(0.0)
28
+ expect(S(f(x), dx)[0, Math::PI]).to eq(7.440786129085082e-17)
27
29
  end
28
30
 
29
31
  it 'ex5' do
@@ -32,20 +34,20 @@ describe Dydx::Integrand do
32
34
  end
33
35
 
34
36
  it 'ex6' do
35
- f(x) <= e ** -x ** 2
37
+ f(x) <= e ^ (- (x ^ 2))
36
38
  expect(f(0)).to eq(1)
37
- expect(f(1)).to eq(1.0 / Math::E)
39
+ expect(f(1)).to eq(1.0/Math::E)
38
40
  expect(f(1000)).to eq(0)
39
- expect(S(f(x), dx)[-1000, 1000, 3000]).to eq(1.77239273)
41
+ expect(S(f(x), dx)[-1000, 1000, 3000]).to eq(1.7724538506374117)
40
42
  end
41
43
 
42
44
  it 'ex7' do
43
- f(x) <= (1.0 / ( 2.0 * Math::PI ) ** 0.5) * e ** (- x ** 2 / 2)
44
- expect(S(f(x), dx)[-1000, 1000]).to eq(1.0)
45
+ f(x) <= (1.0 / ( ( 2.0 * Math::PI ) ^ 0.5 ) ) * ( e ^ (- (x ^ 2) / 2) )
46
+ expect(S(f(x), dx)[-1000, 1000, 1000]).to eq(0.9952054164466917)
45
47
  end
46
48
 
47
49
  it 'ex8' do
48
- f(x) <= (1.0 / ( 2.0 * Math::PI ) ** 0.5) * e ** (- x ** 2 / 2)
49
- expect(S(f(x), dx)[-oo, oo]).to eq(1.0)
50
+ f(x) <= (1.0 / ( ( 2.0 * pi ) ^ 0.5 ) ) * ( e ^ (- (x ^ 2) / 2) )
51
+ expect(S(f(x), dx)[-oo, oo, 1000]).to eq(0.9952054164466917)
50
52
  end
51
53
  end