if( !require('phaseR') ){ install.packages('phaseR') } library(phaseR) # The critical points of this system: # CP = data.frame( x=c(0, 2, 5), y=c(0, 12/5, 0) ) my_jacobian = function(x, y) { # returns the Jacobian at the point (x, y) # J = matrix(c( 1.0 - (2/5)*x - 2*y/(x+6) + 2*x*y/(x+6)^2, -(2*x)/(x+6), y/(x+6) - x*y/(x+6)^2, -0.25 + x/(x+6)), nrow=2, ncol=2, byrow=TRUE) } As = mapply(my_jacobian, CP$x, CP$y, SIMPLIFY=FALSE) for (ii in 1:length(As)){ es = eigen(As[[ii]]) print(sprintf('CP: x= %f; y= %f', CP$x[ii], CP$y[ii])) print('Jacobian=') print(As[[ii]]) print('eigenvalues=') print(es$values) } my_yprime = function(t, y, parameters) { xt = y[1] yt = y[2] dy = rep(NA, length(y)) dy[1] = xt*(1.0 - 0.2 * xt - ( 2 * yt ) / (xt + 6) ) dy[2] = yt*(-0.25 + xt / (xt + 6)) list(dy) } t.end = 40.0 #postscript('../../WriteUp/Graphics/Chapter9/chap_9_sect_5_prob_13_plot.eps', onefile=FALSE, horizontal=FALSE) diff_eq_params = list() flowField(my_yprime, x.lim = c(-0.1, 6.0), y.lim = c(-0.1, 4.5), parameters = diff_eq_params, points = 30, add = FALSE, xlab='x', ylab='y', main=sprintf('sigma= %f', diff_eq_params$sigma)) trajectory(my_yprime, y0 = c(0.1, 4), t.end = t.end, parameters = diff_eq_params, col='black', pch=8) points(CP$x, CP$y, pch=19) par(mfrow=c(1, 1)) #dev.off()