Updated 2017-01-02 21:02:02 by gold

Old Babylonian Interest Rates and eTCL demo example calculator, numerical analysis  edit

This page is under development. Comments are welcome, but please load any comments in the comments section at the bottom of the page. Please include your wiki MONIKER in your comment with the same courtesy that I will give you. Its very hard to reply intelligibly without some background of the correspondent. Thanks,gold

gold Here is some eTCL starter code for Old Babylonian interest rates. Most of the testcases involve replicas or models, using assumptions and rules of thumb.

In the cuneiform coefficient lists and literature on clay tablets, there are coefficients which were used in determining the amount of materials, the daily work rates of the workers, and some interest rates problems. In most cases, the math problem is how the coefficient was used in estimating materials and work rates. One difficulty is determining the effective power of the coefficient in base 60. For example, 20 could represent either 20*3600,20,20/60, 20/3600, or even 1/20. The basic dimensions and final tallies were presented in the Sumerian accounts on clay tablets, but the calculations and some units were left off the tablet. At least one approach for the modern reader and using modern terminology is to develop the implied algebraic equations from the cuneiform numbers. Then the eTCL calculator can be run over a number of testcases to validate the algebraic equations.

From the cuneiform tablets, the common interest rate for temple or institutional silver was 1/5 or 12/60 per year (360 days), and converted to decimal 0.2 or 20 percent for the calculator . The rule of thumb was for silver to double in 5 years. The common interest rate including default debt obligations for barley or grain was 1/3 or 20/60 per year (360 days), and converted to decimal 0.333 or 33 percent for the calculator. The rule of thumb was for grain at 33.3 percent interest rate to double in 2 years. In some reigns, the harvest tax was 1/2 or 50 percent per annum and possibly listed as default debt interest on the books. In modern terms, the interest rates ranged from 20 to 50 percent. The Babylonian method or "algorithm" was find the total years to double the annual sum of principal and interest, raising the exponent for years of the annual sum to approximate for double or other multiple of the annual product, and interpolate the result for the years less months to double.

The Babylonians did not use interest rate in percent for their math problems, but it is worthwhile to compile some parallel results using either the rule of 70 or modern interest formulas. The rule of 70 for percent was doubling time was 70 / (100.*interest_rate_percent). Some modern texts refereed to the rule of 72 for easier fractions. Another modern formula using natural logs was doubling_time equals ln 2 / rate_fraction or mutiples_time equals ln N1/ rate_fraction.
# following statements can be pasted into eTCL console 
set rule_70_problem  [/ 70. [* 100. .20 ]]    #  3.5 years for doubling amount
set rule_70_problem  [/ 70. [* 100. .333 ]]   #   2.102 years for doubling amount
set rule_70_problem  [/ 70. [* 100. .50 ]]   #  1.4 years for doubling amount
set rule_70_problem  [/ 70. [* 100. .05 ]]    #  14.0 years for doubling amount
set ln_rule_problem  [/  [log 2. ]  [* 1.  .2 ] ]    #   3.4657 years for doubling amount
set ln_rule_problem  [/  [log 4. ]  [* 1.  .2 ] ]    #   6.931 years for 4X amount
set ln_rule_problem  [/  [log 2. ]  [* 1.  .333 ] ]    #   2.0815  years for doubling amount
set ln_rule_problem  [/  [log 4. ]  [* 1.  .333 ] ]    #   4.1630 years for 4X amount
set sum [+ 1. 0.2 ] # answer decimal 1.2
set months [* 12. [/ [- [** 1.2 4.  ] 2. ]    [- [** 1.2 4.  ]    [** 1.2 3.  ] ] ]]  # 2.555 less months of 30 days
set babylon_problem [**  1.2 3. ]  # answer decimal 1.7279
set babylon_problem2 [**  1.20  4. ]  # answer decimal 2.0736
set sumer_problem [**  [/ 4. 3. ] 7. ]  # answer decimal 7.49154

The answer for the first testcase was between 3 years for 1.7279 factor and 4 years for 2.0736 factor, see above eTCL statements. The Babylonian solution interpolated between 3 and 4 years for the factor of 2, giving the answer in months short of 4 years.For comparison, the modern lump sum formula for 20 percent at 3.8 years gives factor 1.99. The second testcase was finding the doubling time at 33 percent interest rate. The answer for the second testcase was between 2 years for 1.7689 factor and 3 years for 2.3526 factor. The Babylonian method would interpolate between 2 and 3 years for the factor of 2, giving the answer in months short of 3 years. For comparison, the modern lump sum formula for 33 percent at 2.488 years gives factor 1.908 .The third testcase was finding the doubling time 50 percent interest rate. The answer for the third testcase was between 1 year for 1.5 factor and 2 years for 2.25 factor. The Babylonian method would interpolate between 1 and 2 years for the factor of 2, giving the answer in months short of 2 years. For comparison, the modern lump sum formula for 50 percent interest at 1.7 years gives factor 1.992 .

