#! /usr/bin/env python3 # def euler_solve_logistic ( ): ## euler_solve_logistic() tests euler_solve() on the logistic ODE. from euler_solve import euler_solve import matplotlib.pyplot as plt import numpy as np print ( '' ) print ( 'euler_solve_logistic():' ) # # Input to euler_solve: # def logistic_dydt ( t, y ): dydt = y * ( 1.0 - y ) return dydt tspan = np.array ( [ 0., 5.0 ] ) y0 = 0.01 n = 50 # # Solve. # t, y = euler_solve ( logistic_dydt, tspan, y0, n ) # # Plot. # plt.plot ( t, y, 'b-', linewidth = 3 ) plt.grid ( True ) filename = 'euler_solve_logistic.png' plt.savefig ( filename ) plt.show ( ) print ( ' Graphics saved as "' + filename + '"' ) if ( __name__ == "__main__" ): euler_logistic_test ( )