Precious

“Precious” by Kerinne Jenkins has been selected for the London Independent Film Festival and the Heart of England Film Festival!

Precious

Precious

In a dystopian future, two men meet in an underground tunnel for an exchange of stolen goods.

Liam lives in the stacks, making small black market deals and dreaming of getting out of the city walls. The natural world is a distant memory for those who live in the slums of the city and the passes out are restricted to those with money. Conrad is young, rich and brash and thinks he can buy anything he wants. To him the world is there for his taking and those who aren’t as well off as him are just lazy.

Conrad has promised Liam a way out of the city and a better status in life, middle class status. The upgrade will give him a clean room, a small pension and a cremation service. For this and the transport pass Liam manages to steal an item for Conrad that he has been coveting.

The exchange seems set to give both parties what they want until Liam realises that Conrad has only come through on part of his deal. Ignoring Liam’s desperation and actual needs leads to a heated situation and neither party will leave with what they came for.

London Independent Film Festival

Now confirmed for Thu 23rd April 2009 at The Roxy:

Guest Speaker: Chris Jones
Making film in the UK
Thurs, Apr 23, 7:30pm at the Roxy — Free at the door
Chris Jones is the author of the Guerilla Filmmakers Handbook, and teaches masterclasses in low-budget filmmaking in the UK and around the world.

Heart of England Film Festival

Posted in Bach, Films | Tagged , , , | Leave a comment

Evaluating Pi …

… to 15 decimal places in one easy step (or not too difficult step).

In my previous post one of the examples given of the use of the Gaussian Quadrature function was to evaluate the value of Pi.  Let’s look at that a bit more closely.

Wikipedia has a nice article on the history of Pi, but like most such articles the methods described are either historical methods which are easy to understand but converge slowly, or recent methods which converge very quickly, but which are presented with little or no information about how they were derived.  For example the well known 20th Century Indian mathematician Srinivasa Ramanujan somehow derived the relationship:

\frac{1}{\pi} = \frac{2 \sqrt 2}{9801} \sum_{k=0}^\infty \frac{(4k)!(1103+26390k)}{(k!)^4 396^{4k}}\!

and in 1987 the Chudnovsky brothers  derived:

\frac{426880 \sqrt{10005}}{\pi} = \sum_{k=0}^\infty \frac{(6k)! (13591409 + 545140134k)}{(3k)!(k!)^3 (-640320)^{3k}}\!

which delivers 14 digits per term, but no indication is given of how these relationships were derived.

The early historical methods of calculating Pi, starting with Archimedes in the 3rd century BC, were based on the successive subdivision of polygons.

File:Archimedes pi.svg

Around AD 265, the Wei Kingdom mathematician Liu Hui provided a simple and rigorous iterative algorithmto calculate π to any degree of accuracy. He himself carried through the calculation to a 3072-gon and obtained an approximate value for π of 3.1416.

A simple way to improve the accuracy of the polygon approach is to find an approximation of the area between the circle and the polygon, and add this to the known area of the polygon.  Starting with a hexagon of unit side, this may be divided into 6 equilateral triangles and six circular segments with 60 degree included angle:

Area of 60 degree segment of circle

Area of 60 degree segment of circle

The area of the triangle is 0.5 x 3^0.5 / 2 (0.5 x base x height)

The equation of the segment is (1 – x^2)^0.5 – 3^0.5 / 2

If this equation is integrated between x = -0.5 and x = 0.5, and added to the area of the equilateral triangle, this gives 1/6 the area of the circle of unit radius.  If the integration is evaluated using Gaussian Quadrature, with 8 integration points, the resulting area provides an estimate  of Pi with an error of 2.3E-11; not too bad:

Integration between -0.5 and 0.5

Integration between -0.5 and 0.5

A further 4 significant figures can be obtained by simply changing the limits of integration to X = 0 to 0.5 (and adjusting the triangle area to suit, and multiplying the resulting area by 12):

Integration limits 0 to 0.5

Integration limits 0 to 0.5

The resulting estimate of Pi has an error of 7.6E-15, and matches the built in Excel Pi function to the 14th significant figure.

Posted in Excel, Maths, Newton, UDFs, VBA | Tagged , , , , | 4 Comments

Gaussian Quadrature

