to your HTML Add class="sortable" to any table you'd like to make sortable Click on the headers to sort Thanks to many, many people for contributions and suggestions. Licenced as X11: http://www.kryogenix.org/code/browser/licence.html This basically means: do what you want with it. */ var stIsIE = /*@cc_on!@*/false; sorttable = { init: function() { // quit if this function has already been called if (arguments.callee.done) return; // flag this function so we don't do the same thing twice arguments.callee.done = true; // kill the timer if (_timer) clearInterval(_timer); if (!document.createElement || !document.getElementsByTagName) return; sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; forEach(document.getElementsByTagName('table'), function(table) { if (table.className.search(/\bsortable\b/) != -1) { sorttable.makeSortable(table); } }); }, makeSortable: function(table) { if (table.getElementsByTagName('thead').length == 0) { // table doesn't have a tHead. Since it should have, create one and // put the first table row in it. the = document.createElement('thead'); the.appendChild(table.rows[0]); table.insertBefore(the,table.firstChild); } // Safari doesn't support table.tHead, sigh if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; if (table.tHead.rows.length != 1) return; // can't cope with two header rows // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as // "total" rows, for example). This is B&R, since what you're supposed // to do is put them in a tfoot. So, if there are sortbottom rows, // for backwards compatibility, move them to tfoot (creating it if needed). sortbottomrows = []; for (var i=0; i

