Fourmilog: None Dare Call It Reason

Floating Point Benchmark: Lua Language Added

Thursday, July 24, 2014 22:32

I have posted an update to my trigonometry-intense floating point benchmark which adds Lua to the list of languages in which the benchmark is implemented. A new release of the benchmark collection including Lua is now available for downloading.

Lua was developed with the intention of being a small-footprint scripting language which could be easily embedded in applications. Despite this design goal, which it has achieved superbly, being widely adopted as the means of extensibility for numerous games and applications, it is a remarkably sophisticated language, with support for floating point, complex data structures, object oriented programming, and functional programming. It is a modern realisation of what I attempted to achieve with Atlast in 1990, but with a syntax which most programmers will find familiar and a completely memory-safe architecture (unless compromised by user extensions). If I were developing an application for which I needed scripting or user extensibility, Lua would be my tool of choice, and in porting the benchmark to the language I encountered no problems whatsoever—indeed, it worked the first time.

The relative performance of the various language implementations (with C taken as 1) is as follows. All language implementations of the benchmark listed below produced identical results to the last (11th) decimal place.

Language Relative
Time
Details
C 1 GCC 3.2.3 -O3, Linux
Visual Basic .NET 0.866 All optimisations, Windows XP
FORTRAN 1.008 GNU Fortran (g77) 3.2.3 -O3, Linux
Pascal 1.027
1.077
Free Pascal 2.2.0 -O3, Linux
GNU Pascal 2.1 (GCC 2.95.2) -O3, Linux
Java 1.121 Sun JDK 1.5.0_04-b05, Linux
Visual Basic 6 1.132 All optimisations, Windows XP
Haskell 1.223 GHC 7.4.1-O2 -funbox-strict-fields, Linux
Ada 1.401 GNAT/GCC 3.4.4 -O3, Linux
Go 1.481 Go version go1.1.1 linux/amd64, Linux
Simula 2.099 GNU Cim 5.1, GCC 4.8.1 -O2, Linux
Erlang 3.663
9.335
Erlang/OTP 17, emulator 6.0, HiPE [native, {hipe, [o3]}]
Byte code (BEAM), Linux
ALGOL 60 3.951 MARST 2.7, GCC 4.8.1 -O3, Linux
Lisp 7.41
19.8
GNU Common Lisp 2.6.7, Compiled, Linux
GNU Common Lisp 2.6.7, Interpreted
Smalltalk 7.59 GNU Smalltalk 2.3.5, Linux
Forth 9.92 Gforth 0.7.0, Linux
COBOL 12.5
46.3
Micro Focus Visual COBOL 2010, Windows 7
Fixed decimal instead of computational-2
Algol 68 15.2 Algol 68 Genie 2.4.1 -O3, Linux
Python 17.6 Python 2.3.3 -OO, Linux
Lua 22.7 Lua 5.2.3, Linux
Perl 23.6 Perl v5.8.0, Linux
Ruby 26.1 Ruby 1.8.3, Linux
JavaScript 27.6
39.1
46.9
Opera 8.0, Linux
Internet Explorer 6.0.2900, Windows XP
Mozilla Firefox 1.0.6, Linux
QBasic 148.3 MS-DOS QBasic 1.1, Windows XP Console

The performance of Lua is comparable to other scripting languages which compile to and execute byte-codes, such as Perl, Python, and Ruby. Raw CPU performance is rarely important in a scripting language, as it is mostly used as “glue” to invoke facilities of the host application which run at native code speed.

Back

Atlast 2.0 (64-bit) Released

Wednesday, July 16, 2014 23:56

I have just posted the first update to Atlast since 2007. Atlast is a FORTH-like language toolkit intended to make it easy to open the internal facilities of applications to users, especially on embedded platforms with limited computing and memory resources.

Like FORTH, Atlast provides low-level access to the memory architecture of the machine on which it runs, and is sensitive to the length of data objects. The 1.x releases of Atlast assume integers and pointers are 32 bit quantities and floating point numbers are 64 bit, occupying two stack items. This assumption is no longer the case when building programs in native mode on 64-bit systems: integers, pointers, and floating point values are all 64 bits.

