New in 10.3: MathematicalFunctionData and WolframLanguageData

Paco Jain and Eric Weisstein
Wolfram|Alpha Scientific Content Group

Join the Conversation #WolframTechConf

An (extremely) brief history of special functions in the Wolfram universe

Special functions in the core language

When Mathematica was introduced in 1988, it included 114 special functions.  The current version has about 300

mathFunctions=Join[EntityList[EntityClass["WolframLanguageSymbol",{"FunctionalityArea","MathFunctions"}]],
EntityList[EntityClass["WolframLanguageSymbol",{"FunctionalityArea","NumericConstantFunctions"}]]];

data=Transpose[{EntityValue[mathFunctions,(EntityProperty["version introduced", EntityProperty["WolframLanguageSymbol","VersionIntroduced"], "EntityProperty[\"WolframLanguageSymbol\", \"VersionIntroduced\"]"])],mathFunctions,EntityValue[mathFunctions,(EntityProperty["date introduced", EntityProperty["WolframLanguageSymbol","DateIntroduced"], "EntityProperty[\"WolframLanguageSymbol\", \"DateIntroduced\"]"])]}];

data1=Sort[{ #[[1,3]],{#[[1,1]], SortBy[#2&@@@#,StringLength[Last[#]]&]}}&/@GatherBy[data,First]];

data2=Transpose[{data1,Accumulate[Length[#2[[2]]]&@@@data1]}];

data3=Tooltip[{#1[[1]], #2},Column[{Style[Row[{"version: ", #[[1]]}],Bold,Large],
Row[{"new functions: "}],
 With[{λ=Ceiling[Length[#[[2]]]/4]},Grid[Transpose[PadRight[#,λ,""]&/@Partition[#[[2]],λ,λ, 1,{}]]]]}]&@#1[[2]]]&@@@ data2

Show[{DateListPlot[data3,Filling->Axis,ImageSize -> 500],
        DateListPlot[data3,Filling->Axis,PlotLabel->"Mathematical functions",Joined->False]}]

Some visual waypoints

Functions data in Wolfram|Alpha (2009-present)

Developed  by Michael Trott and Oleg Marichev (as was the Functions Site previously)

CellPrint[Cell[BoxData[ToBoxes[Row[{Image[,ImageSize->130],"          ",Image[,ImageSize->130]}]]],CellMargins->{{150,Automatic},{4,4}}]]

Allows natural-language queries, returning results from our large collection (300,000+) of special function and constant identities:

CellPrint[Cell[BoxData[ToBoxes[Image[,ImageSize->633]//Framed]],CellMargins->{{150,Automatic},{4,4}}]]

Mathematical Function Data

Goals of the project

To make the extensive collection of special function formulas from the Wolfram Functions Site and Wolfram Alpha website available in a computable format

To allow faster integration of new special functions identities into the Wolfram knowledgebase

Overview of the data

348 functions (with more being added)

MathematicalFunctionData["Entities"]
%//Length

across 76 classes

MathematicalFunctionData["EntityClasses"]
%//Length

with data distributed across 50 properties

MathematicalFunctionData["Properties"]
%//Length

Total identities number over 140,000!!

Let’s see some examples

a basic entity/property-value listing returns a list of identities

intReps=MathematicalFunctionData["BesselJ","IntegralRepresentations"];
%//Column

focusing on one of these, we note its structure

myIntRep=intReps[[1]]

Function[{ν,\[FormalZ]},Inactivate[ConditionalExpression[BesselJ[ν,\[FormalZ]]==((((2^(1-ν)) (\[FormalZ]^ν)) (∫_0^1)(((1-(\[FormalT]^2)))^(ν-(1/2))) Cos[\[FormalZ] \[FormalT]]\[DifferentialD]\[FormalT])/((Sqrt[π]) Gamma[ν+(1/2)])),Re[ν]>-(1/2)]]]

wrapping the identity in a pure function allows the user his/her choice of variable symbols

myIntRep[foo, bar]

we use formal symbols (where possible) to avoid polluting the Global` context (for now, greeks cannot be formalized)

MathematicalFunctionData[BesselJ,"SampleIndefiniteIntegrals"][[5]]

we Inactivate the body of the function to prevent immediate evaluation (i.e., to improve user control)

contrast the inactivated version, where it is easy to see what happens at each stage:

myIdent = EntityValue[Entity["MathematicalFunction", "Cos"], "Periodicities"][[1]]
myIdent[z]
% // Activate

Function[{\[FormalZ]}, Inactivate[Cos[\[FormalZ] + 2 π] == Cos[\[FormalZ]]]]

Inactive[Cos][z \!\(\*
TagBox["+",
"InactiveToken",
BaseStyle->"Inactive",
SyntaxForm->"+"]\) 2\!\(\*
TagBox["*",
"InactiveToken",
BaseStyle->"Inactive",
SyntaxForm->"*"]\)π] \!\(\*
TagBox["==",
"InactiveToken",
BaseStyle->"Inactive",
SyntaxForm->"=="]\) Inactive[Cos][z]

True

...with the same identity, but with Inactivate removed.  It evaluates to True earlier than one would like:

myIdent = EntityValue[Entity["MathematicalFunction", "Cos"], "Periodicities"][[1]] /. Verbatim[Inactivate][expr_] -> expr
myIdent[z]
% // Activate

Function[{\[FormalZ]}, Cos[\[FormalZ] + 2 π] == Cos[\[FormalZ]]]

True

True

In a large set of cases, a ConditionalExpression identifies a restricted domain over which an identity is valid

as per the design goals mentioned above, the majority of identities can be verified directly in the Wolfram language (computability)

apply, then Activate:

myIdent = intReps[[1]][v,z]

myIntRep[v,z]//Activate

%/. {z->3, v->2}

or, alternatively:

myIntRep[3,2.0]

%//Activate

another example: sin addition formulas

MathematicalFunctionData[Sin,"AdditionFormulas"]

notice that in this one, one of the arguments to the pure function acts as a head in the identity

myExpr=MathematicalFunctionData[Sin,"AdditionFormulas"][[5]]
myExpr[a,n]//Activate

but we can still substitute in a “value” (a pure function) and compute with it

(myExpr[a,n]//Activate)/. {n->3, a->(#^2&)}
%//Simplify

Specialized functionality

via Property Qualifiers (EntityValue world), which look quite a bit like options to MathematicalFunctionData (though, in technical terms, they are not)

IncludedSubexpressions/ExcludedSubexpressions

a full entity/property listing (no qualifier)

MathematicalFunctionData["EllipticE:Complete","SampleIndefiniteIntegrals"]
%//Length

get only those identities containing EllipticK

MathematicalFunctionData["EllipticE:Complete","SampleIndefiniteIntegrals","IncludedSubexpressions" ->{EllipticK}]
%//Length

further refining the pattern

MathematicalFunctionData["EllipticE:Complete","SampleIndefiniteIntegrals","IncludedSubexpressions" ->{EllipticK[_^2]}]
%//Length

ValidGenerically

a full entity/property listing (no qualifier)

MathematicalFunctionData["Conjugate","AdditionFormulas"]
%//Length

getting only those identities valid across the entire complex plane (excluding possibly sets of measure zero)

MathematicalFunctionData["Conjugate","AdditionFormulas","ValidGenerically"->True]
%//Length

TraditionalFormPresentation

standard listing

MathematicalFunctionData["HermiteH","DifferenceEquations"]

“TraditionalFormPresentation” -> True

MathematicalFunctionData["HermiteH","DifferenceEquations","TraditionalFormPresentation"->True]

Other goodies

Use Ctrl+Equal for natural language discovery of function properties:

LinguisticAssistant

ToEntity/FromEntity for conversion between Wolfram Language expressions and the “entity world”:

ToEntity[ArcTan[x],"MathematicalFunction"]

ToEntity[ArcTan[x,y],"MathematicalFunction"]

On the horizon

exposure of additional functions and properties

analyticity characteristics, function relation graphs,...

new filtering and output options

LeftHandSidePattern, RuleForm,...

mathematical constants (separate domain)

500+ named constants

Thanks!  Don’t go anywhere... Eric is up next to talk about WolframLanguageData

WolframLanguageData

New data collection in V10.3

Brings together useful information about built-in Mathematica symbols and their documentation in a computable way

Includes symbols that (as of the latest released version of Mathematica)

are documented to be in System` context (i.e., have a ref/XXX page in the Wolfram Documentation)

are not documented to be obsolete

(such symbols (should) also have defined ::usage messages)

WolframLanguageData always reflects the most up-to-date state of the Wolfram Language. This means:

symbols that are deprecated as of the latest version of Mathematica are *not* included

WolframLanguageData can contain updates, deletions, corrections, and additions relative to the version of Mathematica in which it is being run

In (and not in) WLData

Examples of symbols that *are* in WLData:

Integrate

ButterworthFilterModel

ItemAspectRatio

Examples of symbols *not* in WLData:

AstronomicalData ("Since Version 10, AstronomicalData has been superseded by PlanetData, etc.")

\[FormalA ] (in System context but documented as ref/character/FormalA)

WolframLanguageData

WolframLanguageData["Sum","KeyboardShortcuts"]

WolframLanguageData["RiemannSiegelTheta","EponymousPeople"]

WolframLanguageData["Cos","RelationshipCommunityGraph"]

Entity["WolframLanguageSymbol", ...]

EntityValue[Entity["WolframLanguageSymbol","Image"],"Timeline"]

EntityList[EntityClass["WolframLanguageSymbol",{"NamedAfter","CarlFriedrichGauss::4vctc"}]]

EntityList[EntityClass["WolframLanguageSymbol",{"Attribute","Constant"}]]

Property qualifiers/implicit entities

Property qualifiers

WolframLanguageData["Sum",EntityProperty["WolframLanguageSymbol","Translations"]]

WolframLanguageData["Sum",EntityProperty["WolframLanguageSymbol","Translations",{"Language"->"German"}]]

Implicit entities

Use an implicitly defined entity to return a list of Wolfram Language symbols named after Gauss:

Entity["WolframLanguageSymbol",{"EponymousPeople"->ContainsAny[{(Entity["Carl Friedrich Gauss", Entity["Person","CarlFriedrichGauss::4vctc"], "Entity[\"Person\", \"CarlFriedrichGauss::4vctc\"]", "person"])}]}]//EntityList

Wolfram|Alpha/free-form input

LinguisticAssistant

InputForm[%]

WolframAlpha["Plus precedence"]

WLData Symbols

Sort@WolframLanguageData[]//Short

Length[%]

WLData Properties

WolframLanguageData["Properties"]

(sinData=WolframLanguageData["Sin","PropertyAssociation"])//Short

WLData Classes

WolframLanguageData["Classes"]

EntityList[EntityClass["WolframLanguageSymbol",{"FunctionalityArea","MathFunctions"}]]//Short

Example 1: Property explorer

sinData=WolframLanguageData["Sin","PropertyAssociation"];

With[{props=SortBy[Normal[sinData],LeafCount]},
Manipulate[property/.props,{{property,EntityProperty["WolframLanguageSymbol","RelationshipCommunityGraph"]},props[[All,1]]},SaveDefinitions->True]
]

Example 2: WordCloud of text strings

WordCloud[DeleteStopwords[Flatten[TextWords[WolframLanguageData["NormalDistribution","TextStrings"]]]]]

Example 3: Graph of SeeAlso's

Length[data=WolframLanguageData[All,{"Entity","RelatedSymbols"}]]//AbsoluteTiming

SeeAlsoNetwork=Graph[data[[All,1]],Flatten[Thread/@DirectedEdge@@@DeleteMissing[data,1,2]]]

Through[{VertexCount,EdgeCount}[SeeAlsoNetwork]]

Example 4: Symbols named after people

Find the tallies of Wolfram Language symbols named after n people:

data=WolframLanguageData[All,{"EponymousPeople","CanonicalName"}];

counts=(#[[1,1]]->#[[All,2;;]])&/@Reverse[SplitBy[Sort[{Length[#1/._Missing->{}],#2,#1}&@@@data],First]];

{#1,Length[#2]}&@@@counts

Show the first several symbols named after two people:

Take[Rule@@@(2/.counts),5]//Column

Show symbols named after three people:

Rule@@@(3/.counts)