5' : ' ▴'; this.appendChild(sortrevind); return; } if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { // if we're already sorted by this column in reverse, just // re-reverse the table, which is quicker sorttable.reverse(this.sorttable_tbody); this.className = this.className.replace('sorttable_sorted_reverse', 'sorttable_sorted'); this.removeChild(document.getElementById('sorttable_sortrevind')); sortfwdind = document.createElement('span'); sortfwdind.id = "sorttable_sortfwdind"; sortfwdind.innerHTML = stIsIE ? '&nbsp6' : ' ▾'; this.appendChild(sortfwdind); return; } // remove sorttable_sorted classes theadrow = this.parentNode; forEach(theadrow.childNodes, function(cell) { if (cell.nodeType == 1) { // an element cell.className = cell.className.replace('sorttable_sorted_reverse',''); cell.className = cell.className.replace('sorttable_sorted',''); } }); sortfwdind = document.getElementById('sorttable_sortfwdind'); if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } sortrevind = document.getElementById('sorttable_sortrevind'); if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } this.className += ' sorttable_sorted'; sortfwdind = document.createElement('span'); sortfwdind.id = "sorttable_sortfwdind"; sortfwdind.innerHTML = stIsIE ? '&nbsp6' : ' ▾'; this.appendChild(sortfwdind); // build an array to sort. This is a Schwartzian transform thing, // i.e., we "decorate" each row with the actual sort key, // sort based on the sort keys, and then put the rows back in order // which is a lot faster because you only do getInnerText once per row row_array = []; col = this.sorttable_columnindex; rows = this.sorttable_tbody.rows; for (var j=0; j 12) { // definitely dd/mm return sorttable.sort_ddmm; } else if (second > 12) { return sorttable.sort_mmdd; } else { // looks like a date, but we can't tell which, so assume // that it's dd/mm (English imperialism!) and keep looking sortfn = sorttable.sort_ddmm; } } } } return sortfn; }, getInnerText: function(node) { // gets the text we want to use for sorting for a cell. // strips leading and trailing whitespace. // this is *not* a generic getInnerText function; it's special to sorttable. // for example, you can override the cell text with a customkey attribute. // it also gets .value for fields. hasInputs = (typeof node.getElementsByTagName == 'function') && node.getElementsByTagName('input').length; if (node.getAttribute("sorttable_customkey") != null) { return node.getAttribute("sorttable_customkey"); } else if (typeof node.textContent != 'undefined' && !hasInputs) { return node.textContent.replace(/^\s+|\s+$/g, ''); } else if (typeof node.innerText != 'undefined' && !hasInputs) { return node.innerText.replace(/^\s+|\s+$/g, ''); } else if (typeof node.text != 'undefined' && !hasInputs) { return node.text.replace(/^\s+|\s+$/g, ''); } else { switch (node.nodeType) { case 3: if (node.nodeName.toLowerCase() == 'input') { return node.value.replace(/^\s+|\s+$/g, ''); } case 4: return node.nodeValue.replace(/^\s+|\s+$/g, ''); break; case 1: case 11: var innerText = ''; for (var i = 0; i =0; i--) { tbody.appendChild(newrows[i]); } delete newrows; }, /* sort functions each sort function takes two parameters, a and b you are comparing a[0] and b[0] */ sort_numeric: function(a,b) { aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); if (isNaN(aa)) aa = 0; bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); if (isNaN(bb)) bb = 0; return aa-bb; }, sort_alpha: function(a,b) { if (a[0]==b[0]) return 0; if (a[0] 0 ) { var q = list[i]; list[i] = list[i+1]; list[i+1] = q; swap = true; } } // for t--; if (!swap) break; for(var i = t; i > b; --i) { if ( comp_func(list[i], list[i-1]) "); var script = document.getElementById("__ie_onload"); script.onreadystatechange = function() { if (this.readyState == "complete") { sorttable.init(); // call the onload handler } }; /*@end @*/ /* for Safari */ if (/WebKit/i.test(navigator.userAgent)) { // sniff var _timer = setInterval(function() { if (/loaded|complete/.test(document.readyState)) { sorttable.init(); // call the onload handler } }, 10); } /* for other browsers */ window.onload = sorttable.init; // written by Dean Edwards, 2005 // with input from Tino Zijdel, Matthias Miller, Diego Perini // http://dean.edwards.name/weblog/2005/10/add-event/ function dean_addEvent(element, type, handler) { if (element.addEventListener) { element.addEventListener(type, handler, false); } else { // assign each event handler a unique ID if (!handler.$$guid) handler.$$guid = dean_addEvent.guid++; // create a hash table of event types for the element if (!element.events) element.events = {}; // create a hash table of event handlers for each element/event pair var handlers = element.events[type]; if (!handlers) { handlers = element.events[type] = {}; // store the existing event handler (if there is one) if (element["on" + type]) { handlers[0] = element["on" + type]; } } // store the event handler in the hash table handlers[handler.$$guid] = handler; // assign a global event handler to do all the work element["on" + type] = handleEvent; } }; // a counter used to create unique IDs dean_addEvent.guid = 1; function removeEvent(element, type, handler) { if (element.removeEventListener) { element.removeEventListener(type, handler, false); } else { // delete the event handler from the hash table if (element.events && element.events[type]) { delete element.events[type][handler.$$guid]; } } }; function handleEvent(event) { var returnValue = true; // grab the event object (IE uses a global event object) event = event || fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event); // get a reference to the hash table of event handlers var handlers = this.events[event.type]; // execute each event handler for (var i in handlers) { this.$$handleEvent = handlers[i]; if (this.$$handleEvent(event) === false) { returnValue = false; } } return returnValue; }; function fixEvent(event) { // add W3C standard event methods event.preventDefault = fixEvent.preventDefault; event.stopPropagation = fixEvent.stopPropagation; return event; }; fixEvent.preventDefault = function() { this.returnValue = false; }; fixEvent.stopPropagation = function() { this.cancelBubble = true; } // Dean's forEach: http://dean.edwards.name/base/forEach.js /* forEach, version 1.0 Copyright 2006, Dean Edwards License: http://www.opensource.org/licenses/mit-license.php */ // array-like enumeration if (!Array.forEach) { // mozilla already supports this Array.forEach = function(array, block, context) { for (var i = 0; i St = eval(form.St1.value); // Level of sexual tension between you. M = eval(form.M2.value); // Are either of you married? C = eval(form.C3.value); // Chance that the rest of the office will discover your liaison. F = eval(form.F4.value); // Chance of getting fired if caught. J = eval(form.J5.value); // How much do you like/need your job? // Calculate values Getiton = Math.pow(H+St,2) - M*J/5*Math.pow(C+F,2); // Your Office Hookup Index Score (Hey, this is Garth Sundem's variable name!) if (Getiton > 0) Output = "Repress yourself no longer. Just don't forget to get your work done too!"; // Threshold Response Comment = Output; // The Bottom Line // Output Calculated Values to Form form.Getiton.value = decimalFP(Getiton, 2); form.Comment.value = Comment; } // End officeHookup function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function leadingPolls(form) { // Convert Input Variables to Numeric Values N = eval(form.N0.value); // How many people were polled? Lead = eval(form.Lead1.value); // What percentage of those polled favor the candidate who appears to be leading? Lag = eval(form.Lag2.value); // What percentage of those polled favor the other main candidate in the race? // Calculate values P = Lead/(Lead + Lag); // Sample Proportion StdE = Math.sqrt(P*(1-P))/Math.sqrt(N); // Standard Error of Proportion Z = (0.5 - P)/(Math.sqrt(2)*StdE); // Standardized Value // Error Function (REF: http://mathworld.wolfram.com/NormalDistribution.html) ERF = Z - 1/3*Math.pow(Z,3) + 1/10*Math.pow(Z,5) - 1/42*Math.pow(Z,7); ERF += 1/216*Math.pow(Z,9) - 1/1320*Math.pow(Z,11) + 1/9360*Math.pow(Z,13) - 1/75600*Math.pow(Z,15) ERF += 1/685440*Math.pow(Z,17) - 1/6894720*Math.pow(Z,19) + 1/76204800*Math.pow(Z,21); ERF *= 2/Math.sqrt(Math.PI); // Probability that the Leading Candidate is Actually Leading in the Race Pr = (1 - 1/2*(1+ERF))*100; // Output Calculated Values to Form form.Pr.value = decimalFP(Pr, 1) + "%"; } // End leadingPolls function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function pctChangeAndCAGR(form) { // Constants DpY = 365.25; // Days per Year MpY = 12; // Months per Year // Convert Input Variables to Numeric Values oldValue = eval(form.oldValue0.value); // Older or Starting Value newValue = eval(form.newValue1.value); // Newer or Ending Value y = eval(form.y2.value); // Number of Elapsed Years m = eval(form.m3.value); // Number of Elapsed Months d = eval(form.d4.value); // Number of Elapsed Days // Calculate values elapsedTime = y + m/MpY + d/DpY; // Elapsed Time (Years) totPctChange = (newValue - oldValue)/oldValue*100; // Total Percentage Change Over Elapsed Time [%] cagr = (Math.pow(newValue/oldValue,1/elapsedTime) - 1)*100; // Annualized Rate of Change [%] // Output Calculated Values to Form form.totPctChange.value = decimalFP(totPctChange, 2) + "%"; form.cagr.value = decimalFP(cagr, 2) + "%"; } // End pctChangeAndCAGR function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function nistHahn (a, b, c, d, e, f, g, x) { // This function will return the result of the NIST Hahn function. nH = (a + b*x + c*Math.pow(x,2) + d*Math.pow(x,3)) / (1.0 + e*x + f*Math.pow(x,2) + g*Math.pow(x,3)); return nH; } // End function nistHahn // //-------|---------|---------|---------|---------|---------|---------|---------| // function agi2005profile(agi, maxIncome, span) { // Set Constants for Income Distribution var a = new Array(1761041.00000016, -10377792727.7977, 1.08759782605846E+20, -70721926.2948904, -63233010245570200000); var b = new Array(1279.19999255219, -71145266609.2926, -16180638574021700, 9203.60673605414, 736390534441309); var c = new Array(0.223609286125466, 58909189.8184725, 791944795062.82, -0.0978215449736087, 72526415975.2507); var d = new Array(-0.000020039643727956, -3151.03871394421, -12657376.2169752, 9.86243457750862E-07, 6093.33008157282); var e = new Array(2.55047483327087E-05, 19106.3963915829, -56363752.7975733, 5.56971037887439E-05, 6504089.09496658); var f = new Array(-4.1309856734027E-09, -0.91456278128234, 4877.21734804562, -6.6274789370825E-10, 546.917093174911); var g = new Array(-1.02954992556153E-13, -1.05575190691649E-05, -0.103256816745442, 7.37160179315225E-15, 4.59485738633583E-05); // Set initial values topIncDist = maxIncome; // Upper Limit of 2005 Income Distribution [2006 USD] if (agi >= topIncDist) agi = topIncDist-span/2; lI = agi - span/2; // Low End of Adjusted Gross Income Range hI = agi + span/2; // High End of Adjusted Gross Income Range cR = 0; // Default Cumulative Number of Tax Returns // Calculate Number of Returns and Aggregate Income within Income Range $0 through $28038.50 if (agi = 14100 && agi 28038.50 && agi 31629.50 && agi 206408.60) { cRH = nistHahn(a[4],b[4],c[4],d[4],e[4],f[4],g[4],hI); // Cumulative Total of Returns at High End of Income Range Increment cRL = nistHahn(a[4],b[4],c[4],d[4],e[4],f[4],g[4],lI); // Cumulative Total of Returns at Low End of Income Range Increment cR = nistHahn(a[4],b[4],c[4],d[4],e[4],f[4],g[4],agi); // Cumulative Total of Returns for AGI } // End If statement. } // End agi2005profile function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function agi2005distribution(form) { // Convert Input Variables to Numeric Values agi = eval(form.agi0.value); // Household Adjusted Gross Income [2006 USD] // Perform calculations agi2005profile(agi, 142000000, 100); nR = cRH - cRL; aI = agi*nR; // Output Calculated Values to Form form.cR.value = decimalFP(cR, 0); form.nR.value = decimalFP(nR, 4); form.aI.value = decimalFP(aI, 2); } // End agi2005distribution function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function diyMarginalTaxBrackets(i,lTR,lCO,mTR,mCO,uTR,uCO,tTR,tCO) { // This function will calculate the effective tax rate for a given income // and a given tax rate schedule. The Super Tax rate allows an easy way to // set up a special tax rate that begins at a given income level. If that // income level is $0, then it sets up a flat tax. If the tax rate is 0%, // and the income level is above $0, then it sets up a taxable income cap. // If both tax rate and income level is above zero, then it sets up a single // tax rate that applies above the entered income level. tR = lTR/100; // Set Default (Minimum) Tax Rate if (i = uCO) tR = uTR/100; // Set Upper Tax Rate if (i = mCO) tR = (uTR - (uCO - i)/(uCO - mCO)*(uTR - mTR))/100; // Set Upper-Middle Tax Rates if (i = lCO) tR = (mTR - (mCO - i)/(mCO - lCO)*(mTR - lTR))/100; // Set Middle-Lowest Tax Rates if (i >= tCO) tR = tTR/100; // Set Super Tax Rate return tR; } // End diyMarginalTaxBrackets function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function diyTaxBrackets(form) { // Convert Input Variables to Numeric Values agi = eval(form.agi00.value); // Household Adjusted Gross Income [$USD] minTR = eval(form.minTR0.value); // Lowest Tax Rate [%] minCO = eval(form.minCO1.value); // Income Level at which Lowest Tax Rate Ends [$USD] midTR = eval(form.midTR2.value); // Middle Tax Rate [%] midCO = eval(form.midCO3.value); // Income Level at which Middle Tax Rate Begins [$USD] uppTR = eval(form.uppTR4.value); // Upper Tax Rate [%] uppCO = eval(form.uppCO5.value); // Income Level at which Upper Tax Rate Begins or Ends [$USD] maxTR = eval(form.maxTR6.value); // Maximum Tax Rate [%] maxCO = eval(form.maxCO7.value); // Income Level at which Maximum Tax Rate Begins or Ends [$USD] // Calculate values for blank entries. if (maxTR==null) maxTR = uppTR; // Set maximum income tax rate if (maxCO==null) maxCO = 142000000-50; // Set maximum income tax rate income threshold if (midTR==null) midTR = (uppTR + minTR)/2; // Set middle income tax rate if (midCO==null) midCO = (uppCO + minCO)/2; // Set middle income tax rate income threshold // Calculate basic tax rate taxRate = diyMarginalTaxBrackets(agi, minTR, minCO, midTR, midCO, uppTR, uppCO, maxTR, maxCO); // Output Calculated Values to Form form.taxRate.value = decimalFP(taxRate*100, 2); } // End diyTaxBrackets function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function exemptions2005dist(inc) { // This function approximates the number of exemptions per tax return per income, // given for 2005 with incomes adjusted to 2006 U.S. dollars. exLowIncome = 61919.5046; exHighIncome = 103199.1744; a = 2.8679179964540102E+00; b = 2.8569898236993878E+00; c = 2.4271892733074372E-03; d = 5.9718033459503084E-01; e = 1.2907163004685194E+00; f = -9.6812748705432296E+03; g = -1.6103260485364628E-02; if (inc exLowIncome && inc = exHighIncome) { exemptions = Math.exp(e + (f/inc) + g*Math.log(inc)); } if (inc > 100*exHighIncome) { exemptions = Math.exp(e + (f/(100*exHighIncome)) + g*Math.log(100*exHighIncome)); } return exemptions; } // End exemptions2005dist function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function numberExemptions2005(form) { // Convert Input Variables to Numeric Values agi = eval(form.agi00.value); // Household Adjusted Gross Income // Calculate values number = exemptions2005dist(agi); // Number of Exemptions at Given Income Level // Output Calculated Values to Form form.number.value = decimalFP(number, 2); } // End numberExemptions2005 function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function porkDividendYield(form) { // Convert Input Variables to Numeric Values D = eval(form.D0.value); // Campaign Contributions (or "Dividend" Payments) P = eval(form.P1.value); // Value of Pork Earmark (or "Share Price") // Calculate values DY = D/P*100; // Earmark (Pork) Dividend Yield // Output Calculated Values to Form form.DY.value = decimalFP(DY, 3) + "%"; } // End porkDividendYield function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function porkBarrel(form) { // This function will project the growth of the number of pork barrel projects // inserted into the U.S. federal government's annual Highway Spending Bill // Convert Input Variables to Numeric Values Y = eval(form.Year0.value); // Year // Calculate values P = 0.8766*Math.pow(Math.E, 0.1715*(Y-1956)); // Number of Earmarks (Pork Barrel Spending Projects) // Output Calculated Values to Form form.P.value = decimalFP(P, 0); } // End porkBarrel function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function electoralBarometer(form) { // Convert Input Variables to Numeric Values NAR = eval(form.NAR0.value); // Current President's Net Approval Rating [%] GDP = eval(form.GDP1.value); // Annual Growth Rate of Gross Domestic Product (GDP) [%] // Calculate values EB = NAR + 5*GDP - 25; // Electoral Barometer Score // Output Calculated Values to Form form.EB.value = decimalFP(EB, 2); } // End electoralBarometer function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function gasPriceChangeImpact(form) { // Convert Input Variables to Numeric Values Distance = eval(form.Distance0.value); // Distance You Typically Drive Every Year [miles] avgMPG = eval(form.avgMPG1.value); // Your Vehicle's Average Mileage [miles per gallon] gasPriceChange = eval(form.gasPriceChange2.value); // Year Over Year Change in the Price of Gas [pennies per gallon] // Calculate values gallonsPerYear = Distance/avgMPG; // Number of Gallons You Consume Every Year [gallons] annualGasPriceChangeCost = gallonsPerYear*gasPriceChange/100; // Yearly Change in How Much You Spend on Gas [$USD] monthlyGasPriceChangeCost = annualGasPriceChangeCost/12; // Monthly Change in How Much You Spend on Gas [$USD] weeklyGasPriceChangeCost = annualGasPriceChangeCost/52; // Weekly Change in How Much You Spend on Gas [$USD] dailyGasPriceChangeCost = annualGasPriceChangeCost/365; // Daily Change in How Much You Spend on Gas [$USD] // Output Calculated Values to Form form.gallonsPerYear.value = decimalFP(gallonsPerYear, 1); form.annualGasPriceChangeCost.value = decimalFP(annualGasPriceChangeCost, 2); form.monthlyGasPriceChangeCost.value = decimalFP(monthlyGasPriceChangeCost, 2); form.weeklyGasPriceChangeCost.value = decimalFP(weeklyGasPriceChangeCost, 2); form.dailyGasPriceChangeCost.value = decimalFP(dailyGasPriceChangeCost, 2); } // End gasPriceChangeImpact function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function driveSlowerOrFaster(form) { // Constants HRtoMIN = 60; // Hours to Minutes Conversion Factor MINtoHR = 1/60; // Minutes to Hours Conversion Factor // Fuel Efficiency vs Speed Profile Coefficients a = 1.7958548967067761E-01; b = 3.1905668571657685E-02; c = 1.9172288354088723E-03; d = -1.5833989643139232E-04; e = 4.1879432158348568E-06; f = -4.8759694423159525E-08; g = 2.1014644323600956E-10; // Convert Input Variables to Numeric Values DD = eval(form.D0.value); // Trip Distance [miles] PP = eval(form.P1.value); // Gasoline Price [$USD/gallon] M1 = eval(form.M12.value); // Typical Mileage Your Car Gets on Trip [mpg] S1 = eval(form.S13.value); // Your Normal Driving Speed for Trip [mph] S2 = eval(form.S24.value); // Speed You'd Consider Driving for Trip [mph] // Calculate Percentage of Maximum Fuel Efficiency, Normal Speed E1 = a + b*Math.pow(S1,1) + c*Math.pow(S1,2) + d*Math.pow(S1,3) + e*Math.pow(S1,4) + f*Math.pow(S1,5) + g*Math.pow(S1,6); // Percentage of Maximum Fuel Efficiency, Alternate Speed E2 = a + b*Math.pow(S2,1) + c*Math.pow(S2,2) + d*Math.pow(S2,3) + e*Math.pow(S2,4) + f*Math.pow(S2,5) + g*Math.pow(S2,6); // Calculate remaining values T1 = DD/S1*HRtoMIN; // Time to Drive, Normal Speed [minutes] T2 = DD/S2*HRtoMIN; // Time to Drive, Alternate Speed [minutes] DT = T2 - T1; // Time Difference [minutes] G1 = DD/M1; // Fuel Consumed, Normal Speed [gallons] G2 = DD/(M1*E2/E1); // Fuel Consumed, Alternate Speed [gallons] DG = G2 - G1; // Fuel Consumption Difference [gallons] C1 = PP*G1; // Fuel Cost, Normal Speed [$USD] C2 = PP*G2; // Fuel Cost, Alternate Speed [$USD] DC = C2 - C1; // Fuel Cost Difference [$USD] EQP = PP*G2/G1; // Equivalent Cost of Gallon of Gas Consumed (Compared to Normal Driving Speed) EQM = -1*DC/(DT*MINtoHR); // Difference in Money Spent per Hour of Driving MPG2 = M1*E2/E1; // Approximate Mileage at Alternate Speed [mpg] // Output Calculated Values to Form form.T1.value = decimalFP(T1, 2); form.T2.value = decimalFP(T2, 2); form.DT.value = decimalFP(DT, 2); form.G1.value = decimalFP(G1, 2); form.G2.value = decimalFP(G2, 2); form.DG.value = decimalFP(DG, 2); form.C1.value = decimalFP(C1, 2); form.C2.value = decimalFP(C2, 2); form.DC.value = decimalFP(DC, 2); form.EQP.value = decimalFP(EQP, 3); form.EQM.value = decimalFP(EQM, 2); form.MPG2.value = decimalFP(MPG2, 2); } // End driveSlowerOrFaster function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function moveClosertoWork(form) { // Constants SYMCTW = "No, it isn't beneficial to move closer to work."; // Default Response // Convert Input Variables to Numeric Values G = eval(form.P0.value); // Price of One Gallon of Gasoline [$USD per gallon] M = eval(form.M1.value); // Mileage Your Vehicle Gets During Your Commute [miles per gallon] R = eval(form.R2.value); // Amount of Your Current Rent or Mortgage Payment [$USD] D1 = eval(form.D13.value); // Current One Way Distance for Commuting to Work [miles] C = eval(form.C4.value); // Amount of Rent or Mortgage Payment at New Residence [$USD] D2 = eval(form.D25.value); // One Way Distance for New Commute to Work [miles] CD = eval(form.CD.value); // Number of Days You Commute to Work Each Week WW = eval(form.WW.value); // Number of Weeks You Work Each Year // Calculate values if (D2=="") D2 = D1; // Set D2 to be same as D1 if left blank CACC = WW*CD*G*D1*2/M; // Your Current Annual Commuting Cost FACC = WW*CD*G*D2*2/M; // Your Annual Commuting Cost from Your New Residence DACC = FACC - CACC; // Difference in Commuting Costs [Positive if Higher] DR = (C - R)*12; // Difference in Annual Rent or Mortgage Payments [Positive if Higher] TD = DACC + DR; // Total Difference in Costs [Positive if Higher] if (TD Well in College D = eval(form.D1.value); // Have You Ever Toured with a Rock Band? G = eval(form.G2.value); // Current Number of Romantic Partners S = eval(form.S3.value); // Marital Status M = eval(form.M4.value); // Dollar Amount of Frivolous IRS Deductions per Year B = eval(form.B5.value); // Number of Offshore or Swiss Bank Accounts R = eval(form.R6.value); // Number of Times Family Member Has Been to Rehab N1 = eval(form.N1.value); // Religion N2 = eval(form.N2.value); // Family N3 = eval(form.N3.value); // Sex N4 = eval(form.N4.value); // Golf N5 = eval(form.N5.value); // Honesty N6 = eval(form.N6.value); // Vacation Time N7 = eval(form.N7.value); // Personal Appearance N8 = eval(form.N8.value); // Speaking Your Mind N9 = eval(form.N9.value); // Your Name on a Library N0 = eval(form.N0.value); // The Good of the Proletariat // Calculate values N = N1 + N6 + N4 + N7 + N9; Run = (S*N - Math.pow((S-2)*(G-1),2))/C/D/(M/100+B+R+1); // Your Candidate Index Factor if (Run >= 1) { Comment = "Fire up the spin machine, you're ready to kick off your campaign this week! "; Comment += "It's time to start courting donations from lobbyists and to put underlings "; Comment += "to work deciding what you believe! "; } Comment = Comment; // The Bottom Line // Output Calculated Values to Form form.Run.value = decimalFP(Run, 2); form.Comment.value = Comment; } // End runForOffice function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function expectedRateInflation(form) { // Convert Input Variables to Numeric Values M = eval(form.M0.value); // Average Growth Rate of Money Supply [%] E = eval(form.E1.value); // Income Elasticity of Money G = eval(form.G2.value); // Annualized Growth of Real GDP [%] // Calculate values I = M - E*G; // Expected Rate of Inflation [%] // Output Calculated Values to Form form.I.value = decimalFP(I, 2); } // End expectedRateInflation function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function appraisedIdeaValue(form) { // Convert Input Variables to Numeric Values P = eval(form.P0.value); // Possible Profit Value [$USD] I = eval(form.I1.value); // Probability of Being Implemented (%) C = eval(form.C2.value); // Cost of Implementing Idea [$USD] // Calculate values V = P*I/100 - C; // Value of the Idea // Output Calculated Values to Form form.V.value = decimalFP(V, 2); } // End appraisedIdeaValue function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function hoursOfSportsWatching(form) { // Convert Input Variables to Numeric Values L = eval(form.L0.value); // Hours spent (or will spend) with her today watching Sleepless in Seattle, strolling hand in hand, or similar V = eval(form.V1.value); // Generally, how volatile is she? (1-10 with 10 being "Vesuvius") Sy = eval(form.Sy2.value); // In the past week, how many hours have you spent watching sporting events? Sh = eval(form.Sh3.value); // For how many of these hours did she enjoy watching sports with you? I = eval(form.I4.value); // Importance of today's sporting event (1-10 with one being "first round Jai alai qualifiers" and 10 being "Super Bowl") R = eval(form.R5.value); // Your current standing in the relationship (1-10 with 10 being "at last night's candle-lit dinner, you gave her a diamond necklace" and one being "over last night's TV dinner, you gave her a Red Sox beer opener") // Calculate values Playball = Math.sqrt(3*(L + 1)/V*(Sh + 2)/(Sy + 2)*Math.abs((R*R -5*R + 1)/Math.sqrt(11 - I))); // Maximum Number of Hours Of Sports Intake // Output Calculated Values to Form form.Playball.value = decimalFP(Playball, 2); } // End hoursOfSportsWatching function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function estimatedDEHouseAppreciation(form) { // Constants STEP = 1; // Default Iterative Increment // Initialize Arrays var PP = new Array(); var Q11 = new Array(); // Convert Input Variables to Numeric Values P = eval(form.P0.value); // Sale Price of Delaware Real Estate [$USD] Q1 = form.Q11.selectedIndex; // Year-Quarter for Given House Sale Q2 = form.Q22.selectedIndex; // Year-Quarter for which to Estimate Value of Property // Populate Q11 Array with Delaware State Average Annualized Rate of House Appreciation for(i=0; i Q2) STEP=2; // Step Direction switch (STEP) { case 1: for (i=Q1+1; i=Q2; i--) { PP[i] = PP[i+1]/Math.pow(Q11[i+1], .25); } // End For Statement. EPV = PP[Q2]; break; default: EPV = P; } // End Switch statement. // Output Calculated Values to Form form.EPV.value = decimalFP(EPV, 2); } // End estimatedDEHouseAppreciation function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function estimatedCHIHouseAppreciation(form) { // Constants STEP = 1; // Default Iterative Increment // Initialize Arrays var PP = new Array(); var Q11 = new Array(); // Convert Input Variables to Numeric Values P = eval(form.P0.value); // Sale Price of Delaware Real Estate [$USD] Q1 = form.Q11.selectedIndex; // Year-Quarter for Given House Sale Q2 = form.Q22.selectedIndex; // Year-Quarter for which to Estimate Value of Property NP = eval(form.NP3.value); // Neighborhood Premium [%] // Populate Q11 Array with Delaware State Average Annualized Rate of House Appreciation for(i=0; i Q2) STEP=2; // Step Direction switch (STEP) { case 1: for (i=Q1+1; i=Q2; i--) { PP[i] = PP[i+1]/Math.pow(Q11[i+1], .25); } // End For Statement. EPV = PP[Q2]; break; default: EPV = P; } // End Switch statement. // Output Calculated Values to Form form.EPV.value = decimalFP(EPV, 2); } // End estimatedCHIHouseAppreciation function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function balanceSheetDynamics(form) { // Default Solvency IS = "Yes."; // Convert Input Variables to Numeric Values GA1 = eval(form.GA10.value); // Good Assets GAA = eval(form.GAA1.value); // Increase Amount of Good Assets BA1 = eval(form.BA12.value); // Bad Assets BAA = eval(form.BAA3.value); // Amount of Bad Assets to Write Off CCL1 = eval(form.CCL14.value); // Liabilities to Customers/Counterparties CCLA = eval(form.CCLA5.value); // Amount of Liabilities to Convert to Equity CBD1 = eval(form.CBD16.value); // Debt Owed to Corporate Bondholders CBDA = eval(form.CBDA7.value); // Amount of Bondholder Debt to Convert to Equity // Calculate values TA1 = GA1 + BA1; // Initial Total Assets GA2 = GA1 + GAA; // Good Assets BA2 = BA1 - BAA; // Bad Assets TA2 = GA2 + BA2; // Total Assets (Equal to Total Liabilities) CCL2 = CCL1-CCLA; // Liabilities to Customers/Counterparties CBD2 = CBD1 - CBDA; // Debt Owed to Company Bondholders OE1 = TA1 - CCL1 - CBD1; // Initial Owner's Equity OE2 = TA2 - CCL2 - CBD2; // Owner's (Shareholder's) Equity HC = CCLA/CCL1*100; // Haircut on Debt TL2 = TA2; // Total Liabilities (Equal to Total Assets) DM = TA2 - TA1; // Amount of Money Destroyed (Negative Value) or Created (Positive Value) LR = (CCL2+CBD2)/OE2; // Leverage Ratio if (LR > 1 && OE2 > 0) IS = "Yes, but overleveraged."; if (OE2 0) issue = 1; // Firm Issued Long Term Debt in Year of Interest if (D108Y0 > 0) issue = 1; // Firm Issued Common or Preferred Stock in Year of Interest ch_earn = D18Y0/ATAY0 - D18Y1/ATAY1; // Change in Earnings ch_cs = (D12Y0 - CRY0)/(D12Y1 - CRY1) - 1; // Change in Cash Sales ch_inv = CIY0/ATAY0; // Change in Inventories ch_rec = CRY0/ATAY0; // Change in Receivables rsst_acc = ((D216Y0-(D01Y0+D01Y0A)-D130Y0) - (D216Y1-(D01Y1+D01Y1A)-D130Y1))/ATAY0; // RSST Accruals formula = A + B*rsst_acc + C*ch_rec + D*ch_inv + E*ch_cs + F*ch_earn + G*issue; // Mathematical Model acct_Pr = Math.exp(formula)/(1 - Math.exp(formula)); // Probability of Accounting Manipulation FScore = acct_Pr/UnProb; // F-Score // F-Score // Output Calculated Values to Form form.FScore.value = decimalFP(FScore, 2); } // End accountingManipulations function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function ficoCreditDefaultRate(form) { // Constants AA = 1.01017877900721; // Coefficient AA BB = 578.624870282080; // Coefficient BB CC = -56.6322665794772; // Coefficient CC DD = -0.00865048235207434; // Coefficient DD // Convert Input Variables to Numeric Values FICO = eval(form.FICO0.value); // Your FICO Score [Between 300 and 850] // Calculate values CDR = sigmoid(AA, BB, CC, DD, FICO)*100; // Probability of Defaulting on Credit // Output Calculated Values to Form form.CDR.value = decimalFP(CDR, 1) + "%"; } // End ficoCreditDefaultRate function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function additionalTimeWorth(form) { // Constants MINtoHR = 60; // Minutes to Hour Conversion // Convert Input Variables to Numeric Values MIN = eval(form.MIN0.value); // Number of Minutes Saved By Buying vs Making COST = eval(form.COST1.value); // Additional Cost of Buying vs Making // Calculate values CPH = MINtoHR/MIN*COST; // Effective Cost per Hour of Having Someone Else Do the Work // Output Calculated Values to Form form.CPH.value = decimalFP(CPH, 2); } // End additionalTimeWorth function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function taxProposals2008(form) { // Constants CINCENT = "Yes"; // Default Increased Incentive Response RINCENT = "Yes"; // Default Increased Incentive Response DINCENT = "Yes"; // Default Increased Incentive Response // Convert Input Variables to Numeric Values CITR = eval(form.CITR0.value)/100; // Current Highest Income Tax Rate [%] CCGD = eval(form.CCGD1.value)/100; // Current Capital Gains and Dividend Tax Rate [%] CMSS = eval(form.CMSS2.value)/100; // Current Medicare & Social Security Tax Rate [%] CETR = eval(form.CETR3.value)/100; // Current Estate Tax Rate [%] CCIT = eval(form.CCIT4.value)/100; // Current Corporate Income Tax Rate [%] RITR = eval(form.RITR0.value)/100; // McCain Highest Income Tax Rate [%] RCGD = eval(form.RCGD1.value)/100; // McCain Capital Gains and Dividend Tax Rate [%] RMSS = eval(form.RMSS2.value)/100; // McCain Medicare & Social Security Tax Rate [%] RETR = eval(form.RETR3.value)/100; // McCain Estate Tax Rate [%] RCIT = eval(form.RCIT4.value)/100; // McCain Corporate Income Tax Rate [%] DITR = eval(form.DITR0.value)/100; // Obama Highest Income Tax Rate [%] DCGD = eval(form.DCGD1.value)/100; // Obama Capital Gains and Dividend Tax Rate [%] DMSS = eval(form.DMSS2.value)/100; // Obama Medicare & Social Security Tax Rate [%] DETR = eval(form.DETR3.value)/100; // Obama Estate Tax Rate [%] DCIT = eval(form.DCIT4.value)/100; // Obama Corporate Income Tax Rate [%] R = eval(form.R5.value)/100; // Rate of Return on Corporate Capital Before Taxes [%] T = eval(form.T6.value); // Length of Investing Period in Years [or Remaining Life Expectancy] // Calculate values CFVC = (1-(CITR+CMSS))*Math.pow((1+R*(1-CCIT)*(1-CCGD)),T)*(1-CETR); // Current Future Value of Each Dollar Earned and Invested Today By End of Investing Period RFVC = (1-(RITR+RMSS))*Math.pow((1+R*(1-RCIT)*(1-RCGD)),T)*(1-RETR); // Mccain Future Value of Each Dollar Earned and Invested Today By End of Investing Period DFVC = (1-(DITR+DMSS))*Math.pow((1+R*(1-DCIT)*(1-DCGD)),T)*(1-DETR); // Current Future Value of Each Dollar Earned and Invested Today By End of Investing Period PFVC = CFVC/CFVC*100; // Current Percentage of Future Value Earned and Invested Compared to Current Law PFVR = RFVC/CFVC*100; // McCain Percentage of Future Value Earned and Invested Compared to Current Law PFVD = DFVC/CFVC*100; // Obama Percentage of Future Value Earned and Invested Compared to Current Law if (PFVC form.elements.length-start) { FR = form.elements.length-start-1; // Set to first record if time extends outside available data. } // Date Calculations beginDate = SP500R[SR].month + "-" + SP500R[SR].year; // Beginning Date of Investments ATBDate = SP500R[ATBR].month + "-" + SP500R[ATBR].year; // Date of All Time Bottom for Stock Market endDate = SP500R[FR].month + "-" + SP500R[FR].year; // Ending Date of Investments // Calculations for All Time Bottom // Time Between Dates [Years] ATBTime = (SP500R[ATBR].YYYY + SP500R[ATBR].MM/12) - (SP500R[SR].YYYY + SP500R[SR].MM/12); for (i=SR; i= 1) OUTPUT = "Whatever magic you might have thought you had to get there without stopping is long gone. Go find a gas station!"; // Alter feedback given user input data comment = OUTPUT; // The Bottom Line // Output Calculated Values to Form form.G.value = decimalFP(G, 2); form.comment.value = comment; } // End stopToGetGas function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function payingForStuffWithoutWorking(form) { // Convert Input Variables to Numeric Values C = eval(form.C0.value); // One Year Cost of Stuff You Want to Buy R = eval(form.R1.value); // Annual Rate of Return on Investment [%] T = eval(form.T2.value); // Estimated Tax Rate [%] I = eval(form.I3.value); // Annual Rate of Inflation [%] // Calculate values R = R/100; // Decimalized Interest Rate T = T/100; // Decimalized Tax Rate I = I/100; // Decimalized Inflation Rate ST = C*(1+T); // Needed Savings Adjusted for Taxes SI = ST*(1+I); // Needed Annual Passive Income (Adjusted for Taxes and Inflation) Savings = SI/R; // Amount Needed to Support Desired Spending // Output Calculated Values to Form form.SI.value = decimalFP(SI, 2); form.Savings.value = decimalFP(Savings, 2); } // End payingForStuffWithoutWorking function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function weddingGuest(form) { // Convert Input Variables to Numeric Values A = eval(form.A.value); // Are they a member of you or your fiancee's immediate family? B = eval(form.B.value); // Are they a member of you or your fiancee's extended family? C = eval(form.C.value); // How many years have either you or your fiancee known them? D = eval(form.D.value); // How many years has it been since either you or your fiancee heard from them? E = eval(form.E.value); // Is it someone that either you or your fiancee never met? F = eval(form.F.value); // Do either you or your fiancee like them? G = eval(form.G.value); // Does your fiancee dislike them? H = eval(form.H.value); // Do you expect that they'll give you a nice gift? I = eval(form.I.value); // Do they expect to be invited? J = eval(form.J.value); // Are they part of a group of people who could be (but do not expect to be) invited? K = eval(form.K.value); // Have they been endorsed by someone subsidizing your wedding? L = eval(form.L.value); // Are they a former significant other for you or your fiancee? M = eval(form.M.value); // Are they mutual friends of both you and your fiancee? N = eval(form.N.value); // Are they members of the opposite sex who are not friends of both you and your fiancee? O = eval(form.O.value); // Did they congratulate you promptly when you announced your engagement? P = eval(form.P.value); // Did they congratulate you on Facebook (or MySpace, etc.) and that was the first you've heard from them in years? Q = eval(form.Q.value); // Were you invited to their wedding? R = eval(form.R.value); // Did you go to their wedding? S = eval(form.S.value); // Do you suspect that they might try to make out with your mother (or other important guest) in a drunken stupor at the reception? // Calculate values Z = A+B+C-D+E+F+G+H+I+J+K+L+M+N+O+P+Q+R+S; // Potential Guest Ranking Score // Output Calculated Values to Form form.Z.value = Z; } // End weddingGuest function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function profitabilityBuyRent(form) { // Default values. Profit = "It's better to rent." // Convert Input Variables to Numeric Values R = eval(form.R0.value); // Annual Rental Payment B = eval(form.B1.value); // Cost of Buying A = eval(form.A2.value); // Net Rate of Appreciation [%] I = eval(form.I3.value); // Cost of Money [%] // Calculate values RR = R/B*100; // Rental Rate PP = RR + A - I; // Profitability [%] if (PP >= 0) Profit = "It's better to buy!"; // If Profitability is positive, set choice to prefer to buy. OUT = Profit; // The Bottom Line // Output Calculated Values to Form form.PP.value = decimalFP(PP, 2)+"%"; form.OUT.value = OUT; } // End profitabilityBuyRent function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function profitabilityStimulus(form) { // Convert Input Variables to Numeric Values B = eval(form.B0.value); // Amount of "Stimulus" Spending A = eval(form.A1.value); // Economic Growth Rate I = eval(form.I2.value); // 30-Year Treaasury Yield Rate P = eval(form.P3.value); // Profitability // Calculate values R = B*(P - A + I)/100; // Increased Amount of Tax Collections // Output Calculated Values to Form form.R.value = decimalFP(R, 0); } // End profitabilityStimulus function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function probabilityDistanceTraveled(form) { // Constants mileTOkm = 1.609344; // Mile to Kilometer Conversion Factor K = 350; // Typical Upper Boundary of Travel Distance for Sample BR = 1.65; // Exponent RG0 = 5.8; // Reference (Typical) Distance Travelled by Individual [km] // Convert Input Variables to Numeric Values RG = eval(form.RG0.value); // Distance Travelled by Individual [miles] // Calculate values RG = RG*mileTOkm; // Convert Entered Distance from Miles to Kilometers, Adjust for Typical Distance Travelled PR = Math.pow(RG + RG0, -BR)*Math.exp(-RG/K)*100; // Probability of Travelling Specific Distance // Output Calculated Values to Form form.PR.value = decimalFP(PR, 4)+"%"; } // End probabilityDistanceTraveled function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function starbucksLatteHomeVSAway(form) { // Set Default Comments Profit = "It's better to get your lattes from Starbucks!"; // Convert Input Variables to Numeric Values H = eval(form.H0.value); // Cost to Make a Caffè Latte at Home S = eval(form.S1.value); // Cost to Buy a Caffè Latte at Starbucks N = eval(form.N6.value); // Number of Caffè Lattes per Year CUP = eval(form.CUP2.value); // Rate of Inflation for Caffè Latte at Starbucks [%] POD = eval(form.POD3.value); // Rate of Inflation for Verismo Caffè Latte Pods [%] B = eval(form.B4.value); // Cost of a Starbucks Verismo Brewer I = eval(form.I5.value); // Cost of Money (Credit Card Interest Rate) [%] // Calculate values R = (S - H)*N; // Cost Difference per Unit Between Buying Lattes or Making Them RR = R/B*100; // Rental Rate A = CUP - POD; // Net Price Inflation for Latte at Starbucks vs Pods at Home PP = RR + A - I; // Profitability [%] if (PP > 0) Profit = "It's better to make your lattes at home!"; // OUT = Profit; // The Bottom Line // Output Calculated Values to Form form.PP.value = decimalFP(PP, 1); form.OUT.value = OUT; } // End starbucksLatteHomeVSAway function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function insulinDosePrototype01(form) { // Convert Input Variables to Numeric Values CBS = eval(form.CBS0.value); // Your Current Blood Sugar Reading TBS = eval(form.TBS1.value); // Your Target Blood Sugar Reading Level CARBS = eval(form.CARBS2.value); // Your Carbohydrate Intake [grams] CIRatio = eval(form.CIRatio3.value); // Your Ratio of Carbohydrates to Insulin Units EXERCISE = eval(form.EXERCISE4.value); // Your Expected Level of Physical Activity RED = eval(form.PointsReducedperDose.value); // Blood Sugar Point Reduction per Insulin Unit // Calculate values DBS = CBS - TBS; // Difference in Blood Sugar BSL = DBS/RED; // Units to Accommodate Blood Sugar Level CARBINTAKE = CARBS/CIRatio; // Units to Accommodate Carbohydrate Intake DOSAGE = BSL + CARBINTAKE - EXERCISE; // Number of Insulin Units for Dosage // Output Calculated Values to Form form.DOSAGE.value = decimalFP(DOSAGE, 1); } // End insulinDosePrototype01 function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function instapunditPostGenerator(form) { // Constants H = "HEH"; // Hypertext P = "."; // Period AS = ""; // Hypertext Link Middle Component AE = ""; // Hypertext Link Ending Component // Convert Input Variables to Numeric Values L = form.L0.value; // Type or Copy and Paste URL Here // Calculate values PostLink = AS + L + AM + H + AE + P; // Hypertext // Output Calculated Values to Form form.PostLink.value = PostLink; } // End instapunditPostGenerator function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function kitovDemographicInflation(form) { // Convert Input Variables to Numeric Values LF2Year = eval(form.LF2Year0.value); // Year of More Recent Annual Civilian Labor Force Data LF2 = eval(form.LF21.value); // Annual Civilian Labor Force for Year Indicated [thousands] LF1 = eval(form.LF12.value); // Previous Year's Civilian Labor Force [thousands] LAG = eval(form.LAG3.value); // Observed Labor Force-Inflation Change Time Lag [years] m = eval(form.m4.value); // Country Specific Multiplier [Equivalent of Slope] b = eval(form.b5.value); // Country Specific Base [Equivalent of y-Intercept] // Calculate values InflationRate = (m*(LF2-LF1)/LF2 + b)*100; // Projected Rate of Inflation [%] Year = Math.round(LF2Year+LAG,0); // Year for Projection // Output Calculated Values to Form form.InflationRate.value = decimalFP(InflationRate, 1) + "%"; form.Year.value = Year; } // End kitovDemographicInflation function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function USPopGDPDebt(form) { // This function returns the value for real and nominal GDP, national debt, and population // between any two years of U.S. history since 1791, as well as their corresponding rates // of growth recorded in the interim. // Convert Input Variables to Numeric Values SY = form.SY0.value; // Starting Year Data EY = form.EY1.value; // Ending Year Data // Starting Year Data Y1 = SY.substring(0,4); // Year P1 = SY.substring(5,14); // Population G1 = SY.substring(15,30); // Nominal GDP D1 = SY.substring(31,46); // Nominal National Debt I1 = SY.substring(47,55)/100000; // GDP Deflator NGP1 = G1/P1; // Nominal GDP per Capita NDP1 = D1/P1; // Nominal National Debt per Capita DTI1 = D1/G1*100; // Debt-to-Income Ratio DTIP1 = NDP1/G1*1000000000; // Debt-per-Capita-to-Income Index RG1 = G1/I1; // Real GDP [constant 2000 USD] RD1 = D1/I1; // Real Debt [constant 2000 USD] RGP1 = RG1/P1; // Real GDP per Capita RDP1 = RD1/P1; // Real National Debt per Capita // Ending Year Data Y2 = EY.substring(0,4); // Year P2 = EY.substring(5,14); // Population G2 = EY.substring(15,30); // Nominal GDP D2 = EY.substring(31,46); // Nominal National Debt I2 = EY.substring(47,55)/100000; // GDP Deflator NGP2 = G2/P2; // Nominal GDP per Capita NDP2 = D2/P2; // Nominal National Debt per Capita DTI2 = D2/G2*100; // Debt-to-Income Ratio DTIP2 = NDP2/G2*1000000000; // Debt-per-Capita-to-Income Index RG2 = G2/I2; // Real GDP [constant 2000 USD] RD2 = D2/I2; // Real National Debt [constant 2000 USD] RGP2 = RG2/P2; // Real GDP per Capita RDP2 = RD2/P2; // Real National Debt per Capita // Rate Calculations T = Y2 - Y1; // Elapsed Years rateP = (Math.pow(1 + (P2 - P1)/P1, 1/T) - 1)*100; // CAGR Population Growth rateD = (Math.pow(1 + (D2 - D1)/D1, 1/T) - 1)*100; // CAGR National Debt rateI = (Math.pow(1 + (I2 - I1)/I1, 1/T) - 1)*100; // CAGR Inflation (GDP Deflator) rateG = (Math.pow(1 + (G2 - G1)/G1, 1/T) - 1)*100; // CAGR GDP rateRG = ((1 + rateG/100)/(1 + rateI/100) - 1)*100; // CAGR Real GDP rateRD = ((1 + rateD/100)/(1 + rateI/100) - 1)*100; // CAGR Real Debt // Output Calculated Values to Form form.Y1.value = Y1; form.Y2.value = Y2; form.P1.value = decimalFP(P1, 0); form.P2.value = decimalFP(P2, 0); form.G1.value = decimalFP(G1, 0); form.G2.value = decimalFP(G2, 0); form.D1.value = decimalFP(D1, 0); form.D2.value = decimalFP(D2, 0); form.NGP1.value = decimalFP(NGP1, 2); form.NGP2.value = decimalFP(NGP2, 2); form.NDP1.value = decimalFP(NDP1, 2); form.NDP2.value = decimalFP(NDP2, 2); form.DTI1.value = decimalFP(DTI1, 1) + "%"; form.DTI2.value = decimalFP(DTI2, 1) + "%"; form.DTIP1.value = decimalFP(DTIP1, 2); form.DTIP2.value = decimalFP(DTIP2, 2); form.rateP.value = decimalFP(rateP, 1) + "%"; form.rateD.value = decimalFP(rateD, 1) + "%"; form.rateG.value = decimalFP(rateG, 1) + "%"; form.RG1.value = decimalFP(RG1, 0); form.RG2.value = decimalFP(RG2, 0); form.RD1.value = decimalFP(RD1, 0); form.RD2.value = decimalFP(RD2, 0); form.rateRD.value = decimalFP(rateRD, 1) + "%"; form.rateRG.value = decimalFP(rateRG, 1) + "%"; form.RGP1.value = decimalFP(RGP1, 2); form.RGP2.value = decimalFP(RGP2, 2); form.RDP1.value = decimalFP(RDP1, 2); form.RDP2.value = decimalFP(RDP2, 2); } // End USPopGDPDebt function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function breastfeedingVSformula(form) { // Convert Input Variables to Numeric Values P = eval(form.P0.value); // Unit Cost of Formula [USD per ounce] A = eval(form.A1.value); // Average Amount of Formula per Day (during one year) [ounces] N = eval(form.N2.value); // Average Number of Breastfeedings per Day (during one year) T = eval(form.T3.value); // Average Time for Each Breastfeeding [minutes] // Calculate values Formula = A*365; // Total Amount of Formula Consumed in One Year Cost = Formula*P; // Annual Cost of Formula [USD] Feedings = N*365; // Approximate Number of Feedings Time = Feedings*T/60; // Total Amount of Time Spent Breastfeeding [hours] SavingsTime = Cost/Time; // Savings per Hour Breastfeeding [USD/hour] SavingsFeeding = Cost/Feedings; // Savings per Breastfeeding [USD] // Output Calculated Values to Form form.Formula.value = decimalFP(Formula, 1); form.Cost.value = "$" + decimalFP(Cost, 2); form.Feedings.value = decimalFP(Feedings, 0); form.Time.value = decimalFP(Time, 2); form.SavingsTime.value = "$" + decimalFP(SavingsTime, 2); form.SavingsFeeding.value = "$" + decimalFP(SavingsFeeding, 2); } // End breastfeedingVSformula function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function DTIPtoMaxIncomeTaxRate(form) { // Constants billion = 1000000000; // Billion A = 95.2695; // Sigmoid Coefficient A B = 1.7669; // Sigmoid Coefficient B C = 1.2752; // Sigmoid Coefficient C D = 18.75; // Standard Deviation of Residual // Convert Input Variables to Numeric Values DEBT = eval(form.DEBT0.value); // National Debt [trillions USD] GDP = eval(form.GDP1.value); // Nominal GDP [trillions USD] POP = eval(form.POP2.value); // Population // Calculate values DTIP = DEBT/POP/GDP*billion; // Debt Burden per Capita (or DTIP, the Debt per Capita-to-Income Index Value) Rate = sigmoid(A, B, C, 0, DTIP); // Corresponding Maximum Income Tax Rate modernRate = Rate - 1.25*D; // Modern Politician Maximum Income Tax Rate // Output Calculated Values to Form form.DTIP.value = decimalFP(DTIP, 3); form.Rate.value = decimalFP(Rate, 1) + "%"; form.modernRate.value = decimalFP(modernRate, 1) + "%"; } // End DTIPtoMaxIncomeTaxRate function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function rothVStraditionalIRA(form) { // Constants N = 4; // Number of Compounding Periods per Year // Base Comment Trad = "The Traditional IRA is the better option, since you will come out ahead by $" Roth = "The Roth IRA is the better option, since you will come out ahead by $"; Neit = "Neither type of IRA is advantageous given the data you entered, as there is no difference between each"; Close = " at the time you withdraw money from the IRA. " // Convert Input Variables to Numeric Values P = eval(form.P0.value); // Amount of Pretax Income Available to Invest Today [$USD] I = eval(form.I1.value); // Average Annual Investment Rate of Return [%] T = eval(form.T2.value); // Time to Hold in Investment Before Withdrawal [Years] FTC = eval(form.FTC3.value); // Your Current Federal Income Tax Bracket [%] STC = eval(form.STC4.value); // Your Current State Income Tax Bracket [%] FTF = eval(form.FTF5.value); // Expected Future Federal Income Tax Bracket [%] STF = eval(form.STF6.value); // Expected Future State Income Tax Bracket [%] // Calculate values TradTaxToday = 0; // Amount of Taxes to Be Taken Out of Amount Available for Investment in Traditional IRA [$USD] RothTaxToday = P*(FTC+STC)/100; // Amount of Taxes to Be Taken Out of Amount Available for Investment in Roth IRA [$USD] TradP = P - TradTaxToday; // Amount To Be Invested in Traditional IRA [$USD] RothP = P - RothTaxToday; // Amount To Be Invested in Roth IRA [$USD] TradF = TradP*Math.pow(1 + I/100/N, N*T); // Expected Future Value of Investment at Time of Withdrawal in Traditional IRA [$USD] RothF = RothP*Math.pow(1 + I/100/N, N*T); // Expected Future Value of Investment at Time of Withdrawal in Roth IRA [$USD] TradTaxWithdraw = TradF*(FTF+STF)/100; // Taxes to Be Paid From Investment at Time of Withdrawal for Traditional IRA [$USD] RothTaxWithdraw = RothF*0; // Taxes to Be Paid From Investment at Time of Withdrawal for Traditional IRA [$USD] TradFinal = TradF - TradTaxWithdraw; // Amount Remaining From Traditional IRA After All Taxes Are Paid [$USD] RothFinal = RothF - RothTaxWithdraw; // Amount Remaining From Roth IRA After All Taxes Are Paid [$USD] Diff = TradFinal - RothFinal; // Difference Between Final Amounts Remaining from Traditional IRA and Roth IRA if(Diff 0) Comment = Trad + decimalFP(Diff, 2) + Close; // Output Calculated Values to Form form.TradTaxToday.value = decimalFP(TradTaxToday, 2); form.RothTaxToday.value = decimalFP(RothTaxToday, 2); form.TradP.value = decimalFP(TradP, 2); form.RothP.value = decimalFP(RothP, 2); form.TradF.value = decimalFP(TradF, 2); form.RothF.value = decimalFP(RothF, 2); form.TradTaxWithdraw.value = decimalFP(TradTaxWithdraw,2); form.RothTaxWithdraw.value = decimalFP(RothTaxWithdraw,2); form.TradFinal.value = decimalFP(TradFinal, 2); form.RothFinal.value = decimalFP(RothFinal, 2); form.Comment.value = Comment; } // End rothVStraditionalIRA function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function kindlenomics(form) { // Constants N = 12; // Compounding Period of Investment comment = "Given your book buying habits and how long you might use the Kindle, you're better off not buying one at today's prices!"; // Default Comment // Convert Input Variables to Numeric Values P = eval(form.P0.value); // Kindle Purchase Price D = eval(form.D1.value); // "Out-the-Door" Depreciation Rate [%] R = eval(form.R2.value); // "Running" Depreciation Rate [%] F = eval(form.F3.value); // "Toy Value" How much of a 'warm fuzzy' (measured in terms of money) do you get from owning this new gadget? TB = eval(form.TB4.value); // Average Price of Traditional Book You Buy SB = eval(form.SB5.value); // Book Salvage Price: How much would you get on average for each of your used traditional books? KB = eval(form.KB6.value); // Average Price of a Kindle Book NB = eval(form.N7.value); // Average Number of Books You Buy Each Month DR = eval(form.DR8.value); // Discount Rate (Annual Rate of Return from Investment with Similar Risk) [%] I = eval(form.I9.value); // Interest Rate (Annual Rate of Return from Savings Account) [%] T = eval(form.T10.value); // Time [in months] of Expected Kindle Usage // Define Arrays CumNPV = new Array(); // Cumulative Net Present Value Array OCC = new Array(); // Opportunity Cost of Capital // Calculate values CumNPV[0] = F - P; // Initial Net Present Value SV0 = P*(1 - D/100); // Initial Salvage Value NBSM = ((TB + SB) - KB)*NB; // Net Book Savings (per Month) OCC[0] = 0; // Initial Opportunity Cost of Capital Used for Purchase Kindle for (i=1; i= 0) comment = "Given your book buying habits and how long you plan to use the Kindle, it is to your advantage to buy one today!"; // Output Calculated Values to Form form.CES.value = decimalFP(CES, 2); form.comment.value = comment; } // End kindlenomics function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function GenerationTheft(form) { // Convert Input Variables to Numeric Values StartPay = eval(form.StartPay0.value); // 2009 Starting Salary (Age 18-24) Data = form.Year1.value; // Select Year to Project Future // Constants A = 95.2695; // Sigmoid Coefficient A B = 1.7669; // Sigmoid Coefficient B C = 1.2752; // Sigmoid Coefficient C // Year Data Year = Data.substring(0,4); // Year GDP = Data.substring(5,10)*1000000; // Projected GDP Debt = Data.substring(11,16)*1000000; // Projected Debt Pop = Data.substring(17,23)*1000; // Projected Population // Calculate values Time = Year - 2009; // Elapsed Years ProjPay = StartPay*(-0.0019*Math.pow(Time,2) + 0.094*Time + 0.9868); // Projected Income in Selected Year if (Time==0) ProjPay = StartPay; DPC = Debt/Pop*1000; // National Debt per Capita DTI = Debt/GDP; // National Debt Burden DTIP = Debt/GDP/Pop*1000000000; // National Debt Burden per Capita Index MaxTaxRate = sigmoid(A, B, C, 0, DTIP); // Corresponding Maximum Income Tax Rate // Calculate Individual Income Tax indTaxRateProj = diyMarginalTaxBrackets(ProjPay, 10, 8000, 25, 30000, MaxTaxRate, 250000, MaxTaxRate, 142000000-50); indTaxRateOrig = diyMarginalTaxBrackets(ProjPay, 10, 8000, 25, 30000, 35, 250000, 35, 142000000-50); indCredits = 2400*1; indTaxProj = (ProjPay*indTaxRateOrig - ProjPay*indTaxRateProj)/ProjPay*100; // Output Calculated Values to Form form.ProjPay.value = decimalFP(ProjPay, 2); form.DPC.value = decimalFP(DPC,2); form.DTI.value = decimalFP(DTI*100,2) + "%"; form.DTIP.value = decimalFP(DTIP,2); form.MaxTaxRate.value = decimalFP(MaxTaxRate, 1) + "%"; form.ProjTaxPaid.value = decimalFP(indTaxProj,2) + "%"; } // End GenerationTheft function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function tenYeartoMortgageRate(form) { // Constants A = 2.77351249772365; // Constant A B = -3.27200486101497; // Constant B C = 0.647289454175958; // Constant C D = -1.07132172945979; // Constant D // Convert Input Variables to Numeric Values T = eval(form.T0.value); // Current 10 Year Constant Maturity U.S. Treasury Yield [%] // Calculate values M = Math.pow((T-D)/A, 1/C) - B; // 30 Year Conventional Fixed Mortgage Rate // Output Calculated Values to Form form.M.value = decimalFP(M, 2); } // End tenYeartoMortgageRate function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function mortgageRateto10Year(form) { // Constants A = 2.77351249772365; // Constant A B = -3.27200486101497; // Constant B C = 0.647289454175958; // Constant C D = -1.07132172945979; // Constant D // Convert Input Variables to Numeric Values M = eval(form.M0.value); // Current 30 Year Conventional Fixed Mortgage Rate [%] // Calculate values T = A*Math.pow(M+B, C) + D; // 10 Year Constant Maturity U.S. Treasury Rate // Output Calculated Values to Form form.T.value = decimalFP(T, 2); } // End tenYeartoMortgageRate function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function remappedSP500bestworstavg(form) { // Convert Input Variables to Numeric Values T = eval(form.T0.value); // Holding Period [years] // Calculate values B = 79.4026063104606*Math.pow(T-0.214246226022783, -0.722475634920739) + 8.07669579380153; // Best Rate of Return A = 9.38; // Average Rate of Return W = -13568.5771736739*Math.pow(T+7.18795201684133, -2.49336307266993) + 7.21848885073263; // Worst Rate of Return // Output Calculated Values to Form form.B.value = decimalFP(B, 1) + "%"; form.A.value = decimalFP(A, 1) + "%"; form.W.value = decimalFP(W, 1) + "%"; } // End remappedSP500bestworstavg function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function backTester(form) { // This function finds the actual historic inflation adjusted rate of return and the value // of a series of investments made in the S&P 500 between any two dates since January 1871, // assuming full dividend reinvestment and no commissions, taxes or fees. // Convert Input Variables to Numeric Values beginDate = form.beginDate.selectedIndex; // Identify Starting Date Record endDate = form.endDate.selectedIndex; // Identify Ending Date Record amount = eval(form.amount.value); // Inflation Adjusted Amount to Invest Each Month princ = eval(form.princ.value); // Starting Principal of Investment start = 14; // Form Element for Beginning of S&P 500 Data Included with Post var SP500R = new Array(); // Set up array for S&P 500 Data for (i=start; i 0) { for (i=beginDate; i LUP) output = "The larger quantity has the lower unit price, making it the better deal."; if (LUP > SUP) output = "The smaller quantity has the lower unit price, making it the better deal."; if (LUP == SUP) output = "There's no difference in the unit price for either size package."; BL = output; // The Bottom Line // Output Calculated Values to Form form.SUP.value = decimalFP(SUP, 3); form.LUP.value = decimalFP(LUP, 3); form.BL.value = BL; } // End UnitPriceCoupon function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function termLife(form) { // Convert Input Variables to Numeric Values THI = eval(form.THI0.value); // How much annual income would your survivors need in the event of your death? SHI = eval(form.SHI1.value); // How much annual income do they bring into your household today? Y = eval(form.Y2.value); // How many years will your survivors need the income? D = eval(form.D3.value); // How much total debt do you have that you would like to have paid off in the event of your death? B = eval(form.B4.value); // How much do you anticipate will be needed to cover your burial expenses? I = eval(form.I5.value); // Annualized interest rate for investing death benefit [%] ALI = eval(form.ALI6.value); // Existing Term Life Insurance // Calculate values R = I/100; // Decimalized Interest Rate AIS = Math.max(-1*(SHI - THI), 0); // Annual Income Shortfall [Amount of Income Needed to Replace Yours] TDB = D + B; // Total Debt and Burial Expenses PV = AIS*(1 + R)/R * (1 - 1/Math.pow((1+R),Y)); // Minimum Amount of Policy Needed to Cover Replacement Income LIN = PV + TDB - ALI; // Estimated Amount of Term Life Insurance Needed // Output Calculated Values to Form form.AIS.value = decimalFP(AIS, 2); form.PV.value = decimalFP(PV, 2); form.LIN.value = decimalFP(LIN, 2); } // End termLife function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function stimulusFTE(form) { // Convert Input Variables to Numeric Values H = eval(form.H0.value); // Hours of Work Compensated for with Stimulus Package Funds Over a Period of Time E = eval(form.E1.value); // Hours One Full Time Employee Would Work During the Same Time Period // Calculate values FTE = H/E; // Number of Equivalent Full Time Workers (Jobs Created or Saved by Stimulus Spending Over the Period of Time) // Output Calculated Values to Form form.FTE.value = decimalFP(FTE, 0); } // End stimulusFTE function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function CAWithhold2009(form) { // This function will perform the paycheck withholding calculations for 2009! // Constants USA = 3650; // Value of (1) Federal Allowance for Annual Pay Period CAA = 108.90; // New Value of (1) California Allowance for Annual Pay Period // Convert Input Variables to Numeric Values SAL = eval(form.AP0.value); // Current Annual Salary ($) PER = setTerm(form.PP1.selectedIndex); // Term of Pay Period FS = form.FS2.selectedIndex; // Filing Status WA = form.WA3.selectedIndex; // Number of Withholding Allowances PT = eval(form.PT4.value); // Pre-Tax 401(k) Contribution (%) AT = eval(form.AT5.value); // After-Tax 401(k) Contribution (%) HCSA = eval(form.HCSA6.value); // Annual Contribution to Health Care Spending Account DCSA = eval(form.DCSA7.value); // Annual Contribution to Dependent Care Spending Account // Set Values for Tax Rates and Income Bracket Threshhold Values USRates = new Array(0.350, 0.330, 0.280, 0.250, 0.150, 0.100); CARates0 = new Array(0.10550, 0.09550, 0.08250, 0.06250, 0.04250, 0.02250, 0.01250); CARatesR = new Array(0.11605, 0.10505, 0.09075, 0.06875, 0.04675, 0.02475, 0.01375); switch(FS) { case 0: // Single CALimits = new Array(1000000, 47055, 37233, 26821, 16994, 7168); CSA = 3692; break; case 1: // Married CALimits = new Array(1000000, 94110, 74466, 53642, 33988, 14336); if (WA 59.5) { RETIREMENT *= 1.0 / (3.7832E+01 - 3.2691E+00*AGE + 1.0908E-01*Math.pow(AGE,2) - 1.6087E-03*Math.pow(AGE,3) + 8.806E-06*Math.pow(AGE,4)); } RETIREMENT = Math.max(RETIREMENT,0); EDUCATION = (-1.3528E+02 - 1.1331E-01*AGE + 9.3392E-02*Math.pow(AGE,2) - 1.3468E-03*Math.pow(AGE,3)) / (1.0 - 9.3579E-02*AGE + 2.4995E-03*Math.pow(AGE,2) - 2.0856E-05*Math.pow(AGE,3)) // Education // Total Expenditures TAXES = FEDERAL + SOCIALSECURITY + STATE + LOCAL; TOTAL = HEALTHCARE + CONTRIBUTIONS + FOOD + HOUSING + APPAREL + TRANSPORTATION + ENTERTAINMENT + OTHER + RETIREMENT + EDUCATION + TAXES; // Percentage Calculations pctHEALTHCARE = HEALTHCARE/TOTAL; pctCONTRIBUTIONS = CONTRIBUTIONS/TOTAL; pctFOOD = FOOD/TOTAL; pctHOUSING = HOUSING/TOTAL; pctAPPAREL = APPAREL/TOTAL; pctTRANSPORTATION = TRANSPORTATION/TOTAL; pctTAXES = TAXES/TOTAL; pctENTERTAINMENT = ENTERTAINMENT/TOTAL; pctOTHER = OTHER/TOTAL; pctRETIREMENT = RETIREMENT/TOTAL; pctEDUCATION = EDUCATION/TOTAL; pctTOTAL = TOTAL/TOTAL; // Output Calculated Values to Form form.HEALTHCARE.value = decimalFP(HEALTHCARE, 2); form.CONTRIBUTIONS.value = decimalFP(CONTRIBUTIONS, 2); form.FOOD.value = decimalFP(FOOD, 2); form.HOUSING.value = decimalFP(HOUSING, 2); form.APPAREL.value = decimalFP(APPAREL, 2); form.TRANSPORTATION.value = decimalFP(TRANSPORTATION, 2); form.TAXES.value = decimalFP(TAXES, 2); form.ENTERTAINMENT.value = decimalFP(ENTERTAINMENT, 2); form.OTHER.value = decimalFP(OTHER, 2); form.RETIREMENT.value = decimalFP(RETIREMENT, 2); form.EDUCATION.value = decimalFP(EDUCATION, 2); form.TOTAL.value = decimalFP(TOTAL, 2); form.pctHEALTHCARE.value = decimalFP(pctHEALTHCARE*100, 1) + "%"; form.pctCONTRIBUTIONS.value = decimalFP(pctCONTRIBUTIONS*100, 1) + "%"; form.pctFOOD.value = decimalFP(pctFOOD*100, 1) + "%"; form.pctHOUSING.value = decimalFP(pctHOUSING*100, 1) + "%"; form.pctAPPAREL.value = decimalFP(pctAPPAREL*100, 1) + "%"; form.pctTRANSPORTATION.value = decimalFP(pctTRANSPORTATION*100, 1) + "%"; form.pctTAXES.value = decimalFP(pctTAXES*100, 1) + "%"; form.pctENTERTAINMENT.value = decimalFP(pctENTERTAINMENT*100, 1) + "%"; form.pctOTHER.value = decimalFP(pctOTHER*100, 1) + "%"; form.pctRETIREMENT.value = decimalFP(pctRETIREMENT*100, 1) + "%"; form.pctEDUCATION.value = decimalFP(pctEDUCATION*100, 1) + "%"; form.pctTOTAL.value = decimalFP(pctTOTAL*100, 1) + "%"; } // End ageIncomeDrivenExpenditures function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function economicData(YEAR) { // This function will project the value of the U.S.' Gross Domestic Product based upon the // Social Security Administration's projection of this data from 2008 through 2085 [ED01], // as represented by the Trustees' Intermediate Cost Assumptions. // // "For the intermediate assumptions, the average annual growth in real GDP is projected to // be 2.4 percent from 2008 to 2018, a slower rate than the 3.0 percent average observed over // the historical 40 year period from 1967 to 2007. This slowdown is primarily due to slower // projected growth in total employment." [ED02] // // "After 2018, no economic cycles are assumed for the three alternatives. Accordingly, projected // rates of growth in real GDP are determined by the projected full-employment rate of growth for // total employment, and the assumed full-employment rates of growth for total U.S. economy productivity // and average hours worked. For the intermediate assumptions, the pro­jected rate of growth for real // GDP falls toward the assumed productivity growth rate because of the projected decline in labor force // growth over the period. At the end of the 75 year projection period, the annual growth in real GDP is // 2.1 percent, due to the assumed ultimate percent changes of about 0.4, 1.7, and 0.0 for total // employment, productivity, and average hours worked, respectively." [ED02] // // Performing a regression analysis of future GDP using the OASDI Trustees' data provided in Table VI.F4 [ED01] // in Microsoft Excel using a simple regression analysis with an exponential model reveals that the Trustees' // anticipate nominal GDP to grow at an average compound annualized rate of 5.16% from 2009 through 2018. // Subtracting the 2.4% real GDP growth rate from this figure indicates an average level of annual inflation of // 2.76%, which is low compared to the U.S. long term average of 3.29% observed since 1913. [ED03] // // Performing a similar regression analysis for the period from 2018 through 2085, we find a nominal GDP // compound annualized growth rate of 4.49%. Given the OASDI Trustees' projected real GDP growth rate of // 2.1%, this indicates they anticipate an average annual rate of inflation of approximately 2.05% during // this period. // // We terminated the projection of GDP data at 2080 since this corresponds to the end of the period for // which the Congressional Budget Office has extended its baseline expenditures projections. // // [ED01] 2009 OASDI Trustees Report. Table VI.F6. - Selected Economic Variables, Calendar Years 2008-85. http://www.ssa.gov/OACT/TR/2009/lr6f6.html. [Accessed 7 December 2009] // [ED02] 2009 OASDI Trustees Report. Principal Economic Assumptions. http://www.ssa.gov/OACT/TR/2009/V_economic.html. [Accessed 7 December 2009] // [ED03] Political Calculations. Mapping Inflation Extremes Since 1913. http://politicalcalculations.blogspot.com/2006/11/mapping-inflation-extremes-since-1913.html. [Accessed 7 December 2009] GDP = new Array(); for(y=YEAR; y High) { // Swap Low and High Values if Mis-entered. Temp = Low; Low = High; High = Temp; } Low = Math.max(Low, 0); // Set Lower Limit at 0 if Negative Value is Entered. Smiths = Math.max(N/100*(fedEmpPayPctile2010(High) - fedEmpPayPctile2010(Low)), 1); // Number of Federal Employees Within Indicated Salary Range // Output Calculated Values to Form form.Smiths.value = decimalFP(Smiths, 0); } // End numFedEmpPayRange2010 function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function areYouOldEnoughToMarryYet(form) { // Constants k = .368; // Probability of Proposal Success // Convert Input Variables to Numeric Values N = eval(form.N0.value); // The Oldest Age by Which You Want to Be Married P = eval(form.P1.value); // The Earliest Age by Which Your Dating Pool Would Include Potential Spouses // Calculate values A = (N - P)*k + P; // Your Optimal Age for Proposing Marriage // Output Calculated Values to Form form.A.value = decimalFP(A, 1); } // End areYouOldEnoughToMarryYet function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function minimumDatingAge(form) { // Convert Input Variables to Numeric Values Age = eval(form.Age0.value); // Your Age legalAge = eval(form.legalAge1.value); // Your State's Age Threshold for Consensual Relationships // Calculate values minimumAge = Math.min(Age/2 + 7, Age-1); // Inter-Age Rule if (Age > 16) minimumAge = Math.max(minimumAge, legalAge); // If user's age is over the statutory age, set minimum age to be the higher of the minimum age or legal age minimumAge = minimumAge; // The Minimum Age of the Potential Members of Your Dating Pool // Output Calculated Values to Form form.minimumAge.value = decimalFP(minimumAge, 0); } // End minimumDatingAge function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function taxCodePages(form) { // Constants R = 0.03253; // Average Exponential Growth Rate of U.S. Tax Code Complexity, 1954-2010 A = 11301.34; // Base Reference Value // Convert Input Variables to Numeric Values Year = eval(form.Year0.value); // Year // Calculate values Pages = A*Math.exp(R*(Year-1954)); // Estimated Number of Pages // Output Calculated Values to Form form.Pages.value = decimalFP(Pages, 0); } // End taxCodePages function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function azSpeedLottery(form) { // Constants Decision = "It makes more sense to pay the fine when you first receive notice by mail."; // Default Decision: Pay the Fine // Convert Input Variables to Numeric Values Cost = eval(form.Cost0.value); // Cost of Administrative Fees (Cost of "Buying" a "Lottery" Ticket) Prize = eval(form.Prize1.value); // Fine for Photo Enforcement Speed Violation (Amount of "Winnings") Odds = eval(form.Odds2.value); // Probability of Not Being Served (Odds of "Winning") [1 in ...] // Calculate values minPrize = Cost*Odds; // Minimum "Prize" Needed to Justify "Playing" the "Lottery" if (minPrize 1) comment = "The person appears less unattractive to you now than if you were fully sober. If you keep drinking, keep checking back...."; // Comment if Impaired, But Not Yet More Attractive if (B > 50) comment = "The conditions and your drinking have combined to seriously distort your perception of reality. You should stop now and get a ride home!"; // Comment if Impaired, And Person Appears To Be Attractive if (B > 100) comment = "Danger. Stop now. That isn't a professional model of any kind."; // Comment if Very Impaired alertNotice = comment; // The Bottom Line // Output Calculated Values to Form form.B.value = decimalFP(B, 1); form.alertNotice.value = alertNotice; } // End beerGoggles function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function winningBaseballRecord(form) { // Constants NRG = 162; // Number of Regular Season Games // Convert Input Variables to Numeric Values R1 = eval(form.R10.value); // Runs Scored For Your Team R2 = eval(form.R21.value); // Runs Scored Against Your Team SLG1 = eval(form.SLG12.value); // Slugging Percentage For Your Team SLG2 = eval(form.SLG23.value); // Slugging Percentage Against Your Team NG = eval(form.NG4.value); // Number of Games Played // Calculate values a = Math.pow(0.723*(R1/NG + R2/NG), 0.373); // Exponent for Offense/Pitching Runs per Game Ratio b = Math.pow(0.977*(R1/NG + R2/NG), -0.947); // Exponent for Offense/Pitching Slugging Percentage Ratio WLRatio = Math.pow(R1/R2, a)*Math.pow(SLG1/SLG2, b); // Ratio of Wins to Losses W1 = NG*WLRatio/(1 + WLRatio); // Projected Current Number of Wins L1 = NG - W1; // Projected Current Number of Losses WNG = W1/NG; // Projected Winning Percentage SW1 = NRG*WLRatio/(1 + WLRatio); // Projected Number of Wins for Full Season SL1 = NRG - SW1; // Projected Number of Losses for Full Season // Output Calculated Values to Form form.WLRatio.value = decimalFP(WLRatio, 3); form.W1.value = decimalFP(W1, 0); form.L1.value = decimalFP(L1, 0); form.WNG.value = decimalFP(WNG, 3); form.SW1.value = decimalFP(SW1, 0); form.SL1.value = decimalFP(SL1, 0); } // End winningBaseballRecord function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function unemploymentDuration2010(form) { // Constants shift = 10.4; // Change in U.S. Duration of Unemployment from 2009 // Convert Input Variables to Numeric Values ueRate = eval(form.ueRate0.value); // Your State's Unemployment Rate // Calculate values ueDuration = 1.105*ueRate + 3.4123 + shift; // Median Number of Weeks of Unemployment // Output Calculated Values to Form form.ueDuration.value = decimalFP(ueDuration, 1); } // End unemploymentDuration2010 function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function sexAppeal(form) { // Convert Input Variables to Numeric Values T = eval(form.T0.value); // [T] If you can see your toes while standing, enter zero. If not, enter the inches of reduced belt size needed to restore your podiatric vision. HH = eval(form.HH1.value); // [HH] Enter the percentage of scalp showing through your hair. (0 = Jean Luc Picard, 100 = Justin Bieber). HB = eval(form.HB2.value); // [HB] Enter the percentage of your body below your neck showing through hair. M = eval(form.M3.value); // [M] Go to a park and smile at ten mothers. How many smile back? (Subtract from this value the number of children who cry.) Oplus = eval(form.Oplus4.value); // [O+] How many of the following do you have or have you had? (A gym membership, a cat or dog, silk boxer sorts, a motorcycle, shoes that cost more than $100, sex in the past month, massage oil and/or bubble bath.) Ominus = eval(form.Ominus5.value); // [O-] How many of the following do you have? (A snake or rat, underwear with holes, a video game machine, Velcro shoes, a condom past its expiration date, any personalized or joke beer paraphernalia, your mother's phone number on speed dial.) SS = eval(form.SS6.value); // [SS] Your shoe size. X = eval(form.X7.value); // [X] Five will be subtracted from your Sex Appeal score if you actually click the "Calculate" button.... // Calculate values SA = 25*Math.sqrt(HB/(HH+25))*((M+Oplus+SS+25)/(T+Ominus+25))-X; // Your Sex Appeal Rank, on a Scale from 0 to 100 // Output Calculated Values to Form form.SA.value = decimalFP(SA, 0); } // End sexAppeal function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function bmiBodyFat(form) { // Convert Input Variables to Numeric Values H = eval(form.H0.value); // Height W = eval(form.W1.value); // Weight HF = eval(form.heightUnits.value); // Height Unit Adjustment Factor WF = eval(form.weightUnits.value); // Weight Unit Adjustment Factor H = H*HF; W = W*WF; Age = eval(form.Age2.value); // Age [years] Gender = eval(form.Gender3.value); // Gender // Calculate values BMI = W/Math.pow(H, 2); // Body Mass Index switch(Gender) { case 0: // Female ABF = 4.35*BMI - 0.05*Math.pow(BMI, 2) - 46.24; // Your Estimated Body Fat Percentage (Based on BMI and Gender Only) break; case 1: // Male ABF = 3.76*BMI - 0.04*Math.pow(BMI, 2) - 47.80; // Male Estimated Adult Body Fat Percentage (Based on BMI and Gender Only) break; } // End Switch Statement ABFAge = 1.39*BMI + 0.16*Age - 10.34*Gender - 9; // Your Estimated Body Fat Percentage (Also Taking Your Age Into Account) // Output Calculated Values to Form form.BMI.value = decimalFP(BMI, 1); form.ABF.value = decimalFP(ABF, 1) + "%"; form.ABFAge.value = decimalFP(ABFAge, 1) + "%"; } // End bmiBodyFat function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function subtractionForMediaTypes(form) { // Convert Input Variables to Numeric Values F = eval(form.F0.value); // First Value S = eval(form.S1.value); // Second Value // Calculate values A = F - S; // Solution // Output Calculated Values to Form form.A.value = decimalFP(A, 2); } // End subtractionForMediaTypes function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function healthCareFSAcash(form) { // Convert Input Variables to Numeric Values A = eval(form.A0.value); // Estimated Copayments for Doctor Visits and Prescription Drugs B = eval(form.B1.value); // Deductibles and Copayments for Dental Coverage C = eval(form.C2.value); // Cost of Reimburseable Items (such as eyeglasses) D = eval(form.D3.value); // Expenses Related to Special Health Care Needs (such as diabetic supplies) E = eval(form.E4.value); // Expected Extraordinary Expenses (such as for baby delivery or major surgery) M = eval(form.M5.value); // Your Employers Maximum Health Care FSA Contribution Amount // Calculate values T = A+B+C+D+E; // Total Expected Health and Dental Care Expenses if (T On how many of the following services are you a registered user? [Facebook, MySpace, Friendster, Twitter, Blogger, Badoo, Bebo, Flickr, LinkedIn]
CT = eval(form.CT2.value); // How many cell phones do you own? D = eval(form.D3.value); // In how many of the following dinosaur activities do you participate on a daily basis?
[read the newspaper,subscribe to a newspaper, use a pen/pencil, watch TV, listen to music that has ever been placed on any nondigital recordable media, recreate offline] W = eval(form.W4.value); // In how many programming languages could you design a widget of any sort? P = eval(form.P5.value); // How many of the following people have you heard of?
Linus Torvalds, Ray Ozzie, Kevin Mitnick, Jean Grey, Samwise Gamgee, Violet Blue] // Calculate values Atech = A + Math.pow(SN + CT + W + P, 2)/Math.sqrt(D + 2); // Age of Your Personal Technological Obsolescence // Output Calculated Values to Form form.Atech.value = decimalFP(Atech, 1); } // End ageTechnologyOvertakes function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function coinTossOdds(form) { // Convert Input Variables to Numeric Values N = eval(form.N0.value); // Total Number of Opportunities k = eval(form.k1.value); // Number of Times the Outcome Goes a Particular Way p = eval(form.p2.value); // Probability of Outcome Occurring in Each Opportunity [%] // Calculate values p = p/100; // Decimalized Probability q = 1 - p; // Opposite Probability probability = Factorial(N)/Factorial(k)/Factorial(N-k)*Math.pow(p, k)*Math.pow(q, N - k)*100; // Probability of the Event Occurring [%] odds = 1/(probability/100); // Odds of the Event Occurring [1 in ...] // Output Calculated Values to Form form.probability.value = decimalFP(probability, 4) + "%"; form.odds.value = decimalFP(odds, 1); } // End coinTossOdds function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function halloweenBucket(form) { // Constants Bucket = "Your Pockets Are More Than Enough"; // Default Output // Convert Input Variables to Numeric Values T = eval(form.T0.value); // Total Time You Plan to Spend Trick or Treating (in hours) A = eval(form.A1.value); // Trick or Treater's Age (If over 20, or below 0, shame on you!) Hc = eval(form.Hc2.value); // Hours Spent on Costume (If Store Bought, Take Price and Divide by 20) Pd = eval(form.Pd3.value); // Population Density of Your Targeted Neighborhood Ma = eval(form.Ma4.value); // Estimated Median Age in the Neighborhood (the lower the age, the more houses you'll likely be visiting) X = eval(form.X5.value); // Your Child's "Lust for Candy" Factor (Enter a value from 1-10, with 10 being "has strategized since last Halloween") // Calculate values B = T*(A - 0.05*A*A + Hc*Pd/Math.sqrt(Ma) + X); // Bucket Size if (B > 1) Bucket = "Your Child Should Use the Small-Size, Plastic Jack-'O-Lantern Bucket"; // Small if (B > 7) Bucket = "Your Child Should Use the Standard-Size Trick-or-Treating Bucket"; // Standard if (B > 12) Bucket = "Your Child Should Upgrade to a Pillowcase"; // Pillowcase if (B > 17) Bucket = "Your Candy Collecting Achiever Should Use a Grocery Bag"; // Grocery if (B > 25) Bucket = "Wow! You Might as Well Let Them Use a Trash Bag!"; // Trash Comment = Bucket; // Your Child's Optimum Halloween Candy Collection Container // Output Calculated Values to Form form.Comment.value = Comment; } // End halloweenBucket function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function FTRtoHMI(form) { // Convert Input Variables to Numeric Values FTC = eval(form.FTC0.value); // Total Federal Tax Receipts for Fiscal Year [billions USD] // Calculate values HMI = 255.982541*Math.pow(FTC, 0.679450); // Projected Household Median Income // Output Calculated Values to Form form.HMI.value = decimalFP(HMI, 0); } // End FTRtoHMI function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function zeroDeficitLine(form) { // Convert Input Variables to Numeric Values MHI = eval(form.MHI0.value); // Median Household Income // Calculate values FSpHH = 0.4425*MHI - 1089.59; // Federal Spending per U.S. Household // Output Calculated Values to Form form.FSpHH.value = decimalFP(FSpHH, 0); } // End zeroDeficitLine function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function incomePercentile2009(form) { // Constants earners = 211254000; // Number of Income Earners in 2009 // Convert Input Variables to Numeric Values x = eval(form.income0.value); // Your Annual Income (Total Money Income) // Calculate values maxIncome = 150000000; if(x= 1) TieTheKnot = "Yes. It's time to start shopping for a ring!"; // Comment = TieTheKnot; // The Bottom Line // Output Calculated Values to Form form.TTK.value = decimalFP(TTK, 2); form.Comment.value = Comment; } // End readyToPropose function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function topOnePctTaxCollections(form) { // Constants a = -5.3805388414261332E+06; // a b = -6.7378355944145390E-12; // b c = 5.2057116603559622E+05; // c d = 6.1169870046247370E-13; // d f= 1.1741786853311759E-01; // f g = 1.0670314607969531E-05; // g h = -4.9596727665121447E-07; // h offset = -1.1778311928168268E+05; // Offset // Convert Input Variables to Numeric Values x = eval(form.x_in0.value); // Maximum U.S. Income Tax Rate y = eval(form.y_in1.value); // Taxable Income Floor to be in Top 1% of Taxpayers // Calculate values z = (a + b*Math.exp(x) + c*Math.log(y) + d*Math.exp(x)*Math.log(y)) / (1.0 + f*x + g*y + h*x*y) + offset; // Estimated Total Tax Collections [millions U.S. dollars] // Output Calculated Values to Form form.z.value = decimalFP(z, 0); } // End topOnePctTaxCollections function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function goldCube(form) { // Constants RM = 19.3; // Density of Gold [grams per cubic centimeter] // Convert Input Variables to Numeric Values A = eval(form.A0.value); // Amount of Federal Spending [billions U.S. dollars] G = eval(form.G1.value); // Spot Price of Gold [U.S. dollars per ounce] // Calculate values RE = RM*62.428; // Convert Gold Density to Pounds per Cubic Foot P = G*16; // Convert Gold Price to Price per Pound W = A*1E9/P; // Equivalent Value in Weight of Gold [pounds] V = W/RE; // Equivalent Volume of Gold [cubic feet] S = Math.pow(V, 1/3); // Side Dimension of Gold Cube [feet] P = V/Math.pow(66.11, 3)*100; // Percent of All Gold Ever Found TEU = V/1160; // Equivalent Number of 20-feet Standard Shipping Containers // Output Calculated Values to Form form.W.value = decimalFP(W, 2); if (S > 10) { form.S.value = decimalFP(S, 1) + " x " + decimalFP(S, 1) + " x " + decimalFP(S, 1); } else { form.S.value = decimalFP(S, 2) + " x " + decimalFP(S, 2) + " x " + decimalFP(S, 2); } form.P.value = decimalFP(P, 4) + "%"; form.TEU.value = decimalFP(TEU, 1); } // End goldCube function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function howManyKids(form) { // Constants O = "No. You're not ready yet!"; // Default Response // Convert Input Variables to Numeric Values S = eval(form.S0.value); // Your combined household salary K = eval(form.K1.value); // Combined, how many brothers and sisters do you and your spouse have (include yourselves in this number) T = eval(form.T2.value); // Combined hours per week you and your significant other work outside the house A = eval(form.A3.value); // On a scale from 1-10, the highest level of aversion you have to any of the following: Changing diapers, sleep deprivation, visiting in-laws, tantrums E = eval(form.E4.value); // On a scale from 1-10, how concerned are you about global overpopulation // Calculate values if (S >= 30000) { K = Math.pow((S - 30000)/5000, 1/3) + (K + 11 - E)/(T/20 + A); // Number of Kids } else { K = -Math.pow((30000 - S)/5000, 1/3) + (K + 11 - E)/(T/20 + A); // Number of Kids; } if (K >= 1) O = "You're probably ready!"; // Should You Have Kids? shouldYou = O; // Should You Have Kids? Kids = K; // How Many Kids Should You Have? C = "No - we just provide that to give you an idea of how close you might be to a particular 'whole child' threshold so you can play with tweaking your input data!"; // Should You Be Concerned by the Decimal Portion of the Answer? // Output Calculated Values to Form form.shouldYou.value = shouldYou; form.Kids.value = decimalFP(Kids, 1); form.C.value = C; } // End howManyKids function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function gasPriceToUnemploymentRate(form) { // Constants CPIJan2011 = 220.223; // Consumer Price Index, January 2011 // Convert Input Variables to Numeric Values Gnominal = eval(form.Gnominal0.value); // Average Price of a Gallon of Gasoline CPILatest = eval(form.CPILatest1.value); // Most Recent Consumer Price Index (CPI-U) Value // Calculate values Greal = CPIJan2011/CPILatest*Gnominal; // Adjust Gasoline Price to be in Constant January 2011 U.S. Dollars UE50 = 1.92*Gnominal + 2.024; // Projected Unemployment Rate // Output Calculated Values to Form form.UE50.value = decimalFP(UE50, 1) + "%"; } // End gasPriceToUnemploymentRate function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function planetValue(form) { // Constants Msun = 1.9891; // Mass of the Sun Mearth = 5.9736; // Mass of the Planet Earth Mmars = 0.64585; // Mass of the Planet Mars Tearth = 254.3; // Effective Temperature Tmars = 210.2; // Effective Temperature // Convert Input Variables to Numeric Values Teff = eval(form.Teff0.value); // Effective Temperature of the Planet [degrees Kelvin] Mplanet = eval(form.Mplanet1.value); // Mass of the Planet [quadrillion kg] Tyr = eval(form.Tyr2.value); // Year of Discovery [Enter 2009 if Discovered Prior to 2009] Tstar = eval(form.Tstar3.value); // Age of the Planet's Star [billion years] Mstar = eval(form.Mstar4.value); // Mass of the Planet's Star [quintillion kg] Vstar = eval(form.Vstar5.value); // Apparent Visual Magnitude (Brightness) of the Planet's Star // Calculate values V1 = 6000000*Tstar/0.5 * Math.pow(Msun/Mstar, 1/3); V2 = Math.exp(-Math.pow(Math.log(Mplanet/Mearth)/Math.LN10/0.2, 2)); V3 = Math.exp(-Math.pow((Teff - 273)/30, 2)); V4 = Math.exp(-((Math.max(Tyr, 2009) - 2009)/4)); V5 = Math.sqrt(Math.pow(2.5, 12-Vstar)); V = V1*V2*V3*V4*V5; // Estimated Value [Constant 2009 U.S. Dollars] // Output Calculated Values to Form form.V.value = decimalFP(V, 2); } // End planetValue function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function lightTechnologyComparison(form) { // This function will find out if one electric light source type is more // economical than a competing technology // Convert Input Variables to Numeric Values C = eval(form.C0.value); // Electricity Rate [$ per kiloWatt-hour] H = eval(form.H1.value); // Time Period of Operation [Hours] L1 = eval(form.L12.value); // Technology for Light #1 [Incandescent, Fluorescent, LED = 1, CFL = 2/3] L2 = eval(form.L23.value); // Technology for Light #2 [Incandescent, Fluorescent, LED = 1, CFL = 2/3] W1 = eval(form.W14.value); // Light #1 Power Consumption Rate [Watts] W2 = eval(form.W25.value); // Light #2 Power Consumption Rate [Watts] T1 = eval(form.T16.value); // Rated Life of Light #1 [Hours] T2 = eval(form.T27.value); // Rated Life of Light #2 [Hours] P1 = eval(form.P18.value); // Purchase Price of Light #1 [$ per Lamp] P2 = eval(form.P29.value); // Purchase Price of Light #2 [$ per Lamp] // Calculate values N1 = Math.ceil(H/T1/L1); // Number of Consumed Units Like Light #1 N2 = Math.ceil(H/T2/L2); // Number of Consumed Units Like Light #1 CB1 = N1*P1; // Cost of Bulbs OVer Time Period of Operation for Light #1 CB2 = N2*P2; // Cost of Bulbs Over Time Period of Operation for Light #2 CE1 = H*W1/1000*C; // Cost of Electricity Over Time Period of Operation for Light #1 CE2 = H*W2/1000*C; // Cost of Electricity Over Time Period of Operation for Light #2 CT1 = CB1 + CE1; // Total Cost of Ownership and Use of Light #1 CT2 = CB2 + CE2; // Total Cost of Ownership and Use of Light #2 if(CT10) IPM = "+"; G = -I*2.65; // Effective Change in GDP Growth Rate if (G>0) GPM = "+"; // Output Calculated Values to Form form.I.value = IPM + decimalFP(I, 1) + "%"; form.G.value = GPM + decimalFP(G, 1) + "%"; } // End cdsGDP function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function perfectToast(form) { // Convert Input Variables to Numeric Values ha = eval(form.ha0.value); // Bread Thickness [millimeters] Cpa = eval(form.Cpa1.value); // Bread Specific Heat [kJ/kg/oC] Cpb = eval(form.Cpb2.value); // Butter Specific Heat [kJ/kg/oC] pa = eval(form.pa3.value); // Density of Bread [g/L] pb = eval(form.pb4.value); // Density of Butter [g/L] T = eval(form.T5.value); // Temperature of Bread Immediately After Toasting [oC] wa = eval(form.wa6.value); // Weight of Bread Slice [g] // Calculate values hb = (Cpa*pa*(T-35))/60/Cpb/pb*ha; // Thickness of Butter [mm] F = Cpa*(T-35)/60/Cpb*wa; // Weight of Butter [g] // Output Calculated Values to Form form.hb.value = decimalFP(hb, 2); form.F.value = decimalFP(F, 2); } // End perfectToast function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function actuarialssIRR2010(form) { // This function will return an approximate internal rate of return for average // Social Security old age beneficiaries under present law (August 2011). The // formula was generated using ZunZun's 3-D contour mapping functions, with x // representing the difference between the individual's birth year and 1913, y // representing the individual's average lifetime annual income in 2010 dollars. // ZunZun generated the various values for the constants a, b, and c. // // Reference Link: http://www.ssa.gov/OACT/NOTES/ran5/an2009-5.html // Convert Input Variables to Numeric Values by = eval(form.by0.value); // Your Birth Year ai = eval(form.ai1.value); // Your Average Lifetime Annual Income hh = eval(form.hh2.value); // Household Type // Calculate values x = by - 0 // Difference Between Birth Year and 1913 // Set Constants if (hh == 0) { // Single Male a = 3.4830058483131051E+07; b = -1.3769406994404348E+07; c = -9.8160827145620715E+01; d = 1.8145060082775326E+06; f = 9.3514340906403959E+00; g = -7.9703860850292258E+04; h = -3.0071162991225719E-01; } if (hh == 1) { // Single Female a = 4.6465115514614679E+07; b = -1.8370376588547118E+07; c = -9.6139752013958059E+01; d = 2.4209750412252117E+06; f = 9.1590634707827121E+00; g = -1.0635075353067368E+05; h = -2.9447480291128159E-01; } if (hh == 2) { // One-Earner Couple a = 4.9682508087921910E+07; b = -1.9637628433339857E+07; c = -1.0157001107651740E+02; d = 2.5873554737905581E+06; f = 9.6840790377464145E+00; g = -1.1363222687139083E+05; h = -3.1141287088394165E-01; } if (hh == 3) { // Two-Earner Couple a = 4.3581663567176104E+07; b = -1.7228949575518753E+07; c = -9.9209529911546269E+01; d = 2.2703632689268854E+06; f = 9.4518688353709877E+00; g = -9.9726351340780966E+04; h = -3.0402682162821293E-01; } // Approximated Internal Rates of Return from Social Security IRR = a; IRR += b*Math.log(x); IRR += c*Math.log(ai); IRR += d*Math.pow(Math.log(x), 2); IRR += f*Math.pow(Math.log(ai), 2); IRR += g*Math.pow(Math.log(x), 3); IRR += h*Math.pow(Math.log(ai), 3); LIRR = IRR - .20; // Low Rate of Return Approximation (%) AIRR = IRR; // Average Rate of Return Approximation (%) HIRR = IRR + .20; // High Rate of Return Approximation (%) // Output Calculated Values to Form form.LIRR.value = decimalFP(LIRR, 2); form.AIRR.value = decimalFP(AIRR, 2); form.HIRR.value = decimalFP(HIRR, 2); } // End actuarialssIRR2010 function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function generalLogistic(A, C, M, B, T, x) { return A + C/Math.pow(1 + T*Math.exp(-1*B*(x - M)) , 1/T); } // End generalLogistic function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function indIncPctle2010(form) { // Constants earners = 211492000; // Number of Income Earners in 2010 PA = 3.3449980649281133E-02; PB = 1.3146441528199077E+01; PC = 1.1910731880657568E+01; PD = 9.9781767595278037E-01; PE = 5.4858345499794581E+00; // Convert Input Variables to Numeric Values x = eval(form.income0.value); // Your Annual Total Money Income // Calculate values percentile = PD + (PA-PD) / Math.pow(1.0 + Math.pow(Math.log(x)/PC, PB), PE); percentile = Math.max(percentile, 0); // Set floor for income percentile percentile = Math.min(percentile, 1); // Set ceiling for income percentile earnLess = percentile*earners; // Approximate Number of Americans Earning Less earnMore = earners - earnLess; // Approximate Number of Americans Earning More percentile *= 100; // Output Calculated Values to Form form.percentile.value = decimalFP(percentile, 1); form.earnLess.value = decimalFP(earnLess, 0); form.earnMore.value = decimalFP(earnMore, 0); } // End indIncPctle2010 function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function hhIncPctle2010(form) { // Constants households = 118682000; // Number of U.S. Households in 2010 HA = 7.0540066417813362E-03; HB = 1.3667304099403975E+01; HC = 1.3615445184767367E+01; HD = 9.9878358756931840E-01; HE = 1.6539706906092988E+01; // Convert Input Variables to Numeric Values x = eval(form.income0.value); // Your Annual Household Total Money Income // Calculate values percentile = HD + (HA-HD) / Math.pow(1.0 + Math.pow(Math.log(x)/HC, HB), HE); percentile = Math.max(percentile, 0); // Set floor for income percentile percentile = Math.min(percentile, 1); // Set ceiling for income percentile earnLess = percentile*households; // Approximate Number of Americans Earning Less earnMore = households - earnLess; // Approximate Number of Americans Earning More percentile *= 100; // Output Calculated Values to Form form.percentile.value = decimalFP(percentile, 1); form.earnLess.value = decimalFP(earnLess, 0); form.earnMore.value = decimalFP(earnMore, 0); } // End hhIncPctle2010 function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function wrongPath2010(form) { // Convert Input Variables to Numeric Values x = eval(form.x0.value); // Median Household Income // Calculate values y = 311420.423287*Math.pow(x, 1.463074); // Estimated Amount of Money Collected by U.S. Government // Output Calculated Values to Form form.y.value = decimalFP(y, 0); } // End wrongPath2010 function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function flatTax2010(form) { // Set Constants tEX2009 = 284239508; // Total Exemptions Claimed in 2009 - Most Recent Data Available (http://www.irs.gov/pub/irs-soi/09intba.xls) cTC2010 = 898549000000; // Cumulative Personal Income Tax Collections for 2010 (http://www.gpoaccess.gov/usbudget/fy12/xls/BUDGET-2012-TAB-2-1.xls) GDP2010 = 14526500000000; // 2010 U.S. GDP (http://www.bea.gov/newsreleases/national/gdp/2011/txt/gdp2q11_2nd.txt) num2010 = 118682000; // Number of Households in 2010 // Income Distribution Constants A2010 = -1.3088145248973815E+03; C2010 = 1.2014608613920317E+05; M2010 = 1.1048130487672319E+01; B2010 = 2.6414531291200865E+00; T2010 = 2.5357700309477940E+00; // Code Reference Constants i = 0; // Counting Variable sAI = 0; // Sum of Aggregate Income inc = 10000; // Income Increment cap = 150000000; // Maximum Value for Income Distribution // Convert Input Variables to Numeric Values tax = eval(form.tax0.value)/100; // Flat Percentage Income Tax Rate itc = eval(form.itc1.value); // Value of Individual Tax Credit tmi = eval(form.tmi2.value); // Your Household Annual Total Money Income num = eval(form.num3.value); // Number of Individuals Covered by Income Reported on Your Tax Return // Individual Income Tax Calculations iit = tmi*tax; // Individual Income Tax [$] iic = itc*num; // Value of Individual Tax Credits [$] tpc = iit - iic; // Net Individual Income Taxes, Post Credits if (tpc = -1)) { var mainMessage =" Merry Christmas!!! "; var speed=175; var scrollingRegion=100; var tempLoc=(scrollingRegion*3/mainMessage.length)+1; if (tempLocscrollingRegion) startPosition=0; setTimeout("Xmascountdown()",speed); } else { if (days >= 0) { var theDay = XmasDate; } else { var theDay = new Date(XmasDate.getYear()+1,XmasDate.getMonth(),XmasDate.getDate()); } var second = Math.floor((theDay.getTime() - today.getTime())/1000); var minute = Math.floor(second/60); var hour = Math.floor(minute/60); var day = Math.floor(hour/24); CDay= day; CHour= hour % 24; CMinute= minute % 60; CSecond= second % 60; dayOrDays = " days, "; hourOrHours = " hours, "; minuteOrMinutes = " minutes and "; secondOrSeconds = " seconds"; if (CDay 0) dayOrDays = " day, "; if (CHour 0) hourOrHours = " hour, "; if (CMinute 0) minuteOrMinutes = " minute and "; if (CSecond 0) secondOrSeconds = " second"; var DayTill = CDay + dayOrDays + CHour + hourOrHours + CMinute + minuteOrMinutes + CSecond + secondOrSeconds; clock.XmascountdownDisplay.value = DayTill; var counter = setTimeout("Xmascountdown()", 1000); } } // End Xmascountdown function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function volPriceAbort2008(form) { // Convert Input Variables to Numeric Values C = eval(form.C0.value); // Annual Caseload // Calculate values P = 350.37*(1 - Math.exp(-4.72*Math.pow((Math.max(C,30) - 28.22), -0.44))) + 412.45; // Average Price Paid for Abortion, 2008 R = C*P; // Estimated Annual Revenue for Abortion Provider // Output Calculated Values to Form form.P.value = decimalFP(P, 2); form.R.value = decimalFP(R, 2); } // End volPriceAbort2008 function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function accountingManipulations2010(form) { // This function differs from the original accountingManipulations function in that it incorporates // soft assets into the overall F-score calculation, the formula for which was modified in a 21 April 2010 // revision to the original paper "Predicting Material Accounting Misstatements". // Constants KNOWN = 494; // Number of Known Manipulating Firms-Years in Authors' Sample NONMAN = 133461; // Number of Non-Manipulating Firms-Years in Authors' Sample // F-Score Coefficients A = -7.893; B = 0.790; C = 2.518; D = 1.191; E = 1.979; F = 0.171; G = -0.932; H = 1.029; // Initial Default Values issue = 0; // Indicates firm has not issued new long-term debt, common stock, or preferred stock. // Convert Input Variables to Numeric Values // Note: Variable Naming Convention is based on Compustat Data Reference and Number of Years prior to the Year of Interest // i.e. Data 6 (Total Assets) is D06, one year prior to year of interest is Y1, resulting variable is: D06Y1 // D12Y0 = eval(form.D12Y00.value); // Sales (Revenues) - Year of Interest D12Y1 = eval(form.D12Y10.value); // Sales (Revenues) - One Year Prior D18Y0 = eval(form.D18Y01.value); // Net Income Before Extraordinary Items or Cumulative Effect of Accounting Changes - Year of Interest D18Y1 = eval(form.D18Y11.value); // Net Income Before Extraordinary Items or Cumulative Effect of Accounting Changes - One Year Prior D01Y0 = eval(form.D01Y02.value); // Cash and Cash Equivalents - Year of Interest D01Y1 = eval(form.D01Y12.value); // Cash and Cash Equivalents - One Year Prior D01Y0A = eval(form.D01Y0A3.value); // Short Term Investments - Year of Interest D01Y1A = eval(form.D01Y1A3.value); // Short Term Investments - One Year Prior D02Y0 = eval(form.D02Y04.value); // Receivables (Total) - Year of Interest D02Y1 = eval(form.D02Y14.value); // Receivables (Total) - One Year Prior D02Y2 = eval(form.D02Y24.value); // Receivables (Total) - Two Years Prior D03Y0 = eval(form.D03Y05.value); // Inventories (Total) - Year of Interest D03Y1 = eval(form.D03Y15.value); // Inventories (Total) - One Year Prior D06Y0 = eval(form.D06Y06.value); // Total Assets - Year of Interest D06Y1 = eval(form.D06Y16.value); // Total Assets - One Year Prior D06Y2 = eval(form.D06Y26.value); // Total Assets - Two Years Prior D08Y0 = eval(form.D08Y0.value); // Property, Plant and Equipment (Total - Net) - Year of Interest D130Y0 = eval(form.D130Y07.value); // Preferred Stock (Total) - Year of Interest D130Y1 = eval(form.D130Y17.value); // Preferred Stock (Total) - One Year Prior D216Y0 = eval(form.D216Y08.value); // Total Shareholder's (or Owner's) Equity - Year of Interest D216Y1 = eval(form.D216Y18.value); // Total Shareholder's (or Owner's) Equity - One Year Prior D111Y0 = eval(form.D111Y09.value); // Issuance of Long-Term Debt - Year of Interest D108Y0 = eval(form.D108Y0X.value); // Issuance of Common or Preferred Stock - Year of Interest // Calculate values UnProb = KNOWN/NONMAN; // Unconditional Probability of Accounting Manipulation ATAY0 = (D06Y0 + D06Y1)/2; // Average Total Assets Between Year[t] and Year[t-1] ATAY1 = (D06Y1 + D06Y2)/2; // Average Total Assets Between Year[t-1] and Year[t-2] CRY0 = D02Y0 - D02Y1; // Change in Receivables Between Year[t] and Year[t-1] CRY1 = D02Y1 - D02Y2; // Change in Receivables Between Year[t-1] and Year[t-2] CIY0 = D03Y0 - D03Y1; // Change in Inventories Between Year[t] and Year[t-1] if (D111Y0 > 0) issue = 1; // Firm Issued Long Term Debt in Year of Interest if (D108Y0 > 0) issue = 1; // Firm Issued Common or Preferred Stock in Year of Interest ch_earn = D18Y0/ATAY0 - D18Y1/ATAY1; // Change in Earnings ch_cs = (D12Y0 - CRY0)/(D12Y1 - CRY1) - 1; // Change in Cash Sales ch_inv = CIY0/ATAY0; // Change in Inventories soft_assets = (D06Y0 - D08Y0 - D01Y0)/D06Y0; // Percentage of Soft Assets ch_rec = CRY0/ATAY0; // Change in Receivables rsst_acc = ((D216Y0-(D01Y0+D01Y0A)-D130Y0) - (D216Y1-(D01Y1+D01Y1A)-D130Y1))/ATAY0; // RSST Accruals formula = A + B*rsst_acc + C*ch_rec + D*ch_inv + E*soft_assets + F*ch_cs + G*ch_earn + H*issue; // Mathematical Model acct_Pr = Math.exp(formula)/(1 - Math.exp(formula)); // Probability of Accounting Manipulation FScore = acct_Pr/UnProb; // F-Score // Output Calculated Values to Form form.FScore.value = decimalFP(FScore, 2); } // End accountingManipulations2010 function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function millionaireDecayFunction(form) { // Constant Values a = 1.4023522734010808E+02; b = 2.5861045923015835E+00; c = 6.1510275142758608E-01; Offset = -4.0228809113431126E+01; // Convert Input Variables to Numeric Values x = eval(form.x0.value); // Number of Years After Having Earned $1 Million // Calculate values y = Math.max(a / (1.0 + Math.pow(x/b, c)) + Offset, 0); // Odds of Still Earning $1 Million After Entered Number of Years // Output Calculated Values to Form form.y.value = decimalFP(y, 1) + "%"; } // End millionaireDecayFunction function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function billionaireDecayFunction(form) { // Constants p1 = 1.27718984563; // a p2 = 0.25921297855; // b p3 = 82.73165076970; // c p4 = 0.00000001351; // d p5 = -2.14385748741; // e Offset = 0.22578156607; // f // Convert Input Variables to Numeric Values v = eval(form.v0.value); // Number of Years After Becoming a Top 400 Taxpayer // Calculate values g = p3/(1+Math.exp((v-p1)/p2)) + p4*Math.exp((v-45)/p5) + Offset; // Probability of Being a Top 400 Taxpayer After Entered Number of Years // Output Calculated Values to Form form.g.value = decimalFP(g, 2) + "%"; } // End billionaireDecayFunction function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function celebrityMarriageOdds(form) { // Convert Input Variables to Numeric Values NYT = eval(form.NYT0.value); // "Good" Fame: Number of search results since 1990 in New York Times archives ENQ = eval(form.ENQ1.value); // "Bad" Fame: Number of search results since 1990 in National Enquirer archives Ah = eval(form.Ah2.value); // Husband's Age Aw = eval(form.Aw3.value); // Wife's Age Sc = eval(form.Sc4.value); // Overexposure: Number of scantily-clad photos among the top five photos returned in a Google image search for the wife's name Md = eval(form.Md5.value); // Dating: Number of months the celebrity couple dated before getting married. T = eval(form.T6.value); // Time: Years after getting married for which to calculate the percentage odds that the couple will still be married. // Calculate values if(NYT==24 && ENQ==23 && Ah==29 && Aw==24 && Sc==0 && Md==6 && T==50) { data = "Default"; } else { data = "0"; } FR = NYT/ENQ; // "Good" to "Bad" Fame Ratio ADER = (Ah + Aw)/(Sc + 5); // Age Disparity/Exposure Ratio DDF = Md*Math.pow(Md/(Md + 2), Math.pow(T, 2)); // Dating Duration Factor C = 50*Math.pow(FR*ADER*DDF, 1/15); // Percentage Chance of Still Being Married After Entered Number of Years // Output Calculated Values to Form form.FR.value = decimalFP(FR, 1); if (data==0) { form.C.value = decimalFP(C, 1) + "%"; } else { form.C.value = decimalFP(C, 15) + "%"; } } // End celebrityMarriageOdds function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function whiteheadOilQuantityChange(form) { // Convert Input Variables to Numeric Values Q = eval(form.Q0.value); // Daily Oil Production Data dP = eval(form.dP.value); // Change in Price P = eval(form.P2.value); // Current Oil Price (per Barrel) ed = eval(form.ed3.value); // Demand Elasticity es = eval(form.es4.value); // Supply Elasticity // Calculate values dQ = -dP*(-ed + es)*Q/(P-dP); // Estimated Change in Quantity of Oil // Output Calculated Values to Form form.F.value = decimalFP(dQ, 0); } // End whiteheadOilQuantityChange function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function odds100(form) { // Convert Input Variables to Numeric Values x = eval(form.x0.value); // Your Current Age xxx = eval(form.xxx1.value); // Your Gender // Calculate percentage odds switch(xxx) { case 0: // NIST Lanczos a = 1.8914210628779582E-17; b = -3.8393903895747944E-01; c = -2.5649393951533865E-02; d = 9.2332838945229062E-02; f = 2.8567058898200470E-01; g = 1.8240274567965394E-02; y = a*Math.exp(-b*x) + c*Math.exp(-d*x) + f*Math.exp(-g*x); break; case 1: // Cellular Conductance with Offset p1 = 1.2122071117924841E+02; p2 = 2.7365970886805648E+00; p3 = -2.1031903122574354E+03; p4 = 3.7393387502800068E-01; p5 = -1.3030458899563473E+02; Offset = 2.1030023289651485E+03; y = p3/(1+Math.exp((x-p1)/p2)) + p4*Math.exp((x-45)/p5) + Offset; break; } // End switch statement. // Calculate values p100 = y*100; // Percentage Chance of Reaching Age 100 if (x>=100) p100 = "100"; // Output Calculated Values to Form form.p100.value = decimalFP(p100, 1) + "%"; } // End odds100 function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function charityTaxDeductionValue(form) { // Convert Input Variables to Numeric Values C = eval(form.C0.value); // Amount Donated to Charity [$] T = eval(form.T1.value); // Your Marginal Tax Bracket [%] // Calculate values R = T/100; // Decimalized Tax Rate V = C*R; // Tax Value of Your Charitable Donations // Output Calculated Values to Form form.V.value = decimalFP(V, 2); } // End charityTaxDeductionValue function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function happinessQuantified(form) { // Convert Input Variables to Numeric Values P1 = eval(form.P10.value); P2 = eval(form.P21.value); E = eval(form.E2.value); H = eval(form.H3.value); // Calculate values HAPPY = (P1 + P2) + 5*E + 3*H; // Your Personal Happiness Level // Output Calculated Values to Form form.HAPPY.value = decimalFP(HAPPY, 1); } // End happinessQuantified function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function caloriesWalk(form) { // Constants Burn = 262; // Average Calories Burned per Hour Walking (160 lb person) // Convert Input Variables to Numeric Values Calories = eval(form.Calories0.value); // Calories // Calculate values Time = Calories/Burn; // Time Hours = Math.floor(Time); // Hours Minutes = Math.floor((Time - Hours)*60); // Minutes OUTPUT = Hours + " hours and " + Minutes + " minutes"; // Approximate Time // Output Calculated Values to Form form.OUTPUT.value = OUTPUT; } // End caloriesWalk function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function hamiltonBrent2Pump(form) { // Convert Input Variables to Numeric Values B = eval(form.B0.value); // Price per Barrel of Brent Crude Oil // Calculate values P = 0.839 + 0.02499*B; // Average U.S. Price per Gallon // Output Calculated Values to Form form.P.value = decimalFP(P, 2); } // End hamiltonBrent2Pump function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function cumulativeOdds(form) { // Constants offenderTake = 7085.91; // Average Take per Offender in U.S. in 2011 // Convert Input Variables to Numeric Values successRate = eval(form.successRate0.value); // Success Rate of Bank Crimes [%] numberCrimes = eval(form.numberCrimes1.value); // Number of Bank Crimes You'll Attempt // Calculate values s = successRate/100; // Decimalized Percentage Odds Odds = Math.pow(s, numberCrimes)*100; // The Odds That You'll Succeed In That Many Bank Crimes Take = offenderTake * numberCrimes; // Your Estimated "Take" from All Your Bank Crimes // Output Calculated Values to Form form.Odds.value = decimalFP(Odds, 1) + "%"; form.Take.value = "$" + decimalFP(Take, 2); } // End cumulativeOdds function. // //-------|---------|---------|---------|---------|---------|---------|---------| // function safeIndex(form) { // Convert Input Variables to Numeric Values N = eval(form.N0.value); // Estimated Population in Known Rage MVP = eval(form.MVP1.value); // Minimum Viable Population // Calculate values SAFE = Math.log(N)/Math.LN10 - Math.log(MVP)/Math.LN10; // SAFE Index Score // Output Calculated Values to Form form.SAFE.value = decimalFP(SAFE, 2); } // End safeIndex function. // //-------|---------|---------|---------|---------|---------|---------|---------| // // //-------|---------|---------|---------|---------|---------|---------|---------| // -->
Political Calculations
Unexpectedly Intriguing!
07 August 2026

