if( !require('phaseR') ){ install.packages('phaseR') } library(phaseR) my_yprime = function(t, y, parameters){ y_prime = y * (1-y^2) list( y_prime ) } diff_eq_params = c() #postscript("../../WriteUp/Graphics/Chapter2/chap_2_sect_5_prob_10_plot.eps", onefile=FALSE, horizontal=FALSE) par(mfrow=c(1, 2)) ys = seq( -2, 2, length.out=100 ) fys = my_yprime( 0.0, ys, diff_eq_params ) fys = fys[[1]] plot( ys, fys, type='l', xlab='y', ylab='f(y)' ) abline(h=0, col='black') grid() # Plot the flow field, nullclines and several trajectories: # flowField(my_yprime, x.lim = c(0, 5), y.lim = c(-3, 3), parameters = diff_eq_params, points = 21, system = "one.dim", add = FALSE, xlab='t') nullclines(my_yprime, x.lim = c(0, 5), y.lim = c(-2.5, 2.5), parameters = diff_eq_params, system = "one.dim") trajectory(my_yprime, y0 = c(-2.5, -0.5, 0.5, 2.75), t.end = 5, parameters = diff_eq_params, system = "one.dim") par(mfrow=c(1, 1)) #dev.off()