Some testcases were developed to check the lump sum formula in the eTCL calculator. For fifth testcase, the modern lump sum formula for principal of 1 and 12 percent interest at 7 years gives amount of 7.5 .For sixth testcase, the modern lump sum formula for principal of 1000 and 15 percent interest at 3 years gives amount of 1520. For seventh testcase, the modern lump sum formula for principal of 1000 and 33 percent interest at 5 years gives amount of 4208.

Testcases Section

In planning any software, it is advisable to gather a number of testcases to check the results of the program. The math for the testcases can be checked by pasting statements in the TCL console. Aside from the TCL calculator display, when one presses the report button on the calculator, one will have console show access to the capacity functions (subroutines).

Testcase 1

table 1printed in tcl wiki format
quantity value comment, if any
testcase number:1
1.0 :principal
0.20 :interest rate decimal fraction
2.0 :doubling coefficient
4.0 :optional putative number of years
1.2 :annual principal times interest rate
2.0 :doubling coefficient
4 :years of 360 days
2.55 :less months of 30 days
3.787: years from 4-(2.555/12.)

Testcase 2

table 2printed in tcl wiki format
quantity value comment, if any
testcase number:2
1.0 :principal
0.333 :interest rate decimal fraction
2.0 :doubling coefficient
3.0 :optional putative number of years
1.333 :answers: annual principal plus interest amount
2.0 :doubling coefficient
3 :years of 360 days
7.47 :less months of 30 days
2.3775 : years from 3-(7.47/12.)

Testcase 33

table 3printed in tcl wiki format
quantity value comment, if any
testcase number:3
1.0 :principal
0.5 :interest rate decimal fraction
2.0 :doubling coefficient
2.0 :optional putative number of years
1.5 :answers: annual principal plus interest amount
2.0 :doubling coefficient
2 :years of 360 days
4. :less months of 30 days
1.66: years from 2-(4./12.)


Screenshots Section

figure 1.


References:

  • Oneliner's Pie in the Sky
  • One Liners
  • google < Babylonian Interest Rates Wikipedia >
  • Ancient Babylonian Algorithms, Donald E. Knuth, Stanford University
  • The oldest example of compound interest in Sumer, seventh power of four thirds (4/3)**7 , Kazuo MUROI
  • Interest, Price, and Profit: An Overview of Mathematical Economics in YBC 46981,
  • Robert Middeke-Conlin Christine Proust, CNRS and Université Paris Diderot
  • Compound Interest Doubling Time Rule: Extensions and Examples from Antiquities,
  • Saad Taha Bakir, ISSN: 2241 - 1968 (print), 2241 – 195X (online)
  • Two Sumerian Words of Fractions in Babylonian Mathematics: igi-n-gál and igi-te-en , Kazuo MUROI
  • O. Neugebauer and A. Sachs, Mathematical Cuneiform Texts, American Oriental Society, Series 29. New Haven, 1945.
  • K. Muroi, Interest Calculation in Babylonian Mathematics:
  • New Interpretations of VAT 8521 and VAT 8528, Historia Scientiarum, 39, (1990), 29-34
  • O. Nuegebauer, The Exact Sciences in Antiquity, Second edition, Dover Publication Inc., New York, 1969

Appendix Code edit