Some inventions are so old that we don't know the names of their inventors. Handaxes made from stone. The bow and arrow. Bricks. The wheel.

Well, maybe not the wheel, because we do know the name of its inventor! The wheel was invented by John Keogh, who was awarded Australian Innovation Patent 2001100012 for its invention in May 2001.

We're not making this up! Here's a colorized version of Figure 2 from the patent, which clearly depicts Keogh's innovation:

Australian Innovation Patent 2001100012 Figure 2

Here is the portion of the Keogh's patent that describes his invention, which certainly matches what we've come to know as the wheel:

The invention relates to a device for facilitating transport of goods and persons. In particular, the device relates to a circular object which enables such goods and persons to be held above a surface and simultaneously moved with respect to the surface approximately parallel thereto.

The background of the invention describes the problem Keogh's wheel solves:

In the past, transportation of goods and persons has been conducted in a number of ways. The predominant means has been transport of persons on foot, and carrying thereby of goods requiring transport.

Other means of transport have included, in colder climates, skis, sleds, toboggans and the like, which slide over a smooth (low coefficient of friction) surface such as ice or snow, thus transporting the person and/or goods. These modes of transport have the advantage that when travelling down a sloped surface, free movement, that is, unassisted forward motion, is possible. The user is only required to apply effort to cause movement when travelling uphill or on a substantially flat plane, and this reduced effort helps the user move to the desired destination more quickly and more easily.

