solver 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 494437a765172c4f950dc9f9b0d802b865bca747
4
- data.tar.gz: 9f8454f7e3891a57cadd13eaba761cf4e13aeaf9
3
+ metadata.gz: ee835df68fc47b2f1c1ffa6e69fd2d3c148322de
4
+ data.tar.gz: 51bed86526a4522ed62ac6d479e9bc150aae508a
5
5
  SHA512:
6
- metadata.gz: 9f152b61a7089fb97991f7624d97814f27a149b964f717e54ff397a942441beb0302d8dde8320015ee7445407ffaf6afbd3b45810a1f042bf0272372b3dc1f9b
7
- data.tar.gz: 94b62848a1e693e6b2a51d55f8a29bf3c6835ccdc60ef131cc50cb537cbf07f3ae285e5c9ed875be7d9632456c77b2ecce38d6c7124be29438d27393231bdd0a
6
+ metadata.gz: 1e264ceac538609f1c7071f437dbe2e482e768c25df2a703335c4b5f285abe1b84da0185ac958c75d4e693685cad645dd1bfc8a558000dca72e2504b3e112026
7
+ data.tar.gz: 1e9ec734d2966626d3080b0e8c0d061867b791c6d0964d7c83ecd123853db0462c681a883f61705d6649156ff009363d7c8210cd2aa75b758f2d6489271e79ce
data/README.md CHANGED
@@ -42,7 +42,7 @@ Let's define an equation to compute the *Time Value of Money* (i.e. compound int
42
42
  tvm_equation = ->(future_value, time, present_value, payment, interest, payments_per_year) {
43
43
  i = interest/100/payments_per_year
44
44
  n = -time
45
- k = (i + 1)**n # not the right way to compute it!
45
+ k = (i + 1)**n
46
46
  present_value + payment*(1-k)/i + future_value*k
47
47
  }
48
48
  ```
@@ -32,7 +32,7 @@ module Flt::Solver
32
32
  @var_descriptions
33
33
  end
34
34
 
35
- # Parameters:
35
+ # Parameters: (using cash-flow sign convention)
36
36
  # :t time in periods
37
37
  # :p number of periods per year
38
38
  # :i percent yearly interest rate
@@ -58,7 +58,11 @@ module Flt::Solver
58
58
  n = -t
59
59
  k = @context.exp(lnp1(i)*n) # (i+1)**n
60
60
  # Equation: -m*k = m0 + pmt*(1-k)/i
61
- m0 + pmt*(@one-k)/i + m*k
61
+ if i == 0 # TODO: with tolerance?
62
+ m0 + pmt*t + m # k == 1
63
+ else
64
+ m0 + pmt*(@one-k)/i + m*k
65
+ end
62
66
  end
63
67
 
64
68
  # ln(x+1)
@@ -1,5 +1,5 @@
1
1
  module Flt
2
2
  module Solver
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
@@ -40,6 +40,16 @@ class TestTVM < MiniTest::Unit::TestCase
40
40
  assert_in_delta @context.Num('331667.006691'), sol[:m], @delta
41
41
  end
42
42
 
43
+ should "work with zero interest" do
44
+ sol = @tvm.solve(:t=>240, :m0=>10000, :m=>0, :i=>0, :p=>12)
45
+ assert_equal [:pmt], sol.keys
46
+ assert_in_delta -10000.0/240, sol[:pmt], @delta
47
+
48
+ sol = @tvm.solve(:t=>240, :m0=>10000, :m=>-300, :i=>0, :p=>12)
49
+ assert_equal [:pmt], sol.keys
50
+ assert_in_delta -(10000.0-300)/240, sol[:pmt], @delta
51
+ end
52
+
43
53
  end
44
54
 
45
55
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Goizueta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-14 00:00:00.000000000 Z
11
+ date: 2019-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: flt
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  version: '0'
129
129
  requirements: []
130
130
  rubyforge_project:
131
- rubygems_version: 2.2.2
131
+ rubygems_version: 2.5.2.3
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: Numeric Solver using Flt