Release 2.0 of Atlast is a dedicated 64-bit implementation of the language. If you are developing on a 64-bit platform and are confident you will only target such platforms, it provides a simpler architecture (no need for double word operations for floating point) and a larger address space and integers. This comes at the cost of loss of source code compatibility with the 32-bit 1.x releases, particularly for floating point code. If your target platform is a 32-bit system and your development machine is 64-bit, it's best to use version 1.2 (which is functionally identical to 2.0), cross-compiled as 32-bit code. If you don't use floating point or do low-level memory twiddling, it's likely your programs will work on both 32- and 64-bit versions.

Although Atlast includes comprehensive pointer and stack limit checking, it is not memory-safe, and consequently I do not encourage its use in modern applications. When it was originally developed in the late 1980s, its ability to fit in a small memory footprint was of surpassing importance. With the extravagant memory and compute power of contemporary machines, this is less important and other scripting languages which are both entirely safe and less obscure in syntax will usually be preferable. Still, some people working with embedded systems very close to the hardware continue to find Atlast useful, and this release updates it for 64-bit architectures.

The distribution archive has been re-organised in 2.0, collecting the regression test, examples from the user manual, and benchmarks in subdirectories. An implementation of my floating point benchmark is included among the examples.

Back

Reading List: The Case for Space Solar Power

Saturday, June 28, 2014 18:24

Mankins, John C. The Case for Space Solar Power. Houston: Virginia Edition, 2014. ISBN 978-0-9913370-0-2.
As world population continues to grow and people in the developing world improve their standard of living toward the level of residents of industrialised nations, demand for energy will increase enormously. Even taking into account anticipated progress in energy conservation and forecasts that world population will reach a mid-century peak and then stabilise, the demand for electricity alone is forecasted to quadruple in the century from 2000 to 2100. If electric vehicles shift a substantial part of the energy consumed for transportation from hydrocarbon fuels to electricity, the demand for electric power will be greater still.

Providing this electricity in an affordable, sustainable way is a tremendous challenge. Most electricity today is produced by burning fuels such as coal, natural gas, and petroleum; by nuclear fission reactors; and by hydroelectric power generated by dams. Quadrupling electric power generation by any of these means poses serious problems. Fossil fuels may be subject to depletion, pose environmental consequences both in extraction and release of combustion products into the atmosphere, and are distributed unevenly around the world, leading to geopolitical tensions between have and have-not countries. Uranium fission is a technology with few environmental drawbacks, but operating it in a safe manner is very demanding and requires continuous vigilance over the decades-long lifespan of a power station. Further, the risk exists that nuclear material can be diverted for weapons use, especially if nuclear power stations proliferate into areas which are politically unstable. Hydroelectric power is clean, generally reliable (except in the case of extreme droughts), and inexhaustible, but unfortunately most rivers which are suitable for its generation have already been dammed, and potential projects which might be developed are insufficient to meet the demand.

Well, what about those “sustainable energy” projects the environmentalists are always babbling about: solar panels, eagle shredders (wind turbines), and the like? They do generate energy without fuel, but they are not the solution to the problem. In order to understand why, we need to look into the nature of the market for electricity, which is segmented into two components, even though the current flows through the same wires. The first is “base load” power. The demand for electricity varies during the day, from day to day, and seasonally (for example, electricity for air conditioning peaks during the mid-day hours of summer). The base load is the electricity demand which is always present, regardless of these changes in demand. If you look at a long-term plot of electricity demand and draw a line through the troughs in the curve, everything below that line is base load power and everything above it is “peak” power. Base load power is typically provided by the sources discussed in the previous paragraph: hydrocarbon, nuclear, and hydroelectric. Because there is a continuous demand for the power they generate, these plants are designed to run non-stop (with excess capacity to cover stand-downs for maintenance), and may be complicated to start up or shut down. In Switzerland, for example, 56% of base load power is produced from hydroelectric plants and 39% from nuclear fission reactors.