Unfortunately, such smooth surfaces for sliding over are not generally available in warmer climates where snow and ice do not form naturally. As such, and in the absence of alternatives, foot transport may be required. It would be useful if a device was available which enabled such unassisted forward motion on downhill slopes on surfaces having a much higher coefficient of friction than snow or ice.

It's hard to believe that such a useful device has only existed as a patented invention since May 2001. But if you've made it this far, you're probably thinking there's something more to this story than the invention of the wheel.

You would be right! Matthew Rimmer's 2025 book Sub-patent Innovation Rights: Utility Models, Petty Patents and Innovation Patents Around the World tells the real story behind Keogh's successfully patented invention:

In 2001, a patent attorney called John Keogh was issued an innovation patent by IP Australia for a ‘circular transportation facilitation device’. There were also patent claims relating to rubber wheels and tires. The field of the invention was a ‘device for facilitating transport of goods and persons’. The background explained that a ‘circular transportation facilitation device’ would be an improvement on walking, and on other devices, like ‘skis, sleds, toboggans and the like’. The application was accompanied by an illustration of a wheel.

There was also a perspective drawing of a cart incorporating ‘a series of circular transportation facilitation devices in accordance with a preferred aspect of the present invention.’

Keough said that he patented the wheel in order to establish that the innovation patent system was flawed because it did not need to be examined by the patent office. He explained his concerns:

