0
$\begingroup$

I would like to find the value n satisfying following equation . How can I do it in Mathematica?

15411 == 123*Fibonacci[n] + 31*Fibonacci[n + 1]

$\endgroup$
5
  • $\begingroup$ FindInstance[ 15411 == (123*Fibonacci[n] + 31*Fibonacci[n + 1]), n, Reals] $\endgroup$
    – george2079
    Commented Apr 5, 2018 at 14:03
  • $\begingroup$ ah, v10.1 yields 11.. (oddly it does not find the result if you make domain Integers ) $\endgroup$
    – george2079
    Commented Apr 5, 2018 at 15:19
  • $\begingroup$ Try FindInstance[ 15411 == (123*Fibonacci[n] + 31*Fibonacci[n + 1]) && n > 0, n, Reals], which yields the result $n=11$ (MMA v. 11.2.0 otherwise yields a negative root near $-12.7544$). $\endgroup$
    – user15994
    Commented Apr 5, 2018 at 15:20
  • $\begingroup$ Using a finite interval makes it return 11: FindInstance[{15411 == (123*Fibonacci[n] + 31*Fibonacci[n + 1]), 0 < n < 200000, n ∈ Integers}, n] $\endgroup$
    – Coolwater
    Commented Apr 5, 2018 at 15:47
  • $\begingroup$ Fibonacci is defined on reals other than integers, so could just use FindRoot. In[6]:= FindRoot[15411 == 123*Fibonacci[n] + 31*Fibonacci[n + 1],{n,9}] Out[6]= {n -> 11.} $\endgroup$ Commented Apr 5, 2018 at 20:58

1 Answer 1

1
$\begingroup$

You can use either Solve or Reduce if you specify an range for n which contains the solution. The range does not have to be tight.

eqn = 15411 == 123*Fibonacci[n] + 31*Fibonacci[n + 1];

sol1 = Solve[{eqn, -50 < n < 50}, n, Integers]

(* {{n -> 11}} *)

Verifying,

eqn /. sol1[[1]]

(* True *)

Or

sol2 = Reduce[{eqn, -50 < n < 50}, n, Integers] // ToRules

(* {n -> 11} *)
$\endgroup$
1
  • 1
    $\begingroup$ or even .. (Pick[#, (eqn /. n -> # ) & /@ #] &@Range[-50, 50] ) $\endgroup$
    – george2079
    Commented Apr 5, 2018 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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