diff --git a/project.clj b/project.clj index 4750505..373db13 100644 --- a/project.clj +++ b/project.clj @@ -4,6 +4,6 @@ :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.6.0"] - [org.clojure/tools.namespace "0.2.4"] - [org.clojure/math.numeric-tower "0.0.4"] - [lein-gorilla "0.3.3"]]) + [org.clojure/tools.namespace "0.2.10"] + [org.clojure/math.numeric-tower "0.0.4"]] + :plugins [[lein-gorilla "0.4.0"]]) diff --git a/src/exponential_tax/core.clj b/src/exponential_tax/core.clj index c3ec916..01d1caf 100644 --- a/src/exponential_tax/core.clj +++ b/src/exponential_tax/core.clj @@ -1,6 +1,52 @@ -(ns exponential-tax.core - (:require [clojure.math.numeric-tower :as math])) +;; gorilla-repl.fileformat = 1 +;; ** +;;; # Exponential Tax worksheet +;;; +;;; This worksheet illustrates the effect of an exponential land tax on holdings of different sizes. +;;; +;;; ## Background +;;; +;;; In Scotland (and in many third world countries), ownership of land is highly concentrated in the hands of a very few, very rich people. This is bad from many points of view; this document isn't really the place to make those arguments. +;;; +;;; For more of the argument, read: +;;; +;;; * [Quarter of a million crofts](http://blog.journeyman.cc/2014/12/quarter-of-million-crofts.html) +;;; * [The Law of Freedom in a Web Page](http://blog.journeyman.cc/2015/03/the-law-of-freedom-in-web-page-or-true.html) +;;; * [Me and you and the Duke of Buccleuch](http://blog.journeyman.cc/2014/12/me-and-you-and-duke-of-buccleuch.html) +;;; +;;; So, having made that introduction, onto the code. +;;; +;;; ## First, some definitions +;;; +;;; ### The namespace +;;; +;;; First of all, we need to declare a namespace and the libraries on which this code depends. +;; ** + +;; @@ +(ns exponential-tax.core + (:require + [clojure.math.numeric-tower :as math] + [gorilla-repl.table :refer :all])) +;; @@ +;; => +;;; {"type":"html","content":"nil","value":"nil"} +;; <= + +;; ** +;;; ## Summing an exponential series +;;; +;;; My proposal for exponential land tax is based on the idea that you pay *a little bit on the first hectare, a bit more on the next, a bit more on the next, and so on*. It's based on that because I started with the legend of the [grains of rice on a chess-board](http://www.singularitysymposium.com/exponential-growth.html). +;;; +;;; So the amount of tax you pay is Σ1..n(cn)e, where *n* is the number of hectares you own. +;;; +;;; Actually, this is almost a purposeless complication; simply applying the exponential function to the number of hectares in a holding scales almost as rapidly. But I think the concept of *a little bit for the first hectare, a bit more for the next, and so on* is easy for folk to grasp. +;;; +;;; But to be able to compute this, we need to be able to construct and sum exponential series. So here's a function to do that. +;; ** + +;; @@ (defn summed-exponential-series "Sum an exponential series from 1 to limit. @@ -8,8 +54,25 @@ `exponent`: the exponent to which they are raised; `limit`: the limit of the range to be summed." [constant exponent limit] - (reduce + (map #(math/expt (* constant %) exponent) (range limit)))) + (reduce + + + (map + #(math/expt + (* constant %) + exponent) + (range limit)))) +;; @@ +;; => +;;; {"type":"html","content":"#'exponential-tax.core/summed-exponential-series","value":"#'exponential-tax.core/summed-exponential-series"} +;; <= +;; ** +;;; ## Formatting money +;;; +;;; It may be convenient to be able to format amounts of money, so here's a function to do this. +;; ** + +;; @@ (defn format-money-amount "Format the number passed as argument as an amount of money (pounds and pence). @@ -17,6 +80,43 @@ [n] (format "£ %,12.2f" n)) +;; @@ +;; => +;;; {"type":"html","content":"#'exponential-tax.core/format-money-amount","value":"#'exponential-tax.core/format-money-amount"} +;; <= + +;; ** +;;; ## Print out sample taxes given a table of holdings +;;; +;;; Since we need to know who will pay how much tax, we're going to want to be able to format a table of taxes due. +;; ** + +;; @@ +(defn sample-taxes + "Prints sample taxable amounts for a table of holdings." + [constant exponent holdings] + (table-view + (map + #(list (first %) + (format-money-amount + (summed-exponential-series + constant + exponent + (second %)))) + holdings) + :columns ["Holding" "Tax"])) +;; @@ +;; => +;;; {"type":"html","content":"#'exponential-tax.core/sample-taxes","value":"#'exponential-tax.core/sample-taxes"} +;; <= + +;; ** +;;; ## And then, of course, we need the actual sizes of holdings +;;; +;;; These numbers are, as far as I can establish, more or less accurate. Add holdings you're interested in to this list. +;; ** + +;; @@ (def holding-sizes [["Average croft" 5] ["Average farm" 101] @@ -32,10 +132,56 @@ ["Duke of Atholl" 58700] ["Duke of Buccleuch" 109000]]) -(defn sample-taxes - "Prints sample taxable amounts for a table of holdings." - [constant exponent holdings] - (map #(print (format "\n%s: £ %,.2f" - (first %) - (summed-exponential-series constant exponent (second %)))) - holdings)) \ No newline at end of file +;; @@ +;; => +;;; {"type":"html","content":"#'exponential-tax.core/holding-sizes","value":"#'exponential-tax.core/holding-sizes"} +;; <= + +;; ** +;;; +;; ** + +;; ** +;;; ## The Variables +;;; +;;; There are two key variables in this scheme, the constant and the exponent. +;;; +;;; ### The constant +;;; +;;; The constant is the amount the first hectare is taxed. It can be very small - a few pennies will do to start. +;; ** + +;; @@ +(def c 1) +;; @@ +;; => +;;; {"type":"html","content":"#'exponential-tax.core/c","value":"#'exponential-tax.core/c"} +;; <= + +;; ** +;;; ### The exponent +;;; +;;; The exponent is the amount each successive hectare's tax is multiplied by. It, too, can be surprisingly small - it needs to be above one, but it doesn't need to be much above one. +;; ** + +;; @@ +(def e 1.05) +;; @@ +;; => +;;; {"type":"html","content":"#'exponential-tax.core/e","value":"#'exponential-tax.core/e"} +;; <= + +;; ** +;;; ## Right, let's put that all together! +;; ** + +;; @@ +(sample-taxes c e holding-sizes) +;; @@ +;; => +;;; {"type":"list-like","open":"