# Looping through all functions defined in Mathematica

Is there a way to loop through all the Functions (Elementary and Special functions) that exist in Mathematica?

I want to construct a table of some identities and maybe I can discover something surprising if I plug every function that there is into my formula.

I.e. I want to do something like:

for function in Mathematica
print function[x]^2


(Note this is not Mathematica syntax, but I hope you get the idea)

Thanks, Michał

• But different functions accept different arguments also. How do you plan to handle this if you have list of all the functions? May 10, 2020 at 4:37
• @Nasser I didn't think about it. Anyway, where can I find such a list of all functions, please? May 10, 2020 at 4:41
• Have you already seen MathematicalFunctionData[]? May 10, 2020 at 4:48
• Can you extract all the names from reference.wolfram.com/language/guide/AlphabeticalListing ? Was there a line of code that did this in Petzold's Mathematica Guidebook for Symbolics?
– Bill
May 10, 2020 at 4:49
• Maybe combining it with FromEntity[] will work? May 10, 2020 at 4:54

Single-argument functions:

funclist = Select[("ArgumentsPattern" /. SyntaxInformation[#]) === {_} &][
FromEntity /@ MathematicalFunctionData[]];

Item[#, Background -> LightBlue] & /@ {"f", "f @ 2"}],
Dividers -> All] • This isn't kglr's fault, but note that the list misses functions like LogisticSigmoid[] and InverseHaversine[]. May 10, 2020 at 7:02

I am sure there is a way to do this using MathematicalFunctionData, just to obtain list of functions. But I could not find it. I got lost in help pages of Entities , FromEntity[], ToEntity[], and so on.

Here is lazy person's way of doing it.

isFunction[name_String] := Module[{m},
m = SyntaxInformation[Symbol[name]];
If[Length[m] > 0, True, False]
];

n = 0;
pkg = "System";
names = Names[pkg <> "*"];

tbl = First@Last@Reap@Do[

Print["Proccesing entry ", k];

If[isFunction[names[[k]]],
n++;
Sow[{n, pkg <> names[[k]]}]
]

, {k, 1, Length[names]}
];


Which gives

{{1, "SystemAASTriangle"},
{2, "SystemAbelianGroup"},
{3, "SystemAbort"},
{4, "SystemAbortKernels"},
{5, "SystemAbortProtect"},
{6, "SystemAbortScheduledTask"}, {7,
.....
{2300, "SystemListLogLinearPlot"},
{2301, "SystemListLogLogPlot"},
{2302, "SystemListLogPlot"},
{2303, "SystemListPicker"},
{2304, "SystemListPickerBox"},
{2305, "SystemListPlay"},
{2306, "SystemListPlot"},
{2307, "SystemListPlot3D"},
{2308, "SystemListPointPlot3D"},
{2309, "SystemListPolarPlot"},
{2310, "SystemListQ"},
{2311, "SystemListSliceContourPlot3D"},
{2312, "SystemListSliceDensityPlot3D"},
{2313, "SystemListSliceVectorPlot3D"},
{2314, "SystemListStepPlot"},
{2315, "SystemListStreamDensityPlot"},
{2316, "SystemListStreamPlot"},
.....
{4431, "System$$DefaultFrontEnd"}, {4432, "SystemDisplayFunction"}, {4433, "SystemFormatType"}, {4434, "SystemFrontEndSession"}, {4435, "System$$SoundDisplayFunction"}}


If when running the above code, you get pop-up windows asking you to login to Wolfram Cloud, just close it. I got such screen many times. I have no idea why it is asking me to login to Wolfram cloud.

Do not worry that they are strings in this list. You could always convert string to Mathematica expression using ToExpression to use the functions.

• This is great, thank you! May 10, 2020 at 6:03
• @MichałKuczynski you are welcome. But you should wait to accept, sometime better answer for your needs might come along. I think you might want to accept Kglr answer instead of mine as it gives you single argument functions which is what you wanted for your tests and it is better answer than mine also. Mine was a hack/workaround since I did not know how to use MathematicalFunctionData` May 10, 2020 at 6:21