sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.33k stars 453 forks source link

provide list of existing symbolic functions together with example argument(s) #17866

Open rwst opened 9 years ago

rwst commented 9 years ago

For testing purposes it would be great to somehow get a list containing tuples with

Is the pynac symbol table complete?

sage: from sage.symbolic.pynac import symbol_table
sage: dic=symbol_table['functions']
sage: dic['lambert_w']
lambert_w
sage: type(_)
<class 'sage.functions.log.Function_lambert_w'>

CC: @videlec @paulmasson

Component: symbolics

Issue created by migration from https://trac.sagemath.org/ticket/17866

videlec commented 9 years ago
comment:1

Good idea! But what are you thinking: writing it down by hand or just parsing the source code?

rwst commented 9 years ago

Description changed:

--- 
+++ 
@@ -3,3 +3,15 @@
 * nargs
 * name
 * a tuple with example args
+
+Is the pynac symbol table complete?
+
+```
+sage: from sage.symbolic.pynac import symbol_table
+sage: dic=symbol_table['functions']
+sage: dic['lambert_w']
+lambert_w
+sage: type(_)
+<class 'sage.functions.log.Function_lambert_w'>
+```
+
rwst commented 9 years ago
comment:2

Apparently on startup all symbolic functions get registered in the Pynac symbol table.

EDIT: This list includes even the numerical ones.

rwst commented 9 years ago
comment:3

For example,

sage: def builtin_symbolic_function_list():     
        from sage.symbolic.pynac import symbol_table
        from sage.symbolic.function import BuiltinFunction
        fdict = symbol_table['functions']
        return ([c for c in fdict.itervalues()
            if isinstance(c, BuiltinFunction) ])
sage: for c in builtin_symbolic_function_list():
    argl = []
    for n in range(c.number_of_arguments()):
        argl.append(2.5)
    print c
    print(CC(c(*argl)))

This allowed me to quickly find that elliptic_e(2.5,2.5) which should give 0.535648... +1.63996... i according to Wolfram, throws an ECL error (fixed in #15046).