I am defining a new analytic function of six variables. I have algorithms to evaluate it numerically, and have amassed a large catalog of analytic properties.

It is easy for me to program the numerics using:

funcF[a_?NumericQ, b_?NumericQ, c_?NumericQ, d_?NumericQ, e_?NumericQ, f_?NumericQ] = (*...*)

I know the analytic expression for its derivative with respect to each argument. I also know the location of all the singularities and the Taylor/asymptotic series expansion of this function near these singularities in all six variables, and a bunch of other identities.

Question: I want to make a package that incorporates this function into Mathematica. What do I need to do to to make it work as seamlessly as possible with its built-in functions like Derivative, Limit, Series Simplify, etc. Clearly, there will be a lot of coding to do, but I'm more than willing.

I already have a head-start from the answer to this question, which nicely makes the custom function ln work well with Derivative and Series. I stumbled upon this page: http://functions.wolfram.com/NB/StruveH.nb which includes functions like DomainAndRange, Singularities, etc. and thought this would be the key to accomplishing my task. Alas, these functions aren't Mathematica functions and can't be evaluated. Is there a template/guideline for this?

  • 1
    $\begingroup$ If you can get Series to swallow it, you'll pretty much get Limit for free. One thing though: make sure it has the NumericFunction attribute set. As for Simplify, there may be ways to teach it tricks. Possibly more important though, if applicable, would be to have UpValues for use by FunctionExpand. $\endgroup$ – Daniel Lichtblau Sep 12 '14 at 19:26
  • $\begingroup$ Thanks; it's working, but seems backwards that I get Series if I have Derivative, and Limit if I have Series. What are the benefits of giving attribute NumericFunction? It seems bit superficial to me. $\endgroup$ – QuantumDot Sep 13 '14 at 8:13
  • $\begingroup$ There will be places in internal Limit (and other) code that check for that attribute, and treat nonnumeric "functions" as being, in effect, inert. So if you have myFunction[x], that might be seen as something for Limit et al to regard as constant rather than being functionally dependent on x. $\endgroup$ – Daniel Lichtblau Sep 13 '14 at 20:57
  • $\begingroup$ Thanks! Also, when would it be useful to define UpValues for use by FunctionExpand? Is it called by internal code of built-in Mathematica functions? $\endgroup$ – QuantumDot Sep 28 '14 at 17:23
  • 1
    $\begingroup$ That case will be a problem since UpValues only reacts to things a level deep. Maybe it would it be workable to define a custom myFunctionExpand that becomes FunctionExpand on input free from f but maps the up-valued definition onto parts containing f With careful use of true/false switches you might even get FunctionExpand to become myFunctionExpand. $\endgroup$ – Daniel Lichtblau Nov 27 '15 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.