# Guessing "exact" values

96 views

### Szabolcs

May 16, 2007, 5:25:20â€¯AM5/16/07
to
"Another computer algebra system" has a function, identify(), which
attempts to guess the exact expression that evaluates to a particular
numerical value.

Example:

In[1]:= N[3Pi+3/2,10]

Out[1]= 10.92477796

> identify(10.92477796);
3
- + 3 Pi
2

Is there a package with similar functionality for Mathematica?

Szabolcs

### dimitris

May 17, 2007, 5:57:55â€¯AM5/17/07
to
I think there is a package of Ted Ersek but I am not sure!
Check www.wolfram.com and its archives.

Dimitris

=CF/=C7 Szabolcs =DD=E3=F1=E1=F8=E5:

### Murray Eisenberg

May 17, 2007, 6:10:05â€¯AM5/17/07
to
As I remember, at IMS'06 (Avignon) Stephen Wolfram (via remote link-up)
played with a function to do just that. Did I remember correctly?

If so, I cannot recall the name of the function, so I don't know whether
the function made it into 6.0. The closest thing I can find is
RootApproximant, but that doesn't seem to "recognize" an expression
involving a transcendental number.

Szabolcs wrote:
> "Another computer algebra system" has a function, identify(), which
> attempts to guess the exact expression that evaluates to a particular
> numerical value.
>
> Example:
>
> In[1]:= N[3Pi+3/2,10]
>
> Out[1]= 10.92477796
>
> > identify(10.92477796);
> 3
> - + 3 Pi
> 2
>
> Is there a package with similar functionality for Mathematica?
>
> Szabolcs
>

--
Murray Eisenberg mur...@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305

### Jean-Marc Gulliet

May 17, 2007, 6:35:37â€¯AM5/17/07
to

Hi,

The built-in function *Rationalize* and the add-on package
NumberTheory`Rationalize` should be the closest equivalent to the
function identify().

In[1]:=
x = N[3*Pi + 3/2]

Out[1]=
10.92477796076938

In[2]:=
Rationalize[x, 0]

Out[2]=
569958623/52171186

In[3]:=
x - %

Out[3]=
0.

In[4]:=
\$Version

Out[4]=
"5.2 for Microsoft Windows (June 20, 2005)"

HTH,
Jean-Marc

### Dana DeLouis

May 18, 2007, 6:17:39â€¯AM5/18/07
to
Hi. This is not the best solution, but here's one idea I use.
It's not the best solution, because I can't find a way to make Mathematica's
is locked in stone.
Maybe an expert can jump in and make this dynamic.

A number we know nothing about...(??)
n = 6.283185307179586

Set the variable to something you would like to use. For me...
NumberToSearch = n;

Re-Enter this equation (Shift Enter), and then click the link.

StringReplace["http://bootes.math.uqam.ca/cgi-bin/ipcgi/lookup.\
pl?Submit=GO+&number=#&lookup_type=simple",
"#" :> ToString[Evaluate[NumberToSearch], InputForm,
NumberMarks -> False]]]

The above click shows it might be 2 Pi.

For your example, I took the full value:
n=10.92477796076938

This number didn't work. Sometimes it won't work if the number is large.
I don't know what "large" means, but the program really works with
fractions.

I decided to divided the number by 3.

NumberToSearch = 10.92477796076938/3
3.641592653589793

If I re-enter the Hyperlink, and click the link, the solution is Pi+1/2.
Multiply by 3 to get your equation.

Reference: http://pi.lacim.uqam.ca/eng/
--
HTH :>)
Dana DeLouis
Windows XP & Mathematica 6.0 & Help files 5.2 :>~

"Szabolcs" <szho...@gmail.com> wrote in message
news:f2eim0\$t2f\$1...@smc.vnet.net...

### Dana DeLouis

May 18, 2007, 6:30:09â€¯AM5/18/07
to
As soon as I hit send, I thought of another way. Don't know why I didn't
think of this sooner. I just modified mine to the following...

RealLookup[NumberToSearch_Real] := Module[
{
s2 = ToString[NumberToSearch, InputForm, NumberMarks -> False],
gi-bin/ipcgi/lookup.pl?Submit=GO+&number=#&lookup_type=simple"
},

]

RealLookup[NumberToSearch_] :=
StringJoin["Number must be Real, not: ",
ToString[NumberToSearch, InputForm]]

RealLookup[2.*Pi]

n = 3*Pi + 3/2;

RealLookup[n/3.]

RealLookup[n/3]

"Number must be Real, not: (3/2 + 3*Pi)/3"

RealLookup["Dog"]

"Number must be Real, not: Dog"

--
HTH :>)
Dana DeLouis

Windows XP & Mathematica 6, and 5.2 Help. :>~

