# Output an Expression in terms of GoldenRatio

Sorry if this is a dumb question (I'm new). I swear I searched and read forums first!

I'm trying to rewrite expressions in terms of the Golden Ratio. For example, I know 9+4Sqrt[5] is Phi^6, but can figure out how to get mathematica to tell me that.

Ideally it would also tell me that 10+4Sqrt[5] is 1+Phi^6 (and more complex versions).

Edit: Thanks everyone! I should have been more specific about my "more complex examples". The problem is, I have no clue what form they'll end up in. I guess I'm hoping for a "FullSimplify" analogue that uses GoldenRatio wherever reasonable. Here's a couple actual examples:

Sqrt[(3 (935 - 65 Sqrt[5] + 4 Sqrt[15 (1205 + 298 Sqrt[5])]))/4490]

1/2 Sqrt[1/
10 (3123 + 1251 Sqrt[5] - 2 Sqrt[4386990 + 1955766 Sqrt[5]])]


I'll try to use, or modify, the suggestions already made. I'll post anything that seems "share-worthy". Sorry for not being more spoecific from the start. Again, thanks for the help!

• Hello Brian and welcome to the Mathematica StackExchange. Don't forget to upvote good answers (and other people's questions) using the triangle above the number next to the post, and use the checkmark to "accept" the answer to your question that you think best answers it
– Jens
Apr 25 '15 at 2:30
• I assume you know about Simplify[9+4Sqrt[5] == GoldenRatio^6], right? The problem is that expressions in terms of GoldenRatio aren't unique. For example, Simplify[GoldenRatio^6 == 5 + 8 GoldenRatio] is also True, and I'm not sure whether you would accept both answers. A very simple answer would be to do this with any given expression expr: replace it by Simplify[expr /.Sqrt[5]->(2GoldenRatio-1)]
– Jens
Apr 25 '15 at 2:33
• I wonder if Simplify's ComplexityFunction option can be useful here?
– user484
Apr 25 '15 at 18:19
• You can format inline code and code blocks by selecting it and clicking the {} button above the edit window. The edit window help button ? is also useful for learning how to format your questions and answers. Apr 26 '15 at 19:24

Limitations apply, as Jens stated in a comment above. Still, if you know a form you are searching for, and can formulate a fitness function for it, you can do something like:

With[
{val = 10 + 4 Sqrt[5],
eq = a + GoldenRatio^b},
eq /. Last@Minimize[
{a + b,
a >= 0 && b > 0 && val == eq},
{a, b}, Integers]]


1 + GoldenRatio^6

Here eq is the form we are searching (over non-negative integer values of a and positive values of b). Minimize is constrained with this requirement, and the solution with minimum sum of a and b is chosen, and then substituted to eq.

It seems that in some similar cases (like when a is constrained to be non-positive) Minimize easily fails to find a solution. NMinimize often works better on these situations.

EDIT:

Another method to find a value as combination of specified constants multiplied by rationals is to use FindIntegerNullVector:

With[
{val = 10 + 4 Sqrt[5],
constants = {1, GoldenRatio^3, GoldenRatio^4}},
constants.Most@#/Last@# &@
FindIntegerNullVector[Append[constants, -val]]]


1 + GoldenRatio^3 + 2 GoldenRatio^4

Or with constants = {1, GoldenRatio}:

6 + 8 GoldenRatio

This code fails in quite ugly ways when relation between the constants (or eq parameters in the case of Minimize variant) can't be found - I'm certain it could be polished a bit.