The patent office would be required to issue a patent for anything. All they’re doing is putting a rubber stamp on it. The impetus came from the Federal Government. Their constituents claimed the cost of obtaining a patent was too high so the government decided to find a way to issue a patent more easily.

Keogh noted that he had no immediate plans to patent fire, crop rotation, or other fundamental advances in civilization. John Keogh had previously written about the dangers of innovation patents, warning: ‘These junk patents may bring the entire Australian patent system into disrepute’.

Keough succeeded far beyond what he might have hoped. The Australian Patent Office was forced to recognize the deficiencies in their practices that were exposed by Keogh's patent. On 30 August 2001, the Keogh's patent was revoked. It would take another 20 years however before Australia's government learned the lesson it should have and finally abolished the country's second-tier innovation patent scheme. Australia's IP Office officially phased out its innovation patent system on 26 August 2021.

Even so, Keogh's patent for the wheel represents a true achievement. Both Keogh and the Australian Patent Office were jointly awarded an Ig-Nobel Prize in 2001 for their accomplishment.

The wheel is an amazing invention. But the story of its 2001 reinvention is just as amazing.

From the Inventions in Everything Archives

The IIE team has previously covered one other example of an invention whose true purpose was to expose problems in how patents are awarded:

Labels:

06 August 2026

The average mortgage payment on the typical new home sold in the U.S. rose above the upper limit of affordability for the typical American household in May 2026.