The balance of electrical demand, peak power, is usually generated by smaller power plants which can be brought on-line and shut down quickly as demand varies. Peaking plants sell their power onto the grid at prices substantially higher than base load plants, which compensates for their less efficient operation and higher capital costs for intermittent operation. In Switzerland, most peak energy is generated by thermal plants which can burn either natural gas or oil.

Now the problem with “alternative energy” sources such as solar panels and windmills becomes apparent: they produce neither base load nor peak power. Solar panels produce electricity only during the day, and when the Sun is not obscured by clouds. Windmills, obviously, only generate when the wind is blowing. Since there is no way to efficiently store large quantities of energy (all existing storage technologies raise the cost of electricity to uneconomic levels), these technologies cannot be used for base load power, since they cannot be relied upon to continuously furnish power to the grid. Neither can they be used for peak power generation, since the times at which they are producing power may not coincide with times of peak demand. That isn't to say these energy sources cannot be useful. For example, solar panels on the roofs of buildings in the American southwest make a tremendous amount of sense since they tend to produce power at precisely the times the demand for air conditioning is greatest. This can smooth out, but not replace, the need for peak power generation on the grid.

If we wish to dramatically expand electricity generation without relying on fossil fuels for base load power, there are remarkably few potential technologies. Geothermal power is reliable and inexpensive, but is only available in a limited number of areas and cannot come close to meeting the demand. Nuclear fission, especially modern, modular designs is feasible, but faces formidable opposition from the fear-based community. If nuclear fusion ever becomes practical, we will have a limitless, mostly clean energy source, but after sixty years of research we are still decades away from an operational power plant, and it is entirely possible the entire effort may fail. The liquid fluoride thorium reactor, a technology demonstrated in the 1960s, could provide centuries of energy without the nuclear waste or weapons diversion risks of uranium-based nuclear power, but even if it were developed to industrial scale it's still a “nuclear reactor” and can be expected to stimulate the same hysteria as existing nuclear technology.

