How to register custom math function?
You first example line bpy.app.driver_namespace['&lt;functionname&gt;'] = &lt;functionname&gt; registers the function within the driver namespace and makes it available as &lt;functionname&gt; within any driver expressions.

From other areas of blender you can access it with it's full data path - bpy.app.driver_namespace['&lt;functionname&gt;'](3) calls that function passing a value of 3.

But that isn't the issue you have with the math object creation -

The XYZ math surface object allows you to enter an arbitrary string to define the surface of the object. As this also allows any python to be run it implements a security feature that prevents any functions not listed in it's safe_list from being run.

To get around this you need to do two steps, add your functions as a module and then import them into the addon and add the names to the safe list. Or you can adjust the usage of the safe list to allow any functions. You may want to duplicate the addon and adjust it so you have your own custom addon that suites your needs. You may also find it easier to define the calculations used and just input a few variables.

For a sign function in a on-line script you can use 1 if x&gt;0 else 0

For a^b I don't see an issue -2**3.5 returns -11.31370849898476