The change comes eight months after the affordability of the median new home had finally become affordable for households earning the median household income for the first time since March 2022. A combination of rising mortgage rates and rising new home prices are responsible for the development. Both have increased since bottoming at their most affordable levels in years in March 2026.

Here are the three numbers that define how affordable a new home is for the typical American household:

  • Median new home sale price: $424,900
  • Median household income: $87,646
  • Average 30-year conventional fixed mortgage rate: 6.44%

Median household income also increased during this time, but not by enough to offset the impact of the other two factors. For a household at the exact middle of the U.S. income spectrum, the average mortgage payment for a new home purchased at the national median sale price with zero-percent down consumed 36.6% of the household's monthly income in May 2026.

This value is higher than the upper threshold of affordability defined by the 28/36 rule that mortgage lenders traditionally use to determine whether to extend a mortgage to new home buyers. A monthly mortgage payment that consumes more than 36% of a household's income means that the median new home sold in May 2026 is outside the affordable reach of a household earning the median income, even if it has no other debts.

The following chart shows how May 2026's level of relative affordability for new homes compares with the affordability for every month since January 2000:

Mortgage Payment for a Median New Home as a Percentage of Median Household Income, January 2000 - May 2026

Looking forward, the average interest rate for a 30-year conventional fixed rate mortgage increased to 6.49% in June 2026. This increase creates additional headwinds for new home affordability in the United States.

