# Solve cannot solve my equation

I tried to brute-force it in C++, but I only got 0, 1, 3, 21, 55.

How to solve this equation in Mathematica? (that doesn't involve real number theory)

My code:

f[x_] := (((1 + Sqrt[5])/2)^x - ((1 - Sqrt[5])/2)^x)/Sqrt[5];
g1[x_] := x*(x + 1)/2
g2[x_] := x*(x - 1)/2
g3[x_] := (x + 2)*(x + 1)/2
g4[x_] := (x + 2)*(x + 3)/2
Solve[f[x] == g1[x], x]
Solve[f[x] == g2[x], x]
Solve[f[x] == g3[x], x]
Solve[f[x] == g4[x], x]

• Those are the only triangular numbers that are also fibonacci numbers. – Carl Woll Nov 3 '17 at 0:16
• Yes, I know. But any algebraic solution in Mathematica? – teed Nov 3 '17 at 0:19
• You want to know whether Mathematica can prove that those are the only triangular numbers that are also fibonacci numbers? If that is your question, I think the answer is no. – Carl Woll Nov 3 '17 at 0:25
• Are you looking for a closed form? A numerical solution? All the solutions on an interval? – anderstood Nov 3 '17 at 0:28
• Something like find the y-values of the points of intersection between the circle x^2+y^2=1 and the line y=4/7x by algebraically manupulating (we can't see): x^2 + (4x/7)^2 = 1 =:> 65x^2/49 = 1 => x = +-sqrt(65/49) then output this: x = {sqrt(65/49), -sqrt(65/49)} – teed Nov 3 '17 at 0:40

Unless this is just a part of more complicated problem, how about visualisation? This is intuitive and simple to understand.

max = 12;

Show[ListLinePlot[Table[{x, N[f[x]]}, {x, 0, max, 1}]],ListLinePlot[Table[{x, N[g1[x]]}, {x, 0, max, 1}], PlotStyle -> Red],ListLinePlot[Table[{x, N[g2[x]]}, {x, 0, max, 1}], PlotStyle -> Blue],ListLinePlot[Table[{x, N[g3[x]]}, {x, 0, max, 1}], PlotStyle -> Green],ListLinePlot[Table[{x, N[g4[x]]}, {x, 0, max, 1}], PlotStyle -> Cyan]]


the plot looks like

Hence, eg.

N[f[12]]

144.

x1 = N[x /. NSolve[g1[x] == f[12], x][[1]]];
x2 = N[x /. NSolve[g1[x] == f[12], x][[2]]];

g1[x1]
g1[x2]


this gives 144. In this case this is helpful as f(x) is defined on integer domain.

I didn't check all of them, but iff g-functions have solutions, they can be found in this manner. You can automize it in a routine.

One can use the fact that the second term in the analytic form of the Fibonacci numbers shrinks geometrically. So the idea is to solve for the first term equal to whatever polynomial, round the result, and see if the integer thusly obtained solves the desired equation.

fibSolve[g_, x_] := Reap[Module[
{candidates, rx},
candidates =
Solve[((1 + Sqrt[5])/2)^x == Sqrt[5]*g && x >= 1, x, Reals];
rx = Round[x /. candidates];
Do[If[Fibonacci[xval] == (g /. x -> xval), Sow[xval]], {xval,
rx}]
]][[2]]


Examples:

g1[x_] := x*(x + 1)/2
g2[x_] := x*(x - 1)/2
g3[x_] := (x + 2)*(x + 1)/2
g4[x_] := (x + 2)*(x + 3)/2

{fibSolve[g1[x], x], fibSolve[g2[x], x], fibSolve[g3[x], x],
fibSolve[g4[x], x]}

(* Out[245]= {{{10}}, {{2}}, {}, {}} *)