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 reasonably without some background of the correspondent. Thanks,gold
gold Here are some TCL calculations for math problems on Combined Market Rate. In modern algebraic notation, the conventional formula for combined market rate (CMR) equals N / (1/mr1 +1/mr2 +1/mr3...... +1/mr( N )), where mr are successive market rates from the first market rate mr1 to the Nth market rate. The units are not critical in the calculator internal math and any consistent input units and output units might be used like dollars to donuts.
A number of Babylonian math problems have been found on market rates and combined market rates, ref Friberg and Proust. The cuneiform word for “market rate” was mahirum, expressed in quantity per price, or usually quantity of oil , lard, or other product per shekel of silver. The market rate is the reciprocal of the market price as eval </ 1. market_price>. Here, the combined market rate of the combination of two or more market rates, effectively the reciprocal of the average price. Some of the problems seem directed towards calculating a combined market rate for a market basket of goods or stock on hand. Some of the problems are directed toward calculating profits in commodities like oil and lard from combined market rates. The Babylonian mathematicians are calculating the market prices, market rates, and unknowns in commodity markets that fluctuate in price over time. Including references to modern examples, buying different commodities and stocks at different prices over time may lead to combined market rate problems. Also, some combined market rate problems with unknowns may require solving 2 or more simultaneous linear equations. A related math method or comparable problem type is the combined work norms, as seen in some old Babylonian math problems. Several linguists have developed alternate theories or methods on the Babylonian solutions for combined market rate. The TCL calculator appears to be working as it stands. Would like to firm up concepts with some better testcases.
In the cuneiform math problems and coefficient lists on clay tablets, there are coefficient numbers which were used in determining the amount of materials and the daily work rates of the workers. In most cases, the math problem is how the coefficient was used in estimating materials, work rates, and math problems. One difficulty is determining the effective magnitude or power of the number coefficient in the base 60 notation. In cuneiform, numbers in base 60 are written using a relative notation. 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 cuneiform accounts on clay tablets, but some calculations, some units, some explanations, and some problem answers (aw shucks!) were left off the tablet. The Babylonians did not use algebra notation, decimal notation, or modern units, so the reader will have to bear some anachronisms in the initial pseudocode preparations and final TCL code. At least one approach for the modern reader and using modern terminology is to develop the implied algebraic equations and decimal equivalents from the cuneiform numbers. Then the TCL calculator can be run over a number of testcases to validate the algebraic equations.
Here is suggested application and tablet presentation for a market rate problem in method of summing base_60 reciprocals. A boy buys 12 apples for 60 cents at the market. Then on his street, the boy sells 3 apples for 20 cents, 3 apples for 10 cents, and 4 apples for 30 cents. The total sales on the street were lumped as 60 cents in jeans pocket. The boy has made a profit of <expr 12-(6+4)> or 2 apples. Compute the shares for each street sale using the Babylonian method of summing base_60 reciprocals. The base_60 reciprocals are computed in <expr 60/3> as 20, <expr 60/3> as 20, and <expr 60/4> as 15. The sum of the base_60 reciprocals is <expr 20+20+15> as 55/60. Further, the base_60 reciprocal of the sum is 60/55, used a multiplying factor. Share a is 20*(60/55) or 21.818. share b is 20*(60/55) or or 21.818, share c is 15*(60/55) or 16.36, using decimal notation here. The check answer is <expr 21.818 +21.818 +16.36 >=59.999 cents. For tablet presentation on the small hand tablets extant, the method of summing base_60 reciprocals is usually presented as 4 columns of 2 to 5 rows.
The extant hand tablets in math are small and are simply columns of numbers only, usually without headers. The TCL table format is suitable to display the mixed base_10 & base_60 numbers. In fact, the tables on clay tablets are the ancestors of the modern math tables and computer spreadsheets. To the basic core of decimal numbers, some labels and sums are added. The math tablets customarily list numbers in descending order of magnitude. In our tablet presentation, the large sale of 4 apples is listed first and not in chronological order. The larger and formal tablets may have line numbers, header labels, totals, numbers in margin, place, and signature, but not common or complete in school tablets.
table | Method of Summing base_60 Reciprocals | printed in | tcl format, mixed base_10 decimals & base_60 | ||
---|---|---|---|---|---|
line number | quantity | base_60 reciprocal | share | base_60 factor | comments, if any |
1 | 4 : | 15: | 16_22 | 60/55 | third street sale |
2 | 3 : | 20: | 21_49 | 60/55 | first street sale |
3 | 3 : | 20: | 21_49 | 60/55 | second street sale |
4 | 10 : | 55/60: | ~ 60 | sums | |
5 | year of King's victory | month 8 | day 2 | Elath the Scribe in Ishtar house | year, date,signature, and place, but not common at school |
A fuel pump at a grocery store has 4 fuels at marked prices for the day. What is the average price and combined market rate of the 4 fuels from hand calculator and the TCL calculator? The price data low octane gas ($1.81), medium octane gas ($2.08), medium octane gas ($2.33), and diesel $(2.09). The average price is eval </ <+ 1.81 2.08 2.33 2.09 > 4. > as $2.0775. The price of fuel is price over quantity as dollars per gallon. The market price of individual fuels is quantity over price as gallons per dollar. In other terms, the market price of individual fuels is the reciprocal of the price (1/price). The combined market price for the four fuels is </ 1. </ <+ </ 1. 0.5524> </ 1. 0.4807> </ 1. 0.42918 > </ 1. 0.47846> > 4. > > or 0.4813 gallons per dollar. As a check answer, the reciprocal of the combined market rate (1/0.4813) is the average price, $2.0775. Loading the reciprocals, the TCL calculator returned an average price of 2.0818 and combined_market_price of 0.4803. Given the inverse relationships of price, the alternate of loading the straight prices into the calculator returns price over quantity as 0.4852 and average market price as 2.061. The alternate of loading market prices is not an intended use of the calculator, but is an alternate check on the calculator.
There are Babylonian texts where two market rates for different quantities are straight added or subtracted. The term for market rate depending on the cuneiform language are mahirum or ganba (KI.LAM). In one problem, the market rate for oil was 8 silas per shekel and 10 sila per shekel; the given difference or profit was 2 sila per shekel. However, there was lack of a small currency in Mesopotamia. Most transactions in Ancient Mesopotamia were in kind and profits were based on the stock, oil, or grain on hand. or effectively the accounting value in barley measures. Lets construct a problem where the reciprocals of prices are easy fractions in base 60. In the constructed problem using a barrel (beriga) of 60 silas ( 1 sila=1 liter) , the merchant brought sesame oil for 12 silas per shekel (mr1) and sold for 10 sila per shekel (mr2) ; the given rate difference was {expr mr2-mr1} or 2 sila per shekel. The original price was 1/mr1, 1/12, or 4/60 shekel per sila. The selling price was 1/mr1, 1/10, or 6/60 shekel per sila. The merchant made a profit of {expr 6/60-4/60}, or 2/60 shekels per sila. Using the modern method of price calculation and following the Friberg derivation, Profit P1 equals Barrel_Capacity * (sell_Price_2 – buy_Price_1), Profit P1 equals Barrel_Capacity * (1/market_rate2 – 1/market_rate1). The profit on a barrel of sesame oil would be P=Barrel_Capacity*( 1/m2-1/m1), {expr 60 * (6/60-4/60)}, or 2 shekels. Using the original market rate, the profit can be expressed in kind as {expr 2*12 } or 24 sila of sesame oil.
Now as life complicates the affairs of the Babylonian merchant, suppose the merchant carries stocks of fine sesame oil and common palm oil, but deals with no silver currency. Now, profits must be measured in kind, oil stocks, or accounting values. There would be 4 market rates (m1&m2 for fine oil, mr1&mr2 for common oil. Lets keep the same market rates for the sesame oil as m1s of 12 and mr2s of 10, but add market rates for the common palm oil as mr1c of 15 and mr2c of 20. Considering the original market prices, the market price ratio of fine oil over common oil would be (1/mr1s)/(1/mr1c) or { expr (1./12)/(1./15)} , 1.25 decimal or 75/60 as a base 60 fraction. Using the same barrel for the common oil, the merchant found a loss of {expr 60*(20/60-15/60) }, or 5 silas of common oil. The loss was equivalent to {expr 5*60/75 } or 4 silas of fine oil. The Babylonians did not use positive and negative numbers in the tablet era, but the tablets do record equivalent of surplus product or deficit product as commonly oil or barley.
Following the Friberg derivation and modern algebra, 1) Price P1 equals market_price_1 and 2) Price P2 equals market_price_2. From the definitions above, Price P1 equals (1/market_rate_1) and Price P2 equals (1 / market_rate_2). For the relationship of P1 over P2, divide the equation as 1) over 2) which results in P1/P2 = (1/market_rate_1)/(1 / market_rate_2). Simplify terms as equation 3) P1 = (market_rate_2 / market_rate_1) * P2. Alternately, equation 4) would be P2= (market_rate_1 / market_rate_2)*P1, note inverse relationship. In terms of modern algebra, the Babylonian problem has at least one linear equation or linear relationship in equation 3) between P1 and P2, using the given market rates m1 and m2. In some Babylonian problems but not all, there is an additional statement that the Babylonian merchant brought equal amounts of P1 at rate m1 and P2 at rate m2 for one unit of currency. The given unit was a gin or 1/60 of shekel, a silver penny or silver mark. The equation setup is 5) total cost or 1 gin equals P1 + P2 or 1 = P1 + P2. Substituting the third equation 3) into the fifth equation 5), 1 = (market_rate_2 / market_rate_1) * P2 + P2. P2 = 1 / (market_rate_2 / market_rate_1 + 1.). Also, there are the findings that 6) P1 = 1-P2 or 7) P2 = 1-P1, in this case where total_cost equals 1. Equations 1) to 7) are the generic equations for a modern algebraic solution of the Babylonian market rates using 2 linear equations. However, there is no guarantee or problem solution in the texts of what method that the Babylonian mathematicians actually used.
In modern algebraic notation, the conventional formula for combined market rate (CMR) equals N / (1/mr1 +1/mr2 +1/mr3...... +1/mr( N )), where mr are successive market rates from the first market rate mr1 to the Nth market rate. In electrical engineering, the algebraic formula for joint resistance of 2 or more parallel resistors is exactly the same. If the reader will pardon a change in variables for joint resistance rp and resistors 1 to N in parallel (r1,r2,r3 etc), some convenient formulas for parallel resistors can be developed to match old textbooks, including the clay tablets. For 2 resistors in parallel, the first equation is 1) 1/rp =1/r1 + 1/r2. Inverting both sides and combining terms on the right gives 2) rp = (r1*r2)/(r1+r2). Solving for r1 and r2 alternately presents 3) r1= (r2*rp)/(r2-rp) and 4) r2= (r1*rp)/(r1-rp). For three resistors, the base equation is 5) 1/rp =1/r1 + 1/r2 + 1/r3. Inverting both sides and combining terms on the right gives 6) rp = (r1*r2*r3)/(r1*r2+r1*r3+r2*r3). The conventional formula for joint resistance rp equals N / (1/r1 +1/r2 +1/r3...... +1/r( N )), where r()'s are successive resistors from the first resistor r1 to the Nth resistor.
For evaluation of the market rates in tablet YBC 4698 (pm. 3, Proust) from the generic linear solution, the entries might be mr1=3 sila, mr2=12 sila, and total_price=1 gin. P2= (1/5) gin, or P2=12/60 gin as a base 60 fraction. P1= 4/5 gin, or P1=48/60 gin as a base 60 fraction. As a math check, the sum of 12/60 plus 48/60 = 1. It is suggested that the modern linear solutions are within +- 20 percent of the possible Babylonian solutions and base 60 round-off, but the complete answer was not found or given in the texts. From the Friberg and Proust paper(s), there is reason to believe the answer was not given, because the solution was inherent or commonly referenced to possible metrological tables or commodity price/rate standards (including law of Eshnunna, see Friberg). The Babylonians mostly used market rates and integer ratios for m1/m2 as limited integers under 30 (in base 60). A table of generic linear solutions from rational integer fractions could be constructed using a TCL subroutine. And if the right Babylonian math tablet could be found …
Now with the generic linear solution for a market rate problem, approximate TCL eval expressions, and the Friberg/Proust translations, we are better prepared to generate the market rate method and math expressions into a TCL subroutine using base 10. Joran Friberg has translated MS3895, a market rate problem which has 24 readable lines. In the MS3895, the Babylonian method is using math expressions in base 60, which the generic linear solution did not use. For example, the Babylonian method in tablet MS3895 is taking squares and there are other market rate expressions from other tablets, which are equivalent to (mr1+mr2)/2, (mr1-mr2)/2,((m1-m2)/2)**2, and mr1*mr2, ref Friberg and Proust. This report will use the modern conventions of algebraic notation , which can be entered into pseudocode or TCL expressions. The math expression (mr1 + mr2)/2 is a conventional average of two rates. The math expression (mr1 - mr2)/2 is a conventional half the difference of two rates. The math expression ((mr1 – mr2)/2)**2 is a square of half the difference of two rates. The math expression mr1*mr2 is the product of two rates, which are treated as an area in some texts. Some of these math expressions appear in Babylonian trapezoid formulas and possibly these market rate methods were adapted from trapezoid or trapezoidal prism formulas. While perhaps redundant to the Friberg and Proust findings in base 60 already, the intent to evaluate the alternate path of the MS3895 midstages and throw out the decimal base 10 expressions into a spreadsheet or table format for study. Since there are some tablets with incomplete or unreadable lines, there might be some advantage in reconstructing the decimal math expressions in the problem set up (program entry), midstage, and answers (program output).
Most of the testcases involve experiments or models, using assumptions, and rules of thumb. For the push buttons in the TCL calculator, 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 to conventional texteditor. For testcases in a computer session, the TCL 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 should be cleared either on the clear button or on the next solve button.
positive Numbers | |||
---|---|---|---|
table 1 | printed in | tcl format | |
quantity | value | comment, if any | |
1: | testcase_number | ||
0.1 : | aa quantity per silver piece | ||
0.2 : | bb quantity per silver piece | ||
0.3 : | cc quantity per silver piece | ||
0.4 : | dd quantity per silver piece | ||
0.0 : | ee quantity per silver piece: | ||
0.0 : | ff quantity per silver piece: | ||
5.2083 : | answers: combined_market_price, silver pieces per quantity: | ||
0.192 : | combined_market_rate, quantity per silver piece |
Mixed positive & negative N. | |||
---|---|---|---|
table 2 | printed in | tcl format | |
quantity | value | comment, if any | |
2: | testcase_number | ||
-0.1 : | aa quantity per silver piece | ||
-0.2 : | bb quantity per silver piece | ||
0.3 : | cc quantity per silver piece | ||
0.4 : | dd quantity per silver piece | ||
0.0 : | ee quantity per silver piece: | ||
0.0 : | ff quantity per silver piece: | ||
-2.2916 : | answers: combined_market_price, silver pieces per quantity: | ||
-0.4363 : | combined_market_rate, quantity per silver piece |
---
mixed zeros and Numbers | |||
---|---|---|---|
original CMR formula balks on unexpected zero's, div by zero | |||
table 3 | printed in | tcl format | |
quantity | value | comment, if any | |
3: | testcase_number | ||
0.1 : | aa quantity per silver piece | ||
0.0 : | bb quantity per silver piece | ||
0.0 : | cc quantity per silver piece | ||
0.2 : | dd quantity per silver piece | ||
0.3 : | ee quantity per silver piece: | ||
0.4 : | ff quantity per silver piece: | ||
5.2083 : | answers: combined_market_price, silver pieces per quantity: | ||
0.192 : | combined_market_rate, quantity per silver piece |
price data from grocery pump | ||
---|---|---|
from prices on pump | printed in | tcl wiki format |
1 / (fuel price) | fuel price | comment, if any |
market rate | dollars per gallon | |
0.5524 | 1.81 | regular gas |
0.4807 | 2.08 | midgrade gas |
0.42918 | 2.33 | premium gas |
0.47846 | 2.09 | diesel fuel |
Note. Dollar was originally a silver piece of one once |
fuel pump market rates in calculator | |||
---|---|---|---|
Original units, dollars per gallon & gallons per dollars | |||
table 4b | printed in | tcl format | |
quantity | value | comment, if any | |
4b: | testcase_number | ||
0.5524 : | aa quantity per silver piece | ||
0.4807 : | bb quantity per silver piece | ||
0.4292 : | cc quantity per silver piece | ||
0.4746 : | dd quantity per silver piece | ||
0.0 : | ee quantity per silver piece: | ||
0.0 : | ff quantity per silver piece: | ||
2.0818 : | answers: combined_market_price, silver pieces per quantity: | ||
0.4803 : | combined_market_rate, quantity per silver piece |
table 5 | printed in | tcl format | |
---|---|---|---|
quantity | value | comment, if any | |
5: | testcase_number | ||
3.0 : | market rate 1, quantity per silver piece: | ||
12.0 : | market rate 2, quantity per silver piece: | ||
1.0 : | total market price, usually silver pieces: | ||
0.80 : | answers, market price 1, usually silver pieces: | 48/60 gin in base 60 fraction | |
0.20 : | market price 2, usually silver pieces: | 12/60 gin in base 60 fraction | |
1.0 : | total market price 1&2, check, usually silver pieces: | calculated check on solution | |
36.0 : | rectangle_area: | ||
7.5 : | half_sum: | ||
4.5 : | half_diff: | ||
20.25 : | square_half_diff: | ||
0.2083 : | combined_market_price, silver pieces per quantity: | ||
4.8 : | combined_market_rate, quantity per silver piece |
table 6 | printed in | tcl format | |
---|---|---|---|
quantity | value | comment, if any | |
2: | testcase_number | MS2299,modified proc | |
3.0 : | aa quantity per silver piece | ||
4.0 : | bb quantity per silver piece | ||
5.0 : | cc quantity per silver piece | ||
6.0 : | dd quantity per silver piece | ||
0.0 : | ee quantity per silver piece: | ||
0.0 : | ff quantity per silver piece: | ||
check answer = 60.000 : | answers: sum of base_60 shares, check answer, usually 60: | ||
21.053 15.789 12.632 10.526 : | base_60 shares , fraction silver piece per share: |
table 7 | printed in | tcl format | |
---|---|---|---|
quantity | value | comment, if any | |
1: | testcase_number | MS2832,MS2830rev, modified proc , Friberg | |
1.0 : | aa quantity per silver piece | ||
2.0 : | bb quantity per silver piece | ||
3.0 : | cc quantity per silver piece | ||
4.0 : | dd quantity per silver piece | ||
0.0 : | ee quantity per silver piece: | ||
0.0 : | ff quantity per silver piece: | ||
check answer = 60.000 : | answers: sum of base_60 shares, check answer, usually 60: | ||
28.800 14.400 9.6000 7.2000 : | base_60 shares , fraction silver piece per share: |
table 8 | printed in | tcl format | |
---|---|---|---|
quantity | value | comment, if any | |
8: | testcase_number | MS2830rev,Friberg, modified proc | |
2.0 : | aa quantity per silver piece | ||
3.0 : | bb quantity per silver piece | ||
15.0 : | cc quantity per silver piece | ||
6.0 : | dd quantity per silver piece | ||
0.0 : | ee quantity per silver piece: | ||
0.0 : | ff quantity per silver piece: | ||
check answer = 60.000 : | answers: sum of base_60 shares, check answer, usually 60: | ||
28.125 18.750 3.7500 9.3750 : | base_60 shares , fraction silver piece per share: |
table 9 | printed in | tcl format | |
---|---|---|---|
quantity | value | comment, if any | |
5: | testcase_number | MS 2268/19, obv,Friberg, modified proc | |
3.5 : | aa quantity per silver piece | fraction from 3+30/60 | |
5.833 : | bb quantity per silver piece | fraction from 5+50/60 | |
7.0 : | cc quantity per silver piece | ||
7.5 : | dd quantity per silver piece | fraction from 7+30/60 | |
14.0 : | ee quantity per silver piece: | ||
0.0 : | ff quantity per silver piece: | ||
check answer = 60.000 : | answers: sum of base_60 shares, check answer, usually 60: | ||
21.302 12.781 10.651 9.9408 5.3254 : | base_60 shares , fraction silver piece per share: |
MS3895 initial entries are overspecified here | ||
---|---|---|
table 10 | printed in | tcl format |
quantity | value | comment, if any |
10: | testcase_number | |
90 : | capacity in oil silas: | decimal for 1_30 base_60, given |
6 : | profit in silver pieces: | given |
0.75 decimal : | mr1-mr2, sila per sheka: | given as 45/60 base_60 |
**** not given follows below **** | ||
3.75 decimal: | market rate 1, quantity per silver piece: | decimal for 3_45 base_60, not given follows |
3.0 : | market rate 2, quantity per silver piece: | not given |
24.0 : | total market price, usually silver pieces: | expr 90*(1/3.75)= 24.0 |
24. : | market price 1, usually silver pieces: | expr 90*(1/3.75)= 24.0 |
30. : | market price 2, usually silver pieces: | expr 90*(1/3.0)= 30.0 |
6.0 : | total profit, check, usually silver pieces: | expr 30-24 |
11.25 : | rectangle_area: | expr (3.)*(90./24) |
3.375 : | half_sum: | expr .5*(3.75+3) |
0.375 : | half_diff: | expr .5*(3.75-3) |
0.140625 : | square_half_diff: | expr (.5*(3.75-3))**2 |
1.666 : | combined_market_rate, quantity per silver piece |
Western trapezoid formulas and trapezoidal prism volume following includes algebraic expressions, terms, and notation not used on tablets side_aa refs top, t. on side side_bb refs bottom, t. on side side_cc refs height, t. on side median_length = .5*(side_aa+side_bb) trapezoid_area= 0.5*(side_aa+side_bb)*height trapezoid_area= median*height trapezoidal_prism_volume= t. vol=length*(0.5*(side_aa+side_bb))*height median divides equal side lengths Babylon market rate problems set up math expressions slant_deviation=(side_aa-side_bb)/height possibly set side_aa >? side_bb in Babylon??? generic linear solution for 2 market_rates 1) Price_P1 equals (1 / market_rate_1) 2) Price_P2 equals (1 / market_rate_2), divide equations 1) and 2) 3) P1 = (market_rate_2 / market_rate_1) * P2 4) P2= (market_rate_1 / market_rate_2)*P1 5) P1+P2=1 , set from problem in this case 6) P1 = 1-P2 or 7) P2 = 1-P1 equivalent math expressions from mr tablets average of two rates or t. median .5*(mr1+mr2) half the difference of two rates .5*(mr1-m2) possible trapezoid slant_deviation height?*(mr1-m2), mr1 >? mr2 square of half the difference of two rates (.5*(mr1-m2))**2 product of two rates, treated as area? mr1*mr2 dollar was originally a silver piece of one ounce
# pretty print from autoindent and ased editor # Babylonian Combined Market Rate calculator # written on Windows XP on TCL # working under TCL version 8.6 # gold on TCL Club, 10aug2018 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 {{} {aa quantity per silver piece :} } lappend names {bb quantity per silver piece:} lappend names {cc quantity per silver piece: } lappend names {dd quantity per silver piece: } lappend names {ee quantity per silver piece:} lappend names {ff quantity per silver piece: } lappend names {combined market price, silver pieces per quantity:: } lappend names {combined market rate, quantity per silver piece:} 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 Babylonian Combined Market Rate from TCL , # de on Facebook TCL Club, 10aug2018 " tk_messageBox -title "About" -message $msg } # adapted from tcl Stats 2011-05-22, arithmetic mean [RLE] # gold on TCL club # ::math::combined_market_rate -- # # Return the combined_market_rate by one,two, or more given rates # market rate defined as quantity per price # or 1 over (price per quantity) # # Arguments: # # args values are one, two, or more given rates # # Results: combined_market_rate # works for positive numbers, negative numbers, # and mixed positive & negative numbers. # arg of zero returns zero # arg of null returns zero # filter foreach drops irregular zero elements from argument proc ::math::combined_market_rate { args} { set sum 0. set N [ expr { [ llength $args ] } ] if { $N == 0 } { return 0 } if { $N == 1 || [ lindex $args 0 ] == 0 } { return 0 } set res {};set counter2 0; # filter foreach drops irregular zero elements foreach item $args {if {$item != 0 } {incr counter2 1; lappend res $item } } set counter 0 foreach val $res { set sum [ expr { $sum + 1./$val } ] incr counter 1 } set combined_market_rate1 [ expr { 1./(($sum*1.)/$counter2) } ] return $combined_market_rate1 } # various testcases on combined_market_rate # puts [::math::combined_market_rate 0.5524 0.4807 0.42918 0.47846 ] # answer 0.48131 " # puts [ ::math::combined_market_rate .1 .2 .3 .4 ] # answer 0.192 # ::math::combined_market_rate -.1 -.2 -.3 -.4 # answer -0.192, correct # operator math formula follows # check [/ 1. [/ [+ [/ 1. -.1] [/ 1. -.2] [/ 1. -0.3 ] [/ 1. -0.4] ] 4. ] ] # returns -0.192, correct # puts " [ ::math::combined_market_rate .1 ] " # :math::combined_market_rate -.1 -.2 .3 .4 # answer -0.4363636363636364 # operator math formula follows # set check [/ 1. [/ [+ [/ 1. -.1] [/ 1. -.2] [/ 1. 0.3 ] [/ 1. 0.4] ] 4. ] ] # check equals -0.4363636363636364 # puts " for (::math::combined_market_rates .1) # returns .1 " # ::math::combined_market_rate {} # null returns zero, correct. # ::math::combined_market_rate 0 # arg 0 returns zero, correct. # addition dated 24sep2018 # added filter foreach to remove zero's # irregular zeros, # test on zero's 0.1 0.0 0.0 0.2 0.3 0.4 # returns 0.192 , correct # test on zero's 0.1 0.0 0.0 0.2 0.3 0.4 # returns 0.192 , correct proc calculate { } { global answer2 global side1 side2 side3 side4 side5 global side6 side7 side8 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 lister { $side1 $side2 $side3 $side4 $side5 $side6 } set combined_market_rate5 1. set combined_market_rate5 [ ::math::combined_market_rate $side1 $side2 $side3 $side4 $side5 $side6] set combined_market_price5 [/ 1. $combined_market_rate5 ] set side7 $combined_market_price5 set side8 $combined_market_rate5 } 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 testcase_number console show; console eval {.console config -bg palegreen} console eval {.console config -font {fixed 20 bold}} console eval {wm geometry . 40x20} console eval {wm title . " Babylonian Combined Market Rate Report , screen grab and paste from console 2 to texteditor"} console eval {. configure -background orange -highlightcolor brown -relief raised -border 30} puts "%|table $testcase_number|printed in| tcl format|% " puts "&| quantity| value| comment, if any|& " puts "&| $testcase_number:|testcase_number | |&" puts "&| $side1 :|aa quantity per silver piece| |&" puts "&| $side2 :|bb quantity per silver piece | |& " puts "&| $side3 :|cc quantity per silver piece | |& " puts "&| $side4 :|dd quantity per silver piece| |&" puts "&| $side5 :|ee quantity per silver piece:| | |&" puts "&| $side6 :|ff quantity per silver piece:| | |&" puts "&| $side7 :|answers: combined_market_price, silver pieces per quantity:| | |&" puts "&| $side8 :|combined_market_rate, quantity per silver piece | |&" } frame .buttons -bg aquamarine4 ::ttk::button .calculator -text "Solve" -command { calculate } ::ttk::button .test2 -text "Testcase1" -command {clearx;fillup .1 .2 .3 .4 0. 0. 5.208 0.192} ::ttk::button .test3 -text "Testcase2" -command {clearx;fillup -0.1 -0.2 0.3 0.4 0. 0. -2.29 -.43636 } ::ttk::button .test4 -text "Testcase3" -command {clearx;fillup 0.1 0. 0. 0.2 0.3 0.4 5.208 0.192 } ::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 . "Babylonian Combined Market Rate Calculator" # This posting, screenshots, and TCL source code is # copyrighted under the TCL/TK 8.6 license terms. # Editorial rights and disclaimers retained # under the TCL/TK license terms. # and will be defended as necessary in court. # end of file
Notes on charts.small case from graphics tags. trapezoidal figure concept for Babylonian market rates. market rate mr equals quantity over price. market price equals price over quantity. sq area reps mr2 * silver sold capacity or sold in kind. median length equals .5*(mr1+mr5) . trapezoid area equals .5*(mr1+mr5)*base_length . median length equals .5*(mr1+mr5). trapezoidal prism vol equals .5*(mr1+mr5)*base_length*cross_length . cross_length median base_length deviation = b. deviation, ref modern slope = (mr1-mr2) / base_length. trapezoid shown erected here, Babylonian trapezoid terms may refer to horizontal trapezoid on side or other l/r mirror layout. base_length in silver or other value. tcl club trapezoidal figure concept for mr's. rectangular area reps (mr1-mr2) * silver profit capacity or profit in kind. cuneiform market rate derives from trade in kind includes capacity in jars of fine oil and bushels of barley. market rate mr equals quantity over price cuneiform market rate derives from trade in kind. .base_length in silver or other value trapezoid shown erected here, Babylonian trapezoid terms may refer to horizontal t. on side or other l/r mirror layout. market rate mr2 median length equals .5*(mr1+mr5). Babylonian deviation, ref modern slope = (mr1-mr2) / base_length. median length equals .5*(mr1+mr5). trapezoid area equals .5*(mr1+mr5)*base_length. trapezoidal prism vol equals .5*(mr1+mr5)*base_length*cross_length. sq area reps mr2 * silver sold capacity or sold in kind. rectangular area reps (mr1-mr2) * silver profit capacity or profit in kind profit in kind. rectangle mr1 - mr2 market price equals price over quantity. market rate mr2 Babylonian deviation, ref modern slope = (mr1-mr2) / base_length. trapezoid area equals .5*(mr1+mr5)*base_length. trapezoidal prism vol equals .5*(mr1+mr5)*base_length*cross_length. median length equals .5*(mr1+mr5). sq area reps mr2 * silver sold capacity or sold in kind (mr1-mr2) * silver. profit capacity or profit in kind rectangular area reps (mr1-mr2) * silver profit capacity or profit in kind. cuneiform market rate derives from trade in kind includes capacity in jars of fine oil and bushels of barley.
gold This page is copyrighted under the TCL/TK license terms, this license .
Please place any comments here, Thanks.