appendix TCL programs and scripts

        # pretty print from autoindent and ased editor
        # Old Babylonian Interest Rates calculator
        # written on Windows XP on eTCL
        # working under TCL version 8.5.6 and eTCL 1.0.1
        # gold on TCL WIKI, 15dec2016
        package require Tk
        package require math::numtheory
        namespace path {::tcl::mathop ::tcl::mathfunc math::numtheory }
        set tcl_precision 17
        frame .frame -relief flat -bg aquamarine4
        pack .frame -side top -fill y -anchor center
        set names {{} {principal  :} }
        lappend names {interest rate per annum, decimal fraction :}
        lappend names {doubling coeff.  : }
        lappend names {optional, years :}
        lappend names {answers: principal plus interest :}
        lappend names {doubling coeff: }
        lappend names {years total: }
        lappend names {less months:} 
        foreach i {1 2 3 4 5 6 7 8} {
            label .frame.label$i -text [lindex $names $i] -anchor e
            entry .frame.entry$i -width 35 -textvariable side$i
            grid .frame.label$i .frame.entry$i -sticky ew -pady 2 -padx 1 }
        proc about {} {
            set msg "Calculator for Old Babylonian Interest Rates 
            from TCL WIKI,
            written on eTCL "
            tk_messageBox -title "About" -message $msg } 
             proc double_function { principle doubling_coeff } {   
             set term_years 0
             set counter 0
             while { $counter < 50.  } {
             set term_years $counter
             if { [** $principle  $term_years ]   > $doubling_coeff } {break}            
             incr counter 
             }
             return $term_years  }  
       proc calculate {     } {
            global answer2
            global side1 side2 side3 side4 side5
            global side6 side7 side8 
            global modern_formula_lump
            global testcase_number 
            incr testcase_number 
            set side1 [* $side1 1. ]
            set side2 [* $side2 1. ]
            set side3 [* $side3 1. ]
            set side4 [* $side4 1. ]
            set side5 [* $side5 1. ]
            set side6 [* $side6 1. ]
            set side7 [* $side7 1. ]
            set side8 [* $side8 1. ]
            set principal $side1  
            set interest $side2 
            set optional_years $side4 
            set doubling_coeff $side3 
            set n [+ $principal [* $principal $interest ] ]
            set rate .2
            set solve_years [double_function $n $doubling_coeff ]
            set solve_years_minus1 [- $solve_years 1 ]
            #set months [expr 12*((1+$rate)**($n-2))/((1+$rate)**$n-(1+$rate)**($n-1))]
            #set months [* 12. [/ [- [** $n 4.  ] 2. ]    [- [** $n 4.  ]    [** $n 3.  ] ] ]]
            set months [* 12. [/ [- [** $n $solve_years  ] 2. ] [- [** $n $solve_years  ] [** $n $solve_years_minus1 ] ] ]]
      set modern_formula_lump [* $principal [** [+ 1. $interest] $optional_years ] ]
            set side5 $n
            set side6 $doubling_coeff 
            set side7 $solve_years
            set side8 $months
                    }
        proc fillup {aa bb cc dd ee ff gg hh} {
            .frame.entry1 insert 0 "$aa"
            .frame.entry2 insert 0 "$bb"
            .frame.entry3 insert 0 "$cc"
            .frame.entry4 insert 0 "$dd"
            .frame.entry5 insert 0 "$ee"
            .frame.entry6 insert 0 "$ff" 
            .frame.entry7 insert 0 "$gg"
            .frame.entry8 insert 0 "$hh" 
             }
        proc clearx {} {
            foreach i {1 2 3 4 5 6 7 8 } {
                .frame.entry$i delete 0 end } }
        proc reportx {} {
            global side1 side2 side3 side4 side5
            global side6 side7 side8
            global switch_factor 
            global modern_formula_lump
            global testcase_number
            console show;
            puts "%|table $testcase_number|printed in| tcl wiki format|% "
            puts "&| quantity| value| comment, if any|& "
            puts "&| testcase number:|$testcase_number | |&"
            puts "&| $side1 :|principal|   |&"
            puts "&| $side2 :|interest rate decimal fraction   | |& "  
            puts "&| $side3 :|doubling coefficient | |& "
            puts "&| $side4 :|optional number of years for lump sum| |&"
            puts "&| $modern_formula_lump :|modern formula lump sum| |&"
            puts "&| $side5 :|answers: annual principal plus interest amount | |&"
            puts "&| $side6 :|doubling coefficient   |  |&"
            puts "&| $side7 :|years of 360 days  |  |&"
            puts "&| $side8 :|less months of 30 days |  |&"                     
            }
        frame .buttons -bg aquamarine4
        ::ttk::button .calculator -text "Solve" -command { calculate   }
        ::ttk::button .test2 -text "Testcase1" -command {clearx;fillup 1.0 0.2  2.0 4.0  1.22  2.0 2.50 2.5}
        ::ttk::button .test3 -text "Testcase2" -command {clearx;fillup 1.0 0.333 2.0 3.0  1.33  2.0 3.00 7.5 }
        ::ttk::button .test4 -text "Testcase3" -command {clearx;fillup 1.0 0.5 2.0 2.0  1.33   2.0 2.00 4.0 }
        ::ttk::button .clearallx -text clear -command {clearx }
        ::ttk::button .about -text about -command {about}
        ::ttk::button .cons -text report -command { reportx }
        ::ttk::button .exit -text exit -command {exit}
        pack .calculator  -in .buttons -side top -padx 10 -pady 5
        pack  .clearallx .cons .about .exit .test4 .test3 .test2   -side bottom -in .buttons
        grid .frame .buttons -sticky ns -pady {0 10}
               . configure -background aquamarine4 -highlightcolor brown -relief raised -border 30
        wm title . "Old Babylonian Interest Rates Calculator"   

Pushbutton Operation

For the push buttons, the recommended procedure is push testcase and fill frame, change first three entries etc, push solve, and then push report. Report allows copy and paste from console.

For testcases in a computer session, the eTCL calculator increments a new testcase number internally, eg. TC(1), TC(2) , TC(3) , TC(N). The testcase number is internal to the calculator and will not be printed until the report button is pushed for the current result numbers. The current result numbers will be cleared on the next solve button. The command { calculate; reportx } or { calculate ; reportx; clearx } can be added or changed to report automatically. Another wrinkle would be to print out the current text, delimiters, and numbers in a TCL wiki style table as
  puts " %| testcase $testcase_number | value| units |comment |%"
  puts " &| volume| $volume| cubic meters |based on length $side1 and width $side2   |&"  

gold This page is copyrighted under the TCL/TK license terms, this license.

Comments Section edit

Please place any comments here, Thanks.