0
$\begingroup$

I am trying to study the stability of a 2-dimensional discrete system (X, Y) by finding the Jacobian at the systems non-trivial equilibrium (X*, Y*). The functions that map the system from one iterate, n, to the next are given by the solutions to ordinary differential equations solved at time t = T

X(n+1) = f(x(T), y(T))

Y(n+1) = g(x(T), y(T))

where x(T) and y(T) depend on X(n) and Y(n).

Here is a MWE of the problem

sol[T_?NumericQ, a_, b_, c_, x0_?NumericQ, y0_?NumericQ] := 
  NDSolve[{
    x'[t] == x0 a - b *x[t]*y[t],
    y'[t] == b*x[t]*y[t] - c y[t],
    x[0] == 0, y[0] == y0}, 
   {x, y}, {t, 0, T]}];

xmap[T_?NumericQ, a_, b_, c_, x0_?NumericQ, y0_?NumericQ] := 
 x[T] /. sol[T, a, b, c, x0, y0]
ymap[T_?NumericQ, a_, b_, c_, h_, j_, x0_?NumericQ, y0_?NumericQ] := 
 h (y[T] /. sol[T, a, b, c, x0, y0])/(1 + 
     j (y[T] /. sol[T, a, b, c, x0, y0]))

where x0 and y0 are placeholders for X(n-1) and Y(n-1). Is it possible to take the partial derivatives of xmap and ymap w.r.t. x0 and y0? I tried this

D[xmap[5, 0.5, 0.25, 1, x0, 200], x0] /. x0 -> 100

But it does not evaluate.

$\endgroup$
4
  • $\begingroup$ There are a few typos here - no closing brace in sol[...{t,0,T], tt should be T in ymap. Those aside, I don't think you can apply NDSolve to an expression that still has undefined parameters in it (how would you carry out the numerical algorithm?), so you can't take the derivative of it either. Additionally, xmap remains unevaluated inside of D because you restrict your definition to numerical values of T, x0 and y0, so D remains unevaluated as well since there is nothing to apply it to. $\endgroup$
    – N.J.Evans
    Apr 8, 2021 at 21:07
  • $\begingroup$ Try for instance f[x_?NumericQ]:=x^2; D[f[x],x]. $\endgroup$
    – N.J.Evans
    Apr 8, 2021 at 21:07
  • 1
    $\begingroup$ It looks like you want a numerical answer. Can you use a numerical approximation to the partial at the point of interest? i.e. (xmap[5,0.5,0.25,1,100+delta,200]-xmap[5,0.5,0.25,1,100-delta,200])/(2*delta) $\endgroup$
    – N.J.Evans
    Apr 8, 2021 at 21:17
  • 1
    $\begingroup$ Definition of the derivative will work fine for my purposes. Thanks for the suggestion. $\endgroup$ Apr 8, 2021 at 22:53

0

Your Answer

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