by John Martyn with Danny Thomson on bass, a live performance in Dublin from 1987
Click to follow the link to You Tube (put your headphones on first) …
by John Martyn with Danny Thomson on bass, a live performance in Dublin from 1987
Click to follow the link to You Tube (put your headphones on first) …
I have updated the ALGLIB Spline and Matrix Function spreadsheet to include 2D interpolation of tabular data, including both linear and cubic spline interpolation. The spreadsheet including the new functions with full open source code may be downloaded from AL-Spline-Matrix03.zip for Excel 2003 and earlier and AL-Spline-Matrix07.zip for the Excel 2007 and 2010 version.
Typical input and output is shown in the screenshots below:
Depiction is a low cost GIS program. I received an e-mail today that they are hosting a webinar on using Depiction with Excel from 10-11 AM PDT on Wed 18th August. Click here for details.
Looks interesting, but it’s 3:00-4:00 AM Sydney time, and I’m not quite that interested.
I have recently imported all the ALGLIB statistics functions into VBA, and written interface functions where required, so that all the functions may now be used as User Defined Functions (UDFs) on the spreadsheet. A spreadsheet including full open source code and descriptions and examples of each function may be downloaded from AL-Stats.zip. The available functions are shown on the screenshots below:
The screen shots show output from the ALGLIB functions together with the equivalent Excel results, where available. Note that many of the Excel functions are only available in Excel 2010, and will not work in earlier versions. Also note that in some cases Excel returns statistics for an estimate of the population value, whereas the ALGLIB functions always return the statistic for the sample. See for example this Wikipedia article on the Kurtosis function.
The ALGLIB functions with names not preceded by AL_ call the ALGLIB code directly. For the remainder it has been necessary to write an interface function for various reasons:
Code for a typical interface function is shown below:
Public Function AL_DistMoments(XA As Variant) As Variant Dim XA0() As Double, N As Long, Ncols As Long, Rtn As Long, DMRes(1 To 4) As Double Dim Mean As Double, Variance As Double, Skewness As Double, Kurtosis As Double Rtn = VarAtoDouble1D_0(XA, XA0, N, Ncols) Call CalculateMoments(XA0, N, Mean, Variance, Skewness, Kurtosis) DMRes(1) = Mean DMRes(2) = Variance DMRes(3) = Skewness DMRes(4) = Kurtosis AL_DistMoments = DMRes End Function
The VarAtoDouble1D_0 routine converts a VBA Variant array into a 1D, base 0, Double array and returns the number of rows and columns of the array:
Function VarAtoDouble1D_0(XL_A As Variant, ByRef Cpp_A() As Double, ByRef Nrows As Long, ByRef Ncols As Long) As Long Dim i As Long, j As Long, LB As Long On Error GoTo iErr If TypeName(XL_A) = "Range" Then XL_A = XL_A.Value2 LB = LBound(XL_A) Nrows = UBound(XL_A) Ncols = UBound(XL_A, 2) ' Copy 2D base 1 variant array to 1D base 0 double array ReDim Cpp_A(0 To Nrows * Ncols - 1) For i = 1 To Nrows For j = 1 To Ncols Cpp_A((i - 1) * Ncols + j - 1) = XL_A(i, j) Next j Next i VarAtoDouble1D_0 = 0 Exit Function iErr: VarAtoDouble1D_0 = 1 End Function
The download spreadsheet includes all the necessary code, but for the benefit of those wanting to use the code direct from the ALGLIB site, or to use the versions in different languages, all the necessary code modules are listed below:
Three air molecules go into a hole,
Well, I say three; could have been four or five.
Could have been nine or ten, doesn’t matter.
Could have been fifteen, twenty – fifty.
Round it up. Hundred. Let’s go mad, eh – two-fifty.
…
Alright, make it a lot simpler, all the air molecules on the planet go into a hole, right?
Hang on – they wouldn’t fit would they? What do you think? What proportion of the Earth’s atmosphere could we fit in a hole through the middle of the Earth. The atmosphere, if it was compressed to sea level pressure occupies about 4 billion cubic km, and a hole through the Earth of 1 square metre cross section would occupy about 0.013 cubic km, so even allowing for a fair bit of extra compression, we aren’t going to get much of the atmosphere into the hole are we? Let’s do the numbers.
Using the AlgLib ODE solver we can easily write a function to calculate the pressure at any distance from the Earth’s centre, starting at normal pressure (say 100 kPa) at the surface. The ODE and the function code are shown in the screen-shot below.
To keep things simple I have made the following assumptions:
1 and 2 are obviously fairly gross approximations, but we only want an order of magnitude result, so let’s see how they work out.
To check out the ODE solver I have started off going from the surface up to an elevation of 10,000 m:
This gives a result of 27.2 kPa, which compares pretty well with the actual pressure (extracted from the Internet) of 26 kPa. Also the ODE function was in close agreement with a simple Runge-Kutta solution carried out on the spreadsheet (see screenshot).
The next step was to go downwards in 100 steps of approximately 64 km each. Here we run into a problem. The AlgLib function fails to converge over this distance. The problem is that it has an iterative error minimisation routine, but very big numbers cause it to crash. To get around this I have used the simple Runge-Kutta method on the spreadsheet, without any error minimisation. Using this we find a pressure at the centre of about 4.3E148 kPa (43 followed by 147 zeros!):
Here is a graph of the pressure against depth on a log vertical scale:
The total mass of air in the hole would be 2.6E164 kg, which is composed of about 1.5E200 atoms.
It is difficult to comprehend just how big these numbers are, but some idea is given by considering that the total number of atoms in the observable universe is estimated to be of the order of 1E80. We would need 1.5E120 Universes to fill the hole. To look at it another way, if every atom in the observable universe was a universe of equal size itself, and if every atom in every one of those universes contained a mass of 200 billion tonnes, then that would provide enough perfect gas to fill the hole so that the pressure at the surface was just 100 kPa.
It is fortunate that no real gas behaves remotely like a perfect gas at high pressures!
In the next post in this series I will look at how much air we would need using real gas behaviour. I just need to find a source of information for compressibility of air at very high pressures.