Two sources of perpetual motion

The buttered cat phenomenon:

The pulling-yourself-up-by-your-boot-straps technique:

Posted in Bach | Tagged , , | Leave a comment

Plotting Charts With Gaps …

… and various sorts of Not a Number.

Back in 2012 (When is an xy chart not an xy chart) I concluded that it was not possible to return an array with empty rows from a user defined function (UDF), and as a result it was not possible to generate a series with gaps in an x-y chart, using a UDF or an array function.

Recently Lori Miller has provided two solutions to this problem (see comments at the link above).  First the easy way:

For users of Excel 365 there’s now an option to “show #N/A as an empty cell” under hidden and empty cell settings dialog.  Right-click on a chart and select “select data”:

Click “Hidden and Empty Cells” and select “Show #N/A as an empty cell:

The XY chart will now display a break between the two values either side of the #N/A, and will retain all the features of an XY or scatter chart.

For those not using Office 365 it’s not so easy , but the spreadsheet SpecialNum.xlsb (also provided by Lori Miller) has a solution.  This spreadsheet has a function returning various types of “not a number”, or NaN.  Nan index 3 returns a value that is treated as a blank cell in XY charts (cell C11 below):

This value is the only one that produces the desired result.  Index values 0 to 2 and 4 to 5 turn the chart into two vertical lines either side of the NaN:

Index 6 retains the rest of the chart, but has two vertical lines either side of the gap going up (presumably to infinity):

Index 7 is similar, but with the lines going downwards.

Index values 8 to 10 plot as 0:

For those interested in the details, the download file has open-source code for generating the different NaN values, and also a table listing the numbers and their features:

 

Posted in Arrays, Charts, Charts, Excel, UDFs, VBA | Tagged , , , | 5 Comments

More circle fitting options with Scipy

A comment on the first post on this topic found that the method used did not work well for short arcs of large radius circles.  An example of the problem can be seen in the screen shots below:

The function has returned an arc with a radius of only 85 m (rather than 6000), and the plots below show that the generated arc is a very poor fit to the data:

The comment pointed to the following page at the SciPy CookBook:

Least squares circle

which provides Python code for 5 alternative fitting methods:

  1. Solve linear system with linalg.solve
  2. Basic usage of optimize.leastsq
  3. Advanced usage of optimize.leastsq, with jacobian
  4. Basic usage of orthogonal distance regression (ODR) with an implicit function definition
  5. Advanced usage of ODR, with jacobian

To accommodate these alternatives in the Fit_Circ3D function I have added an optional “method” argument to the function.  Method 0 calls the original routine.  Methods 1-4 call the SciPy methods listed above (default method = 3 if the argument is omitted).  I have not been able to get method 5 to work properly from my code, so at the moment this option is not available.

The results with method 3 of the new code are shown below, showing a good fit to the scattered data, even with a short large radius arc  (click on the image for full-size view):

The code for the new methods (adapted from the original so that it can be called from Excel, via xlwings) can be found in least_squares_circle2.py.  This file, the spreadsheet IP2_py.xlsb, and the associated Python file IP2_py.py are all available for free download from:

IP2_py.zip

In addition to Excel, the following (free) software is required by the spreadsheet:

  • Python
  • Numpy and Scipy
  • xlwings

All are included in the default Anaconda Python installation.

 

Posted in Coordinate Geometry, Curve fitting, Excel, Link to Python, Maths, Newton, NumPy and SciPy, UDFs, VBA, xlwings | Tagged , , , , , , , | Leave a comment

Seven -Up

A very nice version of John Renbourn’s “Seven Up” recently discovered on You Tube:

 

… which led me to another piece by the same artist:

… and a live version of Sweet Potato by Renbourn himself.

 

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

Year 10 Report

Last years’ statistics for this blog are now uploaded to Onedrive, and since this is now 10 years since the blog started, I have also included statistics since the start. The link to each post is preserved in the spreadsheet, so it makes a convenient index to what has been posted over the year, and what people are looking at from previous years. You should be able to access the links in the window below, or open the file in your browser or Excel, or download it.

Of the 2017 posts, the most popular overall was:

Weighted Least Squares Regression, using Excel, VBA, Alglib and Python

The most popular in the Newton category was:

The Conjugate Beam Method

and the most popular in the Bach category was:

Three tributes to John Clarke

From the “deserving but sadly neglected category” I have chosen (and they are all worth a look/listen):

Newton:

Brent’s Method; Update and Examples

Excel:

Setting up UDF Applications

Bach:

Tam Lin

Over the 10 years of the blog I have selected the most popular post, and two runners up in each category:

Excel

Using LINEST for non-linear curve fitting

Units for Excel

Solving higher order polynomials

In the Newton category:

Frame Analysis with Excel – 4, 2D frame analysis

Elegant solutions, Column buckling, and the hole through the middle of the Earth

Reinforced Concrete – ULS capacity under combined axial load and biaxial bending

and in the Bach category:

George Gently, Matty Groves, and Ebony Buckle

Reynardine

Fine as a Bee’s wing

Posted in Bach, Excel, Newton | Tagged , , | 1 Comment

Elegant proofs – more Pythagoras

Browsing the Plus Magazine site recently, I was struck the proof of Pythagoras’ Theorem shown in the animation below:

Not just because it is an elegant proof, but also because of the author, the 20th President of the United States, James Garfield.

Posted in Maths, Newton | Tagged , , | Leave a comment

More Python rotation functions

The code described in the previous post includes a Python function that rotates 3D coordinates by an angle defined with two vectors, using Rodrigue’s Rotation.  I have now added this function to the IP2_py spreadsheet, where it is used in the original application (fitting a circular arc to 3D data points), and also in the PView user defined function (UDF), to generate a perspective projection of any 3D framework.  The new spreadsheet and associated Python code may be downloaded from:

IP2_py.zip

As well as the new functions, the update includes:

  • Updated Python and VBA code for the latest version of xlwings.
  • Updates to the Python GlobLoc3 and Gamma3 functions.
  • Python code re-named IP2_py.py.

Examples of the new PView and Fit_Circ3D functions are shown in the screenshots below:

As for the previous application, to use the spreadsheet:

  • If necessary, install Python, Numpy, and xlwings.  All the necessary packages are included in the default Anaconda Python installation.
  • Copy IP2_py.xlsb and IP2_py.py to any convenient directory.
  • Run IP2_py.xlsb, and if necessary enable macros.

 

Posted in Coordinate Geometry, Drawing, Excel, Link to Python, Maths, Newton, NumPy and SciPy, UDFs, VBA, xlwings | Tagged , , , , , , , , | Leave a comment