Skip to content

Daniele-Gregori/FindClosedForm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 

Repository files navigation

FindClosedForm

Search for a formula that yields a given number.

Documentation

Usage

0vkuymevwfuwa

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

19ratzkfm7xw9

returns up to n results for the number y.

0meyq3i4awcxw

searches for a formula with the given functional form $f$.

06rtubm985xkh

returns up to n results.

158jxuy0qxe26

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

1n0nle9jezur8

returns up to n results.

Details & Options

$\text{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, 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 $\text{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:

1hfnix3mqduzn

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 $\text{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:

199ju3w1zggt5

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:

01hr0w2n7178r

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:

1s9ukkfon0yrd

The default output of $\text{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 $\underline{\text{ResourceFunction}[\text{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 FindClosedForm is None.

Examples

Basic Examples

Find a possible mathematical function for a number:

FindClosedForm[0.405465]
0izukabojarea

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

FindClosedForm[3.792277]
0oqors7zubg8b

Find formulae in terms of mathematical constants:

FindClosedForm[3.311601]
1snzcxq0uti3y
FindClosedForm[1.044866]
0v4ar2xgljmxi

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

FindClosedForm[1.85653, 1/Zeta[#]^2 &]
1cx9q7kdwwbdj
FindClosedForm[-0.309033, PolyLog[#1, #2] &]
0yeu9hebf3u1x

Scope

Get four results:

FindClosedForm[3.3116, 4]
08lg02cbye4m4

The results are all approximately equivalent:

N[%]

{3.31163, 3.31153, 3.31156, 3.31181}

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

FindClosedForm[0.69314718, 4]
1ukuomhn8sm2t
FullSimplify@Apply[Equal, %]

True

Get ten results based on Log:

FindClosedForm[0.405465, Log, 10]
177t3mylzjkxg
N[%]

{0.405465, 0.405465, 0.405465, 0.405463, 0.405463, 0.405467, 0.405468, 0.405462, 0.405462, 0.405469}

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

FindClosedForm[-1.185732, PolyGamma[#] &]
0qnq3jcs9ebj8
FindClosedForm[0.780653, ArcSinh]
1aumndg21nymy

The arguments can also be roots:

FindClosedForm[1.054136, BarnesG[Sqrt[2] #] &]
0dmka5w0l4gpl

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

FindClosedForm[7.443967, Log[1 + Exp[#]] &]

10 Log[1 + Exp[1/10]]

FindClosedForm[4.688231, Gamma[#1]/Gamma[#2]&]
0ql51gs2scv4c
FindClosedForm[0.7299085, HypergeometricU[#1, #2, #3] &]
1q74rwzgbt23v

Search through a list of functional forms:

FindClosedForm[5.550045, {Sinh, Cosh, Sech, Csch}]
1t2ni8mfhm3zb
FindClosedForm[-1.479735, {EllipticK[#] &, EllipticE[#] &, EllipticPi[#1, #2] &}]
1jmd6cieyll20

Full documentation

See many other examples and the rest of the documentation for all the options, applications, properties and relations at this page on the Wolfram Function Repository.

About

Search for a formula that yields a given number

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published