6
$\begingroup$

To find a possible closed form of a number, I can use the function

WolframAlpha["6.38905609893065", IncludePods -> "PossibleClosedForm"]

It returns a result in the following form:

Possible closed forms

The InputForm of this result displays quite a large expression containing pods and cells represented as XMLElements.

Is there an easy way to extract the first suggested closed form as a normal expression (in this case, E^2 - 1)?

$\endgroup$
  • 2
    $\begingroup$ is this "easy"? WolframAlpha[ "6.38905609893065", {{"PossibleClosedForm", 1}, "FormulaData"}][[1, 1]] $\endgroup$ – chuy Oct 31 '13 at 21:03
4
$\begingroup$

Here is how you attack this: First click on the little "+" in the right upper corner. Then you select either "Subpod content" or directly "Formula data". Both will result in a more specific request which gives you the hint you need:

{WolframAlpha[
  "6.38905609893065", {{"PossibleClosedForm", 1}, "FormulaData"}], 
 WolframAlpha[
  "6.38905609893065", {{"PossibleClosedForm", 2}, "FormulaData"}], 
 WolframAlpha[
  "6.38905609893065", {{"PossibleClosedForm", 3}, "FormulaData"}]}

From this, it is only one step to

WolframAlpha[
  "6.38905609893065", {{"PossibleClosedForm", 1}, "FormulaData"}] /. 
 Hold[expr_ ≈ _] :> expr

Mathematica graphics

$\endgroup$
  • $\begingroup$ Thanks, this was very useful. Unfortunately, it does not handle cases like 9.4536360064616926. In this case WolframAlpha returns $\frac{L^4}5$ with a comment that $L$ is the lemniscate constant. The FormulaData in this case is $Failed, while ideally it would be Gamma[1/4]^8/(320 π^2). $\endgroup$ – Vladimir Reshetnikov Nov 1 '13 at 0:34
  • $\begingroup$ @VladimirReshetnikov Yes, this is very unfortunate, although I kind of expected that this does not work for every possible example. WolframAlpha is more a tool for a human user. $\endgroup$ – halirutan Nov 1 '13 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.