0
$\begingroup$

A trivial example would be

f[x_]:=x
Nest[f, 7, n]

which would of course be 7 because it is independent of n, but Nest requires a machine integer for n.

A little reading took me to RsolveValue

RSolveValue[{x[n + 1] == f[x[n]], x[0] == 7}, x[n], n]

which gives me 7, hooray!

Unfortunately, if I change f:

f[x_]:=0
RSolveValue[{x[n + 1] == f[x[n]], x[0] == 7}, x[n], n]

gives me RSolveValue[{x[1 + n] == 0, x[0] == 7}, x[n], n] and the error For some branches of the general solution, the given boundary conditions lead to an empty solution

I guess it's right to complain, because my boundary condition violates the difference equation. But what I'm looking for is the answer 0

So how can I make this work?

The ultimate goal I have is finding the n'th repeated application of arbitrary operators on a given starting expression.

$\endgroup$
  • 1
    $\begingroup$ "finding the n'th repeated application of arbitrary operators on a given starting expression" is exactly what Nest does, but you have to provide a value for n. Not clear what you are trying to do that is different from that. $\endgroup$ – Rohit Namjoshi Feb 26 at 14:31
  • $\begingroup$ @RohitNamjoshi I am trying to find the answer for any n, i.e. an expression in terms of n $\endgroup$ – John_C Feb 26 at 14:47

Your Answer

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

Browse other questions tagged or ask your own question.