This book explores an entirely different alternative. Think about it: once you get above the Earth's atmosphere and sufficiently far from the Earth to avoid its shadow, the Sun provides a steady 1.368 kilowatts per square metre, and will continue to do so, non-stop, for billions of years into the future (actually, the Sun is gradually brightening, so on the scale of hundreds of millions of years this figure will increase). If this energy could be harvested and delivered efficiently to Earth, the electricity needs of a global technological civilisation could be met with a negligible impact on the Earth's environment. With present-day photovoltaic cells, we can convert 40% of incident sunlight to electricity, and wireless power transmission in the microwave band (to which the Earth's atmosphere is transparent, even in the presence of clouds and precipitation) has been demonstrated at 40% efficiency, with 60% end-to-end efficiency expected for future systems.

Thus, no scientific breakthrough of any kind is required to harvest abundant solar energy which presently streams past the Earth and deliver it to receiving stations on the ground which feed it into the power grid. Since the solar power satellites would generate energy 99.5% of the time (with short outages when passing through the Earth's shadow near the equinoxes, at which time another satellite at a different longitude could pick up the load), this would be base load power, with no fuel source required. It's “just a matter of engineering” to calculate what would be required to build the collector satellite, launch it into geostationary orbit (where it would stay above the same point on Earth), and build the receiver station on the ground to collect the energy beamed down by the satellite. Then, given a proposed design, one can calculate the capital cost to bring such a system into production, its operating cost, the price of power it would deliver to the grid, and the time to recover the investment in the system.

Solar power satellites are not a new idea. In 1968, Peter Glaser published a description of a system with photovoltaic electricity generation and microwave power transmission to an antenna on Earth; in 1973 he was granted U.S. patent 3,781,647 for the system. In the 1970s NASA and the Department of Energy conducted a detailed study of the concept, publishing a reference design in 1979 which envisioned a platform in geostationary orbit with solar arrays measuring 5 by 25 kilometres and requiring a monstrous space shuttle with payload of 250 metric tons and space factories to assemble the platforms. Design was entirely conventional, using much the same technologies as were later used in the International Space Station (ISS) (but for a structure twenty times its size). Given that the ISS has a cost estimated at US$ 150 billion, NASA's 1979 estimate that a complete, operational solar power satellite system comprising 60 power generation platforms and Earth-based infrastructure would cost (in 2014 dollars) between 2.9 and 8.7 trillion might be considered optimistic. Back then, a trillion dollars was a lot of money, and this study pretty much put an end to serious consideration of solar power satellites in the U.S.for almost two decades. In the late 1990s, NASA, realising that much progress has been made in many of the enabling technologies for space solar power, commissioned a “Fresh Look Study”, which concluded that the state of the art was still insufficiently advanced to make power satellites economically feasible.

In this book, the author, after a 25-year career at NASA, recounts the history of solar power satellites to date and presents a radically new design, SPS-ALPHA (Solar Power Satellite by means of Arbitrarily Large Phased Array), which he argues is congruent with 21st century manufacturing technology. There are two fundamental reasons previous cost estimates for solar power satellites have come up with such forbidding figures. First, space hardware is hideously expensive to develop and manufacture. Measured in US$ per kilogram, a laptop computer is around $200/kg, a Boeing 747 $1400/kg, and a smart phone $1800/kg. By comparison, the Space Shuttle Orbiter cost $86,000/kg and the International Space Station around $110,000/kg. Most of the exorbitant cost of space hardware has little to do with the space environment, but is due to its being essentially hand-built in small numbers, and thus never having the benefit of moving down the learning curve as a product is put into mass production nor of automation in manufacturing (which isn't cost-effective when you're only making a few of a product). Second, once you've paid that enormous cost per kilogram for the space hardware, you have launch it from the Earth into space and transport it to the orbit in which it will operate. For communication satellites which, like solar power satellites, operate in geostationary orbit, current launchers cost around US$ 50,000 per kilogram delivered there. New entrants into the market may substantially reduce this cost, but without a breakthrough such as full reusability of the launcher, it will stay at an elevated level.

SPS-ALPHA tackles the high cost of space hardware by adopting a “hyper modular” design, in which the power satellite is composed of huge numbers of identical modules of just eight different types. Each of these modules is on a scale which permits prototypes to be fabricated in facilities no more sophisticated than university laboratories and light enough they fall into the “smallsat” category, permitting inexpensive tests in the space environment as required. A production power satellite, designed to deliver 2 gigawatts of electricity to Earth, will have almost four hundred thousand of each of three types of these modules, assembled in space by 4,888 robot arm modules, using more than two million interconnect modules. These are numbers where mass production economies kick in: once the module design has been tested and certified you can put it out for bids for serial production. And a factory which invests in making these modules inexpensively can be assured of follow-on business if the initial power satellite is a success, since there will a demand for dozens or hundreds more once its practicality is demonstrated. None of these modules is remotely as complicated as an iPhone, and once they are made in comparable quantities shouldn't cost any more. What would an iPhone cost if they only made five of them?

Modularity also requires the design to be distributed and redundant. There is no single-point failure mode in the system. The propulsion and attitude control module is replicated 200 times in the full design. As modules fail, for whatever cause, they will have minimal impact on the performance of the satellite and can be swapped out as part of routine maintenance. The author estimates than on an ongoing basis, around 3% of modules will be replaced per year.

The problem of launch cost is addressed indirectly by the modular design. Since no module masses more than 600 kg (the propulsion module) and none of the others exceed 100 kg, they do not require a heavy lift launcher. Modules can simply be apportioned out among a large number of flights of the most economical launchers available. Construction of a full scale solar power satellite will require between 500 and 1000 launches per year of a launcher with a capacity in the 10 to 20 metric ton range. This dwarfs the entire global launch industry, and will provide motivation to fund the development of new, reusable, launcher designs and the volume of business to push their cost down the learning curve, with a goal of reducing cost for launch to low Earth orbit to US$ 300–500 per kilogram. Note that the SpaceX Falcon Heavy, under development with a projected first flight in 2015, already is priced around US$ 1000/kg without reusability of the three core stages which is expected to be introduced in the future.

The author lays out five “Design Reference Missions” which progress from small-scale tests of a few modules in low Earth orbit to a full production power satellite delivering 2 gigawatts to the electrical grid. He estimates a cost of around US$ 5 billion to the pilot plant demonstrator and 20 billion to the first full scale power satellite. This is not a small sum of money, but is comparable to the approximately US$ 26 billion cost of the Three Gorges Dam in China. Once power satellites start to come on line, each feeding power into the grid with no cost for fuel and modest maintenance expenses (comparable to those for a hydroelectric dam), the initial investment does not take long to be recovered. Further, the power satellite effort will bootstrap the infrastructure for routine, inexpensive access to space, and the power satellite modules can also be used in other space applications (for example, very high power communication satellites).

The most frequently raised objection when power satellites are mentioned is fear that they could be used as a “death ray”. This is, quite simply, nonsense. The microwave power beam arriving at the Earth's surface will have an intensity between 10–20% of summer sunlight, so a mirror reflecting the Sun would be a more effective death ray. Extensive tests were done to determine if the beam would affect birds, insects, and aircraft flying through it and all concluded there was no risk. A power satellite which beamed down its power with a laser could be weaponised, but nobody is proposing that, since it would have problems with atmospheric conditions and cost more than microwave transmission.

This book provides a comprehensive examination of the history of the concept of solar power from space, the various designs proposed over the years and studies conducted of them, and an in-depth presentation of the technology and economic rationale for the SPS-ALPHA system. It presents an energy future which is very different from that which most people envision, provides a way to bring the benefits of electrification to developing regions without any environmental consequences whatever, and ensure a secure supply of electricity for the foreseeable future.

This is a rewarding, but rather tedious read. Perhaps it's due to the author's 25 years at NASA, but the text is cluttered with acronyms—there are fourteen pages of them defined in a glossary at the end of the book—and busy charts, some of which are difficult to read as reproduced in the Kindle edition. Copy editing is so-so: I noted 28 errors, and I wasn't especially looking for them. The index in the Kindle edition lists page numbers in the print edition which are useless because the electronic edition does not contain page numbers.

Back

Reading List: The Death of Money

Thursday, June 26, 2014 23:44

Rickards, James. The Death of Money. New York: Portfolio / Penguin, 2014. ISBN 978-1-591-84670-3.
In his 2011 book Currency Wars (November 2011), the author discusses what he sees as an inevitable conflict among fiat currencies for dominance in international trade as the dollar, debased as a result of profligate spending and assumption of debt by the government that issues it, is displaced as the world's preeminent trading and reserve currency. With all currencies backed by nothing more than promises made by those who issue them, the stage is set for a race to the bottom: one government weakens its currency to obtain short-term advantage in international trade, only to have its competitors devalue, setting off a chain of competitive devaluations which disrupt trade, cause investment to be deferred due to uncertainty, and destroy the savings of those holding the currencies in question. In 2011, Rickards wrote that it was still possible to avert an era of currency war, although that was not the way to bet. In this volume, three years later, he surveys the scene and concludes that we are now in the early stages of a collapse of the global monetary system, which will be replaced by something very different from the status quo, but whose details we cannot, at this time, confidently predict. Investors and companies involved in international commerce need to understand what is happening and take steps to protect themselves in the era of turbulence which is ahead.

We often speak of “globalisation” as if it were something new, emerging only in recent years, but in fact it is an ongoing trend which dates from the age of wooden ships and sail. Once ocean commerce became practical in the 18th century, comparative advantage caused production and processing of goods to be concentrated in locations where they could be done most efficiently, linked by the sea lanes. This commerce was enormously facilitated by a global currency—if trading partners all used their own currencies, a plantation owner in the West Indies shipping sugar to Great Britain might see his profit wiped out if the exchange rate between his currency and the British pound changed by the time the ship arrived and he was paid. From the dawn of global trade to the present there has been a global currency. Initially, it was the British pound, backed by gold in the vaults of the Bank of England. Even commerce between, say, Argentina and Italy, was usually denominated in pounds and cleared through banks in London. The impoverishment of Britain in World War I began a shift of the centre of financial power from London to New York, and after World War II the Bretton Woods conference established the U.S. dollar, backed by gold, as the world's reserve and trade currency. The world continued to have a global currency, but now it was issued in Washington, not London. (The communist bloc did not use dollars for trade within itself, but conducted its trade with nations outside the bloc in dollars.) In 1971, the U.S. suspended the convertibility of the dollar to gold, and ever since the dollar has been entirely a fiat currency, backed only by the confidence of those who hold it that they will be able to exchange it for goods in the future.

The international monetary system is now in a most unusual period. The dollar remains the nominal reserve and trade currency, but the fraction of reserves held and trade conducted in dollars continues to fall. All of the major currencies: the dollar, euro, yen, pound, yuan, rouble—are pure fiat currencies unbacked by any tangible asset, and valued only against one another in ever-shifting foreign exchange markets. Most of these currencies are issued by central banks of governments which have taken on vast amounts of debt which nobody in their right mind believes can ever be paid off, and is approaching levels at which even a modest rise in interest rates to historical mean levels would make the interest on the debt impossible to service. There is every reason for countries holding large reserves of dollars to be worried, but there isn't any other currency which looks substantially better as an alternative. The dollar is, essentially, the best horse in the glue factory.

The author argues that we are on the threshold of a collapse of the international monetary system, and that the outlines of what will replace it are not yet clear. The phrase “collapse of the international monetary system” sounds apocalyptic, but we're not talking about some kind of Mad Max societal cataclysm. As the author observes, the international monetary system collapsed three times in the last century: in 1914, 1939, and 1971, and life went on (albeit in the first two cases, with disastrous and sanguinary wars), and eventually the financial system was reconstructed. There were, in each case, winners and losers, and investors who failed to protect themselves against these turbulent changes paid dearly for their complacency.

In this book, the author surveys the evolving international financial scene. He comes to conclusions which may surprise observers from a variety of perspectives. He believes the Euro is here to stay, and that its advantages to Germany coupled with Germany's economic power will carry it through its current problems. Ultimately, the countries on the periphery will consider the Euro, whatever its costs to them in unemployment and austerity, better than the instability of their national currencies before joining the Eurozone. China is seen as the victim of its own success, with financial warlords skimming off the prosperity of its rapid growth, aided by an opaque and deeply corrupt political class. The developing world is increasingly forging bilateral agreements which bypass the dollar and trade in their own currencies.

What is an investor to do faced with such uncertainty? Well, that's far from clear. The one thing one shouldn't do is assume the present system will persist until you're ready to retire, and invest your retirement savings entirely on the assumption nothing will change. Fortunately, there are alternative investments (for example, gold and silver, farm land, fine art, funds investing in natural resources, and, yes, cash in a variety of currencies [to enable you to pick up bargains when other assets crater]) which will appreciate enormously when the monetary system collapses. You don't have to (and shouldn't) bet everything on a collapse: a relatively small hedge against it will protect you should it happen.

This is an extensively researched and deep investigation of the present state of the international monetary system. As the author notes, ever since all currencies were severed from gold in 1971 and began to float against one another, the complexity of the system has increased enormously. What were once fixed exchange rates, adjusted only when countries faced financial crisis, have been replaced by exchange rates which change in milliseconds, with a huge superstructure of futures, options, currency swaps, and other derivatives whose notional value dwarfs the actual currencies in circulation. This is an immensely fragile system which even a small perturbation can cause to collapse. Faced with a risk whose probability and consequences are impossible to quantify, the prudent investor takes steps to mitigate it. This book provides background for developing such a plan.

Back

Tom Swift and His Airship updated, EPUB added

Sunday, June 22, 2014 14:02

All 25 of the public domain Tom Swift novels have been posted in the Tom Swift and His Pocket Library collection. I am now returning to the earlier novels, upgrading them to use the more modern typography of those I've done in the last few years. The third novel in the series, Tom Swift and His Airship, has now been updated. Several typographical errors in the original edition have been corrected, and Unicode text entities are used for special characters such as single and double quotes and dashes.

An EPUB edition of this novel is now available which may be downloaded to compatible reader devices; the details of how to do this differ from device to device—please consult the documentation for your reader for details.

For additional details about this novel, see the review I wrote when it was originally posted in 2005.

Back