Function Repository Resource:

FindClosedForm

Source Notebook

Search for a formula which yields a given number

Contributed by: Daniele Gregori

ResourceFunction["FindClosedForm"][y]

searches for equivalents to the given number y from common mathematical functions.

ResourceFunction["FindClosedForm"][y,n]

returns up to n results for the number y.

ResourceFunction["FindClosedForm"][y,f]

searches for a formula with the given functional form f.

ResourceFunction["FindClosedForm"][y,f,n]

returns up to n results.

ResourceFunction["FindClosedForm"][y,{f1,f2,}]

searches for a formula for the given number y, among the given list of functional forms fi.

ResourceFunction["FindClosedForm"][y,{f1,f2,},n]

returns up to n results.

Details and Options

ResourceFunction["FindClosedForm"] helps to solve the fundamental problem of Number Recognition, by searching and finding a possible closed formula for a given number y, in terms of arbitrary combinations of elementary and higher mathematical functions.
Before starting any search, ResourceFunction["FindClosedForm"][y,n] queries Wolfram Alpha for possible closed forms of the given number. If this query does not return the required number of results with sufficient precision, the main search algorithm begins.
The fundamental strategy exploited by the search algorithm of ResourceFunction["FindClosedForm"] is that, given a pure Function f, progressively more complex rational arguments are tried for it, until a numerical match with the given value y is found. By default, this match is searched up to linear combinations with algebraic numbers (rationals or roots), as produced by RootApproximant.
When only the first argument y is specified, for each round of argument search, a further search goes on through the following quite common mathematical functions: {Sin, Cos, Tan, ArcSin, ArcCos, ArcTan, ArcCot, Log, Exp, Sinh, Cosh, Tanh, ArcSinh, ArcCosh, ArcTanh, ArcCoth, Zeta, Gamma, PolyGamma, Erf, InverseErf, EllipticK, EllipticE, BarnesG, AiryAi, AiryBi, DedekindEta, ModularLambda}. In addition, FindClosedForm searches a numerical match among algebraic combinations of the following mathematical constants: {Pi, GoldenRatio, Catalan, EulerGamma, Khinchin, Glaisher}.
The second argument can be a mathematical function f or a list of them, each with arbitrary form and any number of arguments, which have to be specified as pure functions (that is, with one or more Slot in their arguments).
In some cases, more than one valid formula can be found. The desired number of results must be specified as a second or third argument.
Notice that the search may take a very long time. If multiple results are requested but only partial results are found, they are printed temporarily to let the user know. If the user decides to abort the search, the earlier results are kept and returned safely.
FindClosedForm accepts the following options:
"SignificantDigits"Automaticthe precision of the numerical match
"FormulaComplexity"Automaticthe complexity degree allowed for the closed form
"WolframAlphaQueries"3set the number of Wolfram Alpha queries to be tried
"SearchQueries"Automaticset the maximum number of queries for the search algorithm
"MonitorSearch"Falsewhether to monitor the argument and function search rounds
"AlgebraicAdd"Truewhether to search a numerical match up to addition of algebraic numbers
"AlgebraicFactor"Truewhether to search a numerical match up to multiplication by algebraic numbers
"RootApproximantMethod"Automaticspecify the method to use while identifying algebraic numbers
"RationalSolutions"Falsewhether simple rational solutions are allowed
"SearchArguments"Automaticspecify the particular arguments to search
"SearchRange""Farey"the type of argument range, for each search round
"SearchComplex"Falsewhether to search complex arguments
"MaxSearchRounds"50limit the number of argument search rounds
"SearchTimeLimit"3600the maximum number of seconds spent on the search
The value for the option "SignificantDigits" is set automatically to the number of digits (before 0) specified in the given number y and is used to determine the order of magnitude of the relative error allowed for the numerical match. It is possible to specify a lower or higher value, so to ignore some numerical error, or require a stricter match.
The value for the option "FormulaComplexity", for any closed form formula, is a positive real which can be custom set or computed as follows: i) take all integers appearing in the formula, possibly being part of rational, algebraic or complex numbers; ii) if a root appears, duplicate its argument a number of times equal to the root degree; iii) for each integer, compute the mean among the square root of its absolute value, its DigitSum and 5 times its IntegerLength; iv) take the total of these means.
The option "WolframAlphaQueries" sets the number of queries to be tried directly on Wolfram Alpha. Notice these can be unsuccessful, because the result of each query: i) may be not precise enough (as determined by "SignificantDigits"); ii) may be too complex (as determined by "FormulaComplexity"); iii) or may not have a corresponding Wolfram Language formula representation.
The option "SearchQueries" determines the number of results to be searched through the main search algorithm of FindClosedForm. When the default Automatic is used, it is taken to be the difference between number of results required, n, and the number of successful results returned by Wolfram|Alpha. Otherwise it is possible to set its value to 0, to make ResourceFunction["FindClosedForm"] effectively return only the selected results from Wolfram|Alpha.
If the options "AlgebraicAdd" or "AlgebraicFactor" are set to True, the numerical match is searched up to addition or multiplication by algebraic numbers, respectively.
If the option "RootApproximantMethod" is set to "BuiltIn", these algebraic numbers are all those found through the built-in functions RootApproximant and ToRadicals. If instead the option "RootApproximantMethod" is set to Automatic, the algebraic numbers are assumed to have one of the absolute values equal to a "small" integer, fraction or fraction root. The complex phase of algebraic numbers is assumed to be within a π -multiple of a "small" fraction. It is also possible to specify the value for the option "RootApproximantMethod" as custom table of possible absolute values, or as a list of an absolute value table and complex phase table. Summarizing, the possible values for the option "RootApproximantMethod" are the following:
"BuiltIn"find the algebraic numbers through RootApproximant
Automaticfind the algebraic numbers rapidly within a default lookup table
{abs1,abs2,}find the algebraic numbers' within a custom lookup table containing absolute values
{abs1,,z1,}absolute values and complex values with non-negative real and imaginary components
If the option "RationalSolutions" is set to True, simple rational solutions are allowed. These are typically trivial, so unless the function searched for is the Identity, or both "AlgebraicAdd" or "AlgebraicFactor" are set to False, the default value for this option is False and thus no simple rational can be returned.
If the option "SearchArguments" is set to Automatic, the algorithm automatically tries arguments within an increasingly larger range each, with a cutoff equal to the search round (or function of it). Notice that argument ranges at successive rounds do overlap, but the program does not recompute the previously tried arguments combinations. In particular, special values for the option "SearchRange", as functions of the search round, are the following:
"Farey"a rational Farey range, ResourceFunction["FareyRange"][-#,#,#]&
"Plain"the rational range Range[-#,#,1/#]&
"Integer"the purely integer range Range[-#,#]&
r[#]&a custom Function of the search round
Arguments to be tried can be specified through the option "SearchArguments" as a List - if there is only one Slot - or as a list of lists - one for each slot - or as an Association between slots and lists, as keys and values respectively, as follows:
Automaticall arguments within the search range for each round
{list}Slot[1] arguments within list
{list1,list2,}Slot[1] within list1,Slot[2] within list2,etc.
<|#1 list1,#2list2, …|>Slot[1] within list1,Slot[2] within list2,etc.
The default output of ResourceFunction["FindClosedForm"] is a list of all the closed forms found, with no duplicates. However, sometimes the functional form may evaluate in such a way to lose information on the arguments used. Through the option "OutputArguments" set to True, also the arguments can be returned in the output, as keys of an association with the corresponding closed forms.
If the option "SearchComplex" is set to True, the search range, for each round, is the complex numbers extension of the ranges determined by the option "SearchRange", as realized through ResourceFunction["ComplexRange"].
The value for the option "MaxSearchRounds" sets the number of search rounds to be tried before terminating the program. Similarly the maximum time spent by the search algorithm can be set through the option "SearchTimeLimit". If the search terminates with no closed form is found, the output of ResourceFunction["FindClosedForm"] is None.

Examples

Basic Examples (4) 

Find a possible mathematical function for a number:

In[1]:=
ResourceFunction["FindClosedForm"][0.405465]
Out[1]=

Find possible closed form for a number in terms of common mathematical functions:

In[2]:=
ResourceFunction["FindClosedForm"][3.792277]
Out[2]=

Find formulae in terms of mathematical constants:

In[3]:=
ResourceFunction["FindClosedForm"][3.311601]
Out[3]=
In[4]:=
ResourceFunction["FindClosedForm"][1.044866]
Out[4]=

Specify the functional form of a formula in the second argument as a pure function:

In[5]:=
ResourceFunction["FindClosedForm"][1.85653, 1/Zeta[#]^2 &]
Out[5]=
In[6]:=
ResourceFunction["FindClosedForm"][-0.309033, PolyLog[#1, #2] &]
Out[6]=

Scope (6) 

Get four results:

In[7]:=
ResourceFunction["FindClosedForm"][3.3116, 4]
Out[7]=

The results are all approximately equivalent:

In[8]:=
N[%]
Out[8]=

Differing results of FindClosedForm can turn out to be strictly equivalent:

In[9]:=
ResourceFunction["FindClosedForm"][0.69314718, 4]
Out[9]=
In[10]:=
FullSimplify@Apply[Equal, %]
Out[10]=

Get ten results based on Log:

In[11]:=
ResourceFunction["FindClosedForm"][0.405465, Log, 10]
Out[11]=
In[12]:=
N[%]
Out[12]=

The numerical match with the functional form is searched up to addition or multiplication by an algebraic number (that is, a Rational or Root):

In[13]:=
ResourceFunction["FindClosedForm"][-1.185732, PolyGamma[#] &]
Out[13]=
In[14]:=
ResourceFunction["FindClosedForm"][0.780653, ArcSinh]
Out[14]=

The arguments can also be roots:

In[15]:=
ResourceFunction["FindClosedForm"][1.054136, BarnesG[Sqrt[2] #] &]
Out[15]=

Specify the form of any function combination, with a number of arguments:

In[16]:=
ResourceFunction["FindClosedForm"][7.443967, Log[1 + Exp[#]] &]
Out[16]=
In[17]:=
ResourceFunction["FindClosedForm"][4.688231, Gamma[#1]/Gamma[#2] &]
Out[17]=
In[18]:=
ResourceFunction["FindClosedForm"][0.7299085, HypergeometricU[#1, #2, #3] &]
Out[18]=

Search through a list of functional forms:

In[19]:=
ResourceFunction["FindClosedForm"][5.550045, {Sinh, Cosh, Sech, Csch}]
Out[19]=
In[20]:=
ResourceFunction[
 "FindClosedForm"][-1.479735, {EllipticK[#] &, EllipticE[#] &, EllipticPi[#1, #2] &}]
Out[20]=

Options (36) 

AlgebraicAdd (2) 

Setting the option "AlgebraicAdd" to False allows one to search the specified functional form, up to multiplication (but not addition) by an algebraic number. This can vastly speed up the search, since special range properties are exploited for certain known functions:

In[21]:=
ResourceFunction["FindClosedForm"][0.1013578, 1/(Gamma[#1] Gamma[#2]) &, "AlgebraicAdd" -> False] // AbsoluteTiming
Out[21]=

Compare with the longer time required without this option:

In[22]:=
ResourceFunction["FindClosedForm"][0.1013578, 1/(Gamma[#1] Gamma[#2]) &] // AbsoluteTiming
Out[22]=

AlgebraicFactor (2) 

Setting the option "AlgebraicFactor" to False allows one to search the specified functional form, up to addition (but not multiplication) of an algebraic number:

In[23]:=
ResourceFunction["FindClosedForm"][-9.6530201, PolyGamma[#1] + PolyGamma[#2] &, "AlgebraicFactor" -> False] // AbsoluteTiming
Out[23]=

Compare with the longer time required without this option:

In[24]:=
ResourceFunction["FindClosedForm"][-9.6530201, PolyGamma[#1] + PolyGamma[#2] &] // AbsoluteTiming
Out[24]=

If both "AlgebraicAdd" and "AlgebraicFactor" options are set to False, the search can be faster but may miss linear combinations of the functional form:

In[25]:=
ResourceFunction["FindClosedForm"][0.3057349, PolyLog[#1, #2] &, "AlgebraicFactor" -> False, "AlgebraicAdd" -> False] // AbsoluteTiming
Out[25]=
In[26]:=
ResourceFunction["FindClosedForm"][0.3057349, PolyLog[#1, #2] &] // AbsoluteTiming
Out[26]=

FormulaComplexity (2) 

If not enough digits are specified, a careful balance between precision and complexity of the result should be reached through the option "FormulaComplexity". In fact, often the desired formula is likely to be the simplest. For example:

In[27]:=
ResourceFunction["FindClosedForm"][38.94017, Gamma]
Out[27]=

The result has the desired functional form and matches the digits:

In[28]:=
N[%, 7]
Out[28]=

However, by reducing the allowed complexity threshold, a simpler result is found:

In[29]:=
ResourceFunction["FindClosedForm"][38.94017, Gamma, "FormulaComplexity" -> 15]
Out[29]=
In[30]:=
N[%, 7]
Out[30]=

By setting "FormulaComplexity" high, more intrinsically complex formulas can be found:

In[31]:=
ResourceFunction["FindClosedForm"][4.51766814, Gamma[#2]^3/Gamma[#1]^2 + Identity[#3] (Gamma[#1]^2/Gamma[#2]) &, "FormulaComplexity" -> 100]
Out[31]=
In[32]:=
N[%, 9]
Out[32]=

MaxSearchRounds (3) 

The maximum number of argument search rounds is set to 50 by default. If the value of the option "SearchRange" is set to Automatic, this also means that the maximum integer argument and maximum rational argument denominator are both 50:

In[33]:=
ResourceFunction["FindClosedForm"][49.44221, Gamma, "AlgebraicAdd" -> False, "AlgebraicFactor" -> False, "SearchRange" -> "Plain"]
Out[33]=

By default, larger or smaller arguments respectively are not reachable:

In[34]:=
ResourceFunction["FindClosedForm"][59.43902, Gamma, "AlgebraicAdd" -> False, "AlgebraicFactor" -> False, "SearchRange" -> "Plain"]
Out[34]=

Changing the value for the option "MaxSearchRounds" allows a solution to be found:

In[35]:=
ResourceFunction["FindClosedForm"][59.43902, Gamma, "MaxSearchRounds" -> 100, "AlgebraicAdd" -> False, "AlgebraicFactor" -> False, "SearchRange" -> "Plain"]
Out[35]=

MonitorSearch (2) 

If the option "MonitorSearch" is set to True, the search round number is printed temporarily during evaluation:

In[36]:=
ResourceFunction["FindClosedForm"][20.0758, Gamma[#]^2 &, "MonitorSearch" -> True]
Out[36]=

If only one argument is specified, or a list of functions appears in the second argument, the function being evaluated is printed also:

In[37]:=
ResourceFunction[
 "FindClosedForm"][3.940443, {ArcSin, ArcCos, ArcTan, ArcCot}, "MonitorSearch" -> True]
Out[37]=

OutputArguments (2) 

If the option "OutputArguments" is set to True, the output is an association with the function arguments:

In[38]:=
ResourceFunction["FindClosedForm"][1.32325, Gamma[#1]/Gamma[#2] &, "OutputArguments" -> True]
Out[38]=
In[39]:=
Gamma[#1]/Gamma[#2] &[Sequence @@ Keys[%][[1]]]
Out[39]=

This option is especially useful in the case the functional form evaluates in such a way so to lose information on its arguments. For example, find a matrix whose determinant is equal to a certain number:

In[40]:=
ResourceFunction["FindClosedForm"][19/18, Det[{{#1, #2}, {#3, #4}}] &,
  "OutputArguments" -> True, "AlgebraicAdd" -> False, "AlgebraicFactor" -> False]
Out[40]=
In[41]:=
Det[{{#1, #2}, {#3, #4}}] &[Sequence @@ Keys[%][[1]]]
Out[41]=

RationalSolutions (4) 

By default, the option "RationalSolutions" is set to False. This means no simple rational solution is considered valid and more sophisticated solutions are searched for:

In[42]:=
ResourceFunction["FindClosedForm"][0.25, Sin[\[Pi] #] &, "RationalSolutions" -> False, "AlgebraicAdd" -> False]
Out[42]=
In[43]:=
N[%, 4]
Out[43]=

If the option "RationalSolutions" is set to True, a simpler exact solution can be found:

In[44]:=
ResourceFunction["FindClosedForm"][0.25, Sin[\[Pi] #] &, "RationalSolutions" -> True, "AlgebraicAdd" -> False]
Out[44]=

If the functional form searched for is the Identity, there is no need of this option:

In[45]:=
ResourceFunction["FindClosedForm"][0.25, Identity[#] &]
Out[45]=

Similarly when both the "AlgebraicFactor" and "AlgebraicAdd" options are set to false, rational solutions are automatically allowed:

In[46]:=
ResourceFunction["FindClosedForm"][0.5, Sin[\[Pi] #] &, "AlgebraicAdd" -> False, "AlgebraicAdd" -> False]
Out[46]=

The solution in this case is clearly:

In[47]:=
Sin[\[Pi]/6]
Out[47]=

RootApproximantMethod (4) 

By default, only a limited set of algebraic numbers can be obtained (through a pre-defined lookup table):

In[48]:=
ResourceFunction["FindClosedForm"][1.32471796, Identity, "FormulaComplexity" -> 300]
Out[48]=
In[49]:=
N[%, 9]
Out[49]=

It is possible to recognize other algebraic numbers by using the built-in function RootApproximant, through the option "RootApproximantMethod" set to "BuiltIn":

In[50]:=
ResourceFunction["FindClosedForm"][1.32471796, Identity, "FormulaComplexity" -> 300, "RootApproximantMethod" -> "BuiltIn"]
Out[50]=
In[51]:=
N[%, 9]
Out[51]=

The problem with the built-in method is that most of the time is spent trying to recognize random reals as higher roots and this makes the search much slower. In this example, the search using the built-in method is over 100 times slower (and requires one more digit):

In[52]:=
ResourceFunction["FindClosedForm"][0.4711847, "WolframAlphaQueries" -> 0] // AbsoluteTiming
Out[52]=
In[53]:=
ResourceFunction["FindClosedForm"][0.47118474, "WolframAlphaQueries" -> 0, "RootApproximantMethod" -> "BuiltIn"] // AbsoluteTiming
Out[53]=
In[54]:=
N[%[[2]], 7]
Out[54]=

As an intermediate solution, in case some algebraic number is missed and you still want a fast search, you could specify a custom lookup table:

In[55]:=
TimeConstrained[
 ResourceFunction["FindClosedForm"][1.25964392365, Gamma, "FormulaComplexity" -> Infinity], 30]
Out[55]=
In[56]:=
ResourceFunction["FindClosedForm"][1.2596439236, Gamma, "FormulaComplexity" -> Infinity, "RootApproximantMethod" -> ResourceFunction["FareyRange"][0, 1, 2000]] // AbsoluteTiming
Out[56]=
In[57]:=
N[%[[2]], 11]
Out[57]=

Notice that the built-in method may miss or misinterpret some algebraic numbers:

In[58]:=
TimeConstrained[
 ResourceFunction["FindClosedForm"][1.2596439236, Gamma, "FormulaComplexity" -> Infinity, "RootApproximantMethod" -> "BuiltIn", "MonitorSearch" -> True] // AbsoluteTiming, 120]
Out[58]=
In[59]:=
N[%[[2]], 11]
Out[59]=

In case complex algebraic numbers are searched for, you can specify a custom table for their phases:

In[60]:=
ResourceFunction["FindClosedForm"][7.38814 + 0.11606 I, Exp, "RootApproximantMethod" -> {Automatic, Range[-1, 1, 1/200]}]
Out[60]=

Without this option, the complex phase is assumed to be within π ResourceFunction["FareyRange"][-1,1,1/100]:

In[61]:=
ResourceFunction["FindClosedForm"][7.38541 + 0.23209 I, Exp]
Out[61]=

SearchArguments (2) 

Through the option "SearchArguments" you can specify each particular search argument to be tried:

In[62]:=
ResourceFunction["FindClosedForm"][4.678938, Gamma[#] &, "SearchArguments" -> {3, 1, 1/3}] // AbsoluteTiming
Out[62]=

This can vastly speed up the search and serves as a debugging tool.


If more than one argument appears in the functional form, you can specify "SearchArguments" as a list of lists, or equivalently as an association:

In[63]:=
ResourceFunction["FindClosedForm"][1.32325, Gamma[#1]/Gamma[#2] &, "SearchArguments" -> {{1, 1/2}, {3, 1, 1/3}}]
Out[63]=
In[64]:=
ResourceFunction["FindClosedForm"][1.32325, Gamma[#1]/Gamma[#2] &, "SearchArguments" -> <|#1 -> {1, 1/2}, #2 -> {3, 1, 1/3}|>]
Out[64]=

SearchComplex (2) 

Search for complex values of the argument:

In[65]:=
ResourceFunction["FindClosedForm"][0.572198 + 0.15332 I, DedekindEta, "SearchComplex" -> True]
Out[65]=

Notice that this option determines only the complex character of the arguments, while complex values by themselves do not necessarily require it:

In[66]:=
ResourceFunction["FindClosedForm"][12.56637 - 10.53566 I, ArcSin, "SearchComplex" -> False]
Out[66]=

SearchQueries (2) 

Return only the results from Wolfram Alpha by setting the option "SearchQueries" to 0:

In[67]:=
ResourceFunction["FindClosedForm"][1.62186, "SearchQueries" -> 0]
Out[67]=

If you specify a higher number, the number of results remains bounded by the second integer argument:

In[68]:=
ResourceFunction["FindClosedForm"][1.62186, 4, "SearchQueries" -> 5]
Out[68]=
In[69]:=
N[%]
Out[69]=

SearchRange (4) 

By default, for each search round the arguments span the Farey range determined by ResourceFunction["FareyRange"][-round,round,round]. For example:

In[70]:=
ResourceFunction["FareyRange"][-3, 3, 3]
Out[70]=
In[71]:=
ResourceFunction["FindClosedForm"][0.442109, PolyLog[#1, #2] &] // AbsoluteTiming
Out[71]=

Otherwise, it is possible to set the option "SearchRange" to "Plain", which creates the shorter rational range Range[-round,round,1/round]:

In[72]:=
Range[-6, 6, 1/6] // Length
Out[72]=
In[73]:=
ResourceFunction["FindClosedForm"][14.911818, Gamma[#1] Gamma[#2] &, "SearchRange" -> "Plain"] // AbsoluteTiming
Out[73]=

Notice the longer time required with the default "Farey" range:

In[74]:=
ResourceFunction["FareyRange"][-6, 6, 6] // Length
Out[74]=
In[75]:=
ResourceFunction["FindClosedForm"][14.911818, Gamma[#1] Gamma[#2] &] // AbsoluteTiming
Out[75]=

Of course, for other arguments, the converse may be true.


Another possible value for this option is "Integer", whereby only integer arguments are searched within the range Range[-round,round]:

In[76]:=
Range[-7, 7]
Out[76]=
In[77]:=
ResourceFunction["FindClosedForm"][6.263643, Log[#1] Log[#2] &, "SearchRange" -> "Integer"] // AbsoluteTiming
Out[77]=

It is possible to specify, as an option value, a custom range function of the search round number:

In[78]:=
ResourceFunction["FindClosedForm"][13.165149, Log, "SearchRange" -> Function@Range[0, 100 #, 25]] // AbsoluteTiming
Out[78]=

SearchTimeLimit (1) 

Limit the time spent by the search algorithm:

In[79]:=
ResourceFunction["FindClosedForm"][3.3116007, 10, "SearchTimeLimit" -> 30] // AbsoluteTiming
Out[79]=
In[80]:=
N[%[[2]], 8]
Out[80]=

Notice that, as in this example, the total time spent by the function may be higher than this option's value, because the time spent on querying Wolfram Alpha is not counted in it.

SignificantDigits (2) 

The option "SignificantDigits" is automatically set to the number of real digits (before 0) specified in the given number. If you want to ignore some numerical error, you can specify a lower value for it:

In[81]:=
res = ResourceFunction["FindClosedForm"][0.81248057539, 1/Zeta[#]^2 &,
   "SignificantDigits" -> 7]
Out[81]=

Without this option setting, the same call takes a large amount of time:

In[82]:=
TimeConstrained[
 ResourceFunction["FindClosedForm"][0.81248057539, 1/Zeta[#]^2 &], 30]
Out[82]=

The numerical error is less than the required precision:

In[83]:=
(N[res, 10] - 0.81248057539)/%
Out[83]=

Specify more significant digits than those available (consider extra digits as valid zeros):

In[84]:=
ResourceFunction["FindClosedForm"][0.693147, Log]
Out[84]=
In[85]:=
TimeConstrained[
 ResourceFunction["FindClosedForm"][0.693147, Log, "SignificantDigits" -> 10], 30]
Out[85]=

The search is unsuccessful because the higher digits do not match:

In[86]:=
(N[Log[2], 8] - 0.693147)/Log[2]
Out[86]=

Keep in mind that, with significant numerical error, the search for the right formula becomes much harder.

WolframAlphaQueries (2) 

The number of Wolfram Alpha query results returned is, by default, 3:

In[87]:=
ResourceFunction["FindClosedForm"][3.3116, 3]
Out[87]=

You can either reduce or increase this number by setting the option "WolframAlphaQueries" to another number:

In[88]:=
ResourceFunction["FindClosedForm"][3.3116, 3, "WolframAlphaQueries" -> 2]
Out[88]=
In[89]:=
ResourceFunction["FindClosedForm"][3.3116, 4, "WolframAlphaQueries" -> 4]
Out[89]=

Notice that the queries may be unsuccessful, so this option just sets an upper limit:

In[90]:=
ResourceFunction["FindClosedForm"][3.3116, 10, "WolframAlphaQueries" -> 10, "SearchQueries" -> 0]
Out[90]=
In[91]:=
N[%]
Out[91]=

Applications (4) 

Besides finding formulae for raw numbers, FindClosedForm[y,f] can be used for verifying relations among special functions. For example, the following identity for EllipticK in terms of Gamma is not trivial to prove through symbolic computation:

In[92]:=
EllipticK[2] == -((4 (-1)^(3/4) Gamma[5/4]^2)/Sqrt[\[Pi]]) // Map[N]
Out[92]=
In[93]:=
EllipticK[2] == -((4 (-1)^(3/4) Gamma[5/4]^2)/
   Sqrt[\[Pi]]) // FullSimplify
Out[93]=

However, FindClosedForm[y,f] can easily verify it:

In[94]:=
ResourceFunction["FindClosedForm"][N[EllipticK[2]], Gamma[#1]^2/Gamma[#2] &, "AlgebraicAdd" -> False]
Out[94]=

Verify a formula for EllipticPi in terms of Gamma and Identity:

In[95]:=
ResourceFunction["FindClosedForm"][N[EllipticPi[1/2, 1/2]], Gamma[#2]^3/Gamma[#1]^2 + Identity[#3] (Gamma[#1]^2/Gamma[#2]) &, "AlgebraicAdd" -> False, "FormulaComplexity" -> 100]
Out[95]=
In[96]:=
EllipticPi[1/2, 1/2] == \[Pi]^(3/2)/(8 Gamma[5/4]^2) + (
   4 Gamma[5/4]^2)/Sqrt[\[Pi]] // Map[N]
Out[96]=

Find relations among different arguments of the same function through FindClosedForm[y,f,n]:

In[97]:=
ResourceFunction["FindClosedForm"][
 N[DedekindEta[1 + 2 I]], DedekindEta, 15, "SearchComplex" -> True, "FormulaComplexity" -> 100]
Out[97]=
In[98]:=
Equal @@ N[%, 40]
Out[98]=

FindClosedForm[y,f,n] can be also used to find solutions to underdetermined systems of equations. For example, find instances of matrices whose determinant is equal to a certain number:

In[99]:=
ResourceFunction["FindClosedForm"][19/18, Det[{{#1, #2}, {#3, #4}}] &, 20, "OutputArguments" -> True, "AlgebraicAdd" -> False, "AlgebraicFactor" -> False]
Out[99]=
In[100]:=
Union@MapApply[Det[{{#1, #2}, {#3, #4}}] &, Keys[%]]
Out[100]=

Compare with the solutions found through the built-in functions Reduce and FindInstance:

In[101]:=
Reduce[Det[{{t, x}, {y, z}}] == 19/18, {t, x, y, z}]
Out[101]=
In[102]:=
FindInstance[
 And[%, -3 <= x <= 3, -3 <= y <= 3, -3 <= z <= 3, -3 <= t <= 3], {t, x, y, z}, Rationals, 10]
Out[102]=
In[103]:=
Union[Det[{{t, x}, {y, z}}] /. %]
Out[103]=

Properties and Relations (3) 

FindClosedForm[y,Identity] generalizes the function Rationalize and works with fewer digits:

In[104]:=
Rationalize[0.6666666666666]
Out[104]=
In[105]:=
ResourceFunction["FindClosedForm"][0.666, Identity]
Out[105]=

When the given number approximates a simple root, FindClosedForm[y,Identity] also generalizes the functions RootApproximant and ToRadicals:

In[106]:=
RootApproximant[4.2426407]
Out[106]=
In[107]:=
ResourceFunction["FindClosedForm"][4.243, Identity]
Out[107]=
In[108]:=
ToRadicals@RootApproximant[0.58480355]
Out[108]=
In[109]:=
ResourceFunction["FindClosedForm"][0.5848, Identity]
Out[109]=

When the formula involves only one argument (and no further multiplied or added algebraic number appears), FindClosedForm[y,f] also generalizes FindRoot:

In[110]:=
Rationalize@FindRoot[3.229211228053242 == BesselK[1, x], {x, 1.}]
Out[110]=
In[111]:=
BesselK[1, x] /. %
Out[111]=
In[112]:=
ResourceFunction["FindClosedForm"][3.22921, BesselK[1, #] &, "AlgebraicAdd" -> False, "AlgebraicFactor" -> False]
Out[112]=

Publisher

Daniele Gregori

Version History

  • 1.0.0 – 02 July 2025

Related Resources

Author Notes

The development of this function benefitted from suggestions by the Wolfram review team.

License Information