Following the recent post on using Brent’s Method solvers on an array (Iterative solvers and arrays), here is another example with an engineering related problem. The example is included in the xlScipy3 spreadsheet, which can be downloaded from:
The depth of the Neutral Axis of a reinforced concrete section, under specified bending moment and axial load, can be found with the cubic equation below (click any image for full size view):
Derivation of the constants A to G is shown below. As before, the equation may either be solved using a Python function (FindDNA), or by evaluating a lambda function entered as text on the spreadsheet. In the former case the constants are passed to the function as an array; in the latter the constants are converted to their numerical value in the text on the spreadsheet, as shown below. Note that this is done automatically using the Eval function:
Results calling Func Type 1 (FindDNA) are shown below:
Using Func Type 2 (evaluating the text function on the spreadsheet) returns the same results. Note that the xl_BrentA arguments must be edited to remove the final argument (the array of constant values), otherwise the function will return an error. To edit an array function: