4
$\begingroup$

Suppose I have the following function g[{x_, y_}, c0_, b_] := {x^2 + c0 - b*y, x} where b and c0 are parameter values.

Suppose we fix the values of c0 and b, say, g[{x_, y_}, -5, 1.2]. Is there a way to get the $nth$ composition of g with itself? So a function say G[{x_,y_},n,-5,1.2] which gives g[{x, y}, -5, 1.2] @* g[{x, y}, -5, 1.2] @* ... @* g[{x, y}, -5, 1.2] $n$ times? I would like to then use this to find period $n$ points using NSolve so I think this is the form I would require.

$\endgroup$
5
$\begingroup$

You can do something like:

gcomp[n_Integer] := Composition @@ ConstantArray[g[#, -5, 1.2] &, n]

Which you can then use as:

gcomp[3][{0, 0}]

Or perhaps even better:

gcomp[n_Integer, c0_, b_] := Composition @@ ConstantArray[g[#, c0, b] &, n];
gcomp[3, -5, 1.2][{0, 0}]
$\endgroup$
1
  • $\begingroup$ This is wonderful thanks! $\endgroup$ – math Nov 17 '20 at 12:07
4
$\begingroup$
n=3;
g[{x_, y_}, c0_, b_] := {x^2 + c0 - b*y, x};
Nest[Function[t, g[t, -5, 1.2]], {x0, y0}, n]
$\endgroup$
1
  • $\begingroup$ n = 3; g[{x_, y_}, c0_, b_] := {x^2 + c0 - b*y, x}; Nest[g[#, -5, 1.2] &, {x0, y0}, n] $\endgroup$ – cvgmt Nov 17 '20 at 12:00

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.