References

U.S. Census Bureau. New Residential Sales Historical Data. Houses Sold. [Excel Spreadsheet]. Accessed 24 July 2026.

U.S. Census Bureau. New Residential Sales Historical Data. Median and Average Sale Price of Houses Sold. [Excel Spreadsheet]. Accessed 24 July 2026.

Freddie Mac. 30-Year Fixed Rate Mortgages Since 1971. [Online Database]. Accessed 1 August 2026. Note: Starting from December 2022, the estimated monthly mortgage rate is taken as the average of weekly 30-year conventional mortgage rates recorded during the calendar month.

Image Credit: Microsoft Bing Image Generator. Prompt: "An editorial cartoon of an American family looking sadly at a new house with a "For Sale" sign in front of it that they cannot afford." We modified the generated image to add text to the label on the "For Sale" sign.

Labels:

05 August 2026
An editorial cartoon of a Wall Street bull and bear looking at a balloon labeled 'AI BUBBLE?' that has deflated. Image generated by Microsoft Copilot Designer

Two months ago, the S&P 500 (Index: SPX) was rising so quickly it raised the prospect the index could see a break down in the relative period of order the index established since the end of 2023.

Instead, after peaking on 2 June 2026, the S&P 500 has reverted toward its established mean trajectory. Through the end of July 2026, the index is hovering right around that 31-month-old central trend curve.