The previous post on integration provided an Excel User Defined Function (UDF) to perform numerical integration using Simpson’s Rule or the Trapezoidal Rule.  A third method is Gaussian Quadrature which is often much more accurate and/or quicker than Simpson’s Rule.  The UDF GaussInt() carries out integration using Gaussian Quadrature, in a similar format to the earlier functions, and has been added to the Eval.xls spreadsheet.  As far as I know this is the only open source VBA code with this technique available on the Web.

The basis of the method is to find the mean value of the function over the integration range by taking a weighted average of the function value at a number of specified points.  Using two integration points provides the same precision as Simpson’s Method using two subdivisions, but increasing the number of integration points increases the precision much more rapidly than a corresponding increase in the number of subdivisions using Simpson’s Method.  In addition to the function to be integrated, constant symbols and values, and the variable symbol, the UDF optionally allows the following values to be specified:

  • Tolerance (maximum estimated error / integration value) – default 1e-10
  • Maximum number of subdivision loops (the number of subdivisions, and approximate execution time, are doubled in each additional loop) – default 10
  • Number of integration points – default 8.

The UDF allows for between 2 and 12 integration points.  For each different number of integration points two arrays are set up, specifying the position and weight of each point.  The values for the required coefficients were taken from: ActiveState Code, and for values up to 8 integration points were checked at: Gauss Legendre Coefficients (link no longer active).

Having set up the coefficient arrays the analysis procedure is quite simple:

  • For each integration point: Substitute the position coefficient into the function
  • Evaluate the function and multiply by the appropriate weighting
  • Sum each integration point to estimate the integration result
  • If the required precision has not been achieved, double the number of subdivisions and repeat

As well as the integration result the UDF provides the estimated error, the number of loops required, and the execution time.

The screen shots below show the evaluation of a trigonometrical function (with exact value of 2), and an evaluation of Pi by finding the area under a unit circle between X=0 and X=0.5.  The upper screen shot is using the GaussInt function, and the lower one using Simpson’s Rule.  It can be seen that the GaussInt function is of the order of 60 times faster, for the same precision, compared with Simpson’s Rule in these cases.

Integration with GaussInt()

Integration with GaussInt()

Integration with EvalIntt(), (Simpson's Method)

Integration with EvalIntt(), (Simpson's Method)

Posted in Excel, Maths, Newton, UDFs, VBA | Tagged , , , , , , | 27 Comments

WolframAlpha

WolframAlpha is coming!

From the link:

“Some might say that Mathematica and A New Kind of Science are ambitious projects. But in recent years I’ve been hard at work on a still more ambitious project—called Wolfram|Alpha.

And I’m excited to say that in just two months it’s going to be going live:”

 

Sounds good, I hope it lives up to the hype 🙂

The “New Kind of Science” link above gives you free on-line access to the complete contents of the book.

A recent review:

Doug Lenat – I was positively impressed with Wolfram Alpha

“…

The bottom line is that there are a large range of queries it can’t parse, and a large range of parsable queries it can’t answer even when it can answer the constituents out of which they should be answerable, but it handles a huge range of numeric and scientific queries correctly even in its current state.  And Dr. Wolfram and his team are chipping away at the natural language blocks, at the holes in the curated data repository, and at increasing the type and depth of logical combination of constituents, one by one, in priority order, just as they should.  I went in to the demo concerned that this might be a competitor to Cyc, given its “hand-curate knowledge and engineer it, versus let anyone add anything” philosophy, but came out of last night’s  demo and discussion seeing Alpha as a complementary technology.  I would invest in this, literally and figuratively.  If it is not gobbled up by one of the existing industry superpowers, his company may well grow to become one of them in a small number of years, with most of us setting our default browser to be Wolfram Alpha.  “

Posted in Computing - general, Maths, Newton | Tagged , , , | Leave a comment

Another update to IP.xls

Following some suggestions from Mike Seymour I have modified my polyline intersection function, and added a new version. The changes are:

  • The data ranges for the new function, IP4(), are entered as four separate ranges, so the X and Y values do not need to be in adjacent columns.
  • For both IP() and IP4() the data may now be arranged in rows, rather than columns.  If the data ranges have more than 2 columns for IP(), or more than 1 column for IP4(), it is assumed that the data is arranged row-wise.

The new spreadsheet may be downloaded from: IP.zip

The spreadsheet also includes a number of geometric and interpolation functions.  As usual, full open-source code is included n the download.  See https://newtonexcelbach.wordpress.com/2008/08/10/intersections-interpolations-and-rotations/ for a full list.

Posted in Excel, Maths, UDFs, VBA | Tagged , , , , | 1 Comment