Numerical Integration; Tanh-Sinh Quadrature v. 4.3

A new version (4.3) of the numerical integration spreadsheet by Graeme Dennes is now available for download from Tanh_Sinh Quadrature.

The Tanh-Sinh Quadrature Version 4.3 workbook now provides a feature for the integration of integrands contained in independent (external) UDFs. By using this feature, changes to the workbook VBA programs are not required, providing a simplification of the use of the workbook. Although the performance shown by this method is not as great as that shown by the VBA-stored method, it is faster than the cell-stored method, and adds to the utility and functionality of the workbook without requiring VBA changes to be made by the user. All 13 quadrature programs can utilise this new feature. Added examples and documentation for using this new feature have been included on the T-S EXAMPLES worksheet. This feature was proposed by Doug Jenkins.

Also included in this release is the ability to evaluate text as a formula, further adding to the functionality of the workbook. Also proposed by Doug.

My thanks to Doug for raising these changes to enhance the workbook.

Graeme Dennes

In addition to the main workbook, containing full documentation and numerous examples, two other workbooks are now included in the download zip file, to simplify the process of using these functions in other applications:

  • Tanh-Sinh Quadrature v4.3 by Graeme Dennes-Code Only.xlsm: includes full open-source VBA code, but documentation is reduced to 2 simple examples of each function.
  • Tanh-Sinh Quadrature v4.3 by Graeme Dennes-Minimal Code.xlsm: includes code for the Tanh-Sinh function only, with two examples of using this function to evaluate integrals required by other routines.

Either of the cut-down workbooks may be incorporated in other applications by either inserting new worksheets and VBA code as required, or by copying the VBA code modules to another application.  VBA modules may be copied between projects by opening both workbooks, then simply selecting the desired modules in the VBE Project Explorer window, and dragging them to the new project “Modules” folder.

Alternatively the workbooks may be saved as an add-in (open the Save-as window, then select “Excel add-in” (*.xlam)), so that all the functions will be available from any open workbook.

This entry was posted in Excel, Maths, Newton, Numerical integration, UDFs, VBA and tagged , , , , , , , , . Bookmark the permalink.

6 Responses to Numerical Integration; Tanh-Sinh Quadrature v. 4.3

  1. Pingback: Tanh-Sinh Quadrature via F2PY | Newton Excel Bach, not (just) an Excel Blog

  2. Pingback: Tanh-Sinh Quadrature via F2PY – Part 3 | Newton Excel Bach, not (just) an Excel Blog

  3. maurizio nardò says:

    If the speedup is attributed to the vba dispatcher, then I’d give a chance to the very old-fashioned computed goto, instead of the huge select case:

    Function vbaDispatch(s As String, x As Double) As Double
    Dim i As Long
    i = Mid$(s, InStrRev(s, “_”) + 1)
    On i GoTo sumx100, sin, cos
    sumx100:
    vbaDispatch = x + 100
    Exit Function
    sin:
    vbaDispatch = sin(x)
    Exit Function
    cos:
    vbaDispatch = cos(x)
    Exit Function
    End Function

    Sub testit()
    Debug.Print vbaDispatch(“cos_3”, 1.57159)
    End Sub

    It jumps directly to the sought “function”, so access time should be constant without penalizing “lowest” functions (those with the highest number in the select block).

    To be honest I don’t know what is the limit of labels for a computed goto, but if excedeed, functions can be “blocked” as in the original function.

    Like

  4. dougaj4 says:

    Thanks Maurizio, it certainly should be worth a try (when I have some time).

    Like

  5. srabutdotcom says:

    Hi
    Could you explain how DE for highly oscillatory function work, i.e the algorithm flow. I can’t imagine it from your code.,

    Thanks

    Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.