Which is to say the index remains well within its established relative period of order after having regressed toward its mean trend trajectory. Whatever bubble might have been forming within the index has mostly deflated.

The following chart visualizes the relationship between the value of the S&P 500 and its underlying trailing year dividends per share from 29 December 2023 through 31 July 2026:

S&P 500 Index Value vs Trailing Year Dividends per Share, 29 December 2023 through 31 July 2026

Previously on Political Calculations

Image Credit: Microsoft Copilot Designer. Prompt: "An editorial cartoon of a Wall Street bull and bear looking at a balloon labeled 'AI BUBBLE?' that has deflated".

Labels: , , ,

04 August 2026
Median Household Income - US Map

Motio Research's initial estimate of U.S. median household income for June 2026 is $88,110, a $370 (or 0.4%) decrease from the firm's initial estimate of $88,480 for May 2026.

Here are screenshots of the interactive charts Motio Research provides to visualize trends in the U.S.' median household income. The first chart presents the firm's Household Income Index, which is based on a three-month moving average that sets the period of January 2010 through March 2010 at a value of 100. The second chart presents their monthly median household income estimates in nominal (not adjusted for inflation) terms for the period from January 2010 through June 2026.

Monthly Household Income Index

Motio Research: Household Income Index, January-March 2010 through April-June 2026

Median Household Income Estimates

Motio Research: Nominal Median Household Income Estimates, January 2010 - June 2026

Motio Research offered the following analysis of the month-over-month decline in their survey-based median household income estimate:

The U.S. Real Median Household Income Index fell to 118.9. Nominal median household income also declined, falling 0.3% to $88,110. The real estimates are expressed in June 2026 dollars using Chained CPI-U; the series are seasonally adjusted three-month averages, and the index is set to 100 in March 2010.

Year-over-year change is Motio’s principal measure of household-income direction and momentum. Real household-income growth had strengthened from 2.3% in March to 2.7% in April before easing to 2.6% in May. The full percentage-point decline in June sharply interrupted that stronger trajectory.

Although larger one-month declines in the real-income level occurred in May 2010 and January 2021, both took place during contractionary or pandemic-disrupted phases of the household-income series. June’s combination of a 0.5% decline in the level and a full percentage-point loss of year-over-year momentum represents the largest simultaneous weakening in the two measures recorded during an established expansion phase of the series.

“One month of weakness does not establish a turning point, and we would caution against interpreting it as one,” said Matías Scaglione, Co-Founder and Principal Economist at Motio Research. “June nevertheless warrants attention because both the level and momentum of real household income weakened substantially during an established upswing. Whether this reflects temporary volatility or the beginning of a broader deterioration in household-income conditions is the question the next several releases will help answer.”

Analyst's Notes

Political Calculations produces monthly median household income estimates using an alternate methodology that complements Motio Research's survey-based estimates. In June 2026, Political Calculations' initial estimate of median household income is $87,934. This estimate is $291 (or 0.3%) higher than our initial estimate of $87,643 for May 2026's median household income.

The following chart presents our estimates of U.S. median household income, both adjusted for inflation (blue) and not-adjusted for inflation (red) for each month from January 2000 through May 2026.

Median Household Income in the 21st Century: Nominal and Real Modeled Estimates, January 2000 to June 2026

Political Calculations' June 2026 estimate is $176 (0.2%) below Motio Research's estimate of $88,110 for the month, which largely closes the gap we've observed between the two sets of estimates since Motio Research's estimates surged upward in July 2025.

For the latest in our coverage of median household income in the United States, follow this link!

References

U.S. Bureau of Economic Analysis. Table 2.6. Personal Income and Its Disposition, Monthly, Personal Income and Outlays, Not Seasonally Adjusted, Monthly, Middle of Month. Population. [Online Database (via Federal Reserve Economic Data)]. Last Updated: 30 July 2026. Accessed: 30 July 2026.

U.S. Bureau of Economic Analysis. Table 2.6. Personal Income and Its Disposition, Monthly, Personal Income and Outlays, Not Seasonally Adjusted, Monthly, Middle of Month. Compensation of Employees, Received: Wage and Salary Disbursements. [Online Database (via Federal Reserve Economic Data)]. Last Updated: 30 July 2026. Accessed: 30 July 2026.

Image credit: U.S. Census Bureau. We modified the public domain image to make it more generally applicable beyond reporting the median household income from 2022.

Labels:

03 August 2026
An editorial cartoon showing a Wall Street bull and bear spinning a Price Is Right style Big Wheel labeled 'WHICH WAY WILL STOCKS GO?’ with values 'UP' and 'DOWN'. Image generated with Microsoft Copilot Designer.

The direction the S&P 500 (Index: SPX) takes is shaping up a lot like a playing a game that has a 50% chance of winning or a 50% chance of losing.

Investors saw that game play out during the past week as several of the Big Tech companies that dominate the index reported their earnings and updated their outlooks. For example, the world's biggest company, Apple (NASDAQ: AAPL) briefly touched a $5 trillion valuation before disappointing investors with its supply chain struggles, sending its shares lower.

But that loss was offset for the index as both Amazon (NASDAQ: AMZN) and Microsoft (NASDAQ: MSFT) were more positive.

By the time the trading week ended on Friday, 31 July 2026, the bulls came out ahead as the index rose almost 1.1% above its previous week's close to reach a value of 7,489.72.

The latest update of the alternative futures chart shows stock prices are consistent with investors focusing their forward looking attention on either the current quarter of 2026-Q3 or the more distant quarter of 2026-Q4.

Alternative Futures - S&P 500 - 2026Q3 - Standard Model (m=-2.0 from 28 Apr 2025) - Snapshot on 31 Jul 2026

The dividend futures-based model indicates very little difference in where it projects the level of the S&P 500 would be for investors fixing their attention on either these two future quarters.

As for why these two quarters would be of particular interest to investors, they happen to represent the likely timing of when the Fed will act to change the Federal Funds Rate. The CME Group's FedWatch Tool projects two quarter point rate hikes before the end of 2026. The first would occur after the Fed meets on 16 September (2026-Q3) and the second would take place on 9 December (2026-Q4).

Here are the market-moving headlines of the week that was:

Monday, 27 July 2026
Tuesday, 28 July 2026
Wednesday, 29 July 2026
Thursday, 30 July 2026
Friday, 31 July 2026

The BEA's first estimate of annualized real GDP growth during 2026-Q2 is 1.5%, just a bit below the Atlanta Fed's GDPNow tool's final estimate of +1.7% for the quarter. Meanwhile, GDPNow tool's first estimate of real GDP growth for the U.S. economy in the now current quarter of 2026-Q3 is +5.0%.

Image credit: Microsoft Copilot Designer. Prompt: "An editorial cartoon showing a Wall Street bull and bear spinning a Price Is Right style Big Wheel labeled 'WHICH WAY WILL STOCKS GO?’ with values 'UP' and 'DOWN'".

Labels: ,

About Political Calculations

Welcome to the blogosphere's toolchest! Here, unlike other blogs dedicated to analyzing current events, we create easy-to-use, simple tools to do the math related to them so you can get in on the action too! If you would like to learn more about these tools, or if you would like to contribute ideas to develop for this blog, please e-mail us at:

ironman at politicalcalculations

Thanks in advance!

Recent Posts

Indices, Futures, and Bonds

Closing values for previous trading day.

Most Popular Posts
Quick Index

Site Data

This site is primarily powered by:

This page is powered by Blogger. Isn't yours?

CSS Validation

Valid CSS!

RSS Site Feed

AddThis Feed Button

JavaScript

The tools on this site are built using JavaScript. If you would like to learn more, one of the best free resources on the web is available at W3Schools.com.

Other Cool Resources

Blog Roll

Market Links

Useful Election Data
Charities We Support
Shopping Guides
Recommended Reading
Recently Shopped

Seeking Alpha Certified

Archives