5
$\begingroup$

In some cases Mathematica expresses the result of calculations using fundamental constants. For example:

4 Sum[2/((4 n + 1) (4 n + 3)), {n, 0, \[Infinity]}]

(* $\pi$ *)

or

Sum[1/n!, {n, 0, \[Infinity]}]

(* $e$ *)

But in others, it does not:

13/8 + Sum[((-1)^(n + 1) (2 n + 1)!)/((n + 2)! n! 4^(2 n + 3)), 
{n, 0, \[Infinity]}]

(* $\frac{13}{8}+\frac{1}{8} \left(4 \sqrt{5}-9\right)$ *)

You can apply Simplify to that result to see that it is:

(* $\frac{1}{2} \left(1+\sqrt{5}\right)$ *)

Exactly.

But this is the GoldenRatio, $\varphi$.

Why didn't Mathematica express the summation in terms of $\varphi$?

More specifically: Why does Mathematica express (simplify) some results using mathematical constants but not others? How can I computationally force or convert or express results to be expressed in mathematical constants, if possible?

$\endgroup$

1 Answer 1

7
$\begingroup$

How can I computationally force or convert or express results to be expressed in mathematical constants, if possible?

For the GoldenRatio, it shows up as $\phi$ only in TraditionalForm. So it is not a built in symbol like there is for $e$ and $\pi$. Typing GoldenRatio just echoes back GoldenRatio.

So only way I see to force the output to be $\phi$, which is GoldenRatio but written as a symbol, is to use your own transformation rules

myRules = # /. 1/2 (1 + Sqrt[5]) -> TraditionalForm[GoldenRatio] &;
s = 13/8 + Sum[((-1)^(n + 1) (2 n + 1)!)/((n + 2)! n! 4^(2 n + 3)), {n, 0, ∞}];
Simplify[s, TransformationFunctions -> {Automatic, myRules}]

Gives

Mathematica graphics

Which is still GoldenRatio

 N[%]

Mathematica graphics

You could have the rule be the following if you prefer.

myRules = # /. 1/2 (1 + Sqrt[5]) -> GoldenRatio &;
s = 13/8 + Sum[((-1)^(n + 1) (2 n + 1)!)/((n + 2)! n! 4^(2 n + 3)), {n, 0, ∞}];
Simplify[s, TransformationFunctions -> {Automatic, myRules}]

Mathematica graphics

As to why it does not do that automatically, my guess is that it is probably very expensive computationally to always check for these values in the output and replace them with known constants each time. There are 100's of known Mathematical constants

enter image description here

And having to check for each buried value inside long expressions each time and replace these with known built-in symbols (if these exist in Mathematica to start with), it will slow down the computation. It also depends on the form of the expression and how it is written to detect these.

But one can always use their own transformation rules as above.

$\endgroup$
2
  • $\begingroup$ Perfect. Thorough. Clear. Scholarly. Helpful. ($\checkmark$) $\endgroup$ Aug 13 at 19:45
  • 1
    $\begingroup$ Since replacements are done structurally, Sqrt[5] :> 2*GoldenRatio - 1 would match more general cases. $\endgroup$
    – Bob Hanlon
    Aug 14 at 16:26

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.