"Szabolcs" <szho...@gmail.com> wrote in message
news:f2eim0\$t2f\$1...@smc.vnet.net...
> "Another computer algebra system" has a function, identify(), which
> attempts to guess the exact expression that evaluates to a particular
> numerical value.
>
> Example:
>
> In[1]:= N[3Pi+3/2,10]
>
> Out[1]= 10.92477796
>
> > identify(10.92477796);
>

### Roman

May 18, 2007, 6:42:57â€¯AM5/18/07
to
Check out the "inverse symbolic calculator" at
http://oldweb.cecm.sfu.ca/projects/ISC/
Roman.

### Andrzej Kozlowski

May 18, 2007, 6:47:30â€¯AM5/18/07
to
Mathematica can "recognize" algebraic numbers, by using the function
RootApproximant (or the function Recognize in the Legacy
NumberTherory package):

Sqrt[5 + 2*Sqrt[6]]

This may not look so impressive until you check:

FullSimplify[Sqrt[2] + Sqrt[3] - Sqrt[5 + 2*Sqrt[6]]]
0

Anyway, doing this for algebraic numbers has a solid mathematical
basis: the so called LLL Lattice Reduction) algorithm. I don=92t know, =

however, of any mathematical basis for "recognizing" transcendentals, =

except by means of stored values or some other "ad hoc" approach
(essentially "sophisticated guessing")

Andrzej Kozlowski

On 17 May 2007, at 18:59, Murray Eisenberg wrote:

> As I remember, at IMS'06 (Avignon) Stephen Wolfram (via remote link-=

> up)

> played with a function to do just that. Did I remember correctly?
>
> If so, I cannot recall the name of the function, so I don't know
> whether
> the function made it into 6.0. The closest thing I can find is
> RootApproximant, but that doesn't seem to "recognize" an expression
> involving a transcendental number.
>

> Szabolcs wrote:
>> "Another computer algebra system" has a function, identify(), which
>> attempts to guess the exact expression that evaluates to a particular
>> numerical value.
>>
>> Example:
>>
>> In[1]:= N[3Pi+3/2,10]
>>
>> Out[1]= 10.92477796
>>
>>> identify(10.92477796);
>> 3
>> - + 3 Pi
>> 2
>>
>> Is there a package with similar functionality for Mathematica?
>>
>> Szabolcs
>>
>

### Szabolcs

May 19, 2007, 4:35:20â€¯AM5/19/07
to
dimitris wrote:
> I think there is a package of Ted Ersek but I am not sure!
> Check www.wolfram.com and its archives.

Thanks for everyone who replied! I learned a lot today.

I did not find the package by Ted Ersek, but I found another one by Eric
Weisstein:

http://library.wolfram.com/infocenter/MathSource/5087/

The relevant file is Simplify.m
Interesting functions are ToExact and TranscendentalRecognize.

In another thread someone mentioned a website which can be used for
similar purposes:
http://pi.lacim.uqam.ca/eng/

### Murray Eisenberg

May 19, 2007, 4:51:36â€¯AM5/19/07
to
When I run that code and click the link, my browser shows a "File not
found!" error page.

--

### Daniel Lichtblau

May 19, 2007, 5:10:15â€¯AM5/19/07
to
>>--
>>Murray Eisenberg mur...@math.umass.edu
>>Mathematics & Statistics Dept.
>>Lederle Graduate Research Tower phone 413 549-1020 (H)
>>University of Massachusetts 413 545-2859 (W)
>>710 North Pleasant Street fax 413 545-1801
>>Amherst, MA 01003-9305
>>

A common approach is to use a predefined basis of transcendentals, e.g
certain powers of e, pi, gamma, and maybe some set of radicals of
"small" integers. One then seeks rational combinations of these that
give the input value to close approximation. This step typically uses
LLL or PSLQ.

Simple code to demonstrate the concept was presented in TMJ back in 1996
(and based on some email and maybe news group correspondence from late
1995). The reference is below.

Transcendental Recognition. In: Tricks of the Trade, Paul Abbott editor.
The Mathematica Journal 6(2):29-30 (1996).

To obtain electronically go to:

http://www.mathematica-journal.com/issue/v6i2/

notebook, go to "Trancendental Recognition" section.

I'll mention that a perusal of documentation suggests the identify()
function for the most part uses this approach.

Daniel Lichtblau
Wolfram Research

### Szabolcs

May 20, 2007, 2:51:39â€¯AM5/20/07
to

Thanks again for all the replies!

I think that I need to explain that I sent this message before I
received the replies from Dana DeLouis and Roman, but for some reason it
arrived with a delay of 2 days.

### Szabolcs

May 21, 2007, 6:09:46â€¯AM5/21/07
to
Murray Eisenberg wrote:
> When I run that code and click the link, my browser shows a "File not
> found!" error page.
>

It is because of the line break in the URL. Make sure that after you
paste it, you remove the spaces which got inserted between ...
"ipcgi/lookup." and "pl?Submit" ...

Szabolcs